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 
33 #define LIBEVDEV_ATTRIBUTE_PRINTF(_format, _args) __attribute__ ((format (printf, _format, _args)))
34 
750 struct libevdev;
751 
761 };
762 
777 struct libevdev* libevdev_new(void);
778 
801 int libevdev_new_from_fd(int fd, struct libevdev **dev);
802 
816 void libevdev_free(struct libevdev *dev);
817 
825 };
826 
843 typedef void (*libevdev_log_func_t)(enum libevdev_log_priority priority,
844  void *data,
845  const char *file, int line,
846  const char *func,
847  const char *format, va_list args)
849 
869 
883 
896 
916 typedef void (*libevdev_device_log_func_t)(const struct libevdev *dev,
917  enum libevdev_log_priority priority,
918  void *data,
919  const char *file, int line,
920  const char *func,
921  const char *format, va_list args)
923 
945 void libevdev_set_device_log_function(struct libevdev *dev,
947  enum libevdev_log_priority priority,
948  void *data);
949 
956 };
957 
980 int libevdev_grab(struct libevdev *dev, enum libevdev_grab_mode grab);
981 
1014 int libevdev_set_fd(struct libevdev* dev, int fd);
1015 
1054 int libevdev_change_fd(struct libevdev* dev, int fd);
1055 
1064 int libevdev_get_fd(const struct libevdev* dev);
1065 
1086 };
1087 
1138 int libevdev_next_event(struct libevdev *dev, unsigned int flags, struct input_event *ev);
1139 
1162 int libevdev_has_event_pending(struct libevdev *dev);
1163 
1178 const char* libevdev_get_name(const struct libevdev *dev);
1179 
1193 void libevdev_set_name(struct libevdev *dev, const char *name);
1194 
1210 const char * libevdev_get_phys(const struct libevdev *dev);
1211 
1225 void libevdev_set_phys(struct libevdev *dev, const char *phys);
1226 
1240 const char * libevdev_get_uniq(const struct libevdev *dev);
1241 
1255 void libevdev_set_uniq(struct libevdev *dev, const char *uniq);
1256 
1266 int libevdev_get_id_product(const struct libevdev *dev);
1267 
1279 void libevdev_set_id_product(struct libevdev *dev, int product_id);
1280 
1290 int libevdev_get_id_vendor(const struct libevdev *dev);
1291 
1303 void libevdev_set_id_vendor(struct libevdev *dev, int vendor_id);
1304 
1314 int libevdev_get_id_bustype(const struct libevdev *dev);
1315 
1327 void libevdev_set_id_bustype(struct libevdev *dev, int bustype);
1328 
1338 int libevdev_get_id_version(const struct libevdev *dev);
1339 
1351 void libevdev_set_id_version(struct libevdev *dev, int version);
1352 
1362 int libevdev_get_driver_version(const struct libevdev *dev);
1363 
1374 int libevdev_has_property(const struct libevdev *dev, unsigned int prop);
1375 
1387 int libevdev_enable_property(struct libevdev *dev, unsigned int prop);
1388 
1397 int libevdev_disable_property(struct libevdev *dev, unsigned int prop);
1398 
1409 int libevdev_has_event_type(const struct libevdev *dev, unsigned int type);
1410 
1422 int libevdev_has_event_code(const struct libevdev *dev, unsigned int type, unsigned int code);
1423 
1436 int libevdev_get_abs_minimum(const struct libevdev *dev, unsigned int code);
1437 
1450 int libevdev_get_abs_maximum(const struct libevdev *dev, unsigned int code);
1451 
1464 int libevdev_get_abs_fuzz(const struct libevdev *dev, unsigned int code);
1465 
1478 int libevdev_get_abs_flat(const struct libevdev *dev, unsigned int code);
1479 
1492 int libevdev_get_abs_resolution(const struct libevdev *dev, unsigned int code);
1493 
1507 const struct input_absinfo* libevdev_get_abs_info(const struct libevdev *dev, unsigned int code);
1508 
1531 int libevdev_get_event_value(const struct libevdev *dev, unsigned int type, unsigned int code);
1532 
1567 int libevdev_set_event_value(struct libevdev *dev, unsigned int type, unsigned int code, int value);
1568 
1594 int libevdev_fetch_event_value(const struct libevdev *dev, unsigned int type, unsigned int code, int *value);
1595 
1616 int libevdev_get_slot_value(const struct libevdev *dev, unsigned int slot, unsigned int code);
1617 
1646 int libevdev_set_slot_value(struct libevdev *dev, unsigned int slot, unsigned int code, int value);
1647 
1673 int libevdev_fetch_slot_value(const struct libevdev *dev, unsigned int slot, unsigned int code, int *value);
1674 
1688 int libevdev_get_num_slots(const struct libevdev *dev);
1689 
1705 int libevdev_get_current_slot(const struct libevdev *dev);
1706 
1718 void libevdev_set_abs_minimum(struct libevdev *dev, unsigned int code, int min);
1719 
1731 void libevdev_set_abs_maximum(struct libevdev *dev, unsigned int code, int max);
1732 
1744 void libevdev_set_abs_fuzz(struct libevdev *dev, unsigned int code, int fuzz);
1745 
1757 void libevdev_set_abs_flat(struct libevdev *dev, unsigned int code, int flat);
1758 
1770 void libevdev_set_abs_resolution(struct libevdev *dev, unsigned int code, int resolution);
1771 
1783 void libevdev_set_abs_info(struct libevdev *dev, unsigned int code, const struct input_absinfo *abs);
1784 
1802 int libevdev_enable_event_type(struct libevdev *dev, unsigned int type);
1803 
1830 int libevdev_disable_event_type(struct libevdev *dev, unsigned int type);
1831 
1865 int libevdev_enable_event_code(struct libevdev *dev, unsigned int type, unsigned int code, const void *data);
1866 
1894 int libevdev_disable_event_code(struct libevdev *dev, unsigned int type, unsigned int code);
1895 
1910 int libevdev_kernel_set_abs_info(struct libevdev *dev, unsigned int code, const struct input_absinfo *abs);
1911 
1918 };
1919 
1933 int libevdev_kernel_set_led_value(struct libevdev *dev, unsigned int code, enum libevdev_led_value value);
1934 
1958 int libevdev_kernel_set_led_values(struct libevdev *dev, ...);
1959 
1974 int libevdev_set_clock_id(struct libevdev *dev, int clockid);
1975 
1997 int libevdev_event_is_type(const struct input_event *ev, unsigned int type);
1998 
2022 int libevdev_event_is_code(const struct input_event *ev, unsigned int type, unsigned int code);
2023 
2035 const char * libevdev_event_type_get_name(unsigned int type);
2048 const char * libevdev_event_code_get_name(unsigned int type, unsigned int code);
2049 
2070 const char * libevdev_event_value_get_name(unsigned int type,
2071  unsigned int code,
2072  int value);
2086 const char* libevdev_property_get_name(unsigned int prop);
2087 
2100 int libevdev_event_type_get_max(unsigned int type);
2101 
2116 int libevdev_event_type_from_name(const char *name);
2117 
2134 int libevdev_event_type_from_name_n(const char *name, size_t len);
2135 
2155 int libevdev_event_code_from_name(unsigned int type, const char *name);
2156 
2178 int libevdev_event_code_from_name_n(unsigned int type, const char *name,
2179  size_t len);
2180 
2202 int libevdev_event_value_from_name(unsigned int type, unsigned int code,
2203  const char *name);
2204 
2221 int
2222 libevdev_event_type_from_code_name(const char *name);
2223 
2242 int
2243 libevdev_event_type_from_code_name_n(const char *name, size_t len);
2244 
2261 int
2262 libevdev_event_code_from_code_name(const char *name);
2263 
2282 int
2283 libevdev_event_code_from_code_name_n(const char *name, size_t len);
2284 
2308 int libevdev_event_value_from_name_n(unsigned int type, unsigned int code,
2309  const char *name, size_t len);
2310 
2323 int libevdev_property_from_name(const char *name);
2324 
2339 int libevdev_property_from_name_n(const char *name, size_t len);
2340 
2358 int libevdev_get_repeat(const struct libevdev *dev, int *delay, int *period);
2359 
2360 /********* DEPRECATED SECTION *********/
2361 #if defined(__GNUC__) && __GNUC__ >= 4
2362 #define LIBEVDEV_DEPRECATED __attribute__ ((deprecated))
2363 #else
2364 #define LIBEVDEV_DEPRECATED
2365 #endif
2366 
2367 #ifdef __cplusplus
2368 }
2369 #endif
2370 
2371 #endif /* LIBEVDEV_H */
@ LIBEVDEV_UNGRAB
Ungrab the device if currently grabbed.
Definition: libevdev.h:955
int libevdev_event_type_get_max(unsigned int type)
int libevdev_has_event_code(const struct libevdev *dev, unsigned int type, unsigned int code)
int libevdev_event_value_from_name_n(unsigned int type, unsigned int code, const char *name, size_t len)
const struct input_absinfo * libevdev_get_abs_info(const struct libevdev *dev, unsigned int code)
void libevdev_set_id_version(struct libevdev *dev, int version)
int libevdev_event_type_from_name(const char *name)
int libevdev_kernel_set_led_value(struct libevdev *dev, unsigned int code, enum libevdev_led_value value)
void(*) voi libevdev_set_device_log_function)(struct libevdev *dev, libevdev_device_log_func_t logfunc, enum libevdev_log_priority priority, void *data)
Definition: libevdev.h:945
int libevdev_has_property(const struct libevdev *dev, unsigned int prop)
int libevdev_event_type_from_code_name_n(const char *name, size_t len)
@ LIBEVDEV_GRAB
Grab the device if not currently grabbed.
Definition: libevdev.h:954
int libevdev_event_value_from_name(unsigned int type, unsigned int code, const char *name)
@ LIBEVDEV_READ_FLAG_BLOCKING
The fd is not in O_NONBLOCK and a read may block.
Definition: libevdev.h:760
int libevdev_property_from_name_n(const char *name, size_t len)
@ LIBEVDEV_LED_OFF
Turn the LED off.
Definition: libevdev.h:1917
int libevdev_get_abs_resolution(const struct libevdev *dev, unsigned int code)
int libevdev_event_type_from_name_n(const char *name, size_t len)
libevdev_read_status
Definition: libevdev.h:1069
int libevdev_enable_event_type(struct libevdev *dev, unsigned int type)
int libevdev_property_from_name(const char *name)
int libevdev_enable_property(struct libevdev *dev, unsigned int prop)
int libevdev_kernel_set_led_values(struct libevdev *dev,...)
int libevdev_fetch_event_value(const struct libevdev *dev, unsigned int type, unsigned int code, int *value)
struct libevdev * libevdev_new(void)
int libevdev_get_slot_value(const struct libevdev *dev, unsigned int slot, unsigned int code)
libevdev_log_priority
Definition: libevdev.h:821
int libevdev_get_id_version(const struct libevdev *dev)
#define LIBEVDEV_ATTRIBUTE_PRINTF(_format, _args)
Definition: libevdev.h:33
void libevdev_set_abs_flat(struct libevdev *dev, unsigned int code, int flat)
const char * libevdev_event_code_get_name(unsigned int type, unsigned int code)
int libevdev_kernel_set_abs_info(struct libevdev *dev, unsigned int code, const struct input_absinfo *abs)
int libevdev_get_event_value(const struct libevdev *dev, unsigned int type, unsigned int code)
int libevdev_event_code_from_name_n(unsigned int type, const char *name, size_t len)
void libevdev_set_abs_maximum(struct libevdev *dev, unsigned int code, int max)
int libevdev_event_code_from_code_name_n(const char *name, size_t len)
int libevdev_set_slot_value(struct libevdev *dev, unsigned int slot, unsigned int code, int value)
int libevdev_set_fd(struct libevdev *dev, int fd)
void libevdev_set_id_vendor(struct libevdev *dev, int vendor_id)
void libevdev_free(struct libevdev *dev)
enum libevdev_log_priority libevdev_get_log_priority(void)
int libevdev_get_repeat(const struct libevdev *dev, int *delay, int *period)
int libevdev_fetch_slot_value(const struct libevdev *dev, unsigned int slot, unsigned int code, int *value)
void libevdev_set_id_product(struct libevdev *dev, int product_id)
@ LIBEVDEV_READ_FLAG_FORCE_SYNC
Pretend the next event is a SYN_DROPPED and require the caller to sync.
Definition: libevdev.h:758
int libevdev_has_event_type(const struct libevdev *dev, unsigned int type)
@ LIBEVDEV_LOG_INFO
informational messages
Definition: libevdev.h:823
int libevdev_has_event_pending(struct libevdev *dev)
void libevdev_set_abs_info(struct libevdev *dev, unsigned int code, const struct input_absinfo *abs)
int libevdev_get_id_bustype(const struct libevdev *dev)
void libevdev_set_name(struct libevdev *dev, const char *name)
void(*) voi libevdev_set_log_function)(libevdev_log_func_t logfunc, void *data)
Definition: libevdev.h:868
const char * libevdev_get_uniq(const struct libevdev *dev)
void libevdev_set_id_bustype(struct libevdev *dev, int bustype)
libevdev_read_flag
Definition: libevdev.h:755
int libevdev_get_id_product(const struct libevdev *dev)
libevdev_led_value
Definition: libevdev.h:1915
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) LIBEVDEV_ATTRIBUTE_PRINTF(6
Definition: libevdev.h:843
int libevdev_get_id_vendor(const struct libevdev *dev)
void libevdev_set_uniq(struct libevdev *dev, const char *uniq)
@ LIBEVDEV_LOG_ERROR
critical errors and application bugs
Definition: libevdev.h:822
void libevdev_set_abs_fuzz(struct libevdev *dev, unsigned int code, int fuzz)
int libevdev_get_abs_flat(const struct libevdev *dev, unsigned int code)
int libevdev_get_num_slots(const struct libevdev *dev)
@ LIBEVDEV_READ_STATUS_SYNC
Depending on the libevdev_next_event() read flag:
Definition: libevdev.h:1085
@ LIBEVDEV_LOG_DEBUG
debug information
Definition: libevdev.h:824
int libevdev_next_event(struct libevdev *dev, unsigned int flags, struct input_event *ev)
int libevdev_get_abs_minimum(const struct libevdev *dev, unsigned int code)
int libevdev_disable_property(struct libevdev *dev, unsigned int prop)
@ LIBEVDEV_READ_STATUS_SUCCESS
libevdev_next_event() has finished without an error and an event is available for processing.
Definition: libevdev.h:1076
void libevdev_set_abs_resolution(struct libevdev *dev, unsigned int code, int resolution)
int libevdev_get_current_slot(const struct libevdev *dev)
void libevdev_set_abs_minimum(struct libevdev *dev, unsigned int code, int min)
int libevdev_event_is_code(const struct input_event *ev, unsigned int type, unsigned int code)
int libevdev_enable_event_code(struct libevdev *dev, unsigned int type, unsigned int code, const void *data)
void(* libevdev_device_log_func_t)(const struct libevdev *dev, enum libevdev_log_priority priority, void *data, const char *file, int line, const char *func, const char *format, va_list args) LIBEVDEV_ATTRIBUTE_PRINTF(7
Definition: libevdev.h:916
const char * libevdev_property_get_name(unsigned int prop)
const char * libevdev_event_value_get_name(unsigned int type, unsigned int code, int value)
int libevdev_get_driver_version(const struct libevdev *dev)
int libevdev_event_code_from_name(unsigned int type, const char *name)
int libevdev_set_clock_id(struct libevdev *dev, int clockid)
int libevdev_get_abs_maximum(const struct libevdev *dev, unsigned int code)
void libevdev_set_phys(struct libevdev *dev, const char *phys)
int libevdev_disable_event_code(struct libevdev *dev, unsigned int type, unsigned int code)
int libevdev_change_fd(struct libevdev *dev, int fd)
int libevdev_disable_event_type(struct libevdev *dev, unsigned int type)
const char * libevdev_get_phys(const struct libevdev *dev)
int libevdev_get_fd(const struct libevdev *dev)
int libevdev_get_abs_fuzz(const struct libevdev *dev, unsigned int code)
const char * libevdev_event_type_get_name(unsigned int type)
void libevdev_set_log_priority(enum libevdev_log_priority priority)
int libevdev_event_code_from_code_name(const char *name)
int libevdev_grab(struct libevdev *dev, enum libevdev_grab_mode grab)
int libevdev_event_is_type(const struct input_event *ev, unsigned int type)
libevdev_grab_mode
Definition: libevdev.h:953
const char * libevdev_get_name(const struct libevdev *dev)
@ LIBEVDEV_LED_ON
Turn the LED on.
Definition: libevdev.h:1916
@ LIBEVDEV_READ_FLAG_NORMAL
Process data in normal mode.
Definition: libevdev.h:757
@ LIBEVDEV_READ_FLAG_SYNC
Process data in sync mode.
Definition: libevdev.h:756
int libevdev_set_event_value(struct libevdev *dev, unsigned int type, unsigned int code, int value)
int libevdev_event_type_from_code_name(const char *name)
int libevdev_new_from_fd(int fd, struct libevdev **dev)