libevdev  0.9.1
A wrapper library for evdev devices
 All Files Functions Typedefs Enumerations Enumerator Macros Groups Pages
libevdev.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013 Red Hat, Inc.
3  *
4  * Permission to use, copy, modify, distribute, and sell this software and its
5  * documentation for any purpose is hereby granted without fee, provided that
6  * the above copyright notice appear in all copies and that both that copyright
7  * notice and this permission notice appear in supporting documentation, and
8  * that the name of the copyright holders not be used in advertising or
9  * publicity pertaining to distribution of the software without specific,
10  * written prior permission. The copyright holders make no representations
11  * about the suitability of this software for any purpose. It is provided "as
12  * is" without express or implied warranty.
13  *
14  * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16  * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20  * OF THIS SOFTWARE.
21  */
22 
23 #ifndef LIBEVDEV_H
24 #define LIBEVDEV_H
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 #include <linux/input.h>
31 #include <stdarg.h>
32 
422 struct libevdev;
423 
433 };
434 
449 struct libevdev* libevdev_new(void);
450 
473 int libevdev_new_from_fd(int fd, struct libevdev **dev);
474 
485 void libevdev_free(struct libevdev *dev);
486 
494 };
495 
512 typedef void (*libevdev_log_func_t)(enum libevdev_log_priority priority,
513  void *data,
514  const char *file, int line,
515  const char *func,
516  const char *format, va_list args);
517 
530 void libevdev_set_log_function(libevdev_log_func_t logfunc, void *data);
531 
543 
550 
557 };
558 
577 int libevdev_grab(struct libevdev *dev, enum libevdev_grab_mode grab);
578 
602 int libevdev_set_fd(struct libevdev* dev, int fd);
603 
628 int libevdev_change_fd(struct libevdev* dev, int fd);
629 
638 int libevdev_get_fd(const struct libevdev* dev);
639 
640 
661 };
698 int libevdev_next_event(struct libevdev *dev, unsigned int flags, struct input_event *ev);
699 
722 int libevdev_has_event_pending(struct libevdev *dev);
723 
734 const char* libevdev_get_name(const struct libevdev *dev);
735 
745 void libevdev_set_name(struct libevdev *dev, const char *name);
746 
758 const char * libevdev_get_phys(const struct libevdev *dev);
759 
769 void libevdev_set_phys(struct libevdev *dev, const char *phys);
770 
780 const char * libevdev_get_uniq(const struct libevdev *dev);
781 
791 void libevdev_set_uniq(struct libevdev *dev, const char *uniq);
792 
802 int libevdev_get_id_product(const struct libevdev *dev);
803 
813 void libevdev_set_id_product(struct libevdev *dev, int product_id);
814 
824 int libevdev_get_id_vendor(const struct libevdev *dev);
825 
835 void libevdev_set_id_vendor(struct libevdev *dev, int vendor_id);
836 
846 int libevdev_get_id_bustype(const struct libevdev *dev);
847 
857 void libevdev_set_id_bustype(struct libevdev *dev, int bustype);
858 
868 int libevdev_get_id_version(const struct libevdev *dev);
869 
879 void libevdev_set_id_version(struct libevdev *dev, int version);
880 
890 int libevdev_get_driver_version(const struct libevdev *dev);
891 
902 int libevdev_has_property(const struct libevdev *dev, unsigned int prop);
903 
915 int libevdev_enable_property(struct libevdev *dev, unsigned int prop);
916 
927 int libevdev_has_event_type(const struct libevdev *dev, unsigned int type);
928 
940 int libevdev_has_event_code(const struct libevdev *dev, unsigned int type, unsigned int code);
941 
952 int libevdev_get_abs_minimum(const struct libevdev *dev, unsigned int code);
963 int libevdev_get_abs_maximum(const struct libevdev *dev, unsigned int code);
974 int libevdev_get_abs_fuzz(const struct libevdev *dev, unsigned int code);
985 int libevdev_get_abs_flat(const struct libevdev *dev, unsigned int code);
996 int libevdev_get_abs_resolution(const struct libevdev *dev, unsigned int code);
997 
1009 const struct input_absinfo* libevdev_get_abs_info(const struct libevdev *dev, unsigned int code);
1010 
1033 int libevdev_get_event_value(const struct libevdev *dev, unsigned int type, unsigned int code);
1034 
1061 int libevdev_set_event_value(struct libevdev *dev, unsigned int type, unsigned int code, int value);
1062 
1088 int libevdev_fetch_event_value(const struct libevdev *dev, unsigned int type, unsigned int code, int *value);
1089 
1110 int libevdev_get_slot_value(const struct libevdev *dev, unsigned int slot, unsigned int code);
1111 
1138 int libevdev_set_slot_value(struct libevdev *dev, unsigned int slot, unsigned int code, int value);
1139 
1165 int libevdev_fetch_slot_value(const struct libevdev *dev, unsigned int slot, unsigned int code, int *value);
1166 
1180 int libevdev_get_num_slots(const struct libevdev *dev);
1181 
1195 int libevdev_get_current_slot(const struct libevdev *dev);
1196 
1204 void libevdev_set_abs_minimum(struct libevdev *dev, unsigned int code, int min);
1205 
1213 void libevdev_set_abs_maximum(struct libevdev *dev, unsigned int code, int max);
1214 
1222 void libevdev_set_abs_fuzz(struct libevdev *dev, unsigned int code, int fuzz);
1223 
1231 void libevdev_set_abs_flat(struct libevdev *dev, unsigned int code, int flat);
1232 
1240 void libevdev_set_abs_resolution(struct libevdev *dev, unsigned int code, int resolution);
1241 
1249 void libevdev_set_abs_info(struct libevdev *dev, unsigned int code, const struct input_absinfo *abs);
1250 
1268 int libevdev_enable_event_type(struct libevdev *dev, unsigned int type);
1269 
1296 int libevdev_disable_event_type(struct libevdev *dev, unsigned int type);
1297 
1325 int libevdev_enable_event_code(struct libevdev *dev, unsigned int type, unsigned int code, const void *data);
1326 
1354 int libevdev_disable_event_code(struct libevdev *dev, unsigned int type, unsigned int code);
1355 
1370 int libevdev_kernel_set_abs_info(struct libevdev *dev, unsigned int code, const struct input_absinfo *abs);
1371 
1372 
1379 };
1380 
1394 int libevdev_kernel_set_led_value(struct libevdev *dev, unsigned int code, enum libevdev_led_value value);
1395 
1419 int libevdev_kernel_set_led_values(struct libevdev *dev, ...);
1420 
1435 int libevdev_set_clock_id(struct libevdev *dev, int clockid);
1436 
1458 int libevdev_event_is_type(const struct input_event *ev, unsigned int type);
1459 
1483 int libevdev_event_is_code(const struct input_event *ev, unsigned int type, unsigned int code);
1484 
1496 const char * libevdev_event_type_get_name(unsigned int type);
1509 const char * libevdev_event_code_get_name(unsigned int type, unsigned int code);
1510 
1524 const char* libevdev_property_get_name(unsigned int prop);
1525 
1538 int libevdev_event_type_get_max(unsigned int type);
1539 
1554 int libevdev_event_type_from_name(const char *name);
1555 
1572 int libevdev_event_type_from_name_n(const char *name, size_t len);
1573 
1593 int libevdev_event_code_from_name(unsigned int type, const char *name);
1594 
1616 int libevdev_event_code_from_name_n(unsigned int type, const char *name,
1617  size_t len);
1618 
1636 int libevdev_get_repeat(const struct libevdev *dev, int *delay, int *period);
1637 
1638 
1639 /********* DEPRECATED SECTION *********/
1640 #if defined(__GNUC__) && __GNUC__ >= 4
1641 #define LIBEVDEV_DEPRECATED __attribute__ ((deprecated))
1642 #else
1643 #define LIBEVDEV_DEPRECATED
1644 #endif
1645 
1646 #ifdef __cplusplus
1647 }
1648 #endif
1649 
1650 #endif /* LIBEVDEV_H */
libevdev_read_status
Definition: libevdev.h:644
int libevdev_get_abs_resolution(const struct libevdev *dev, unsigned int code)
Get the axis resolution for the given axis, as advertised by the kernel.
int libevdev_has_event_pending(struct libevdev *dev)
Check if there are events waiting for us.
libevdev_log_priority
Definition: libevdev.h:490
int libevdev_event_type_from_name_n(const char *name, size_t len)
Look up an event-type by its name.
enum libevdev_log_priority libevdev_get_log_priority(void)
int libevdev_has_property(const struct libevdev *dev, unsigned int prop)
int libevdev_change_fd(struct libevdev *dev, int fd)
Change the fd for this device, without re-reading the actual device.
int libevdev_enable_property(struct libevdev *dev, unsigned int prop)
const char * libevdev_event_type_get_name(unsigned int type)
int libevdev_has_event_code(const struct libevdev *dev, unsigned int type, unsigned int code)
const struct input_absinfo * libevdev_get_abs_info(const struct libevdev *dev, unsigned int code)
Get the axis info for the given axis, as advertised by the kernel.
void libevdev_set_abs_fuzz(struct libevdev *dev, unsigned int code, int fuzz)
Change the fuzz for the given EV_ABS event code, if the code exists.
Process data in sync mode.
Definition: libevdev.h:428
int libevdev_get_fd(const struct libevdev *dev)
libevdev_led_value
Definition: libevdev.h:1376
void libevdev_set_uniq(struct libevdev *dev, const char *uniq)
debug information
Definition: libevdev.h:493
const char * libevdev_event_code_get_name(unsigned int type, unsigned int code)
int libevdev_get_repeat(const struct libevdev *dev, int *delay, int *period)
Get the repeat delay and repeat period values for this device.
void libevdev_set_log_function(libevdev_log_func_t logfunc, void *data)
Set a printf-style logging handler for library-internal logging.
The fd is not in O_NONBLOCK and a read may block.
Definition: libevdev.h:432
int libevdev_has_event_type(const struct libevdev *dev, unsigned int type)
int libevdev_event_code_from_name(unsigned int type, const char *name)
Look up an event-code by its type and name.
Turn the LED off.
Definition: libevdev.h:1378
void libevdev_set_abs_maximum(struct libevdev *dev, unsigned int code, int max)
Change the maximum for the given EV_ABS event code, if the code exists.
Pretend the next event is a SYN_DROPPED and require the caller to sync.
Definition: libevdev.h:430
int libevdev_get_abs_fuzz(const struct libevdev *dev, unsigned int code)
Get the axis fuzz for the given axis, as advertised by the kernel.
int libevdev_set_slot_value(struct libevdev *dev, unsigned int slot, unsigned int code, int value)
Set the value for a given code for the given slot.
int libevdev_event_code_from_name_n(unsigned int type, const char *name, size_t len)
Look up an event-code by its type and name.
void libevdev_set_id_vendor(struct libevdev *dev, int vendor_id)
void libevdev_set_log_priority(enum libevdev_log_priority priority)
Define the minimum level to be printed to the log handler.
void libevdev_set_abs_resolution(struct libevdev *dev, unsigned int code, int resolution)
Change the resolution for the given EV_ABS event code, if the code exists.
int libevdev_get_abs_minimum(const struct libevdev *dev, unsigned int code)
Get the minimum axis value for the given axis, as advertised by the kernel.
int libevdev_grab(struct libevdev *dev, enum libevdev_grab_mode grab)
Grab or ungrab the device through a kernel EVIOCGRAB.
Turn the LED on.
Definition: libevdev.h:1377
int libevdev_get_id_bustype(const struct libevdev *dev)
int libevdev_event_type_get_max(unsigned int type)
int libevdev_event_type_from_name(const char *name)
Look up an event-type by its name.
int libevdev_disable_event_code(struct libevdev *dev, unsigned int type, unsigned int code)
Forcibly disable an event code on this device, even if the underlying device provides it...
int libevdev_get_slot_value(const struct libevdev *dev, unsigned int slot, unsigned int code)
Return the current value of the code for the given slot.
int libevdev_get_event_value(const struct libevdev *dev, unsigned int type, unsigned int code)
Behaviour of this function is undefined if the device does not provide the event. ...
const char * libevdev_get_name(const struct libevdev *dev)
int libevdev_get_driver_version(const struct libevdev *dev)
int libevdev_get_id_version(const struct libevdev *dev)
int libevdev_get_abs_flat(const struct libevdev *dev, unsigned int code)
Get the axis flat for the given axis, as advertised by the kernel.
int libevdev_next_event(struct libevdev *dev, unsigned int flags, struct input_event *ev)
Get the next event from the device.
const char * libevdev_get_uniq(const struct libevdev *dev)
Depending on the libevdev_next_event() read flag:
Definition: libevdev.h:660
int libevdev_new_from_fd(int fd, struct libevdev **dev)
Initialize a new libevdev device from the given fd.
void(* libevdev_log_func_t)(enum libevdev_log_priority priority, void *data, const char *file, int line, const char *func, const char *format, va_list args)
Logging function called by library-internal logging.
Definition: libevdev.h:512
int libevdev_fetch_event_value(const struct libevdev *dev, unsigned int type, unsigned int code, int *value)
Fetch the current value of the event type.
int libevdev_set_event_value(struct libevdev *dev, unsigned int type, unsigned int code, int value)
Set the value for a given event type and code.
int libevdev_kernel_set_abs_info(struct libevdev *dev, unsigned int code, const struct input_absinfo *abs)
Set the device's EV_ABS axis to the value defined in the abs parameter.
int libevdev_fetch_slot_value(const struct libevdev *dev, unsigned int slot, unsigned int code, int *value)
Fetch the current value of the code for the given slot.
int libevdev_get_abs_maximum(const struct libevdev *dev, unsigned int code)
Get the maximum axis value for the given axis, as advertised by the kernel.
void libevdev_set_id_bustype(struct libevdev *dev, int bustype)
int libevdev_get_current_slot(const struct libevdev *dev)
Get the currently active slot.
int libevdev_event_is_code(const struct input_event *ev, unsigned int type, unsigned int code)
Helper function to check if an event is of a specific type and code.
int libevdev_event_is_type(const struct input_event *ev, unsigned int type)
Helper function to check if an event is of a specific type.
void libevdev_set_id_version(struct libevdev *dev, int version)
const char * libevdev_property_get_name(unsigned int prop)
int libevdev_get_id_product(const struct libevdev *dev)
const char * libevdev_get_phys(const struct libevdev *dev)
Virtual devices such as uinput devices have no phys location.
int libevdev_enable_event_type(struct libevdev *dev, unsigned int type)
Forcibly enable an event type on this device, even if the underlying device does not support it...
int libevdev_kernel_set_led_value(struct libevdev *dev, unsigned int code, enum libevdev_led_value value)
Turn an LED on or off.
int libevdev_set_clock_id(struct libevdev *dev, int clockid)
Set the clock ID to be used for timestamps.
int libevdev_get_num_slots(const struct libevdev *dev)
Get the number of slots supported by this device.
libevdev_next_event() has finished without an error and an event is available for processing...
Definition: libevdev.h:651
int libevdev_enable_event_code(struct libevdev *dev, unsigned int type, unsigned int code, const void *data)
Forcibly enable an event type on this device, even if the underlying device does not support it...
libevdev_read_flag
Definition: libevdev.h:427
int libevdev_set_fd(struct libevdev *dev, int fd)
Set the fd for this struct and initialize internal data.
int libevdev_kernel_set_led_values(struct libevdev *dev,...)
Turn multiple LEDs on or off simultaneously.
void libevdev_set_abs_flat(struct libevdev *dev, unsigned int code, int flat)
Change the flat for the given EV_ABS event code, if the code exists.
void libevdev_set_phys(struct libevdev *dev, const char *phys)
int libevdev_disable_event_type(struct libevdev *dev, unsigned int type)
Forcibly disable an event type on this device, even if the underlying device provides it...
critical errors and application bugs
Definition: libevdev.h:491
void libevdev_set_abs_info(struct libevdev *dev, unsigned int code, const struct input_absinfo *abs)
Change the abs info for the given EV_ABS event code, if the code exists.
Grab the device if not currently grabbed.
Definition: libevdev.h:555
void libevdev_set_name(struct libevdev *dev, const char *name)
void libevdev_free(struct libevdev *dev)
Clean up and free the libevdev struct.
void libevdev_set_abs_minimum(struct libevdev *dev, unsigned int code, int min)
Change the minimum for the given EV_ABS event code, if the code exists.
informational messages
Definition: libevdev.h:492
int libevdev_get_id_vendor(const struct libevdev *dev)
Process data in normal mode.
Definition: libevdev.h:429
libevdev_grab_mode
Definition: libevdev.h:554
void libevdev_set_id_product(struct libevdev *dev, int product_id)
struct libevdev * libevdev_new(void)
Initialize a new libevdev device.
Ungrab the device if currently grabbed.
Definition: libevdev.h:556