* }
* printf("Input device name: \"%s\"\n", libevdev_get_name(dev));
* printf("Input device ID: bus %#x vendor %#x product %#x\n",
- * libevdev_get_bustype(dev),
- * libevdev_get_vendor_id(dev),
- * libevdev_get_product_id(dev));
+ * libevdev_get_id_bustype(dev),
+ * libevdev_get_id_vendor(dev),
+ * libevdev_get_id_product(dev));
* if (!libevdev_has_event_type(dev, EV_REL) ||
* !libevdev_has_event_code(dev, EV_KEY, BTN_LEFT)) {
* printf("This device does not look like a mouse\n");
*
* do {
* struct input_event ev;
- * rc = libevdev_next_event(dev, LIBEVDEV_READ_NORMAL, &ev);
+ * rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, &ev);
* if (rc == 0)
* printf("Event: %s %s %d\n",
* libevdev_get_event_type_name(ev.type),
* @ingroup events
*/
enum libevdev_read_flag {
- LIBEVDEV_READ_SYNC = 1, /**< Process data in sync mode */
- LIBEVDEV_READ_NORMAL = 2, /**< Process data in normal mode */
- LIBEVDEV_FORCE_SYNC = 4, /**< Pretend the next event is a SYN_DROPPED. There is
- no reason to ever use this except for
- automated tests, so don't. */
- LIBEVDEV_READ_BLOCKING = 8, /**< The fd is not in O_NONBLOCK and a read may block */
+ LIBEVDEV_READ_FLAG_SYNC = 1, /**< Process data in sync mode */
+ LIBEVDEV_READ_FLAG_NORMAL = 2, /**< Process data in normal mode */
+ LIBEVDEV_READ_FLAG_FORCE_SYNC = 4, /**< Pretend the next event is a SYN_DROPPED and
+ require the caller to sync */
+ LIBEVDEV_READ_FLAG_BLOCKING = 8, /**< The fd is not in O_NONBLOCK and a read may block */
+
};
/**
* @ingroup init
*/
enum libevdev_log_priority {
- LIBEVDEV_LOG_ERROR = 10, /**< cricitical errors and application bugs */
+ LIBEVDEV_LOG_ERROR = 10, /**< critical errors and application bugs */
LIBEVDEV_LOG_INFO = 20, /**< informational messages */
LIBEVDEV_LOG_DEBUG = 30, /**< debug information */
};
*/
int libevdev_get_fd(const struct libevdev* dev);
+
+/**
+ * @ingroup events
+ */
+enum libevdev_read_status {
+ /**
+ * libevdev_next_event() has finished without an error
+ * and an event is available for processing.
+ *
+ * @see libevdev_next_event
+ */
+ LIBEVDEV_READ_STATUS_SUCCESS = 0,
+ /**
+ * Depending on the libevdev_next_event() read flag:
+ * * libevdev received a SYN_DROPPED from the device, and the caller should
+ * now resync the device, or,
+ * * an event has been read in sync mode.
+ *
+ * @see libevdev_next_event
+ */
+ LIBEVDEV_READ_STATUS_SYNC = 1,
+};
/**
* @ingroup events
*
* Get the next event from the device. This function operates in two different
* modes: normal mode or sync mode.
*
- * In normal mode, this function returns 0 and returns the event in the
- * parameter ev. If no events are available at this time, it returns -EAGAIN
- * and ev is undefined.
+ * In normal mode, this function returns LIBEVDEV_READ_STATUS_SUCCESS and
+ * returns the event in the parameter ev. If no events are available at this
+ * time, it returns -EAGAIN and ev is undefined.
*
- * If a SYN_DROPPED is read from the device, this function returns 1. The
- * caller should now call this function with the LIBEVDEV_READ_SYNC flag set,
- * to get the set of events that make up the device state delta. This function
- * returns 1 for each event part of that delta, until it returns -EAGAIN once
- * all events have been synced.
+ * If a SYN_DROPPED is read from the device, this function returns
+ * LIBEVDEV_READ_STATUS_SYNC. The caller should now call this function with the
+ * LIBEVDEV_READ_FLAG_SYNC flag set, to get the set of events that make up the
+ * device state delta. This function returns LIBEVDEV_READ_STATUS_SYNC for
+ * each event part of that delta, until it returns -EAGAIN once all events
+ * have been synced.
*
* If a device needs to be synced by the caller but the caller does not call
- * with the LIBEVDEV_READ_SYNC flag set, all events from the diff are dropped
- * and event processing continues as normal.
+ * with the LIBEVDEV_READ_STATUS_SYNC flag set, all events from the diff are
+ * dropped and event processing continues as normal.
*
* @param dev The evdev device, already initialized with libevdev_set_fd()
- * @param flags Set of flags to determine behaviour. If LIBEVDEV_READ_NORMAL
- * is set, the next event is read in normal mode. If LIBEVDEV_READ_SYNC is
+ * @param flags Set of flags to determine behaviour. If LIBEVDEV_READ_FLAG_NORMAL
+ * is set, the next event is read in normal mode. If LIBEVDEV_READ_FLAG_SYNC is
* set, the next event is read in sync mode.
* @param ev On success, set to the current event.
* @return On failure, a negative errno is returned.
- * @retval 0 One or more events where read of the device
+ * @retval LIBEVDEV_READ_STATUS_SUCCESS One or more events where read of the device
* @retval -EAGAIN No events are currently available on the device
- * @retval 1 A SYN_DROPPED event was received, or a synced event was
- * returned.
+ * @retval LIBEVDEV_READ_STATUS_SYNC A SYN_DROPPED event was received, or a
+ * synced event was returned.
*
* @note This function is signal-safe.
*/
int libevdev_kernel_set_abs_info(struct libevdev *dev, unsigned int code, const struct input_absinfo *abs);
+/**
+ * @ingroup kernel
+ */
enum libevdev_led_value {
LIBEVDEV_LED_ON = 3,
LIBEVDEV_LED_OFF = 4,
int libevdev_kernel_set_led_values(struct libevdev *dev, ...);
/**
+ * @ingroup kernel
+ *
+ * Set the clock ID to be used for timestamps. Further events from this device
+ * will report an event time based on the given clock.
+ *
+ * This is a modification only affecting this representation of
+ * this device.
+ *
+ * @param dev The evdev device, already initialized with libevdev_set_fd()
+ * @param clockid The clock to use for future events. Permitted values
+ * are CLOCK_MONOTONIC and CLOCK_REALTIME (the default).
+ * @return zero on success, or a negative errno on failure
+ */
+int libevdev_set_clock_id(struct libevdev *dev, int clockid);
+
+/**
* @ingroup misc
*
* Helper function to check if an event is of a specific type. This is
#define LIBEVDEV_DEPRECATED
#endif
+LIBEVDEV_DEPRECATED extern const enum libevdev_read_flag LIBEVDEV_READ_SYNC;
+LIBEVDEV_DEPRECATED extern const enum libevdev_read_flag LIBEVDEV_READ_NORMAL;
+LIBEVDEV_DEPRECATED extern const enum libevdev_read_flag LIBEVDEV_FORCE_SYNC;
+LIBEVDEV_DEPRECATED extern const enum libevdev_read_flag LIBEVDEV_READ_BLOCKING;
+
/* replacement: libevdev_kernel_set_abs_info */
int libevdev_kernel_set_abs_value(struct libevdev *dev, unsigned int code, const struct input_absinfo *abs) LIBEVDEV_DEPRECATED;
int libevdev_get_event_type_max(unsigned int type) LIBEVDEV_DEPRECATED;
/** replacement: libevdev_property_get_name */
-const char* libevdev_get_property_name(unsigned int prop);
+const char* libevdev_get_property_name(unsigned int prop) LIBEVDEV_DEPRECATED;
/** replacement: libevdev_event_type_get_name */
const char * libevdev_get_event_type_name(unsigned int type) LIBEVDEV_DEPRECATED;
const char * libevdev_get_event_code_name(unsigned int type, unsigned int code) LIBEVDEV_DEPRECATED;
/** replacement: libevdev_event_is_type */
-int libevdev_is_event_type(const struct input_event *ev, unsigned int type);
+int libevdev_is_event_type(const struct input_event *ev, unsigned int type) LIBEVDEV_DEPRECATED;
/** replacement: libevdev_event_is_code */
-int libevdev_is_event_code(const struct input_event *ev, unsigned int type, unsigned int code);
+int libevdev_is_event_code(const struct input_event *ev, unsigned int type, unsigned int code) LIBEVDEV_DEPRECATED;
/**************************************/
#ifdef __cplusplus