[PATCH libevdev 2/3] Name-space the read flags better
Peter Hutterer
peter.hutterer at who-t.net
Tue Sep 10 19:12:48 PDT 2013
Rename from LIBEVDEV_READ_foo to LIBEVDEV_READ_FLAG_foo to differentiate
better from LIBEVDEV_READ_STATUS_foo.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
libevdev/Makefile.am | 2 +-
libevdev/libevdev-int.h | 6 +--
libevdev/libevdev.c | 16 ++++--
libevdev/libevdev.h | 22 +++++---
test/test-libevdev-events.c | 120 ++++++++++++++++++++++----------------------
test/test-libevdev-init.c | 8 +--
tools/libevdev-events.c | 4 +-
7 files changed, 95 insertions(+), 83 deletions(-)
diff --git a/libevdev/Makefile.am b/libevdev/Makefile.am
index 851a5a0..552df70 100644
--- a/libevdev/Makefile.am
+++ b/libevdev/Makefile.am
@@ -13,7 +13,7 @@ libevdev_la_SOURCES = \
libevdev_la_LDFLAGS = \
-version-info $(LIBEVDEV_LT_VERSION) \
- -export-symbols-regex '^libevdev_' \
+ -export-symbols-regex '^libevdev_|^LIBEVDEV_' \
$(GCOV_LDFLAGS) \
$(GNU_LD_FLAGS)
diff --git a/libevdev/libevdev-int.h b/libevdev/libevdev-int.h
index 7f21060..259e21f 100644
--- a/libevdev/libevdev-int.h
+++ b/libevdev/libevdev-int.h
@@ -59,9 +59,9 @@
* default state: SYNC_NONE
*
* SYNC_NONE → SYN_DROPPED or forced sync → SYNC_NEEDED
- * SYNC_NEEDED → libevdev_next_event(LIBEVDEV_READ_SYNC) → SYNC_IN_PROGRESS
- * SYNC_NEEDED → libevdev_next_event(LIBEVDEV_READ_SYNC_NONE) → SYNC_NONE
- * SYNC_IN_PROGRESS → libevdev_next_event(LIBEVDEV_READ_SYNC_NONE) → SYNC_NONE
+ * SYNC_NEEDED → libevdev_next_event(LIBEVDEV_READ_FLAG_SYNC) → SYNC_IN_PROGRESS
+ * SYNC_NEEDED → libevdev_next_event(LIBEVDEV_READ_FLAG_SYNC_NONE) → SYNC_NONE
+ * SYNC_IN_PROGRESS → libevdev_next_event(LIBEVDEV_READ_FLAG_SYNC_NONE) → SYNC_NONE
* SYNC_IN_PROGRESS → no sync events left → SYNC_NONE
*
*/
diff --git a/libevdev/libevdev.c b/libevdev/libevdev.c
index d863c8d..6f7e2a6 100644
--- a/libevdev/libevdev.c
+++ b/libevdev/libevdev.c
@@ -35,6 +35,12 @@
#define MAXEVENTS 64
+/* DEPRECATED */
+LIBEVDEV_EXPORT const enum libevdev_read_flag LIBEVDEV_READ_SYNC = LIBEVDEV_READ_FLAG_SYNC;
+LIBEVDEV_EXPORT const enum libevdev_read_flag LIBEVDEV_READ_NORMAL = LIBEVDEV_READ_FLAG_NORMAL;
+LIBEVDEV_EXPORT const enum libevdev_read_flag LIBEVDEV_FORCE_SYNC = LIBEVDEV_READ_FLAG_FORCE_SYNC;
+LIBEVDEV_EXPORT const enum libevdev_read_flag LIBEVDEV_READ_BLOCKING = LIBEVDEV_READ_FLAG_BLOCKING;
+
static int sync_mt_state(struct libevdev *dev, int create_events);
static int
@@ -729,12 +735,12 @@ libevdev_next_event(struct libevdev *dev, unsigned int flags, struct input_event
return -EBADF;
}
- if (!(flags & (LIBEVDEV_READ_NORMAL|LIBEVDEV_READ_SYNC|LIBEVDEV_FORCE_SYNC))) {
+ if (!(flags & (LIBEVDEV_READ_FLAG_NORMAL|LIBEVDEV_READ_FLAG_SYNC|LIBEVDEV_READ_FLAG_FORCE_SYNC))) {
log_bug("invalid flags %#x\n.\n", flags);
return -EINVAL;
}
- if (flags & LIBEVDEV_READ_SYNC) {
+ if (flags & LIBEVDEV_READ_FLAG_SYNC) {
if (dev->sync_state == SYNC_NEEDED) {
rc = sync_state(dev);
if (rc != 0)
@@ -769,14 +775,14 @@ libevdev_next_event(struct libevdev *dev, unsigned int flags, struct input_event
read in any more.
*/
do {
- if (!(flags & LIBEVDEV_READ_BLOCKING) ||
+ if (!(flags & LIBEVDEV_READ_FLAG_BLOCKING) ||
queue_num_elements(dev) == 0) {
rc = read_more_events(dev);
if (rc < 0 && rc != -EAGAIN)
goto out;
}
- if (flags & LIBEVDEV_FORCE_SYNC) {
+ if (flags & LIBEVDEV_READ_FLAG_FORCE_SYNC) {
dev->sync_state = SYNC_NEEDED;
rc = LIBEVDEV_READ_STATUS_SYNC;
goto out;
@@ -797,7 +803,7 @@ libevdev_next_event(struct libevdev *dev, unsigned int flags, struct input_event
rc = LIBEVDEV_READ_STATUS_SYNC;
}
- if (flags & LIBEVDEV_READ_SYNC && dev->queue_nsync > 0) {
+ if (flags & LIBEVDEV_READ_FLAG_SYNC && dev->queue_nsync > 0) {
dev->queue_nsync--;
rc = LIBEVDEV_READ_STATUS_SYNC;
if (dev->queue_nsync == 0)
diff --git a/libevdev/libevdev.h b/libevdev/libevdev.h
index f08fc04..0fcfb70 100644
--- a/libevdev/libevdev.h
+++ b/libevdev/libevdev.h
@@ -123,7 +123,7 @@ extern "C" {
*
* 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),
@@ -292,12 +292,13 @@ struct libevdev;
* @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
+ 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. 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_BLOCKING = 8, /**< The fd is not in O_NONBLOCK and a read may block */
+
};
/**
@@ -535,7 +536,7 @@ enum libevdev_read_status {
*
* 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_SYNC flag set, to get the set of events that make up 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.
@@ -545,8 +546,8 @@ enum libevdev_read_status {
* 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.
@@ -1403,6 +1404,11 @@ int libevdev_get_repeat(struct libevdev *dev, int *delay, int *period);
#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;
diff --git a/test/test-libevdev-events.c b/test/test-libevdev-events.c
index b1c263d..7903043 100644
--- a/test/test-libevdev-events.c
+++ b/test/test-libevdev-events.c
@@ -42,12 +42,12 @@ START_TEST(test_next_event)
-1);
ck_assert_msg(rc == 0, "Failed to create device: %s", strerror(-rc));
- rc = libevdev_next_event(dev, LIBEVDEV_READ_NORMAL, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, &ev);
ck_assert_int_eq(rc, -EAGAIN);
uinput_device_event(uidev, EV_KEY, BTN_LEFT, 1);
uinput_device_event(uidev, EV_SYN, SYN_REPORT, 0);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_NORMAL, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SUCCESS);
ck_assert_int_eq(ev.type, EV_KEY);
ck_assert_int_eq(ev.code, BTN_LEFT);
@@ -86,7 +86,7 @@ START_TEST(test_syn_event)
*/
uinput_device_event(uidev, EV_KEY, BTN_LEFT, 1);
uinput_device_event(uidev, EV_SYN, SYN_REPORT, 0);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_NORMAL, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SUCCESS);
ck_assert_int_eq(ev.type, EV_KEY);
ck_assert_int_eq(ev.code, BTN_LEFT);
@@ -99,14 +99,14 @@ START_TEST(test_syn_event)
ev.value = 0;
rc = write(pipefd[1], &ev, sizeof(ev));
ck_assert_int_eq(rc, sizeof(ev));
- rc = libevdev_next_event(dev, LIBEVDEV_READ_NORMAL, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, &ev);
libevdev_change_fd(dev, uinput_device_get_fd(uidev));
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SUCCESS);
ck_assert_int_eq(ev.type, EV_SYN);
ck_assert_int_eq(ev.code, SYN_REPORT);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_NORMAL, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
/* only check for the rc, nothing actually changed on the device */
@@ -136,18 +136,18 @@ START_TEST(test_event_type_filtered)
libevdev_disable_event_type(dev, EV_REL);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_NORMAL, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, &ev);
ck_assert_int_eq(rc, -EAGAIN);
uinput_device_event(uidev, EV_REL, REL_X, 1);
uinput_device_event(uidev, EV_KEY, REL_Y, 1);
uinput_device_event(uidev, EV_SYN, SYN_REPORT, 0);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_NORMAL, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SUCCESS);
ck_assert_int_eq(ev.type, EV_SYN);
ck_assert_int_eq(ev.code, SYN_REPORT);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_NORMAL, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, &ev);
ck_assert_int_eq(rc, -EAGAIN);
libevdev_free(dev);
@@ -171,24 +171,24 @@ START_TEST(test_event_code_filtered)
libevdev_disable_event_code(dev, EV_REL, REL_X);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_NORMAL, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, &ev);
ck_assert_int_eq(rc, -EAGAIN);
uinput_device_event(uidev, EV_REL, REL_X, 1);
uinput_device_event(uidev, EV_REL, REL_Y, 1);
uinput_device_event(uidev, EV_SYN, SYN_REPORT, 0);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_NORMAL, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SUCCESS);
ck_assert_int_eq(ev.type, EV_REL);
ck_assert_int_eq(ev.code, REL_Y);
ck_assert_int_eq(ev.value, 1);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_NORMAL, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SUCCESS);
ck_assert_int_eq(ev.type, EV_SYN);
ck_assert_int_eq(ev.code, SYN_REPORT);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_NORMAL, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, &ev);
ck_assert_int_eq(rc, -EAGAIN);
libevdev_free(dev);
@@ -219,11 +219,11 @@ START_TEST(test_has_event_pending)
ck_assert_int_eq(libevdev_has_event_pending(dev), 1);
- libevdev_next_event(dev, LIBEVDEV_READ_NORMAL, &ev);
+ libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, &ev);
ck_assert_int_eq(libevdev_has_event_pending(dev), 1);
- while ((rc = libevdev_next_event(dev, LIBEVDEV_READ_NORMAL, &ev)) != -EAGAIN)
+ while ((rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, &ev)) != -EAGAIN)
;
ck_assert_int_eq(libevdev_has_event_pending(dev), 0);
@@ -259,29 +259,29 @@ START_TEST(test_syn_delta_button)
uinput_device_event(uidev, EV_KEY, BTN_RIGHT, 1);
uinput_device_event(uidev, EV_KEY, KEY_MAX, 1);
uinput_device_event(uidev, EV_SYN, SYN_REPORT, 0);
- rc = libevdev_next_event(dev, LIBEVDEV_FORCE_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_FORCE_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
ck_assert_int_eq(ev.type, EV_KEY);
ck_assert_int_eq(ev.code, BTN_LEFT);
ck_assert_int_eq(ev.value, 1);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
ck_assert_int_eq(ev.type, EV_KEY);
ck_assert_int_eq(ev.code, BTN_RIGHT);
ck_assert_int_eq(ev.value, 1);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
ck_assert_int_eq(ev.type, EV_KEY);
ck_assert_int_eq(ev.code, KEY_MAX);
ck_assert_int_eq(ev.value, 1);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
ck_assert_int_eq(ev.type, EV_SYN);
ck_assert_int_eq(ev.code, SYN_REPORT);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
ck_assert_int_eq(rc, -EAGAIN);
ck_assert(libevdev_get_event_value(dev, EV_KEY, BTN_LEFT));
@@ -326,29 +326,29 @@ START_TEST(test_syn_delta_abs)
uinput_device_event(uidev, EV_ABS, ABS_Y, 500);
uinput_device_event(uidev, EV_ABS, ABS_MAX, 700);
uinput_device_event(uidev, EV_SYN, SYN_REPORT, 0);
- rc = libevdev_next_event(dev, LIBEVDEV_FORCE_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_FORCE_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
ck_assert_int_eq(ev.type, EV_ABS);
ck_assert_int_eq(ev.code, ABS_X);
ck_assert_int_eq(ev.value, 100);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
ck_assert_int_eq(ev.type, EV_ABS);
ck_assert_int_eq(ev.code, ABS_Y);
ck_assert_int_eq(ev.value, 500);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
ck_assert_int_eq(ev.type, EV_ABS);
ck_assert_int_eq(ev.code, ABS_MAX);
ck_assert_int_eq(ev.value, 700);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
ck_assert_int_eq(ev.type, EV_SYN);
ck_assert_int_eq(ev.code, SYN_REPORT);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
ck_assert_int_eq(rc, -EAGAIN);
uinput_device_free(uidev);
@@ -402,65 +402,65 @@ START_TEST(test_syn_delta_mt)
uinput_device_event(uidev, EV_ABS, ABS_MT_TRACKING_ID, 2);
uinput_device_event(uidev, EV_SYN, SYN_REPORT, 0);
- rc = libevdev_next_event(dev, LIBEVDEV_FORCE_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_FORCE_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
ck_assert_int_eq(ev.type, EV_ABS);
ck_assert_int_eq(ev.code, ABS_X);
ck_assert_int_eq(ev.value, 1);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
ck_assert_int_eq(ev.type, EV_ABS);
ck_assert_int_eq(ev.code, ABS_Y);
ck_assert_int_eq(ev.value, 5);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
ck_assert_int_eq(ev.type, EV_ABS);
ck_assert_int_eq(ev.code, ABS_MT_SLOT);
ck_assert_int_eq(ev.value, 0);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
ck_assert_int_eq(ev.type, EV_ABS);
ck_assert_int_eq(ev.code, ABS_MT_POSITION_X);
ck_assert_int_eq(ev.value, 100);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
ck_assert_int_eq(ev.type, EV_ABS);
ck_assert_int_eq(ev.code, ABS_MT_POSITION_Y);
ck_assert_int_eq(ev.value, 500);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
ck_assert_int_eq(ev.type, EV_ABS);
ck_assert_int_eq(ev.code, ABS_MT_TRACKING_ID);
ck_assert_int_eq(ev.value, 1);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
ck_assert_int_eq(ev.type, EV_ABS);
ck_assert_int_eq(ev.code, ABS_MT_SLOT);
ck_assert_int_eq(ev.value, 1);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
ck_assert_int_eq(ev.type, EV_ABS);
ck_assert_int_eq(ev.code, ABS_MT_POSITION_X);
ck_assert_int_eq(ev.value, 1);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
ck_assert_int_eq(ev.type, EV_ABS);
ck_assert_int_eq(ev.code, ABS_MT_POSITION_Y);
ck_assert_int_eq(ev.value, 5);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
ck_assert_int_eq(ev.type, EV_ABS);
ck_assert_int_eq(ev.code, ABS_MT_TRACKING_ID);
ck_assert_int_eq(ev.value, 2);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
ck_assert_int_eq(ev.type, EV_SYN);
ck_assert_int_eq(ev.code, SYN_REPORT);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
ck_assert_int_eq(rc, -EAGAIN);
uinput_device_free(uidev);
@@ -488,29 +488,29 @@ START_TEST(test_syn_delta_led)
uinput_device_event(uidev, EV_LED, LED_CAPSL, 1);
uinput_device_event(uidev, EV_LED, LED_MAX, 1);
uinput_device_event(uidev, EV_SYN, SYN_REPORT, 0);
- rc = libevdev_next_event(dev, LIBEVDEV_FORCE_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_FORCE_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
ck_assert_int_eq(ev.type, EV_LED);
ck_assert_int_eq(ev.code, LED_NUML);
ck_assert_int_eq(ev.value, 1);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
ck_assert_int_eq(ev.type, EV_LED);
ck_assert_int_eq(ev.code, LED_CAPSL);
ck_assert_int_eq(ev.value, 1);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
ck_assert_int_eq(ev.type, EV_LED);
ck_assert_int_eq(ev.code, LED_MAX);
ck_assert_int_eq(ev.value, 1);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
ck_assert_int_eq(ev.type, EV_SYN);
ck_assert_int_eq(ev.code, SYN_REPORT);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
ck_assert_int_eq(rc, -EAGAIN);
ck_assert_int_eq(libevdev_get_event_value(dev, EV_LED, LED_NUML), 1);
@@ -542,29 +542,29 @@ START_TEST(test_syn_delta_sw)
uinput_device_event(uidev, EV_SW, SW_MICROPHONE_INSERT, 1);
uinput_device_event(uidev, EV_SW, SW_MAX, 1);
uinput_device_event(uidev, EV_SYN, SYN_REPORT, 0);
- rc = libevdev_next_event(dev, LIBEVDEV_FORCE_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_FORCE_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
ck_assert_int_eq(ev.type, EV_SW);
ck_assert_int_eq(ev.code, SW_LID);
ck_assert_int_eq(ev.value, 1);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
ck_assert_int_eq(ev.type, EV_SW);
ck_assert_int_eq(ev.code, SW_MICROPHONE_INSERT);
ck_assert_int_eq(ev.value, 1);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
ck_assert_int_eq(ev.type, EV_SW);
ck_assert_int_eq(ev.code, SW_MAX);
ck_assert_int_eq(ev.value, 1);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
ck_assert_int_eq(ev.type, EV_SYN);
ck_assert_int_eq(ev.code, SYN_REPORT);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
ck_assert_int_eq(rc, -EAGAIN);
ck_assert_int_eq(libevdev_get_event_value(dev, EV_SW, SW_LID), 1);
@@ -605,10 +605,10 @@ START_TEST(test_skipped_sync)
uinput_device_event(uidev, EV_ABS, ABS_X, 100);
uinput_device_event(uidev, EV_ABS, ABS_Y, 500);
uinput_device_event(uidev, EV_SYN, SYN_REPORT, 0);
- rc = libevdev_next_event(dev, LIBEVDEV_FORCE_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_FORCE_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_NORMAL, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, &ev);
ck_assert_int_eq(rc, -EAGAIN);
ck_assert_int_eq(libevdev_get_event_value(dev, EV_KEY, BTN_LEFT), 1);
@@ -649,16 +649,16 @@ START_TEST(test_incomplete_sync)
uinput_device_event(uidev, EV_ABS, ABS_X, 100);
uinput_device_event(uidev, EV_ABS, ABS_Y, 500);
uinput_device_event(uidev, EV_SYN, SYN_REPORT, 0);
- rc = libevdev_next_event(dev, LIBEVDEV_FORCE_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_FORCE_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
ck_assert_int_eq(ev.type, EV_KEY);
ck_assert_int_eq(ev.code, BTN_LEFT);
ck_assert_int_eq(ev.value, 1);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_NORMAL, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, &ev);
ck_assert_int_eq(rc, -EAGAIN);
ck_assert_int_eq(libevdev_get_event_value(dev, EV_KEY, BTN_LEFT), 1);
@@ -686,10 +686,10 @@ START_TEST(test_empty_sync)
-1);
ck_assert_msg(rc == 0, "Failed to create device: %s", strerror(-rc));
- rc = libevdev_next_event(dev, LIBEVDEV_FORCE_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_FORCE_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
ck_assert_int_eq(rc, -EAGAIN);
uinput_device_free(uidev);
@@ -741,7 +741,7 @@ START_TEST(test_event_values)
ck_assert_int_eq(value, 0);
do {
- rc = libevdev_next_event(dev, LIBEVDEV_READ_NORMAL, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, &ev);
} while (rc == 0);
ck_assert_int_eq(rc, -EAGAIN);
@@ -862,7 +862,7 @@ START_TEST(test_mt_event_values)
ck_assert_int_eq(libevdev_get_slot_value(dev, 1, ABS_MT_POSITION_Y), 0);
do {
- rc = libevdev_next_event(dev, LIBEVDEV_READ_NORMAL, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, &ev);
} while (rc == LIBEVDEV_READ_STATUS_SUCCESS);
ck_assert_int_eq(rc, -EAGAIN);
diff --git a/test/test-libevdev-init.c b/test/test-libevdev-init.c
index 02dfa8b..70a553c 100644
--- a/test/test-libevdev-init.c
+++ b/test/test-libevdev-init.c
@@ -115,15 +115,15 @@ START_TEST(test_log_init)
ck_assert(dev != NULL);
libevdev_set_log_function(logfunc, logdata);
- libevdev_next_event(dev, LIBEVDEV_READ_NORMAL, NULL);
+ libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, NULL);
libevdev_set_log_function(NULL, NULL);
- libevdev_next_event(dev, LIBEVDEV_READ_NORMAL, NULL);
+ libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, NULL);
libevdev_set_log_function(logfunc, logdata);
- libevdev_next_event(dev, LIBEVDEV_READ_NORMAL, NULL);
+ libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, NULL);
- /* libevdev_next_event(dev, LIBEVDEV_READ_NORMAL, NULL) should
+ /* libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, NULL) should
trigger a log message. We called it three times, but only twice
with the logfunc set, thus, ensure we only called the logfunc
twice */
diff --git a/tools/libevdev-events.c b/tools/libevdev-events.c
index fe7092c..f18c387 100644
--- a/tools/libevdev-events.c
+++ b/tools/libevdev-events.c
@@ -170,12 +170,12 @@ main(int argc, char **argv)
do {
struct input_event ev;
- rc = libevdev_next_event(dev, LIBEVDEV_READ_NORMAL|LIBEVDEV_READ_BLOCKING, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL|LIBEVDEV_READ_FLAG_BLOCKING, &ev);
if (rc == LIBEVDEV_READ_STATUS_SYNC) {
printf("::::::::::::::::::::: dropped ::::::::::::::::::::::\n");
while (rc == LIBEVDEV_READ_STATUS_SYNC) {
print_sync_event(&ev);
- rc = libevdev_next_event(dev, LIBEVDEV_READ_SYNC, &ev);
+ rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
}
printf("::::::::::::::::::::: re-synced ::::::::::::::::::::::\n");
} else if (rc == LIBEVDEV_READ_STATUS_SUCCESS)
--
1.8.3.1
More information about the Input-tools
mailing list