[PATCH libinput 2/2] evdev: the range between dpad and trigger-happy are keys, not buttons

Peter Hutterer peter.hutterer at who-t.net
Tue May 10 03:44:23 UTC 2016


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 at who-t.net>
---
 src/evdev.c     |  6 +++++-
 test/keyboard.c | 38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/src/evdev.c b/src/evdev.c
index bcd9c5b..cd05cfc 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -568,7 +568,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;
 }
diff --git a/test/keyboard.c b/test/keyboard.c
index b2f9851..f3aa9df 100644
--- a/test/keyboard.c
+++ b/test/keyboard.c
@@ -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);
 }
-- 
2.7.4



More information about the wayland-devel mailing list