[PATCH libevdev 7/7] When enabling EV_REP, set the delay/period values
Peter Hutterer
peter.hutterer at who-t.net
Sun Jul 28 21:06:37 PDT 2013
Just enabling EV_REP sets them to zero, but when enabling them directly,
a value is required.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
libevdev/libevdev.c | 18 +++++++++++++++---
libevdev/libevdev.h | 4 ++--
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/libevdev/libevdev.c b/libevdev/libevdev.c
index eb7401a..e474835 100644
--- a/libevdev/libevdev.c
+++ b/libevdev/libevdev.c
@@ -826,8 +826,16 @@ libevdev_enable_event_type(struct libevdev *dev, unsigned int type)
if (type > EV_MAX)
return -1;
+ if (libevdev_has_event_type(dev, type))
+ return 0;
+
set_bit(dev->bits, type);
+ if (type == EV_REP) {
+ int delay = 0, period = 0;
+ libevdev_enable_event_code(dev, EV_REP, REP_DELAY, &delay);
+ libevdev_enable_event_code(dev, EV_REP, REP_PERIOD, &period);
+ }
return 0;
}
@@ -852,9 +860,10 @@ libevdev_enable_event_code(struct libevdev *dev, unsigned int type,
if (libevdev_enable_event_type(dev, type))
return -1;
- if (type != EV_ABS && data != NULL)
- return -1;
- else if (type == EV_ABS && data == NULL)
+ if (type == EV_ABS || type == EV_REP) {
+ if (data == NULL)
+ return -1;
+ } else if (data != NULL)
return -1;
if (type == EV_SYN)
@@ -870,6 +879,9 @@ libevdev_enable_event_code(struct libevdev *dev, unsigned int type,
if (type == EV_ABS) {
const struct input_absinfo *abs = data;
dev->abs_info[code] = *abs;
+ } else if (type == EV_REP) {
+ const int *value = data;
+ dev->rep_values[code] = *value;
}
return 0;
diff --git a/libevdev/libevdev.h b/libevdev/libevdev.h
index 32100fb..606501b 100644
--- a/libevdev/libevdev.h
+++ b/libevdev/libevdev.h
@@ -871,8 +871,8 @@ int libevdev_disable_event_type(struct libevdev *dev, unsigned int type);
* @param dev The evdev device, already initialized with libevdev_set_fd()
* @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 If type is EV_ABS, data points to a struct input_absinfo. Otherwise, data must be
- * NULL
+ * @param data If type is EV_ABS, data points to a struct input_absinfo. If type is EV_REP, data
+ * points to an integer. Otherwise, data must be NULL.
*
* @return 0 on success or -1 otherwise
*
--
1.8.2.1
More information about the Input-tools
mailing list