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 
1399 int libevdev_has_event_type(const struct libevdev *dev, unsigned int type);
1400 
1412 int libevdev_has_event_code(const struct libevdev *dev, unsigned int type, unsigned int code);
1413 
1426 int libevdev_get_abs_minimum(const struct libevdev *dev, unsigned int code);
1427 
1440 int libevdev_get_abs_maximum(const struct libevdev *dev, unsigned int code);
1441 
1454 int libevdev_get_abs_fuzz(const struct libevdev *dev, unsigned int code);
1455 
1468 int libevdev_get_abs_flat(const struct libevdev *dev, unsigned int code);
1469 
1482 int libevdev_get_abs_resolution(const struct libevdev *dev, unsigned int code);
1483 
1497 const struct input_absinfo* libevdev_get_abs_info(const struct libevdev *dev, unsigned int code);
1498 
1521 int libevdev_get_event_value(const struct libevdev *dev, unsigned int type, unsigned int code);
1522 
1557 int libevdev_set_event_value(struct libevdev *dev, unsigned int type, unsigned int code, int value);
1558 
1584 int libevdev_fetch_event_value(const struct libevdev *dev, unsigned int type, unsigned int code, int *value);
1585 
1606 int libevdev_get_slot_value(const struct libevdev *dev, unsigned int slot, unsigned int code);
1607 
1636 int libevdev_set_slot_value(struct libevdev *dev, unsigned int slot, unsigned int code, int value);
1637 
1663 int libevdev_fetch_slot_value(const struct libevdev *dev, unsigned int slot, unsigned int code, int *value);
1664 
1678 int libevdev_get_num_slots(const struct libevdev *dev);
1679 
1695 int libevdev_get_current_slot(const struct libevdev *dev);
1696 
1708 void libevdev_set_abs_minimum(struct libevdev *dev, unsigned int code, int min);
1709 
1721 void libevdev_set_abs_maximum(struct libevdev *dev, unsigned int code, int max);
1722 
1734 void libevdev_set_abs_fuzz(struct libevdev *dev, unsigned int code, int fuzz);
1735 
1747 void libevdev_set_abs_flat(struct libevdev *dev, unsigned int code, int flat);
1748 
1760 void libevdev_set_abs_resolution(struct libevdev *dev, unsigned int code, int resolution);
1761 
1773 void libevdev_set_abs_info(struct libevdev *dev, unsigned int code, const struct input_absinfo *abs);
1774 
1792 int libevdev_enable_event_type(struct libevdev *dev, unsigned int type);
1793 
1820 int libevdev_disable_event_type(struct libevdev *dev, unsigned int type);
1821 
1855 int libevdev_enable_event_code(struct libevdev *dev, unsigned int type, unsigned int code, const void *data);
1856 
1884 int libevdev_disable_event_code(struct libevdev *dev, unsigned int type, unsigned int code);
1885 
1900 int libevdev_kernel_set_abs_info(struct libevdev *dev, unsigned int code, const struct input_absinfo *abs);
1901 
1908 };
1909 
1923 int libevdev_kernel_set_led_value(struct libevdev *dev, unsigned int code, enum libevdev_led_value value);
1924 
1948 int libevdev_kernel_set_led_values(struct libevdev *dev, ...);
1949 
1964 int libevdev_set_clock_id(struct libevdev *dev, int clockid);
1965 
1987 int libevdev_event_is_type(const struct input_event *ev, unsigned int type);
1988 
2012 int libevdev_event_is_code(const struct input_event *ev, unsigned int type, unsigned int code);
2013 
2025 const char * libevdev_event_type_get_name(unsigned int type);
2038 const char * libevdev_event_code_get_name(unsigned int type, unsigned int code);
2039 
2060 const char * libevdev_event_value_get_name(unsigned int type,
2061  unsigned int code,
2062  int value);
2076 const char* libevdev_property_get_name(unsigned int prop);
2077 
2090 int libevdev_event_type_get_max(unsigned int type);
2091 
2106 int libevdev_event_type_from_name(const char *name);
2107 
2124 int libevdev_event_type_from_name_n(const char *name, size_t len);
2125 
2145 int libevdev_event_code_from_name(unsigned int type, const char *name);
2146 
2168 int libevdev_event_code_from_name_n(unsigned int type, const char *name,
2169  size_t len);
2170 
2192 int libevdev_event_value_from_name(unsigned int type, unsigned int code,
2193  const char *name);
2194 
2211 int
2212 libevdev_event_type_from_code_name(const char *name);
2213 
2232 int
2233 libevdev_event_type_from_code_name_n(const char *name, size_t len);
2234 
2251 int
2252 libevdev_event_code_from_code_name(const char *name);
2253 
2272 int
2273 libevdev_event_code_from_code_name_n(const char *name, size_t len);
2274 
2298 int libevdev_event_value_from_name_n(unsigned int type, unsigned int code,
2299  const char *name, size_t len);
2300 
2313 int libevdev_property_from_name(const char *name);
2314 
2329 int libevdev_property_from_name_n(const char *name, size_t len);
2330 
2348 int libevdev_get_repeat(const struct libevdev *dev, int *delay, int *period);
2349 
2350 /********* DEPRECATED SECTION *********/
2351 #if defined(__GNUC__) && __GNUC__ >= 4
2352 #define LIBEVDEV_DEPRECATED __attribute__ ((deprecated))
2353 #else
2354 #define LIBEVDEV_DEPRECATED
2355 #endif
2356 
2357 #ifdef __cplusplus
2358 }
2359 #endif
2360 
2361 #endif /* LIBEVDEV_H */
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)
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)
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)
Turn the LED off.
Definition: libevdev.h:1907
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)
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)
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:1905
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)
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)
Depending on the libevdev_next_event() read flag:
Definition: libevdev.h:1085
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)
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)
Turn the LED on.
Definition: libevdev.h:1906
Process data in normal mode.
Definition: libevdev.h:757
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)