Disallow disabling of EV_SYN

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2013-07-01 10:08:02 +10:00
parent bed8a95e0a
commit 0aa639b443
3 changed files with 8 additions and 1 deletions

View file

@ -795,7 +795,7 @@ libevdev_enable_event_type(struct libevdev *dev, unsigned int type)
int
libevdev_disable_event_type(struct libevdev *dev, unsigned int type)
{
if (type > EV_MAX)
if (type > EV_MAX || type == EV_SYN)
return -1;
clear_bit(dev->bits, type);

View file

@ -736,6 +736,9 @@ int libevdev_enable_event_type(struct libevdev *dev, unsigned int type);
* In most cases, a caller likely only wants to disable a single code, not
* the whole type. Use libevdev_disable_event_code() for that.
*
* Disabling EV_SYN will not work. Don't shoot yourself in the foot.
* It hurts.
*
* This is a local modification only affecting only this representation of
* this device.
*
@ -793,6 +796,9 @@ int libevdev_enable_event_code(struct libevdev *dev, unsigned int type, unsigned
* This is a local modification only affecting only this representation of
* this device.
*
* Disabling EV_SYN will not work. Don't shoot yourself in the foot.
* It hurts.
*
* @param dev The evdev device, already initialized with libevdev_set_fd()
* @param type The event type to disable (EV_ABS, EV_KEY, ...)
* @param code The event code to disable (ABS_X, REL_X, etc.)

View file

@ -563,6 +563,7 @@ START_TEST(test_device_disable_bit_invalid)
ck_assert_int_eq(libevdev_disable_event_code(dev, EV_ABS, ABS_MAX + 1), -1);
ck_assert_int_eq(libevdev_disable_event_code(dev, EV_MAX + 1, ABS_MAX + 1), -1);
ck_assert_int_eq(libevdev_disable_event_type(dev, EV_MAX + 1), -1);
ck_assert_int_eq(libevdev_disable_event_type(dev, EV_SYN), -1);
uinput_device_free(uidev);
libevdev_free(dev);