From ab2f20bfd6ad632b1ab5c41a0aac54d8bf2e0bc3 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 27 Aug 2013 13:33:37 +1000 Subject: [PATCH] Revamp the API once again Another look at the current API showed some inconsistencies, rectified in this commit: libevdev_kernel_*: modify the underlying kernel device libevdev_event_type_*: something with an event type libevdev_event_code_*: something with an event code libevdev_event_*: struct input_event-related functions (i.e. not device-related) libevdev_property_*: something with a property libevdev_*: anything applying to a device Hopefully that's the last API change. Current symbols deprecated and aliased. Signed-off-by: Peter Hutterer Acked-by: Benjamin Tissoires --- libevdev/libevdev-int.h | 1 + libevdev/libevdev-uinput.c | 2 +- libevdev/libevdev-util.h | 2 +- libevdev/libevdev.c | 41 +++++++++- libevdev/libevdev.h | 32 ++++++-- test/test-event-names.c | 180 ++++++++++++++++++++--------------------- test/test-libevdev-has-event.c | 6 +- test/test-uinput.c | 4 +- tools/libevdev-events.c | 10 +-- 9 files changed, 166 insertions(+), 112 deletions(-) diff --git a/libevdev/libevdev-int.h b/libevdev/libevdev-int.h index e77db32..7f21060 100644 --- a/libevdev/libevdev-int.h +++ b/libevdev/libevdev-int.h @@ -39,6 +39,7 @@ #define ABS_MT_CNT (ABS_MT_MAX - ABS_MT_MIN + 1) #define LIBEVDEV_EXPORT __attribute__((visibility("default"))) #define LIBEVDEV_PRINTF(_format, _args) __attribute__ ((format (printf, _format, _args))) +#define ALIAS(_to) __attribute__((alias(#_to))) #undef min #undef max diff --git a/libevdev/libevdev-uinput.c b/libevdev/libevdev-uinput.c index af98fa4..dc62159 100644 --- a/libevdev/libevdev-uinput.c +++ b/libevdev/libevdev-uinput.c @@ -359,7 +359,7 @@ libevdev_uinput_write_event(const struct libevdev_uinput *uinput_dev, if (type > EV_MAX) return -EINVAL; - max = libevdev_get_event_type_max(type); + max = libevdev_event_type_get_max(type); if (max == -1 || code > (unsigned int)max) return -EINVAL; diff --git a/libevdev/libevdev-util.h b/libevdev/libevdev-util.h index 6c79404..3a40a61 100644 --- a/libevdev/libevdev-util.h +++ b/libevdev/libevdev-util.h @@ -56,7 +56,7 @@ set_bit_state(unsigned long *array, int bit, int state) #define max_mask(uc, lc) \ case EV_##uc: \ *mask = dev->lc##_bits; \ - max = libevdev_get_event_type_max(type); \ + max = libevdev_event_type_get_max(type); \ break; diff --git a/libevdev/libevdev.c b/libevdev/libevdev.c index aa5cbd6..70680d6 100644 --- a/libevdev/libevdev.c +++ b/libevdev/libevdev.c @@ -1244,26 +1244,41 @@ libevdev_grab(struct libevdev *dev, enum libevdev_grab_mode grab) return rc < 0 ? -errno : 0; } +/* DEPRECATED */ LIBEVDEV_EXPORT int libevdev_is_event_type(const struct input_event *ev, unsigned int type) +ALIAS(libevdev_event_is_type); + +LIBEVDEV_EXPORT int +libevdev_event_is_type(const struct input_event *ev, unsigned int type) { return type < EV_CNT && ev->type == type; } +/* DEPRECATED */ LIBEVDEV_EXPORT int libevdev_is_event_code(const struct input_event *ev, unsigned int type, unsigned int code) +ALIAS(libevdev_event_is_code); + +LIBEVDEV_EXPORT int +libevdev_event_is_code(const struct input_event *ev, unsigned int type, unsigned int code) { int max; - if (!libevdev_is_event_type(ev, type)) + if (!libevdev_event_is_type(ev, type)) return 0; - max = libevdev_get_event_type_max(type); + max = libevdev_event_type_get_max(type); return (max > -1 && code <= (unsigned int)max && ev->code == code); } +/* DEPRECATED */ LIBEVDEV_EXPORT const char* libevdev_get_event_type_name(unsigned int type) +ALIAS(libevdev_event_type_get_name); + +LIBEVDEV_EXPORT const char* +libevdev_event_type_get_name(unsigned int type) { if (type > EV_MAX) return NULL; @@ -1271,10 +1286,15 @@ libevdev_get_event_type_name(unsigned int type) return ev_map[type]; } +/* DEPRECATED */ LIBEVDEV_EXPORT const char* libevdev_get_event_code_name(unsigned int type, unsigned int code) +ALIAS(libevdev_event_code_get_name); + +LIBEVDEV_EXPORT const char* +libevdev_event_code_get_name(unsigned int type, unsigned int code) { - int max = libevdev_get_event_type_max(type); + int max = libevdev_event_type_get_max(type); if (max == -1 || code > (unsigned int)max) return NULL; @@ -1282,8 +1302,18 @@ libevdev_get_event_code_name(unsigned int type, unsigned int code) return event_type_map[type][code]; } +/* DEPRECATED */ +LIBEVDEV_EXPORT const char* +libevdev_get_input_prop_name(unsigned int prop) +ALIAS(libevdev_property_get_name); + +/* DEPRECATED */ LIBEVDEV_EXPORT const char* libevdev_get_property_name(unsigned int prop) +ALIAS(libevdev_property_get_name); + +LIBEVDEV_EXPORT const char* +libevdev_property_get_name(unsigned int prop) { if (prop > INPUT_PROP_MAX) return NULL; @@ -1291,8 +1321,13 @@ libevdev_get_property_name(unsigned int prop) return input_prop_map[prop]; } +/* DEPRECATED */ LIBEVDEV_EXPORT int libevdev_get_event_type_max(unsigned int type) +ALIAS(libevdev_event_type_get_max); + +LIBEVDEV_EXPORT int +libevdev_event_type_get_max(unsigned int type) { if (type > EV_MAX) return -1; diff --git a/libevdev/libevdev.h b/libevdev/libevdev.h index 82142d6..472e1b9 100644 --- a/libevdev/libevdev.h +++ b/libevdev/libevdev.h @@ -1255,7 +1255,7 @@ int libevdev_kernel_set_led_values(struct libevdev *dev, ...); * @return 1 if the event type matches the given type, 0 otherwise (or if * type is invalid) */ -int libevdev_is_event_type(const struct input_event *ev, unsigned int type); +int libevdev_event_is_type(const struct input_event *ev, unsigned int type); /** * @ingroup misc @@ -1280,7 +1280,7 @@ int libevdev_is_event_type(const struct input_event *ev, unsigned int type); * @return 1 if the event type matches the given type and code, 0 otherwise * (or if type/code are invalid) */ -int libevdev_is_event_code(const struct input_event *ev, unsigned int type, unsigned int code); +int libevdev_event_is_code(const struct input_event *ev, unsigned int type, unsigned int code); /** * @ingroup misc @@ -1293,7 +1293,7 @@ int libevdev_is_event_code(const struct input_event *ev, unsigned int type, unsi * @note The list of names is compiled into libevdev. If the kernel adds new * defines for new properties libevdev will not automatically pick these up. */ -const char * libevdev_get_event_type_name(unsigned int type); +const char * libevdev_event_type_get_name(unsigned int type); /** * @ingroup misc * @@ -1306,7 +1306,7 @@ const char * libevdev_get_event_type_name(unsigned int type); * @note The list of names is compiled into libevdev. If the kernel adds new * defines for new properties libevdev will not automatically pick these up. */ -const char * libevdev_get_event_code_name(unsigned int type, unsigned int code); +const char * libevdev_event_code_get_name(unsigned int type, unsigned int code); /** * @ingroup misc @@ -1319,9 +1319,9 @@ const char * libevdev_get_event_code_name(unsigned int type, unsigned int code); * @note The list of names is compiled into libevdev. If the kernel adds new * defines for new properties libevdev will not automatically pick these up. * @note On older kernels input properties may not be defined and - * libevdev_get_input_prop_name() will always return NULL + * libevdev_property_get_name() will always return NULL */ -const char* libevdev_get_property_name(unsigned int prop); +const char* libevdev_property_get_name(unsigned int prop); /** * @ingroup misc @@ -1335,7 +1335,7 @@ const char* libevdev_get_property_name(unsigned int prop); * @note The max value is compiled into libevdev. If the kernel changes the * max value, libevdev will not automatically pick these up. */ -int libevdev_get_event_type_max(unsigned int type); +int libevdev_event_type_get_max(unsigned int type); /** * @ingroup bits @@ -1363,8 +1363,26 @@ int libevdev_get_repeat(struct libevdev *dev, int *delay, int *period); /* 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; + /* replacement: libevdev_set_log_function */ void libevdev_set_log_handler(struct libevdev *dev, libevdev_log_func_t logfunc) LIBEVDEV_DEPRECATED; + +/** replacement: libevdev_event_type_get_max */ +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); + +/** replacement: libevdev_event_type_get_name */ +const char * libevdev_get_event_type_name(unsigned int type) LIBEVDEV_DEPRECATED; +/** replacement: libevdev_event_code_get_name */ +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); + +/** replacement: libevdev_event_is_code */ +int libevdev_is_event_code(const struct input_event *ev, unsigned int type, unsigned int code); /**************************************/ #ifdef __cplusplus diff --git a/test/test-event-names.c b/test/test-event-names.c index e7d92bb..57e8e7a 100644 --- a/test/test-event-names.c +++ b/test/test-event-names.c @@ -25,48 +25,48 @@ START_TEST(test_limits) { - ck_assert(libevdev_get_event_type_name(EV_MAX + 1) == NULL); - ck_assert(libevdev_get_event_code_name(EV_ABS, ABS_MAX + 1) == NULL); - ck_assert(libevdev_get_event_code_name(EV_REL, REL_MAX + 1) == NULL); - ck_assert(libevdev_get_event_code_name(EV_KEY, KEY_MAX + 1) == NULL); - ck_assert(libevdev_get_event_code_name(EV_LED, LED_MAX + 1) == NULL); - ck_assert(libevdev_get_event_code_name(EV_SW, SW_MAX + 1) == NULL); - ck_assert(libevdev_get_event_code_name(EV_MSC, MSC_MAX + 1) == NULL); - ck_assert(libevdev_get_event_code_name(EV_SND, SND_MAX + 1) == NULL); - ck_assert(libevdev_get_event_code_name(EV_REP, REP_MAX + 1) == NULL); - ck_assert(libevdev_get_event_code_name(EV_FF, FF_MAX + 1) == NULL); - ck_assert(libevdev_get_event_code_name(EV_MAX + 1, 0) == NULL); + ck_assert(libevdev_event_type_get_name(EV_MAX + 1) == NULL); + ck_assert(libevdev_event_code_get_name(EV_ABS, ABS_MAX + 1) == NULL); + ck_assert(libevdev_event_code_get_name(EV_REL, REL_MAX + 1) == NULL); + ck_assert(libevdev_event_code_get_name(EV_KEY, KEY_MAX + 1) == NULL); + ck_assert(libevdev_event_code_get_name(EV_LED, LED_MAX + 1) == NULL); + ck_assert(libevdev_event_code_get_name(EV_SW, SW_MAX + 1) == NULL); + ck_assert(libevdev_event_code_get_name(EV_MSC, MSC_MAX + 1) == NULL); + ck_assert(libevdev_event_code_get_name(EV_SND, SND_MAX + 1) == NULL); + ck_assert(libevdev_event_code_get_name(EV_REP, REP_MAX + 1) == NULL); + ck_assert(libevdev_event_code_get_name(EV_FF, FF_MAX + 1) == NULL); + ck_assert(libevdev_event_code_get_name(EV_MAX + 1, 0) == NULL); } END_TEST START_TEST(test_type_name) { - ck_assert_str_eq(libevdev_get_event_type_name(EV_SYN), "EV_SYN"); - ck_assert_str_eq(libevdev_get_event_type_name(EV_REL), "EV_REL"); - ck_assert_str_eq(libevdev_get_event_type_name(EV_ABS), "EV_ABS"); - ck_assert_str_eq(libevdev_get_event_type_name(EV_MSC), "EV_MSC"); - ck_assert_str_eq(libevdev_get_event_type_name(EV_SW), "EV_SW"); - ck_assert_str_eq(libevdev_get_event_type_name(EV_LED), "EV_LED"); - ck_assert_str_eq(libevdev_get_event_type_name(EV_SND), "EV_SND"); - ck_assert_str_eq(libevdev_get_event_type_name(EV_REP), "EV_REP"); - ck_assert_str_eq(libevdev_get_event_type_name(EV_FF), "EV_FF"); - ck_assert_str_eq(libevdev_get_event_type_name(EV_PWR), "EV_PWR"); - ck_assert_str_eq(libevdev_get_event_type_name(EV_FF_STATUS), "EV_FF_STATUS"); - ck_assert_str_eq(libevdev_get_event_type_name(EV_MAX), "EV_MAX"); + ck_assert_str_eq(libevdev_event_type_get_name(EV_SYN), "EV_SYN"); + ck_assert_str_eq(libevdev_event_type_get_name(EV_REL), "EV_REL"); + ck_assert_str_eq(libevdev_event_type_get_name(EV_ABS), "EV_ABS"); + ck_assert_str_eq(libevdev_event_type_get_name(EV_MSC), "EV_MSC"); + ck_assert_str_eq(libevdev_event_type_get_name(EV_SW), "EV_SW"); + ck_assert_str_eq(libevdev_event_type_get_name(EV_LED), "EV_LED"); + ck_assert_str_eq(libevdev_event_type_get_name(EV_SND), "EV_SND"); + ck_assert_str_eq(libevdev_event_type_get_name(EV_REP), "EV_REP"); + ck_assert_str_eq(libevdev_event_type_get_name(EV_FF), "EV_FF"); + ck_assert_str_eq(libevdev_event_type_get_name(EV_PWR), "EV_PWR"); + ck_assert_str_eq(libevdev_event_type_get_name(EV_FF_STATUS), "EV_FF_STATUS"); + ck_assert_str_eq(libevdev_event_type_get_name(EV_MAX), "EV_MAX"); } END_TEST START_TEST(test_code_abs_name) { /* pick out a few only */ - ck_assert_str_eq(libevdev_get_event_code_name(EV_ABS, ABS_X), "ABS_X"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_ABS, ABS_Y), "ABS_Y"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_ABS, ABS_X), "ABS_X"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_ABS, ABS_Y), "ABS_Y"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_ABS, ABS_MT_SLOT), "ABS_MT_SLOT"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_ABS, ABS_MISC), "ABS_MISC"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_ABS, ABS_MAX), "ABS_MAX"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_ABS, ABS_MT_SLOT), "ABS_MT_SLOT"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_ABS, ABS_MISC), "ABS_MISC"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_ABS, ABS_MAX), "ABS_MAX"); - ck_assert(libevdev_get_event_code_name(EV_ABS, ABS_MAX - 1) == NULL); + ck_assert(libevdev_event_code_get_name(EV_ABS, ABS_MAX - 1) == NULL); } END_TEST @@ -74,12 +74,12 @@ END_TEST START_TEST(test_code_rel_name) { /* pick out a few only */ - ck_assert_str_eq(libevdev_get_event_code_name(EV_REL, REL_X), "REL_X"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_REL, REL_Y), "REL_Y"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_REL, REL_MISC), "REL_MISC"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_REL, REL_MAX), "REL_MAX"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_REL, REL_X), "REL_X"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_REL, REL_Y), "REL_Y"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_REL, REL_MISC), "REL_MISC"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_REL, REL_MAX), "REL_MAX"); - ck_assert(libevdev_get_event_code_name(EV_REL, REL_MAX - 1) == NULL); + ck_assert(libevdev_event_code_get_name(EV_REL, REL_MAX - 1) == NULL); } END_TEST @@ -87,34 +87,34 @@ END_TEST START_TEST(test_code_key_name) { /* pick out a few only */ - ck_assert_str_eq(libevdev_get_event_code_name(EV_KEY, KEY_RESERVED), "KEY_RESERVED"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_KEY, KEY_ESC), "KEY_ESC"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_KEY, KEY_1), "KEY_1"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_KEY, KEY_2), "KEY_2"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_KEY, KEY_UNKNOWN), "KEY_UNKNOWN"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_KEY, KEY_RESERVED), "KEY_RESERVED"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_KEY, KEY_ESC), "KEY_ESC"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_KEY, KEY_1), "KEY_1"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_KEY, KEY_2), "KEY_2"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_KEY, KEY_UNKNOWN), "KEY_UNKNOWN"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_KEY, BTN_0), "BTN_0"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_KEY, BTN_LEFT), "BTN_LEFT"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_KEY, BTN_TRIGGER), "BTN_TRIGGER"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_KEY, BTN_A), "BTN_A"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_KEY, BTN_TOOL_PEN), "BTN_TOOL_PEN"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_KEY, BTN_0), "BTN_0"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_KEY, BTN_LEFT), "BTN_LEFT"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_KEY, BTN_TRIGGER), "BTN_TRIGGER"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_KEY, BTN_A), "BTN_A"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_KEY, BTN_TOOL_PEN), "BTN_TOOL_PEN"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_KEY, KEY_TOUCHPAD_TOGGLE), "KEY_TOUCHPAD_TOGGLE"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_KEY, BTN_TRIGGER_HAPPY), "BTN_TRIGGER_HAPPY1"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_KEY, KEY_TOUCHPAD_TOGGLE), "KEY_TOUCHPAD_TOGGLE"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_KEY, BTN_TRIGGER_HAPPY), "BTN_TRIGGER_HAPPY1"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_KEY, KEY_MAX), "KEY_MAX"); - ck_assert(libevdev_get_event_code_name(EV_KEY, KEY_MAX - 1) == NULL); + ck_assert_str_eq(libevdev_event_code_get_name(EV_KEY, KEY_MAX), "KEY_MAX"); + ck_assert(libevdev_event_code_get_name(EV_KEY, KEY_MAX - 1) == NULL); /* special cases that resolve to something else */ - ck_assert_str_eq(libevdev_get_event_code_name(EV_KEY, KEY_HANGUEL), "KEY_HANGEUL"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_KEY, KEY_SCREENLOCK), "KEY_COFFEE"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_KEY, BTN_MISC), "BTN_0"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_KEY, BTN_MOUSE), "BTN_LEFT"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_KEY, BTN_JOYSTICK), "BTN_TRIGGER"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_KEY, BTN_GAMEPAD), "BTN_A"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_KEY, BTN_DIGI), "BTN_TOOL_PEN"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_KEY, BTN_WHEEL), "BTN_GEAR_DOWN"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_KEY, BTN_TRIGGER_HAPPY), "BTN_TRIGGER_HAPPY1"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_KEY, KEY_HANGUEL), "KEY_HANGEUL"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_KEY, KEY_SCREENLOCK), "KEY_COFFEE"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_KEY, BTN_MISC), "BTN_0"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_KEY, BTN_MOUSE), "BTN_LEFT"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_KEY, BTN_JOYSTICK), "BTN_TRIGGER"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_KEY, BTN_GAMEPAD), "BTN_A"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_KEY, BTN_DIGI), "BTN_TOOL_PEN"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_KEY, BTN_WHEEL), "BTN_GEAR_DOWN"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_KEY, BTN_TRIGGER_HAPPY), "BTN_TRIGGER_HAPPY1"); } END_TEST @@ -122,11 +122,11 @@ END_TEST START_TEST(test_code_led_name) { /* pick out a few only */ - ck_assert_str_eq(libevdev_get_event_code_name(EV_LED, LED_NUML), "LED_NUML"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_LED, LED_KANA), "LED_KANA"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_LED, LED_MAX), "LED_MAX"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_LED, LED_NUML), "LED_NUML"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_LED, LED_KANA), "LED_KANA"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_LED, LED_MAX), "LED_MAX"); - ck_assert(libevdev_get_event_code_name(EV_LED, LED_MAX - 1) == NULL); + ck_assert(libevdev_event_code_get_name(EV_LED, LED_MAX - 1) == NULL); } END_TEST @@ -134,11 +134,11 @@ END_TEST START_TEST(test_code_snd_name) { /* pick out a few only */ - ck_assert_str_eq(libevdev_get_event_code_name(EV_SND, SND_CLICK), "SND_CLICK"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_SND, SND_TONE), "SND_TONE"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_SND, SND_MAX), "SND_MAX"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_SND, SND_CLICK), "SND_CLICK"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_SND, SND_TONE), "SND_TONE"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_SND, SND_MAX), "SND_MAX"); - ck_assert(libevdev_get_event_code_name(EV_SND, SND_MAX - 1) == NULL); + ck_assert(libevdev_event_code_get_name(EV_SND, SND_MAX - 1) == NULL); } END_TEST @@ -146,14 +146,14 @@ END_TEST START_TEST(test_code_msc_name) { /* pick out a few only */ - ck_assert_str_eq(libevdev_get_event_code_name(EV_MSC, MSC_SERIAL), "MSC_SERIAL"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_MSC, MSC_RAW), "MSC_RAW"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_MSC, MSC_SERIAL), "MSC_SERIAL"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_MSC, MSC_RAW), "MSC_RAW"); #ifdef MSC_TIMESTAMP - ck_assert_str_eq(libevdev_get_event_code_name(EV_MSC, MSC_TIMESTAMP), "MSC_TIMESTAMP"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_MSC, MSC_TIMESTAMP), "MSC_TIMESTAMP"); #endif - ck_assert_str_eq(libevdev_get_event_code_name(EV_MSC, MSC_MAX), "MSC_MAX"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_MSC, MSC_MAX), "MSC_MAX"); - ck_assert(libevdev_get_event_code_name(EV_MSC, MSC_MAX - 1) == NULL); + ck_assert(libevdev_event_code_get_name(EV_MSC, MSC_MAX - 1) == NULL); } END_TEST @@ -161,12 +161,12 @@ END_TEST START_TEST(test_code_sw_name) { /* pick out a few only */ - ck_assert_str_eq(libevdev_get_event_code_name(EV_SW, SW_LID), "SW_LID"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_SW, SW_RFKILL_ALL), "SW_RFKILL_ALL"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_SW, SW_LINEIN_INSERT), "SW_LINEIN_INSERT"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_SW, SW_MAX), "SW_MAX"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_SW, SW_LID), "SW_LID"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_SW, SW_RFKILL_ALL), "SW_RFKILL_ALL"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_SW, SW_LINEIN_INSERT), "SW_LINEIN_INSERT"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_SW, SW_MAX), "SW_MAX"); - ck_assert(libevdev_get_event_code_name(EV_SW, SW_MAX - 1) == NULL); + ck_assert(libevdev_event_code_get_name(EV_SW, SW_MAX - 1) == NULL); } END_TEST @@ -174,22 +174,22 @@ END_TEST START_TEST(test_code_ff_name) { /* pick out a few only */ - ck_assert_str_eq(libevdev_get_event_code_name(EV_FF, FF_STATUS_STOPPED), "FF_STATUS_STOPPED"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_FF, FF_FRICTION), "FF_FRICTION"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_FF, FF_CUSTOM), "FF_CUSTOM"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_FF, FF_MAX), "FF_MAX"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_FF, FF_STATUS_STOPPED), "FF_STATUS_STOPPED"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_FF, FF_FRICTION), "FF_FRICTION"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_FF, FF_CUSTOM), "FF_CUSTOM"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_FF, FF_MAX), "FF_MAX"); - ck_assert(libevdev_get_event_code_name(EV_FF, FF_MAX - 1) == NULL); + ck_assert(libevdev_event_code_get_name(EV_FF, FF_MAX - 1) == NULL); } END_TEST START_TEST(test_code_syn_name) { - ck_assert_str_eq(libevdev_get_event_code_name(EV_SYN, SYN_REPORT), "SYN_REPORT"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_SYN, SYN_CONFIG), "SYN_CONFIG"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_SYN, SYN_MT_REPORT), "SYN_MT_REPORT"); - ck_assert_str_eq(libevdev_get_event_code_name(EV_SYN, SYN_DROPPED), "SYN_DROPPED"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_SYN, SYN_REPORT), "SYN_REPORT"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_SYN, SYN_CONFIG), "SYN_CONFIG"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_SYN, SYN_MT_REPORT), "SYN_MT_REPORT"); + ck_assert_str_eq(libevdev_event_code_get_name(EV_SYN, SYN_DROPPED), "SYN_DROPPED"); /* there is no SYN_MAX */ } @@ -210,12 +210,12 @@ END_TEST START_TEST(test_event_type_max) { - ck_assert_int_eq(libevdev_get_event_type_max(EV_ABS), ABS_MAX); - ck_assert_int_eq(libevdev_get_event_type_max(EV_REL), REL_MAX); - ck_assert_int_eq(libevdev_get_event_type_max(EV_KEY), KEY_MAX); + ck_assert_int_eq(libevdev_event_type_get_max(EV_ABS), ABS_MAX); + ck_assert_int_eq(libevdev_event_type_get_max(EV_REL), REL_MAX); + ck_assert_int_eq(libevdev_event_type_get_max(EV_KEY), KEY_MAX); - ck_assert_int_eq(libevdev_get_event_type_max(EV_MAX - 1), -1); - ck_assert_int_eq(libevdev_get_event_type_max(EV_MAX + 1), -1); + ck_assert_int_eq(libevdev_event_type_get_max(EV_MAX - 1), -1); + ck_assert_int_eq(libevdev_event_type_get_max(EV_MAX + 1), -1); } END_TEST @@ -251,7 +251,7 @@ START_TEST(test_event_code) if (i == ev.type || i == EV_SYN) continue; - for (j = 0; j < libevdev_get_event_type_max(i); i++) { + for (j = 0; j < libevdev_event_type_get_max(i); i++) { ck_assert_int_eq(libevdev_is_event_code(&ev, i, j), 0); } } diff --git a/test/test-libevdev-has-event.c b/test/test-libevdev-has-event.c index ed10140..242f991 100644 --- a/test/test-libevdev-has-event.c +++ b/test/test-libevdev-has-event.c @@ -56,7 +56,7 @@ START_TEST(test_has_ev_bit) *evbit, 0, -1); ck_assert_msg(rc == 0, "%s: Failed to create device with: %s", - libevdev_get_event_type_name(*evbit), + libevdev_event_type_get_name(*evbit), strerror(-rc)); ck_assert_msg(libevdev_has_event_type(dev, EV_SYN), "for event type %d\n", *evbit); @@ -123,7 +123,7 @@ START_TEST(test_event_codes) continue; } - max = libevdev_get_event_type_max(*evbit); + max = libevdev_event_type_get_max(*evbit); for (code = 1; code < max; code += 10) { if (*evbit == EV_ABS) { @@ -167,7 +167,7 @@ START_TEST(test_event_code_limits) continue; } - max = libevdev_get_event_type_max(*evbit); + max = libevdev_event_type_get_max(*evbit); ck_assert(max != -1); if (*evbit == EV_ABS) { diff --git a/test/test-uinput.c b/test/test-uinput.c index e7546d1..2e9d3cd 100644 --- a/test/test-uinput.c +++ b/test/test-uinput.c @@ -65,7 +65,7 @@ START_TEST(test_uinput_create_device) ck_assert_int_eq(rc, 0); for (type = 0; type < EV_CNT; type++) { - int max = libevdev_get_event_type_max(type); + int max = libevdev_event_type_get_max(type); if (max == -1) continue; @@ -144,7 +144,7 @@ START_TEST(test_uinput_create_device_from_fd) ck_assert_int_eq(rc, 0); for (type = 0; type < EV_CNT; type++) { - int max = libevdev_get_event_type_max(type); + int max = libevdev_event_type_get_max(type); if (max == -1) continue; diff --git a/tools/libevdev-events.c b/tools/libevdev-events.c index 1590965..1511227 100644 --- a/tools/libevdev-events.c +++ b/tools/libevdev-events.c @@ -62,7 +62,7 @@ print_code_bits(struct libevdev *dev, unsigned int type, unsigned int max) if (!libevdev_has_event_code(dev, type, i)) continue; - printf(" Event code %i (%s)\n", i, libevdev_get_event_code_name(type, i)); + printf(" Event code %i (%s)\n", i, libevdev_event_code_get_name(type, i)); if (type == EV_ABS) print_abs_bits(dev, i); } @@ -76,7 +76,7 @@ print_bits(struct libevdev *dev) for (i = 0; i <= EV_MAX; i++) { if (libevdev_has_event_type(dev, i)) - printf(" Event type %d (%s)\n", i, libevdev_get_event_type_name(i)); + printf(" Event type %d (%s)\n", i, libevdev_event_type_get_name(i)); switch(i) { case EV_KEY: print_code_bits(dev, EV_KEY, KEY_MAX); @@ -113,15 +113,15 @@ int print_event(struct input_event *ev) printf("Event: time %ld.%06ld, ++++++++++++++++++++ %s +++++++++++++++\n", ev->time.tv_sec, ev->time.tv_usec, - libevdev_get_event_type_name(ev->type)); + libevdev_event_type_get_name(ev->type)); else printf("Event: time %ld.%06ld, type %d (%s), code %d (%s), value %d\n", ev->time.tv_sec, ev->time.tv_usec, ev->type, - libevdev_get_event_type_name(ev->type), + libevdev_event_type_get_name(ev->type), ev->code, - libevdev_get_event_code_name(ev->type, ev->code), + libevdev_event_code_get_name(ev->type, ev->code), ev->value); return 0; } -- 2.7.4