mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-03 10:00:27 +01:00
evdev: the range between dpad and trigger-happy are keys, not buttons
Affected keys: KEY_ALS_TOGGLE KEY_BUTTONCONFIG KEY_TASKMANAGER KEY_JOURNAL KEY_CONTROLPANEL KEY_APPSELECT KEY_SCREENSAVER KEY_VOICECOMMAND KEY_BRIGHTNESS_MIN KEY_BRIGHTNESS_MAX KEY_KBDINPUTASSIST_PREV KEY_KBDINPUTASSIST_NEXT KEY_KBDINPUTASSIST_PREVGROUP KEY_KBDINPUTASSIST_NEXTGROUP KEY_KBDINPUTASSIST_ACCEPT KEY_KBDINPUTASSIST_CANCEL https://bugs.freedesktop.org/show_bug.cgi?id=95295 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
fb5a97211b
commit
8527242ed9
2 changed files with 43 additions and 1 deletions
|
|
@ -586,7 +586,11 @@ get_key_type(uint16_t code)
|
|||
return EVDEV_KEY_TYPE_BUTTON;
|
||||
if (code >= KEY_OK && code <= KEY_LIGHTS_TOGGLE)
|
||||
return EVDEV_KEY_TYPE_KEY;
|
||||
if (code >= BTN_DPAD_UP && code <= BTN_TRIGGER_HAPPY40)
|
||||
if (code >= BTN_DPAD_UP && code <= BTN_DPAD_RIGHT)
|
||||
return EVDEV_KEY_TYPE_BUTTON;
|
||||
if (code >= KEY_ALS_TOGGLE && code <= KEY_KBDINPUTASSIST_CANCEL)
|
||||
return EVDEV_KEY_TYPE_KEY;
|
||||
if (code >= BTN_TRIGGER_HAPPY && code <= BTN_TRIGGER_HAPPY40)
|
||||
return EVDEV_KEY_TYPE_BUTTON;
|
||||
return EVDEV_KEY_TYPE_NONE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -342,6 +342,42 @@ START_TEST(keyboard_time_usec)
|
|||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(keyboard_no_buttons)
|
||||
{
|
||||
struct litest_device *dev = litest_current_device();
|
||||
struct libinput *li = dev->libinput;
|
||||
struct libinput_event *event;
|
||||
int code;
|
||||
const char *name;
|
||||
|
||||
litest_drain_events(dev->libinput);
|
||||
|
||||
for (code = 0; code < KEY_MAX; code++) {
|
||||
if (!libevdev_has_event_code(dev->evdev, EV_KEY, code))
|
||||
continue;
|
||||
|
||||
name = libevdev_event_code_get_name(EV_KEY, code);
|
||||
if (!name || !strneq(name, "KEY_", 4))
|
||||
continue;
|
||||
|
||||
litest_keyboard_key(dev, code, true);
|
||||
litest_keyboard_key(dev, code, false);
|
||||
libinput_dispatch(li);
|
||||
|
||||
event = libinput_get_event(li);
|
||||
litest_is_keyboard_event(event,
|
||||
code,
|
||||
LIBINPUT_KEY_STATE_PRESSED);
|
||||
libinput_event_destroy(event);
|
||||
event = libinput_get_event(li);
|
||||
litest_is_keyboard_event(event,
|
||||
code,
|
||||
LIBINPUT_KEY_STATE_RELEASED);
|
||||
libinput_event_destroy(event);
|
||||
}
|
||||
}
|
||||
END_TEST
|
||||
|
||||
void
|
||||
litest_setup_tests(void)
|
||||
{
|
||||
|
|
@ -351,4 +387,6 @@ litest_setup_tests(void)
|
|||
litest_add("keyboard:keys", keyboard_has_key, LITEST_KEYS, LITEST_ANY);
|
||||
litest_add("keyboard:keys", keyboard_keys_bad_device, LITEST_ANY, LITEST_ANY);
|
||||
litest_add("keyboard:time", keyboard_time_usec, LITEST_KEYS, LITEST_ANY);
|
||||
|
||||
litest_add("keyboard:events", keyboard_no_buttons, LITEST_KEYS, LITEST_ANY);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue