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;
}
if (libevdev_enable_event_type(dev, type))
return -1;
- if (type != EV_ABS && data != NULL)
- return -1;
- else if (type == EV_ABS && data == NULL)
- return -1;
-
- if (type == EV_SYN)
- return 0;
+ switch(type) {
+ case EV_SYN:
+ return 0;
+ case EV_ABS:
+ case EV_REP:
+ if (data == NULL)
+ return -1;
+ break;
+ default:
+ if (data != NULL)
+ return -1;
+ break;
+ }
max = type_to_mask(dev, type, &mask);
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;
* @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
*
ck_assert_int_eq(libevdev_enable_event_type(dev, EV_MAX + 1), -1);
ck_assert_int_eq(libevdev_enable_event_code(dev, EV_ABS, ABS_Y, NULL), -1);
+ ck_assert_int_eq(libevdev_enable_event_code(dev, EV_REP, REP_DELAY, NULL), -1);
uinput_device_free(uidev);
libevdev_free(dev);