summaryrefslogtreecommitdiff
path: root/libevdev
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2013-08-27 13:33:37 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2013-09-10 11:25:09 +1000
commitab2f20bfd6ad632b1ab5c41a0aac54d8bf2e0bc3 (patch)
tree3d638f2b951faa74bb6bc4c4dd917e10df86c605 /libevdev
parent14ac764ec86452ca607403f314b0f8355d80290c (diff)
downloadlibevdev-ab2f20bfd6ad632b1ab5c41a0aac54d8bf2e0bc3.tar.gz
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 <peter.hutterer@who-t.net> Acked-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Diffstat (limited to 'libevdev')
-rw-r--r--libevdev/libevdev-int.h1
-rw-r--r--libevdev/libevdev-uinput.c2
-rw-r--r--libevdev/libevdev-util.h2
-rw-r--r--libevdev/libevdev.c41
-rw-r--r--libevdev/libevdev.h32
5 files changed, 66 insertions, 12 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