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 
1398 int libevdev_disable_property(struct libevdev *dev, unsigned int prop);
1399 
1410 int libevdev_has_event_type(const struct libevdev *dev, unsigned int type);
1411 
1423 int libevdev_has_event_code(const struct libevdev *dev, unsigned int type, unsigned int code);
1424 
1437 int libevdev_get_abs_minimum(const struct libevdev *dev, unsigned int code);
1438 
1451 int libevdev_get_abs_maximum(const struct libevdev *dev, unsigned int code);
1452 
1465 int libevdev_get_abs_fuzz(const struct libevdev *dev, unsigned int code);
1466 
1479 int libevdev_get_abs_flat(const struct libevdev *dev, unsigned int code);
1480 
1493 int libevdev_get_abs_resolution(const struct libevdev *dev, unsigned int code);
1494 
1508 const struct input_absinfo* libevdev_get_abs_info(const struct libevdev *dev, unsigned int code);
1509 
1532 int libevdev_get_event_value(const struct libevdev *dev, unsigned int type, unsigned int code);
1533 
1568 int libevdev_set_event_value(struct libevdev *dev, unsigned int type, unsigned int code, int value);
1569 
1595 int libevdev_fetch_event_value(const struct libevdev *dev, unsigned int type, unsigned int code, int *value);
1596 
1617 int libevdev_get_slot_value(const struct libevdev *dev, unsigned int slot, unsigned int code);
1618 
1647 int libevdev_set_slot_value(struct libevdev *dev, unsigned int slot, unsigned int code, int value);
1648 
1674 int libevdev_fetch_slot_value(const struct libevdev *dev, unsigned int slot, unsigned int code, int *value);
1675 
1689 int libevdev_get_num_slots(const struct libevdev *dev);
1690 
1706 int libevdev_get_current_slot(const struct libevdev *dev);
1707 
1719 void libevdev_set_abs_minimum(struct libevdev *dev, unsigned int code, int min);
1720 
1732 void libevdev_set_abs_maximum(struct libevdev *dev, unsigned int code, int max);
1733 
1745 void libevdev_set_abs_fuzz(struct libevdev *dev, unsigned int code, int fuzz);
1746 
1758 void libevdev_set_abs_flat(struct libevdev *dev, unsigned int code, int flat);
1759 
1771 void libevdev_set_abs_resolution(struct libevdev *dev, unsigned int code, int resolution);
1772 
1784 void libevdev_set_abs_info(struct libevdev *dev, unsigned int code, const struct input_absinfo *abs);
1785 
1803 int libevdev_enable_event_type(struct libevdev *dev, unsigned int type);
1804 
1831 int libevdev_disable_event_type(struct libevdev *dev, unsigned int type);
1832 
1866 int libevdev_enable_event_code(struct libevdev *dev, unsigned int type, unsigned int code, const void *data);
1867 
1895 int libevdev_disable_event_code(struct libevdev *dev, unsigned int type, unsigned int code);
1896 
1911 int libevdev_kernel_set_abs_info(struct libevdev *dev, unsigned int code, const struct input_absinfo *abs);
1912 
1918  LIBEVDEV_LED_OFF = 4
1919 };
1920 
1934 int libevdev_kernel_set_led_value(struct libevdev *dev, unsigned int code, enum libevdev_led_value value);
1935 
1959 int libevdev_kernel_set_led_values(struct libevdev *dev, ...);
1960 
1975 int libevdev_set_clock_id(struct libevdev *dev, int clockid);
1976 
1998 int libevdev_event_is_type(const struct input_event *ev, unsigned int type);
1999 
2023 int libevdev_event_is_code(const struct input_event *ev, unsigned int type, unsigned int code);
2024 
2036 const char * libevdev_event_type_get_name(unsigned int type);
2049 const char * libevdev_event_code_get_name(unsigned int type, unsigned int code);
2050 
2071 const char * libevdev_event_value_get_name(unsigned int type,
2072  unsigned int code,
2073  int value);
2087 const char* libevdev_property_get_name(unsigned int prop);
2088 
2101 int libevdev_event_type_get_max(unsigned int type);
2102 
2117 int libevdev_event_type_from_name(const char *name);
2118 
2135 int libevdev_event_type_from_name_n(const char *name, size_t len);
2136 
2156 int libevdev_event_code_from_name(unsigned int type, const char *name);
2157 
2179 int libevdev_event_code_from_name_n(unsigned int type, const char *name,
2180  size_t len);
2181 
2203 int libevdev_event_value_from_name(unsigned int type, unsigned int code,
2204  const char *name);
2205 
2222 int
2224 
2243 int
2244 libevdev_event_type_from_code_name_n(const char *name, size_t len);
2245 
2262 int
2264 
2283 int
2284 libevdev_event_code_from_code_name_n(const char *name, size_t len);
2285 
2309 int libevdev_event_value_from_name_n(unsigned int type, unsigned int code,
2310  const char *name, size_t len);
2311 
2324 int libevdev_property_from_name(const char *name);
2325 
2340 int libevdev_property_from_name_n(const char *name, size_t len);
2341 
2359 int libevdev_get_repeat(const struct libevdev *dev, int *delay, int *period);
2360 
2361 /********* DEPRECATED SECTION *********/
2362 #if defined(__GNUC__) && __GNUC__ >= 4
2363 #define LIBEVDEV_DEPRECATED __attribute__ ((deprecated))
2364 #else
2365 #define LIBEVDEV_DEPRECATED
2366 #endif
2367 
2368 #ifdef __cplusplus
2369 }
2370 #endif
2371 
2372 #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:1918
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:1916
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)
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: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:1917
@ 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)