From ea8c69c3e4fb0f26bb69a4f0d5d0c52a8cbfe1df Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Sat, 29 Jun 2013 18:25:30 +1000 Subject: [PATCH] Change signature for kernel_enable_event_code to match enable_event_code They do essentially the same thing, so the function signature should be null. Signed-off-by: Peter Hutterer --- libevdev/libevdev.c | 16 +++++++++++++--- libevdev/libevdev.h | 8 +++++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/libevdev/libevdev.c b/libevdev/libevdev.c index d4cebc6..c3db8a1 100644 --- a/libevdev/libevdev.c +++ b/libevdev/libevdev.c @@ -863,7 +863,8 @@ libevdev_kernel_enable_event_type(struct libevdev *dev, unsigned int type) } int -libevdev_kernel_enable_event_code(struct libevdev *dev, unsigned int type, unsigned int code) +libevdev_kernel_enable_event_code(struct libevdev *dev, unsigned int type, + unsigned int code, const void *data) { int rc; int uinput_bit; @@ -890,9 +891,18 @@ libevdev_kernel_enable_event_code(struct libevdev *dev, unsigned int type, unsig } rc = ioctl(dev->fd, uinput_bit, type); - if (rc != -1) - libevdev_enable_event_type(dev, type); + if (rc == -1) + goto out; + rc = libevdev_enable_event_type(dev, type); + if (rc == -1) + goto out; + + /* FIXME: can't back out of this if it fails */ + if (type == EV_ABS) + rc = libevdev_kernel_set_abs_value(dev, code, (const struct input_absinfo*)data); + +out: return (rc != -1) ? 0 : -errno; } diff --git a/libevdev/libevdev.h b/libevdev/libevdev.h index d9f1daa..0472302 100644 --- a/libevdev/libevdev.h +++ b/libevdev/libevdev.h @@ -737,12 +737,18 @@ int libevdev_kernel_enable_event_type(struct libevdev *dev, unsigned int type); * This cannot be undone, the kernel only allows to enable axes, not disable * them. * + * The last argument depends on the type and code: + * - If type is EV_ABS, the vararg must be a pointer to a struct input_absinfo + * containing the data for this axis. + * - For all other types, the argument is ignored. + * * This function calls libevdev_kernel_enable_event_type() if necessary. * * @param type The event type to enable (EV_ABS, EV_KEY, ...) * @param code The event code to enable (ABS_X, REL_X, etc.) + * @param data Axis/key data, depending on type and code */ -int libevdev_kernel_enable_event_code(struct libevdev *dev, unsigned int type, unsigned int code); +int libevdev_kernel_enable_event_code(struct libevdev *dev, unsigned int type, unsigned int code, const void *data); /** * @ingroup kernel -- 2.7.4