mirror of
https://gitlab.freedesktop.org/libevdev/libevdev.git
synced 2026-02-11 01:20:31 +01:00
When enabling EV_REP, set the delay/period values
Just enabling EV_REP sets them to zero, but when enabling them directly, a value is required. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
This commit is contained in:
parent
fc7c3b73a4
commit
40493c3ff2
3 changed files with 27 additions and 9 deletions
|
|
@ -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,13 +860,19 @@ 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)
|
||||
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);
|
||||
|
||||
|
|
@ -870,6 +884,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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*
|
||||
|
|
|
|||
|
|
@ -572,6 +572,7 @@ START_TEST(test_device_enable_bit_invalid)
|
|||
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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue