testevdev: Adapt to a broader definition of keyboards At the time I contributed this unit test, SDL had a relatively narrow definition of what is a keyboard, approximately matching udev ID_INPUT_KEYBOARD. Now it uses the equivalent of udev ID_INPUT_KEY, which matches anything with keyboard keys, and not just reasonably complete alphanumeric keyboards. Fixes: 040bd7a9 "Fix udev not detecting ID_INPUT_KEY devices when udev is not running" Signed-off-by: Simon McVittie <smcv@collabora.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
diff --git a/test/testevdev.c b/test/testevdev.c
index 8e3fdaa..76a12ef 100644
--- a/test/testevdev.c
+++ b/test/testevdev.c
@@ -595,7 +595,7 @@ static const GuessTest guess_tests[] =
* to the arrow, page up and page down keys, so it's a joystick
* with a subset of a keyboard attached. */
/* TODO: Should this be JOYSTICK, or even JOYSTICK|KEYBOARD? */
- .expected = SDL_UDEV_DEVICE_UNKNOWN,
+ .expected = SDL_UDEV_DEVICE_KEYBOARD,
/* SYN, KEY */
.ev = { 0x03 },
.keys = {
@@ -607,7 +607,7 @@ static const GuessTest guess_tests[] =
/* BTN_1, BTN_2, BTN_A, BTN_B, BTN_MODE */
/* 0x100 */ 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x10,
/* 0x140 */ ZEROx8,
- /* next, previous */
+ /* next (keyboard page down), previous (keyboard page up) */
/* 0x180 */ 0x00, 0x00, 0x80, 0x10, ZEROx4,
},
},
@@ -658,7 +658,7 @@ static const GuessTest guess_tests[] =
.name = "Wiimote - Classic Controller",
/* TODO: Should this be JOYSTICK, or maybe JOYSTICK|KEYBOARD?
* It's unusual in the same ways as the Wiimote */
- .expected = SDL_UDEV_DEVICE_UNKNOWN,
+ .expected = SDL_UDEV_DEVICE_KEYBOARD,
/* SYN, KEY, ABS */
.ev = { 0x0b },
/* Hat 1-3 */
@@ -672,7 +672,7 @@ static const GuessTest guess_tests[] =
/* A, B, X, Y, MODE, TL, TL2, TR, TR2 */
/* 0x100 */ ZEROx4, 0x00, 0x13, 0xdb, 0x10,
/* 0x140 */ ZEROx8,
- /* next, previous */
+ /* next (keyboard page down), previous (keyboard page up) */
/* 0x180 */ 0x00, 0x00, 0x80, 0x10, ZEROx4,
},
},
@@ -753,7 +753,8 @@ static const GuessTest guess_tests[] =
},
{
.name = "Thinkpad ACPI buttons",
- .expected = SDL_UDEV_DEVICE_UNKNOWN,
+ /* SDL treats this as a keyboard because it has a power button */
+ .expected = SDL_UDEV_DEVICE_KEYBOARD,
/* SYN, KEY, MSC, SW */
.ev = { 0x33 },
.keys = {
@@ -812,7 +813,8 @@ static const GuessTest guess_tests[] =
.vendor_id = 0x0000,
.product_id = 0x0003,
.version = 0x0000,
- .expected = SDL_UDEV_DEVICE_UNKNOWN,
+ /* SDL treats KEY_SLEEP as indicating a keyboard */
+ .expected = SDL_UDEV_DEVICE_KEYBOARD,
/* SYN, KEY */
.ev = { 0x03 },
.keys = {
@@ -838,7 +840,8 @@ static const GuessTest guess_tests[] =
.vendor_id = 0x0000,
.product_id = 0x0001,
.version = 0x0000,
- .expected = SDL_UDEV_DEVICE_UNKNOWN,
+ /* SDL treats KEY_POWER as indicating a keyboard */
+ .expected = SDL_UDEV_DEVICE_KEYBOARD,
/* SYN, KEY */
.ev = { 0x03 },
.keys = {
@@ -853,7 +856,8 @@ static const GuessTest guess_tests[] =
.vendor_id = 0x0000,
.product_id = 0x0006,
.version = 0x0000,
- .expected = SDL_UDEV_DEVICE_UNKNOWN,
+ /* SDL treats brightness control, etc. as keyboard keys */
+ .expected = SDL_UDEV_DEVICE_KEYBOARD,
/* SYN, KEY */
.ev = { 0x03 },
.keys = {
@@ -870,7 +874,7 @@ static const GuessTest guess_tests[] =
.vendor_id = 0x17aa,
.product_id = 0x5054,
.version = 0x4101,
- .expected = SDL_UDEV_DEVICE_UNKNOWN,
+ .expected = SDL_UDEV_DEVICE_KEYBOARD,
/* SYN, KEY */
.ev = { 0x03 },
.keys = {
@@ -908,9 +912,8 @@ static const GuessTest guess_tests[] =
.product_id = 0x6009,
/* For some reason the special keys like mute and wlan toggle
* show up here instead of, or in addition to, as part of
- * the keyboard - so udev reports this as having keys too.
- * SDL currently doesn't. */
- .expected = SDL_UDEV_DEVICE_MOUSE,
+ * the keyboard - so both udev and SDL report this as having keys too. */
+ .expected = SDL_UDEV_DEVICE_MOUSE | SDL_UDEV_DEVICE_KEYBOARD,
/* SYN, KEY, REL, MSC, LED */
.ev = { 0x17, 0x00, 0x02 },
/* X, Y */