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 
751 struct libevdev;
752 
762 };
763 
778 struct libevdev* libevdev_new(void);
779 
802 int libevdev_new_from_fd(int fd, struct libevdev **dev);
803 
817 void libevdev_free(struct libevdev *dev);
818 
825  LIBEVDEV_LOG_DEBUG = 30
826 };
827 
844 typedef void (*libevdev_log_func_t)(enum libevdev_log_priority priority,
845  void *data,
846  const char *file, int line,
847  const char *func,
848  const char *format, va_list args)
850 
870 
884 
897 
917 typedef void (*libevdev_device_log_func_t)(const struct libevdev *dev,
918  enum libevdev_log_priority priority,
919  void *data,
920  const char *file, int line,
921  const char *func,
922  const char *format, va_list args)
924 
946 void libevdev_set_device_log_function(struct libevdev *dev,
948  enum libevdev_log_priority priority,
949  void *data);
950 
956  LIBEVDEV_UNGRAB = 4
957 };
958 
981 int libevdev_grab(struct libevdev *dev, enum libevdev_grab_mode grab);
982 
1015 int libevdev_set_fd(struct libevdev* dev, int fd);
1016 
1055 int libevdev_change_fd(struct libevdev* dev, int fd);
1056 
1065 int libevdev_get_fd(const struct libevdev* dev);
1066 
1087 };
1088 
1139 int libevdev_next_event(struct libevdev *dev, unsigned int flags, struct input_event *ev);
1140 
1163 int libevdev_has_event_pending(struct libevdev *dev);
1164 
1179 const char* libevdev_get_name(const struct libevdev *dev);
1180 
1194 void libevdev_set_name(struct libevdev *dev, const char *name);
1195 
1211 const char * libevdev_get_phys(const struct libevdev *dev);
1212 
1226 void libevdev_set_phys(struct libevdev *dev, const char *phys);
1227 
1241 const char * libevdev_get_uniq(const struct libevdev *dev);
1242 
1256 void libevdev_set_uniq(struct libevdev *dev, const char *uniq);
1257 
1267 int libevdev_get_id_product(const struct libevdev *dev);
1268 
1280 void libevdev_set_id_product(struct libevdev *dev, int product_id);
1281 
1291 int libevdev_get_id_vendor(const struct libevdev *dev);
1292 
1304 void libevdev_set_id_vendor(struct libevdev *dev, int vendor_id);
1305 
1315 int libevdev_get_id_bustype(const struct libevdev *dev);
1316 
1328 void libevdev_set_id_bustype(struct libevdev *dev, int bustype);
1329 
1339 int libevdev_get_id_version(const struct libevdev *dev);
1340 
1352 void libevdev_set_id_version(struct libevdev *dev, int version);
1353 
1363 int libevdev_get_driver_version(const struct libevdev *dev);
1364 
1375 int libevdev_has_property(const struct libevdev *dev, unsigned int prop);
1376 
1388 int libevdev_enable_property(struct libevdev *dev, unsigned int prop);
1389 
1400 int libevdev_has_event_type(const struct libevdev *dev, unsigned int type);
1401 
1413 int libevdev_has_event_code(const struct libevdev *dev, unsigned int type, unsigned int code);
1414 
1427 int libevdev_get_abs_minimum(const struct libevdev *dev, unsigned int code);
1428 
1441 int libevdev_get_abs_maximum(const struct libevdev *dev, unsigned int code);
1442 
1455 int libevdev_get_abs_fuzz(const struct libevdev *dev, unsigned int code);
1456 
1469 int libevdev_get_abs_flat(const struct libevdev *dev, unsigned int code);
1470 
1483 int libevdev_get_abs_resolution(const struct libevdev *dev, unsigned int code);
1484 
1498 const struct input_absinfo* libevdev_get_abs_info(const struct libevdev *dev, unsigned int code);
1499 
1522 int libevdev_get_event_value(const struct libevdev *dev, unsigned int type, unsigned int code);
1523 
1558 int libevdev_set_event_value(struct libevdev *dev, unsigned int type, unsigned int code, int value);
1559 
1585 int libevdev_fetch_event_value(const struct libevdev *dev, unsigned int type, unsigned int code, int *value);
1586 
1607 int libevdev_get_slot_value(const struct libevdev *dev, unsigned int slot, unsigned int code);
1608 
1637 int libevdev_set_slot_value(struct libevdev *dev, unsigned int slot, unsigned int code, int value);
1638 
1664 int libevdev_fetch_slot_value(const struct libevdev *dev, unsigned int slot, unsigned int code, int *value);
1665 
1679 int libevdev_get_num_slots(const struct libevdev *dev);
1680 
1696 int libevdev_get_current_slot(const struct libevdev *dev);
1697 
1709 void libevdev_set_abs_minimum(struct libevdev *dev, unsigned int code, int min);
1710 
1722 void libevdev_set_abs_maximum(struct libevdev *dev, unsigned int code, int max);
1723 
1735 void libevdev_set_abs_fuzz(struct libevdev *dev, unsigned int code, int fuzz);
1736 
1748 void libevdev_set_abs_flat(struct libevdev *dev, unsigned int code, int flat);
1749 
1761 void libevdev_set_abs_resolution(struct libevdev *dev, unsigned int code, int resolution);
1762 
1774 void libevdev_set_abs_info(struct libevdev *dev, unsigned int code, const struct input_absinfo *abs);
1775 
1793 int libevdev_enable_event_type(struct libevdev *dev, unsigned int type);
1794 
1821 int libevdev_disable_event_type(struct libevdev *dev, unsigned int type);
1822 
1856 int libevdev_enable_event_code(struct libevdev *dev, unsigned int type, unsigned int code, const void *data);
1857 
1885 int libevdev_disable_event_code(struct libevdev *dev, unsigned int type, unsigned int code);
1886 
1901 int libevdev_kernel_set_abs_info(struct libevdev *dev, unsigned int code, const struct input_absinfo *abs);
1902 
1908  LIBEVDEV_LED_OFF = 4
1909 };
1910 
1924 int libevdev_kernel_set_led_value(struct libevdev *dev, unsigned int code, enum libevdev_led_value value);
1925 
1949 int libevdev_kernel_set_led_values(struct libevdev *dev, ...);
1950 
1965 int libevdev_set_clock_id(struct libevdev *dev, int clockid);
1966 
1988 int libevdev_event_is_type(const struct input_event *ev, unsigned int type);
1989 
2013 int libevdev_event_is_code(const struct input_event *ev, unsigned int type, unsigned int code);
2014 
2026 const char * libevdev_event_type_get_name(unsigned int type);
2039 const char * libevdev_event_code_get_name(unsigned int type, unsigned int code);
2040 
2061 const char * libevdev_event_value_get_name(unsigned int type,
2062  unsigned int code,
2063  int value);
2077 const char* libevdev_property_get_name(unsigned int prop);
2078 
2091 int libevdev_event_type_get_max(unsigned int type);
2092 
2107 int libevdev_event_type_from_name(const char *name);
2108 
2125 int libevdev_event_type_from_name_n(const char *name, size_t len);
2126 
2146 int libevdev_event_code_from_name(unsigned int type, const char *name);
2147 
2169 int libevdev_event_code_from_name_n(unsigned int type, const char *name,
2170  size_t len);
2171 
2193 int libevdev_event_value_from_name(unsigned int type, unsigned int code,
2194  const char *name);
2195 
2212 int
2214 
2233 int
2234 libevdev_event_type_from_code_name_n(const char *name, size_t len);
2235 
2252 int
2254 
2273 int
2274 libevdev_event_code_from_code_name_n(const char *name, size_t len);
2275 
2299 int libevdev_event_value_from_name_n(unsigned int type, unsigned int code,
2300  const char *name, size_t len);
2301 
2314 int libevdev_property_from_name(const char *name);
2315 
2330 int libevdev_property_from_name_n(const char *name, size_t len);
2331 
2349 int libevdev_get_repeat(const struct libevdev *dev, int *delay, int *period);
2350 
2351 /********* DEPRECATED SECTION *********/
2352 #if defined(__GNUC__) && __GNUC__ >= 4
2353 #define LIBEVDEV_DEPRECATED __attribute__ ((deprecated))
2354 #else
2355 #define LIBEVDEV_DEPRECATED
2356 #endif
2357 
2358 #ifdef __cplusplus
2359 }
2360 #endif
2361 
2362 #endif /* LIBEVDEV_H */
@ LIBEVDEV_UNGRAB
Ungrab the device if currently grabbed.
Definition: libevdev.h:956
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)
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:955
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:761
int libevdev_property_from_name_n(const char *name, size_t len)
@ LIBEVDEV_LED_OFF
Turn the LED off.
Definition: libevdev.h:1908
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:1070
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)
void libevdev_set_log_function(libevdev_log_func_t logfunc, void *data)
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:822
int libevdev_get_id_version(const struct libevdev *dev)
#define LIBEVDEV_ATTRIBUTE_PRINTF(_format, _args)
Definition: libevdev.h:33
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)
Definition: libevdev.h:844
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:759
int libevdev_has_event_type(const struct libevdev *dev, unsigned int type)
@ LIBEVDEV_LOG_INFO
informational messages
Definition: libevdev.h:824
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)
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:756
int libevdev_get_id_product(const struct libevdev *dev)
void libevdev_set_device_log_function(struct libevdev *dev, libevdev_device_log_func_t logfunc, enum libevdev_log_priority priority, void *data)
libevdev_led_value
Definition: libevdev.h:1906
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:823
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:1086
@ LIBEVDEV_LOG_DEBUG
debug information
Definition: libevdev.h:825
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_READ_STATUS_SUCCESS
libevdev_next_event() has finished without an error and an event is available for processing.
Definition: libevdev.h:1077
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)
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:954
const char * libevdev_get_name(const struct libevdev *dev)
@ LIBEVDEV_LED_ON
Turn the LED on.
Definition: libevdev.h:1907
@ LIBEVDEV_READ_FLAG_NORMAL
Process data in normal mode.
Definition: libevdev.h:758
@ LIBEVDEV_READ_FLAG_SYNC
Process data in sync mode.
Definition: libevdev.h:757
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)
Definition: libevdev.h:917
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)