libevdev.h
Go to the documentation of this file.
/*
* Copyright © 2013 Red Hat, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that copyright
* notice and this permission notice appear in supporting documentation, and
* that the name of the copyright holders not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. The copyright holders make no representations
* about the suitability of this software for any purpose. It is provided "as
* is" without express or implied warranty.
*
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*/
#ifndef LIBEVDEV_H
#define LIBEVDEV_H
#ifdef __cplusplus
extern "C" {
#endif
#include <linux/input.h>
#include <stdarg.h>
#define LIBEVDEV_ATTRIBUTE_PRINTF(_format, _args) __attribute__ ((format (printf, _format, _args)))
struct libevdev;
enum libevdev_read_flag {
LIBEVDEV_READ_FLAG_SYNC = 1,
LIBEVDEV_READ_FLAG_NORMAL = 2,
LIBEVDEV_READ_FLAG_FORCE_SYNC = 4,
LIBEVDEV_READ_FLAG_BLOCKING = 8
};
struct libevdev* libevdev_new(void);
int libevdev_new_from_fd(int fd, struct libevdev **dev);
void libevdev_free(struct libevdev *dev);
enum libevdev_log_priority {
LIBEVDEV_LOG_ERROR = 10,
LIBEVDEV_LOG_INFO = 20,
LIBEVDEV_LOG_DEBUG = 30
};
typedef 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, 0);
void libevdev_set_log_function(libevdev_log_func_t logfunc, void *data);
void libevdev_set_log_priority(enum libevdev_log_priority priority);
enum libevdev_log_priority libevdev_get_log_priority(void);
typedef 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, 0);
void libevdev_set_device_log_function(struct libevdev *dev,
libevdev_device_log_func_t logfunc,
enum libevdev_log_priority priority,
void *data);
enum libevdev_grab_mode {
LIBEVDEV_GRAB = 3,
LIBEVDEV_UNGRAB = 4
};
int libevdev_grab(struct libevdev *dev, enum libevdev_grab_mode grab);
int libevdev_set_fd(struct libevdev* dev, int fd);
int libevdev_change_fd(struct libevdev* dev, int fd);
int libevdev_get_fd(const struct libevdev* dev);
enum libevdev_read_status {
LIBEVDEV_READ_STATUS_SUCCESS = 0,
LIBEVDEV_READ_STATUS_SYNC = 1
};
int libevdev_next_event(struct libevdev *dev, unsigned int flags, struct input_event *ev);
int libevdev_has_event_pending(struct libevdev *dev);
const char* libevdev_get_name(const struct libevdev *dev);
void libevdev_set_name(struct libevdev *dev, const char *name);
const char * libevdev_get_phys(const struct libevdev *dev);
void libevdev_set_phys(struct libevdev *dev, const char *phys);
const char * libevdev_get_uniq(const struct libevdev *dev);
void libevdev_set_uniq(struct libevdev *dev, const char *uniq);
int libevdev_get_id_product(const struct libevdev *dev);
void libevdev_set_id_product(struct libevdev *dev, int product_id);
int libevdev_get_id_vendor(const struct libevdev *dev);
void libevdev_set_id_vendor(struct libevdev *dev, int vendor_id);
int libevdev_get_id_bustype(const struct libevdev *dev);
void libevdev_set_id_bustype(struct libevdev *dev, int bustype);
int libevdev_get_id_version(const struct libevdev *dev);
void libevdev_set_id_version(struct libevdev *dev, int version);
int libevdev_get_driver_version(const struct libevdev *dev);
int libevdev_has_property(const struct libevdev *dev, unsigned int prop);
int libevdev_enable_property(struct libevdev *dev, unsigned int prop);
int libevdev_disable_property(struct libevdev *dev, unsigned int prop);
int libevdev_has_event_type(const struct libevdev *dev, unsigned int type);
int libevdev_has_event_code(const struct libevdev *dev, unsigned int type, unsigned int code);
int libevdev_get_abs_minimum(const struct libevdev *dev, unsigned int code);
int libevdev_get_abs_maximum(const struct libevdev *dev, unsigned int code);
int libevdev_get_abs_fuzz(const struct libevdev *dev, unsigned int code);
int libevdev_get_abs_flat(const struct libevdev *dev, unsigned int code);
int libevdev_get_abs_resolution(const struct libevdev *dev, unsigned int code);
const struct input_absinfo* libevdev_get_abs_info(const struct libevdev *dev, unsigned int code);
int libevdev_get_event_value(const struct libevdev *dev, unsigned int type, unsigned int code);
int libevdev_set_event_value(struct libevdev *dev, unsigned int type, unsigned int code, int value);
int libevdev_fetch_event_value(const struct libevdev *dev, unsigned int type, unsigned int code, int *value);
int libevdev_get_slot_value(const struct libevdev *dev, unsigned int slot, unsigned int code);
int libevdev_set_slot_value(struct libevdev *dev, unsigned int slot, unsigned int code, int value);
int libevdev_fetch_slot_value(const struct libevdev *dev, unsigned int slot, unsigned int code, int *value);
int libevdev_get_num_slots(const struct libevdev *dev);
int libevdev_get_current_slot(const struct libevdev *dev);
void libevdev_set_abs_minimum(struct libevdev *dev, unsigned int code, int min);
void libevdev_set_abs_maximum(struct libevdev *dev, unsigned int code, int max);
void libevdev_set_abs_fuzz(struct libevdev *dev, unsigned int code, int fuzz);
void libevdev_set_abs_flat(struct libevdev *dev, unsigned int code, int flat);
void libevdev_set_abs_resolution(struct libevdev *dev, unsigned int code, int resolution);
void libevdev_set_abs_info(struct libevdev *dev, unsigned int code, const struct input_absinfo *abs);
int libevdev_enable_event_type(struct libevdev *dev, unsigned int type);
int libevdev_disable_event_type(struct libevdev *dev, unsigned int type);
int libevdev_enable_event_code(struct libevdev *dev, unsigned int type, unsigned int code, const void *data);
int libevdev_disable_event_code(struct libevdev *dev, unsigned int type, unsigned int code);
int libevdev_kernel_set_abs_info(struct libevdev *dev, unsigned int code, const struct input_absinfo *abs);
enum libevdev_led_value {
LIBEVDEV_LED_ON = 3,
LIBEVDEV_LED_OFF = 4
};
int libevdev_kernel_set_led_value(struct libevdev *dev, unsigned int code, enum libevdev_led_value value);
int libevdev_kernel_set_led_values(struct libevdev *dev, ...);
int libevdev_set_clock_id(struct libevdev *dev, int clockid);
int libevdev_event_is_type(const struct input_event *ev, unsigned int type);
int libevdev_event_is_code(const struct input_event *ev, unsigned int type, unsigned int code);
const char * libevdev_event_type_get_name(unsigned int type);
const char * libevdev_event_code_get_name(unsigned int type, unsigned int code);
const char * libevdev_event_value_get_name(unsigned int type,
unsigned int code,
int value);
const char* libevdev_property_get_name(unsigned int prop);
int libevdev_event_type_get_max(unsigned int type);
int libevdev_event_type_from_name(const char *name);
int libevdev_event_type_from_name_n(const char *name, size_t len);
int libevdev_event_code_from_name(unsigned int type, const char *name);
int libevdev_event_code_from_name_n(unsigned int type, const char *name,
size_t len);
int libevdev_event_value_from_name(unsigned int type, unsigned int code,
const char *name);
int
libevdev_event_type_from_code_name(const char *name);
int
libevdev_event_type_from_code_name_n(const char *name, size_t len);
int
libevdev_event_code_from_code_name(const char *name);
int
libevdev_event_code_from_code_name_n(const char *name, size_t len);
int libevdev_event_value_from_name_n(unsigned int type, unsigned int code,
const char *name, size_t len);
int libevdev_property_from_name(const char *name);
int libevdev_property_from_name_n(const char *name, size_t len);
int libevdev_get_repeat(const struct libevdev *dev, int *delay, int *period);
/********* DEPRECATED SECTION *********/
#if defined(__GNUC__) && __GNUC__ >= 4
#define LIBEVDEV_DEPRECATED __attribute__ ((deprecated))
#else
#define LIBEVDEV_DEPRECATED
#endif
#ifdef __cplusplus
}
#endif
#endif /* LIBEVDEV_H */
LIBEVDEV_UNGRAB
@ LIBEVDEV_UNGRAB
Ungrab the device if currently grabbed.
Definition: libevdev.h:955
libevdev_event_type_get_max
int libevdev_event_type_get_max(unsigned int type)
libevdev_has_event_code
int libevdev_has_event_code(const struct libevdev *dev, unsigned int type, unsigned int code)
libevdev_event_value_from_name_n
int libevdev_event_value_from_name_n(unsigned int type, unsigned int code, const char *name, size_t len)
libevdev_get_abs_info
const struct input_absinfo * libevdev_get_abs_info(const struct libevdev *dev, unsigned int code)
libevdev_set_id_version
void libevdev_set_id_version(struct libevdev *dev, int version)
libevdev_event_type_from_name
int libevdev_event_type_from_name(const char *name)
libevdev_kernel_set_led_value
int libevdev_kernel_set_led_value(struct libevdev *dev, unsigned int code, enum libevdev_led_value value)
libevdev_set_device_log_function
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
libevdev_has_property
int libevdev_has_property(const struct libevdev *dev, unsigned int prop)
libevdev_event_type_from_code_name_n
int libevdev_event_type_from_code_name_n(const char *name, size_t len)
LIBEVDEV_GRAB
@ LIBEVDEV_GRAB
Grab the device if not currently grabbed.
Definition: libevdev.h:954
libevdev_event_value_from_name
int libevdev_event_value_from_name(unsigned int type, unsigned int code, const char *name)
LIBEVDEV_READ_FLAG_BLOCKING
@ LIBEVDEV_READ_FLAG_BLOCKING
The fd is not in O_NONBLOCK and a read may block.
Definition: libevdev.h:760
libevdev_property_from_name_n
int libevdev_property_from_name_n(const char *name, size_t len)
LIBEVDEV_LED_OFF
@ LIBEVDEV_LED_OFF
Turn the LED off.
Definition: libevdev.h:1917
libevdev_get_abs_resolution
int libevdev_get_abs_resolution(const struct libevdev *dev, unsigned int code)
libevdev_event_type_from_name_n
int libevdev_event_type_from_name_n(const char *name, size_t len)
libevdev_read_status
libevdev_read_status
Definition: libevdev.h:1069
libevdev_enable_event_type
int libevdev_enable_event_type(struct libevdev *dev, unsigned int type)
libevdev_property_from_name
int libevdev_property_from_name(const char *name)
libevdev_enable_property
int libevdev_enable_property(struct libevdev *dev, unsigned int prop)
libevdev_kernel_set_led_values
int libevdev_kernel_set_led_values(struct libevdev *dev,...)
libevdev_fetch_event_value
int libevdev_fetch_event_value(const struct libevdev *dev, unsigned int type, unsigned int code, int *value)
libevdev_new
struct libevdev * libevdev_new(void)
libevdev_get_slot_value
int libevdev_get_slot_value(const struct libevdev *dev, unsigned int slot, unsigned int code)
libevdev_log_priority
libevdev_log_priority
Definition: libevdev.h:821
libevdev_get_id_version
int libevdev_get_id_version(const struct libevdev *dev)
LIBEVDEV_ATTRIBUTE_PRINTF
#define LIBEVDEV_ATTRIBUTE_PRINTF(_format, _args)
Definition: libevdev.h:33
libevdev_set_abs_flat
void libevdev_set_abs_flat(struct libevdev *dev, unsigned int code, int flat)
libevdev_event_code_get_name
const char * libevdev_event_code_get_name(unsigned int type, unsigned int code)
libevdev_kernel_set_abs_info
int libevdev_kernel_set_abs_info(struct libevdev *dev, unsigned int code, const struct input_absinfo *abs)
libevdev_get_event_value
int libevdev_get_event_value(const struct libevdev *dev, unsigned int type, unsigned int code)
libevdev_event_code_from_name_n
int libevdev_event_code_from_name_n(unsigned int type, const char *name, size_t len)
libevdev_set_abs_maximum
void libevdev_set_abs_maximum(struct libevdev *dev, unsigned int code, int max)
libevdev_event_code_from_code_name_n
int libevdev_event_code_from_code_name_n(const char *name, size_t len)
libevdev_set_slot_value
int libevdev_set_slot_value(struct libevdev *dev, unsigned int slot, unsigned int code, int value)
libevdev_set_fd
int libevdev_set_fd(struct libevdev *dev, int fd)
libevdev_set_id_vendor
void libevdev_set_id_vendor(struct libevdev *dev, int vendor_id)
libevdev_free
void libevdev_free(struct libevdev *dev)
libevdev_get_log_priority
enum libevdev_log_priority libevdev_get_log_priority(void)
libevdev_get_repeat
int libevdev_get_repeat(const struct libevdev *dev, int *delay, int *period)
libevdev_fetch_slot_value
int libevdev_fetch_slot_value(const struct libevdev *dev, unsigned int slot, unsigned int code, int *value)
libevdev_set_id_product
void libevdev_set_id_product(struct libevdev *dev, int product_id)
LIBEVDEV_READ_FLAG_FORCE_SYNC
@ LIBEVDEV_READ_FLAG_FORCE_SYNC
Pretend the next event is a SYN_DROPPED and require the caller to sync.
Definition: libevdev.h:758
libevdev_has_event_type
int libevdev_has_event_type(const struct libevdev *dev, unsigned int type)
LIBEVDEV_LOG_INFO
@ LIBEVDEV_LOG_INFO
informational messages
Definition: libevdev.h:823
libevdev_has_event_pending
int libevdev_has_event_pending(struct libevdev *dev)
libevdev_set_abs_info
void libevdev_set_abs_info(struct libevdev *dev, unsigned int code, const struct input_absinfo *abs)
libevdev_get_id_bustype
int libevdev_get_id_bustype(const struct libevdev *dev)
libevdev_set_name
void libevdev_set_name(struct libevdev *dev, const char *name)
libevdev_set_log_function
void(*) voi libevdev_set_log_function)(libevdev_log_func_t logfunc, void *data)
Definition: libevdev.h:868
libevdev_get_uniq
const char * libevdev_get_uniq(const struct libevdev *dev)
libevdev_set_id_bustype
void libevdev_set_id_bustype(struct libevdev *dev, int bustype)
libevdev_read_flag
libevdev_read_flag
Definition: libevdev.h:755
libevdev_get_id_product
int libevdev_get_id_product(const struct libevdev *dev)
libevdev_led_value
libevdev_led_value
Definition: libevdev.h:1915
libevdev_log_func_t
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
libevdev_get_id_vendor
int libevdev_get_id_vendor(const struct libevdev *dev)
libevdev_set_uniq
void libevdev_set_uniq(struct libevdev *dev, const char *uniq)
LIBEVDEV_LOG_ERROR
@ LIBEVDEV_LOG_ERROR
critical errors and application bugs
Definition: libevdev.h:822
libevdev_set_abs_fuzz
void libevdev_set_abs_fuzz(struct libevdev *dev, unsigned int code, int fuzz)
libevdev_get_abs_flat
int libevdev_get_abs_flat(const struct libevdev *dev, unsigned int code)
libevdev_get_num_slots
int libevdev_get_num_slots(const struct libevdev *dev)
LIBEVDEV_READ_STATUS_SYNC
@ LIBEVDEV_READ_STATUS_SYNC
Depending on the libevdev_next_event() read flag:
Definition: libevdev.h:1085
LIBEVDEV_LOG_DEBUG
@ LIBEVDEV_LOG_DEBUG
debug information
Definition: libevdev.h:824
libevdev_next_event
int libevdev_next_event(struct libevdev *dev, unsigned int flags, struct input_event *ev)
libevdev_get_abs_minimum
int libevdev_get_abs_minimum(const struct libevdev *dev, unsigned int code)
libevdev_disable_property
int libevdev_disable_property(struct libevdev *dev, unsigned int prop)
LIBEVDEV_READ_STATUS_SUCCESS
@ LIBEVDEV_READ_STATUS_SUCCESS
libevdev_next_event() has finished without an error and an event is available for processing.
Definition: libevdev.h:1076
libevdev_set_abs_resolution
void libevdev_set_abs_resolution(struct libevdev *dev, unsigned int code, int resolution)
libevdev_get_current_slot
int libevdev_get_current_slot(const struct libevdev *dev)
libevdev_set_abs_minimum
void libevdev_set_abs_minimum(struct libevdev *dev, unsigned int code, int min)
libevdev_event_is_code
int libevdev_event_is_code(const struct input_event *ev, unsigned int type, unsigned int code)
libevdev_enable_event_code
int libevdev_enable_event_code(struct libevdev *dev, unsigned int type, unsigned int code, const void *data)
libevdev_device_log_func_t
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
libevdev_property_get_name
const char * libevdev_property_get_name(unsigned int prop)
libevdev_event_value_get_name
const char * libevdev_event_value_get_name(unsigned int type, unsigned int code, int value)
libevdev_get_driver_version
int libevdev_get_driver_version(const struct libevdev *dev)
libevdev_event_code_from_name
int libevdev_event_code_from_name(unsigned int type, const char *name)
libevdev_set_clock_id
int libevdev_set_clock_id(struct libevdev *dev, int clockid)
libevdev_get_abs_maximum
int libevdev_get_abs_maximum(const struct libevdev *dev, unsigned int code)
libevdev_set_phys
void libevdev_set_phys(struct libevdev *dev, const char *phys)
libevdev_disable_event_code
int libevdev_disable_event_code(struct libevdev *dev, unsigned int type, unsigned int code)
libevdev_change_fd
int libevdev_change_fd(struct libevdev *dev, int fd)
libevdev_disable_event_type
int libevdev_disable_event_type(struct libevdev *dev, unsigned int type)
libevdev_get_phys
const char * libevdev_get_phys(const struct libevdev *dev)
libevdev_get_fd
int libevdev_get_fd(const struct libevdev *dev)
libevdev_get_abs_fuzz
int libevdev_get_abs_fuzz(const struct libevdev *dev, unsigned int code)
libevdev_event_type_get_name
const char * libevdev_event_type_get_name(unsigned int type)
libevdev_set_log_priority
void libevdev_set_log_priority(enum libevdev_log_priority priority)
libevdev_event_code_from_code_name
int libevdev_event_code_from_code_name(const char *name)
libevdev_grab
int libevdev_grab(struct libevdev *dev, enum libevdev_grab_mode grab)
libevdev_event_is_type
int libevdev_event_is_type(const struct input_event *ev, unsigned int type)
libevdev_grab_mode
libevdev_grab_mode
Definition: libevdev.h:953
libevdev_get_name
const char * libevdev_get_name(const struct libevdev *dev)
LIBEVDEV_LED_ON
@ LIBEVDEV_LED_ON
Turn the LED on.
Definition: libevdev.h:1916
LIBEVDEV_READ_FLAG_NORMAL
@ LIBEVDEV_READ_FLAG_NORMAL
Process data in normal mode.
Definition: libevdev.h:757
LIBEVDEV_READ_FLAG_SYNC
@ LIBEVDEV_READ_FLAG_SYNC
Process data in sync mode.
Definition: libevdev.h:756
libevdev_set_event_value
int libevdev_set_event_value(struct libevdev *dev, unsigned int type, unsigned int code, int value)
libevdev_event_type_from_code_name
int libevdev_event_type_from_code_name(const char *name)
libevdev_new_from_fd
int libevdev_new_from_fd(int fd, struct libevdev **dev)