| 1 |
/* |
| 2 |
Copyright (C) 1997-2026 Sam Lantinga <[email protected]> |
| 3 |
Copyright (C) 2020-2022 Collabora Ltd. |
| 4 |
|
| 5 |
This software is provided 'as-is', without any express or implied |
| 6 |
warranty. In no event will the authors be held liable for any damages |
| 7 |
arising from the use of this software. |
| 8 |
|
| 9 |
Permission is granted to anyone to use this software for any purpose, |
| 10 |
including commercial applications, and to alter it and redistribute it |
| 11 |
freely. |
| 12 |
*/ |
| 13 |
|
| 14 |
#if 0 /* SDL2 Classic included this here, but we don't. */ |
| 15 |
#include "../src/SDL_internal.h" |
| 16 |
#endif |
| 17 |
|
| 18 |
#include <stdio.h> |
| 19 |
#include <string.h> |
| 20 |
|
| 21 |
static int run_test(void); |
| 22 |
|
| 23 |
#if defined(HAVE_LIBUDEV_H) || defined(SDL_JOYSTICK_LINUX) |
| 24 |
|
| 25 |
#include <stdint.h> |
| 26 |
|
| 27 |
#include "SDL_stdinc.h" |
| 28 |
#include "SDL_endian.h" |
| 29 |
#include "../src/core/linux/SDL_evdev_capabilities.h" |
| 30 |
#include "../src/core/linux/SDL_evdev_capabilities.c" |
| 31 |
|
| 32 |
static const struct |
| 33 |
{ |
| 34 |
int code; |
| 35 |
const char *name; |
| 36 |
} device_classes[] = { |
| 37 |
#define CLS(x) \ |
| 38 |
{ \ |
| 39 |
SDL_UDEV_DEVICE_##x, #x \ |
| 40 |
} |
| 41 |
CLS(MOUSE), |
| 42 |
CLS(KEYBOARD), |
| 43 |
CLS(JOYSTICK), |
| 44 |
CLS(SOUND), |
| 45 |
CLS(TOUCHSCREEN), |
| 46 |
CLS(ACCELEROMETER), |
| 47 |
CLS(TOUCHPAD), |
| 48 |
#undef CLS |
| 49 |
{ 0, NULL } |
| 50 |
}; |
| 51 |
|
| 52 |
typedef struct |
| 53 |
{ |
| 54 |
const char *name; |
| 55 |
uint16_t bus_type; |
| 56 |
uint16_t vendor_id; |
| 57 |
uint16_t product_id; |
| 58 |
uint16_t version; |
| 59 |
uint8_t ev[(EV_MAX + 1) / 8]; |
| 60 |
uint8_t keys[(KEY_MAX + 1) / 8]; |
| 61 |
uint8_t abs[(ABS_MAX + 1) / 8]; |
| 62 |
uint8_t rel[(REL_MAX + 1) / 8]; |
| 63 |
uint8_t ff[(FF_MAX + 1) / 8]; |
| 64 |
uint8_t props[INPUT_PROP_MAX / 8]; |
| 65 |
int expected; |
| 66 |
} GuessTest; |
| 67 |
|
| 68 |
/* |
| 69 |
* Test-cases for guessing a device type from its capabilities. |
| 70 |
* |
| 71 |
* The bytes in ev, etc. are in little-endian byte order |
| 72 |
* Trailing zeroes can be omitted. |
| 73 |
* |
| 74 |
* The evemu-describe tool is a convenient way to add a test-case for |
| 75 |
* a physically available device. |
| 76 |
*/ |
| 77 |
#define ZEROx4 0, 0, 0, 0 |
| 78 |
#define ZEROx8 ZEROx4, ZEROx4 |
| 79 |
#define FFx4 0xff, 0xff, 0xff, 0xff |
| 80 |
#define FFx8 FFx4, FFx4 |
| 81 |
|
| 82 |
/* Test-cases derived from real devices or from Linux kernel source */ |
| 83 |
/* *INDENT-OFF* */ /* clang-format off */ |
| 84 |
static const GuessTest guess_tests[] = |
| 85 |
{ |
| 86 |
{ |
| 87 |
.name = "Xbox 360 wired USB controller", |
| 88 |
.bus_type = 0x0003, |
| 89 |
.vendor_id = 0x045e, |
| 90 |
.product_id = 0x028e, |
| 91 |
.expected = SDL_UDEV_DEVICE_JOYSTICK, |
| 92 |
/* SYN, KEY, ABS, FF */ |
| 93 |
.ev = { 0x0b, 0x00, 0x20 }, |
| 94 |
/* X, Y, Z, RX, RY, RZ, HAT0X, HAT0Y */ |
| 95 |
.abs = { 0x3f, 0x00, 0x03 }, |
| 96 |
.keys = { |
| 97 |
/* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8, |
| 98 |
/* A, B, X, Y, TL, TR, SELECT, START, MODE, THUMBL, THUMBR */ |
| 99 |
/* 0x100 */ ZEROx4, 0x00, 0x00, 0xdb, 0x7c, |
| 100 |
}, |
| 101 |
}, |
| 102 |
{ |
| 103 |
.name = "X-Box One Elite", |
| 104 |
.bus_type = 0x0003, |
| 105 |
.vendor_id = 0x045e, |
| 106 |
.product_id = 0x02e3, |
| 107 |
.expected = SDL_UDEV_DEVICE_JOYSTICK, |
| 108 |
/* SYN, KEY, ABS */ |
| 109 |
.ev = { 0x0b }, |
| 110 |
/* X, Y, Z, RX, RY, RZ, HAT0X, HAT0Y */ |
| 111 |
.abs = { 0x3f, 0x00, 0x03 }, |
| 112 |
.keys = { |
| 113 |
/* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8, |
| 114 |
/* A, B, X, Y, TL, TR, SELECT, START, MODE, THUMBL, THUMBR */ |
| 115 |
/* 0x100 */ ZEROx4, 0x00, 0x00, 0xdb, 0x7c, |
| 116 |
}, |
| 117 |
}, |
| 118 |
{ |
| 119 |
.name = "X-Box One S via Bluetooth", |
| 120 |
.bus_type = 0x0005, |
| 121 |
.vendor_id = 0x045e, |
| 122 |
.product_id = 0x02e0, |
| 123 |
.version = 0x1130, |
| 124 |
.expected = SDL_UDEV_DEVICE_JOYSTICK, |
| 125 |
/* SYN, KEY, ABS */ |
| 126 |
.ev = { 0x0b }, |
| 127 |
/* X, Y, Z, RX, RY, RZ, HAT0X, HAT0Y */ |
| 128 |
.abs = { 0x3f, 0x00, 0x03 }, |
| 129 |
.keys = { |
| 130 |
/* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8, |
| 131 |
/* A, B, X, Y, TL, TR, SELECT, START, MODE, THUMBL, THUMBR */ |
| 132 |
/* 0x100 */ ZEROx4, 0x00, 0x00, 0xdb, 0x7c, |
| 133 |
}, |
| 134 |
}, |
| 135 |
{ |
| 136 |
.name = "X-Box One S wired", |
| 137 |
.bus_type = 0x0003, |
| 138 |
.vendor_id = 0x045e, |
| 139 |
.product_id = 0x02ea, |
| 140 |
.version = 0x0301, |
| 141 |
.expected = SDL_UDEV_DEVICE_JOYSTICK, |
| 142 |
/* SYN, KEY, ABS */ |
| 143 |
.ev = { 0x0b }, |
| 144 |
/* X, Y, Z, RX, RY, RZ, HAT0X, HAT0Y */ |
| 145 |
.abs = { 0x3f, 0x00, 0x03 }, |
| 146 |
.keys = { |
| 147 |
/* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8, |
| 148 |
/* A, B, X, Y, TL, TR, SELECT, START, MODE, THUMBL, THUMBR */ |
| 149 |
/* 0x100 */ ZEROx4, 0x00, 0x00, 0xdb, 0x7c, |
| 150 |
}, |
| 151 |
}, |
| 152 |
{ |
| 153 |
.name = "DualShock 4 - gamepad", |
| 154 |
.bus_type = 0x0003, |
| 155 |
.vendor_id = 0x054c, |
| 156 |
.product_id = 0x09cc, |
| 157 |
.expected = SDL_UDEV_DEVICE_JOYSTICK, |
| 158 |
/* SYN, KEY, ABS, MSC, FF */ |
| 159 |
/* Some versions only have 0x0b, SYN, KEY, ABS, like the |
| 160 |
* Bluetooth example below */ |
| 161 |
.ev = { 0x1b, 0x00, 0x20 }, |
| 162 |
/* X, Y, Z, RX, RY, RZ, HAT0X, HAT0Y */ |
| 163 |
.abs = { 0x3f, 0x00, 0x03 }, |
| 164 |
.keys = { |
| 165 |
/* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8, |
| 166 |
/* A, B, X, Y, TL, TR, TL2, TR2, SELECT, START, MODE, |
| 167 |
* THUMBL, THUMBR */ |
| 168 |
/* 0x100 */ ZEROx4, 0x00, 0x00, 0xdb, 0x7f, |
| 169 |
}, |
| 170 |
}, |
| 171 |
{ |
| 172 |
.name = "DualShock 4 - gamepad via Bluetooth", |
| 173 |
.bus_type = 0x0005, |
| 174 |
.vendor_id = 0x054c, |
| 175 |
.product_id = 0x09cc, |
| 176 |
.expected = SDL_UDEV_DEVICE_JOYSTICK, |
| 177 |
/* SYN, KEY, ABS */ |
| 178 |
.ev = { 0x0b }, |
| 179 |
/* X, Y, Z, RX, RY, RZ, HAT0X, HAT0Y */ |
| 180 |
.abs = { 0x3f, 0x00, 0x03 }, |
| 181 |
.keys = { |
| 182 |
/* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8, |
| 183 |
/* A, B, X, Y, TL, TR, TL2, TR2, SELECT, START, MODE, |
| 184 |
* THUMBL, THUMBR */ |
| 185 |
/* 0x100 */ ZEROx4, 0x00, 0x00, 0xdb, 0x7f, |
| 186 |
}, |
| 187 |
}, |
| 188 |
{ |
| 189 |
.name = "DualShock 4 - touchpad", |
| 190 |
.bus_type = 0x0003, |
| 191 |
.vendor_id = 0x054c, |
| 192 |
.product_id = 0x09cc, |
| 193 |
.expected = SDL_UDEV_DEVICE_TOUCHPAD, |
| 194 |
/* SYN, KEY, ABS */ |
| 195 |
.ev = { 0x0b }, |
| 196 |
/* X, Y, multitouch */ |
| 197 |
.abs = { 0x03, 0x00, 0x00, 0x00, 0x00, 0x80, 0x60, 0x02 }, |
| 198 |
.keys = { |
| 199 |
/* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8, |
| 200 |
/* Left mouse button */ |
| 201 |
/* 0x100 */ 0x00, 0x00, 0x01, 0x00, ZEROx4, |
| 202 |
/* BTN_TOOL_FINGER and some multitouch stuff */ |
| 203 |
/* 0x140 */ 0x20, 0x24, 0x00, 0x00 |
| 204 |
}, |
| 205 |
/* POINTER, BUTTONPAD */ |
| 206 |
.props = { 0x05 }, |
| 207 |
}, |
| 208 |
{ |
| 209 |
.name = "DualShock 4 - accelerometer", |
| 210 |
.bus_type = 0x0003, |
| 211 |
.vendor_id = 0x054c, |
| 212 |
.product_id = 0x09cc, |
| 213 |
.expected = SDL_UDEV_DEVICE_ACCELEROMETER, |
| 214 |
/* SYN, ABS, MSC */ |
| 215 |
.ev = { 0x19 }, |
| 216 |
/* X, Y, Z, RX, RY, RZ */ |
| 217 |
.abs = { 0x3f }, |
| 218 |
/* ACCELEROMETER */ |
| 219 |
.props = { 0x40 }, |
| 220 |
}, |
| 221 |
{ |
| 222 |
.name = "DualShock 4 via USB dongle", |
| 223 |
.bus_type = 0x0003, |
| 224 |
.vendor_id = 0x054c, |
| 225 |
.product_id = 0x0ba0, |
| 226 |
.version = 0x8111, |
| 227 |
.expected = SDL_UDEV_DEVICE_JOYSTICK, |
| 228 |
/* SYN, ABS, KEY */ |
| 229 |
.ev = { 0x0b }, |
| 230 |
/* X, Y, Z, RX, RY, RZ, HAT0X, HAT0Y */ |
| 231 |
.abs = { 0x3f, 0x00, 0x03 }, |
| 232 |
.keys = { |
| 233 |
/* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8, |
| 234 |
/* A, B, X, Y, TL, TR, TL2, TR2, SELECT, START, MODE, |
| 235 |
* THUMBL, THUMBR */ |
| 236 |
/* 0x100 */ ZEROx4, 0x00, 0x00, 0xdb, 0x7f, |
| 237 |
}, |
| 238 |
}, |
| 239 |
{ |
| 240 |
.name = "DualShock 3 - gamepad", |
| 241 |
.bus_type = 0x0003, |
| 242 |
.vendor_id = 0x054c, |
| 243 |
.product_id = 0x0268, |
| 244 |
.expected = SDL_UDEV_DEVICE_JOYSTICK, |
| 245 |
/* SYN, KEY, ABS, MSC, FF */ |
| 246 |
.ev = { 0x1b, 0x00, 0x20 }, |
| 247 |
/* X, Y, Z, RX, RY, RZ */ |
| 248 |
.abs = { 0x3f }, |
| 249 |
.keys = { |
| 250 |
/* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8, |
| 251 |
/* A, B, X, Y, TL, TR, TL2, TR2, SELECT, START, MODE, |
| 252 |
* THUMBL, THUMBR */ |
| 253 |
/* 0x100 */ ZEROx4, 0x00, 0x00, 0xdb, 0x7f, |
| 254 |
/* 0x140 */ ZEROx8, |
| 255 |
/* 0x180 */ ZEROx8, |
| 256 |
/* 0x1c0 */ ZEROx8, |
| 257 |
/* Digital dpad */ |
| 258 |
/* 0x200 */ ZEROx4, 0x0f, 0x00, 0x00, 0x00, |
| 259 |
}, |
| 260 |
}, |
| 261 |
{ |
| 262 |
.name = "DualShock 3 - accelerometer", |
| 263 |
.bus_type = 0x0003, |
| 264 |
.vendor_id = 0x054c, |
| 265 |
.product_id = 0x0268, |
| 266 |
.expected = SDL_UDEV_DEVICE_ACCELEROMETER, |
| 267 |
/* SYN, ABS */ |
| 268 |
.ev = { 0x09 }, |
| 269 |
/* X, Y, Z */ |
| 270 |
.abs = { 0x07 }, |
| 271 |
/* ACCELEROMETER */ |
| 272 |
.props = { 0x40 }, |
| 273 |
}, |
| 274 |
{ |
| 275 |
.name = "Steam Controller - gamepad", |
| 276 |
.bus_type = 0x0003, |
| 277 |
.vendor_id = 0x28de, |
| 278 |
.product_id = 0x1142, |
| 279 |
.expected = SDL_UDEV_DEVICE_JOYSTICK, |
| 280 |
/* SYN, KEY, ABS */ |
| 281 |
.ev = { 0x0b }, |
| 282 |
/* X, Y, RX, RY, HAT0X, HAT0Y, HAT2X, HAT2Y */ |
| 283 |
.abs = { 0x1b, 0x00, 0x33 }, |
| 284 |
.keys = { |
| 285 |
/* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8, |
| 286 |
/* A, B, X, Y, TL, TR, TL2, TR2, SELECT, START, MODE, |
| 287 |
* THUMBL, THUMBR, joystick THUMB, joystick THUMB2 */ |
| 288 |
/* 0x100 */ ZEROx4, 0x06, 0x00, 0xdb, 0x7f, |
| 289 |
/* GEAR_DOWN, GEAR_UP */ |
| 290 |
/* 0x140 */ 0x00, 0x00, 0x03, 0x00, ZEROx4, |
| 291 |
/* 0x180 */ ZEROx8, |
| 292 |
/* 0x1c0 */ ZEROx8, |
| 293 |
/* Digital dpad */ |
| 294 |
/* 0x200 */ ZEROx4, 0x0f, 0x00, 0x00, 0x00, |
| 295 |
}, |
| 296 |
}, |
| 297 |
{ |
| 298 |
/* Present to support lizard mode, even if no Steam Controller |
| 299 |
* is connected */ |
| 300 |
.name = "Steam Controller - dongle", |
| 301 |
.bus_type = 0x0003, |
| 302 |
.vendor_id = 0x28de, |
| 303 |
.product_id = 0x1142, |
| 304 |
.expected = (SDL_UDEV_DEVICE_KEYBOARD |
| 305 |
| SDL_UDEV_DEVICE_MOUSE), |
| 306 |
/* SYN, KEY, REL, MSC, LED, REP */ |
| 307 |
.ev = { 0x17, 0x00, 0x12 }, |
| 308 |
/* X, Y, mouse wheel, high-res mouse wheel */ |
| 309 |
.rel = { 0x03, 0x09 }, |
| 310 |
.keys = { |
| 311 |
/* 0x00 */ 0xfe, 0xff, 0xff, 0xff, FFx4, |
| 312 |
/* 0x40 */ 0xff, 0xff, 0xcf, 0x01, 0xdf, 0xff, 0x80, 0xe0, |
| 313 |
/* 0x80 */ ZEROx8, |
| 314 |
/* 0xc0 */ ZEROx8, |
| 315 |
/* 0x100 */ 0x00, 0x00, 0x1f, 0x00, ZEROx4, |
| 316 |
}, |
| 317 |
}, |
| 318 |
{ |
| 319 |
.name = "Guitar Hero for PS3", |
| 320 |
.bus_type = 0x0003, |
| 321 |
.vendor_id = 0x12ba, |
| 322 |
.product_id = 0x0100, |
| 323 |
.version = 0x0110, |
| 324 |
.expected = SDL_UDEV_DEVICE_JOYSTICK, |
| 325 |
/* SYN, KEY, ABS */ |
| 326 |
.ev = { 0x0b }, |
| 327 |
/* X, Y, Z, RZ, HAT0X, HAT0Y */ |
| 328 |
.abs = { 0x27, 0x00, 0x03 }, |
| 329 |
.keys = { |
| 330 |
/* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8, |
| 331 |
/* ABC, XYZ, TL, TR, TL2, TR2, SELECT, START, MODE */ |
| 332 |
/* 0x100 */ ZEROx4, 0x00, 0x00, 0xff, 0x1f, |
| 333 |
}, |
| 334 |
}, |
| 335 |
{ |
| 336 |
.name = "G27 Racing Wheel, 0003:046d:c29b v0111", |
| 337 |
.bus_type = 0x0003, |
| 338 |
.vendor_id = 0x046d, |
| 339 |
.product_id = 0xc29b, |
| 340 |
.version = 0x0111, |
| 341 |
.expected = SDL_UDEV_DEVICE_JOYSTICK, |
| 342 |
/* SYN, KEY, ABS */ |
| 343 |
.ev = { 0x0b }, |
| 344 |
/* X, Y, Z, RZ, HAT0X, HAT0Y */ |
| 345 |
.abs = { 0x27, 0x00, 0x03 }, |
| 346 |
.keys = { |
| 347 |
/* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8, |
| 348 |
/* 16 buttons: TRIGGER, THUMB, THUMB2, TOP, TOP2, PINKIE, BASE, |
| 349 |
* BASE2..BASE6, unregistered event codes 0x12c-0x12e, DEAD */ |
| 350 |
/* 0x100 */ ZEROx4, 0xff, 0xff, 0x00, 0x00, |
| 351 |
/* 0x140 */ ZEROx8, |
| 352 |
/* 0x180 */ ZEROx8, |
| 353 |
/* 0x1c0 */ ZEROx8, |
| 354 |
/* 0x200 */ ZEROx8, |
| 355 |
/* 0x240 */ ZEROx8, |
| 356 |
/* 0x280 */ ZEROx8, |
| 357 |
/* TRIGGER_HAPPY1..TRIGGER_HAPPY7 */ |
| 358 |
/* 0x2c0 */ 0x7f, |
| 359 |
}, |
| 360 |
}, |
| 361 |
{ |
| 362 |
.name = "Logitech Driving Force, 0003:046d:c294 v0100", |
| 363 |
.bus_type = 0x0003, |
| 364 |
.vendor_id = 0x046d, |
| 365 |
.product_id = 0xc294, |
| 366 |
.version = 0x0100, |
| 367 |
.expected = SDL_UDEV_DEVICE_JOYSTICK, |
| 368 |
/* SYN, KEY, ABS */ |
| 369 |
.ev = { 0x0b }, |
| 370 |
/* X, Y, RZ, HAT0X, HAT0Y */ |
| 371 |
.abs = { 0x23, 0x00, 0x03 }, |
| 372 |
.keys = { |
| 373 |
/* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8, |
| 374 |
/* 12 buttons: TRIGGER, THUMB, THUMB2, TOP, TOP2, PINKIE, BASE, |
| 375 |
* BASE2..BASE6 */ |
| 376 |
/* 0x100 */ ZEROx4, 0xff, 0x0f, 0x00, 0x00, |
| 377 |
}, |
| 378 |
}, |
| 379 |
{ |
| 380 |
.name = "Logitech Dual Action", |
| 381 |
.bus_type = 0x0003, |
| 382 |
.vendor_id = 0x046d, |
| 383 |
.product_id = 0xc216, |
| 384 |
.version = 0x0110, |
| 385 |
/* Logitech RumblePad 2 USB, 0003:046d:c218 v0110, is the same |
| 386 |
* except for having force feedback, which we don't use in our |
| 387 |
* heuristic */ |
| 388 |
/* Jess Tech GGE909 PC Recoil Pad, 0003:0f30:010b v0110, is the same */ |
| 389 |
/* 8BitDo SNES30, 0003:2dc8:ab20 v0110, is the same */ |
| 390 |
.expected = SDL_UDEV_DEVICE_JOYSTICK, |
| 391 |
/* SYN, KEY, ABS */ |
| 392 |
.ev = { 0x0b }, |
| 393 |
/* X, Y, Z, RZ, HAT0X, HAT0Y */ |
| 394 |
.abs = { 0x27, 0x00, 0x03 }, |
| 395 |
.keys = { |
| 396 |
/* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8, |
| 397 |
/* 12 buttons: TRIGGER, THUMB, THUMB2, TOP, TOP2, PINKIE, BASE, |
| 398 |
* BASE2..BASE6 */ |
| 399 |
/* 0x100 */ ZEROx4, 0xff, 0x0f, 0x00, 0x00, |
| 400 |
}, |
| 401 |
}, |
| 402 |
{ |
| 403 |
.name = "Saitek ST290 Pro flight stick", |
| 404 |
.bus_type = 0x0003, |
| 405 |
.vendor_id = 0x06a3, |
| 406 |
.product_id = 0x0160, /* 0x0460 seems to be the same */ |
| 407 |
.version = 0x0100, |
| 408 |
.expected = SDL_UDEV_DEVICE_JOYSTICK, |
| 409 |
/* SYN, KEY, ABS, MSC */ |
| 410 |
.ev = { 0x1b }, |
| 411 |
/* X, Y, Z, RZ, HAT0X, HAT0Y */ |
| 412 |
.abs = { 0x27, 0x00, 0x03 }, |
| 413 |
.keys = { |
| 414 |
/* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8, |
| 415 |
/* TRIGGER, THUMB, THUMB2, TOP, TOP2, PINKIE */ |
| 416 |
/* 0x100 */ ZEROx4, 0x3f, 0x00, 0x00, 0x00, |
| 417 |
}, |
| 418 |
}, |
| 419 |
{ |
| 420 |
.name = "Saitek X52 Pro Flight Control System", |
| 421 |
.bus_type = 0x0003, |
| 422 |
.vendor_id = 0x06a3, |
| 423 |
.product_id = 0x0762, |
| 424 |
.version = 0x0111, |
| 425 |
.expected = SDL_UDEV_DEVICE_JOYSTICK, |
| 426 |
.ev = { 0x0b }, |
| 427 |
/* XYZ, RXYZ, throttle, hat0, MISC, unregistered event code 0x29 */ |
| 428 |
.abs = { 0x7f, 0x00, 0x03, 0x00, 0x00, 0x03 }, |
| 429 |
.keys = { |
| 430 |
/* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8, |
| 431 |
/* 16 buttons: TRIGGER, THUMB, THUMB2, TOP, TOP2, PINKIE, BASE, |
| 432 |
* BASE2..BASE6, unregistered event codes 0x12c-0x12e, DEAD */ |
| 433 |
/* 0x100 */ ZEROx4, 0xff, 0xff, 0x00, 0x00, |
| 434 |
/* 0x140 */ ZEROx8, |
| 435 |
/* 0x180 */ ZEROx8, |
| 436 |
/* 0x1c0 */ ZEROx8, |
| 437 |
/* 0x200 */ ZEROx8, |
| 438 |
/* 0x240 */ ZEROx8, |
| 439 |
/* 0x280 */ ZEROx8, |
| 440 |
/* TRIGGER_HAPPY1..TRIGGER_HAPPY23 */ |
| 441 |
/* 0x2c0 */ 0xff, 0xff, 0x7f, |
| 442 |
}, |
| 443 |
}, |
| 444 |
{ |
| 445 |
.name = "Logitech Extreme 3D", |
| 446 |
.bus_type = 0x0003, |
| 447 |
.vendor_id = 0x046d, |
| 448 |
.product_id = 0xc215, |
| 449 |
.version = 0x0110, |
| 450 |
.expected = SDL_UDEV_DEVICE_JOYSTICK, |
| 451 |
/* SYN, KEY, ABS, MSC */ |
| 452 |
.ev = { 0x0b }, |
| 453 |
/* X, Y, RZ, throttle, hat 0 */ |
| 454 |
.abs = { 0x63, 0x00, 0x03 }, |
| 455 |
.keys = { |
| 456 |
/* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8, |
| 457 |
/* 12 buttons: TRIGGER, THUMB, THUMB2, TOP, TOP2, PINKIE, BASE, |
| 458 |
* BASE2..BASE6 */ |
| 459 |
/* 0x100 */ ZEROx4, 0xff, 0x0f, 0x00, 0x00, |
| 460 |
}, |
| 461 |
}, |
| 462 |
{ |
| 463 |
.name = "Hori Real Arcade Pro VX-SA", |
| 464 |
.bus_type = 0x0003, |
| 465 |
.vendor_id = 0x24c6, |
| 466 |
.product_id = 0x5501, |
| 467 |
.version = 0x0533, |
| 468 |
.expected = SDL_UDEV_DEVICE_JOYSTICK, |
| 469 |
/* SYN, KEY, ABS */ |
| 470 |
.ev = { 0x0b }, |
| 471 |
/* X, Y, Z, RX, RY, RZ, hat 0 */ |
| 472 |
.abs = { 0x3f, 0x00, 0x03 }, |
| 473 |
.keys = { |
| 474 |
/* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8, |
| 475 |
/* A, B, X, Y, TL, TR, SELECT, START, MODE, THUMBL, THUMBR */ |
| 476 |
/* 0x100 */ ZEROx4, 0x00, 0x00, 0xdb, 0x7c, |
| 477 |
}, |
| 478 |
}, |
| 479 |
{ |
| 480 |
.name = "Switch Pro Controller via Bluetooth", |
| 481 |
.bus_type = 0x0005, |
| 482 |
.vendor_id = 0x057e, |
| 483 |
.product_id = 0x2009, |
| 484 |
.version = 0x0001, |
| 485 |
.expected = SDL_UDEV_DEVICE_JOYSTICK, |
| 486 |
/* SYN, KEY, ABS */ |
| 487 |
.ev = { 0x0b }, |
| 488 |
/* X, Y, RX, RY, hat 0 */ |
| 489 |
.abs = { 0x1b, 0x00, 0x03 }, |
| 490 |
.keys = { |
| 491 |
/* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8, |
| 492 |
/* 16 buttons: TRIGGER, THUMB, THUMB2, TOP, TOP2, PINKIE, BASE, |
| 493 |
* BASE2..BASE6, unregistered event codes 0x12c-0x12e, DEAD */ |
| 494 |
/* 0x100 */ ZEROx4, 0xff, 0xff, 0x00, 0x00, |
| 495 |
/* 0x140 */ ZEROx8, |
| 496 |
/* 0x180 */ ZEROx8, |
| 497 |
/* 0x1c0 */ ZEROx8, |
| 498 |
/* 0x200 */ ZEROx8, |
| 499 |
/* 0x240 */ ZEROx8, |
| 500 |
/* 0x280 */ ZEROx8, |
| 501 |
/* TRIGGER_HAPPY1..TRIGGER_HAPPY2 */ |
| 502 |
/* 0x2c0 */ 0x03, |
| 503 |
}, |
| 504 |
}, |
| 505 |
{ |
| 506 |
.name = "Switch Pro Controller via USB", |
| 507 |
.bus_type = 0x0003, |
| 508 |
.vendor_id = 0x057e, |
| 509 |
.product_id = 0x2009, |
| 510 |
.version = 0x0111, |
| 511 |
.expected = SDL_UDEV_DEVICE_JOYSTICK, |
| 512 |
/* SYN, KEY, ABS */ |
| 513 |
.ev = { 0x0b }, |
| 514 |
/* X, Y, Z, RZ, HAT0X, HAT0Y */ |
| 515 |
.abs = { 0x27, 0x00, 0x03 }, |
| 516 |
.keys = { |
| 517 |
/* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8, |
| 518 |
}, |
| 519 |
}, |
| 520 |
{ |
| 521 |
.name = "Thrustmaster Racing Wheel FFB", |
| 522 |
/* Mad Catz FightStick TE S+ PS4, 0003:0738:8384:0111 v0111 |
| 523 |
* (aka Street Fighter V Arcade FightStick TES+) |
| 524 |
* is functionally the same */ |
| 525 |
.bus_type = 0x0003, |
| 526 |
.vendor_id = 0x044f, |
| 527 |
.product_id = 0xb66d, |
| 528 |
.version = 0x0110, |
| 529 |
.expected = SDL_UDEV_DEVICE_JOYSTICK, |
| 530 |
.ev = { 0x0b }, |
| 531 |
/* XYZ, RXYZ, hat 0 */ |
| 532 |
.abs = { 0x3f, 0x00, 0x03 }, |
| 533 |
.keys = { |
| 534 |
/* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8, |
| 535 |
/* ABC, XYZ, TL, TR, TL2, TR2, SELECT, START, MODE, |
| 536 |
* THUMBL */ |
| 537 |
/* 0x100 */ ZEROx4, 0x00, 0x00, 0xff, 0x3f, |
| 538 |
}, |
| 539 |
}, |
| 540 |
{ |
| 541 |
.name = "Thrustmaster T.Flight Hotas X", |
| 542 |
.bus_type = 0x0003, |
| 543 |
.vendor_id = 0x044f, |
| 544 |
.product_id = 0xb108, |
| 545 |
.version = 0x0100, |
| 546 |
.expected = SDL_UDEV_DEVICE_JOYSTICK, |
| 547 |
.ev = { 0x0b }, |
| 548 |
/* XYZ, RZ, throttle, hat 0 */ |
| 549 |
.abs = { 0x67, 0x00, 0x03 }, |
| 550 |
.keys = { |
| 551 |
/* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8, |
| 552 |
/* trigger, thumb, thumb2, top, top2, pinkie, base, |
| 553 |
* base2..base6 */ |
| 554 |
/* 0x100 */ ZEROx4, 0xff, 0x0f |
| 555 |
}, |
| 556 |
}, |
| 557 |
{ |
| 558 |
.name = "8BitDo N30 Pro 2", |
| 559 |
.bus_type = 0x0003, |
| 560 |
.vendor_id = 0x2dc8, |
| 561 |
.product_id = 0x9015, |
| 562 |
.version = 0x0111, |
| 563 |
/* 8BitDo NES30 Pro, 0003:2dc8:9001 v0111, is the same */ |
| 564 |
.expected = SDL_UDEV_DEVICE_JOYSTICK, |
| 565 |
.ev = { 0x0b }, |
| 566 |
/* XYZ, RZ, gas, brake, hat0 */ |
| 567 |
.abs = { 0x27, 0x06, 0x03 }, |
| 568 |
.keys = { |
| 569 |
/* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8, |
| 570 |
/* ABC, XYZ, TL, TR, TL2, TR2, select, start, mode, thumbl, |
| 571 |
* thumbr */ |
| 572 |
/* 0x100 */ ZEROx4, 0x00, 0x00, 0xff, 0x7f, |
| 573 |
}, |
| 574 |
}, |
| 575 |
{ |
| 576 |
.name = "Retro Power SNES-style controller, 0003:0079:0011 v0110", |
| 577 |
.bus_type = 0x0003, |
| 578 |
.vendor_id = 0x0079, |
| 579 |
.product_id = 0x0011, |
| 580 |
.version = 0x0110, |
| 581 |
.expected = SDL_UDEV_DEVICE_JOYSTICK, |
| 582 |
.ev = { 0x0b }, |
| 583 |
/* X, Y */ |
| 584 |
.abs = { 0x03 }, |
| 585 |
.keys = { |
| 586 |
/* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8, |
| 587 |
/* trigger, thumb, thumb2, top, top2, pinkie, base, |
| 588 |
* base2..base4 */ |
| 589 |
/* 0x100 */ ZEROx4, 0xff, 0x03, 0x00, 0x00, |
| 590 |
}, |
| 591 |
}, |
| 592 |
{ |
| 593 |
.name = "Wiimote - buttons", |
| 594 |
.bus_type = 0x0005, |
| 595 |
.vendor_id = 0x057e, |
| 596 |
.product_id = 0x0306, |
| 597 |
.version = 0x8600, |
| 598 |
/* This one is a bit weird because some of the buttons are mapped |
| 599 |
* to the arrow, page up and page down keys, so it's a joystick |
| 600 |
* with a subset of a keyboard attached. */ |
| 601 |
/* TODO: Should this be JOYSTICK, or even JOYSTICK|KEYBOARD? */ |
| 602 |
.expected = SDL_UDEV_DEVICE_KEYBOARD, |
| 603 |
/* SYN, KEY */ |
| 604 |
.ev = { 0x03 }, |
| 605 |
.keys = { |
| 606 |
/* 0x00 */ ZEROx8, |
| 607 |
/* left, right, up down */ |
| 608 |
/* 0x40 */ ZEROx4, 0x80, 0x16, 0x00, 0x00, |
| 609 |
/* 0x80 */ ZEROx8, |
| 610 |
/* 0xc0 */ ZEROx8, |
| 611 |
/* BTN_1, BTN_2, BTN_A, BTN_B, BTN_MODE */ |
| 612 |
/* 0x100 */ 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x10, |
| 613 |
/* 0x140 */ ZEROx8, |
| 614 |
/* next (keyboard page down), previous (keyboard page up) */ |
| 615 |
/* 0x180 */ 0x00, 0x00, 0x80, 0x10, ZEROx4, |
| 616 |
}, |
| 617 |
}, |
| 618 |
{ |
| 619 |
.name = "Wiimote - Motion Plus or accelerometer", |
| 620 |
.bus_type = 0x0005, |
| 621 |
.vendor_id = 0x057e, |
| 622 |
.product_id = 0x0306, |
| 623 |
.version = 0x8600, |
| 624 |
.expected = SDL_UDEV_DEVICE_ACCELEROMETER, |
| 625 |
/* SYN, ABS */ |
| 626 |
.ev = { 0x09 }, |
| 627 |
/* RX, RY, RZ */ |
| 628 |
.abs = { 0x38 }, |
| 629 |
}, |
| 630 |
{ |
| 631 |
.name = "Wiimote - IR positioning", |
| 632 |
.bus_type = 0x0005, |
| 633 |
.vendor_id = 0x057e, |
| 634 |
.product_id = 0x0306, |
| 635 |
.version = 0x8600, |
| 636 |
.expected = SDL_UDEV_DEVICE_UNKNOWN, |
| 637 |
/* SYN, ABS */ |
| 638 |
.ev = { 0x09 }, |
| 639 |
/* HAT0 to HAT3 */ |
| 640 |
.abs = { 0x00, 0x1f }, |
| 641 |
}, |
| 642 |
{ |
| 643 |
.name = "Wiimote - Nunchuck", |
| 644 |
.bus_type = 0x0005, |
| 645 |
.vendor_id = 0x057e, |
| 646 |
.product_id = 0x0306, |
| 647 |
.version = 0x8600, |
| 648 |
/* TODO: Should this be JOYSTICK? It has one stick and two buttons */ |
| 649 |
.expected = SDL_UDEV_DEVICE_UNKNOWN, |
| 650 |
/* SYN, KEY, ABS */ |
| 651 |
.ev = { 0x0b }, |
| 652 |
/* RX, RY, RZ, hat 0 */ |
| 653 |
.abs = { 0x38, 0x00, 0x03 }, |
| 654 |
.keys = { |
| 655 |
/* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8, |
| 656 |
/* C and Z buttons */ |
| 657 |
/* 0x100 */ ZEROx4, 0x00, 0x00, 0x24, 0x00, |
| 658 |
}, |
| 659 |
}, |
| 660 |
{ |
| 661 |
/* Flags guessed from kernel source code */ |
| 662 |
.name = "Wiimote - Classic Controller", |
| 663 |
/* TODO: Should this be JOYSTICK, or maybe JOYSTICK|KEYBOARD? |
| 664 |
* It's unusual in the same ways as the Wiimote */ |
| 665 |
.expected = SDL_UDEV_DEVICE_KEYBOARD, |
| 666 |
/* SYN, KEY, ABS */ |
| 667 |
.ev = { 0x0b }, |
| 668 |
/* Hat 1-3 */ |
| 669 |
.abs = { 0x00, 0x1c }, |
| 670 |
.keys = { |
| 671 |
/* 0x00 */ ZEROx8, |
| 672 |
/* left, right, up down */ |
| 673 |
/* 0x40 */ ZEROx4, 0x80, 0x16, 0x00, 0x00, |
| 674 |
/* 0x80 */ ZEROx8, |
| 675 |
/* 0xc0 */ ZEROx8, |
| 676 |
/* A, B, X, Y, MODE, TL, TL2, TR, TR2 */ |
| 677 |
/* 0x100 */ ZEROx4, 0x00, 0x13, 0xdb, 0x10, |
| 678 |
/* 0x140 */ ZEROx8, |
| 679 |
/* next (keyboard page down), previous (keyboard page up) */ |
| 680 |
/* 0x180 */ 0x00, 0x00, 0x80, 0x10, ZEROx4, |
| 681 |
}, |
| 682 |
}, |
| 683 |
{ |
| 684 |
/* Flags guessed from kernel source code */ |
| 685 |
.name = "Wiimote - Balance Board", |
| 686 |
/* TODO: Should this be JOYSTICK? */ |
| 687 |
.expected = SDL_UDEV_DEVICE_UNKNOWN, |
| 688 |
/* SYN, KEY, ABS */ |
| 689 |
.ev = { 0x0b }, |
| 690 |
/* Hat 0-1 */ |
| 691 |
.abs = { 0x00, 0x0f }, |
| 692 |
.keys = { |
| 693 |
/* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8, |
| 694 |
/* A */ |
| 695 |
/* 0x100 */ ZEROx4, 0x00, 0x00, 0x01, 0x00, |
| 696 |
}, |
| 697 |
}, |
| 698 |
{ |
| 699 |
/* Flags guessed from kernel source code */ |
| 700 |
.name = "Wiimote - Wii U Pro Controller", |
| 701 |
.expected = SDL_UDEV_DEVICE_JOYSTICK, |
| 702 |
/* SYN, KEY, ABS */ |
| 703 |
.ev = { 0x0b }, |
| 704 |
/* X, Y, RX, RY */ |
| 705 |
.abs = { 0x1b }, |
| 706 |
.keys = { |
| 707 |
/* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8, |
| 708 |
/* A, B, X, Y, TL, TR, TL2, TR2, SELECT, START, MODE, |
| 709 |
* THUMBL, THUMBR */ |
| 710 |
/* 0x100 */ ZEROx4, 0x00, 0x00, 0xdb, 0x7f, |
| 711 |
/* 0x140 */ ZEROx8, |
| 712 |
/* 0x180 */ ZEROx8, |
| 713 |
/* 0x1c0 */ ZEROx8, |
| 714 |
/* Digital dpad */ |
| 715 |
/* 0x200 */ ZEROx4, 0x0f, 0x00, 0x00, 0x00, |
| 716 |
}, |
| 717 |
}, |
| 718 |
{ |
| 719 |
.name = "Synaptics TM3381-002 (Thinkpad X280 trackpad)", |
| 720 |
.bus_type = 0x001d, /* BUS_RMI */ |
| 721 |
.vendor_id = 0x06cb, |
| 722 |
.product_id = 0x0000, |
| 723 |
.version = 0x0000, |
| 724 |
.expected = SDL_UDEV_DEVICE_TOUCHPAD, |
| 725 |
/* SYN, KEY, ABS */ |
| 726 |
.ev = { 0x0b }, |
| 727 |
/* X, Y, pressure, multitouch */ |
| 728 |
.abs = { 0x03, 0x00, 0x00, 0x01, 0x00, 0x80, 0xf3, 0x06 }, |
| 729 |
.keys = { |
| 730 |
/* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8, |
| 731 |
/* Left mouse button */ |
| 732 |
/* 0x100 */ 0x00, 0x00, 0x01, 0x00, ZEROx4, |
| 733 |
/* BTN_TOOL_FINGER and some multitouch gestures */ |
| 734 |
/* 0x140 */ 0x20, 0xe5 |
| 735 |
}, |
| 736 |
/* POINTER, BUTTONPAD */ |
| 737 |
.props = { 0x05 }, |
| 738 |
}, |
| 739 |
{ |
| 740 |
.name = "TPPS/2 Elan TrackPoint (Thinkpad X280)", |
| 741 |
.bus_type = 0x0011, /* BUS_I8042 */ |
| 742 |
.vendor_id = 0x0002, |
| 743 |
.product_id = 0x000a, |
| 744 |
.version = 0x0000, |
| 745 |
.expected = SDL_UDEV_DEVICE_MOUSE, |
| 746 |
/* SYN, KEY, REL */ |
| 747 |
.ev = { 0x07 }, |
| 748 |
/* X, Y */ |
| 749 |
.rel = { 0x03 }, |
| 750 |
.keys = { |
| 751 |
/* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8, |
| 752 |
/* Left, middle, right mouse buttons */ |
| 753 |
/* 0x100 */ 0x00, 0x00, 0x07, |
| 754 |
}, |
| 755 |
/* POINTER, POINTING_STICK */ |
| 756 |
.props = { 0x21 }, |
| 757 |
}, |
| 758 |
{ |
| 759 |
.name = "Thinkpad ACPI buttons", |
| 760 |
/* SDL treats this as a keyboard because it has a power button */ |
| 761 |
.expected = SDL_UDEV_DEVICE_KEYBOARD, |
| 762 |
/* SYN, KEY, MSC, SW */ |
| 763 |
.ev = { 0x33 }, |
| 764 |
.keys = { |
| 765 |
/* 0x00 */ ZEROx8, |
| 766 |
/* 0x40 */ ZEROx4, 0x00, 0x00, 0x0e, 0x01, |
| 767 |
/* 0x80 */ 0x00, 0x50, 0x11, 0x51, 0x00, 0x28, 0x00, 0xc0, |
| 768 |
/* 0xc0 */ 0x04, 0x20, 0x10, 0x02, 0x1b, 0x70, 0x01, 0x00, |
| 769 |
/* 0x100 */ ZEROx8, |
| 770 |
/* 0x140 */ ZEROx4, 0x00, 0x00, 0x50, 0x00, |
| 771 |
/* 0x180 */ ZEROx8, |
| 772 |
/* 0x1c0 */ 0x00, 0x00, 0x04, 0x18, ZEROx4, |
| 773 |
/* 0x200 */ ZEROx8, |
| 774 |
/* 0x240 */ 0x40, 0x00, 0x01, 0x00, ZEROx4, |
| 775 |
}, |
| 776 |
}, |
| 777 |
{ |
| 778 |
.name = "PC speaker", |
| 779 |
.bus_type = 0x0010, /* BUS_ISA */ |
| 780 |
.vendor_id = 0x001f, |
| 781 |
.product_id = 0x0001, |
| 782 |
.version = 0x0100, |
| 783 |
.expected = SDL_UDEV_DEVICE_UNKNOWN, |
| 784 |
/* SYN, SND */ |
| 785 |
.ev = { 0x01, 0x00, 0x04 }, |
| 786 |
}, |
| 787 |
{ |
| 788 |
.name = "ALSA headphone detection, etc.", |
| 789 |
.bus_type = 0x0000, |
| 790 |
.vendor_id = 0x0000, |
| 791 |
.product_id = 0x0000, |
| 792 |
.version = 0x0000, |
| 793 |
.expected = SDL_UDEV_DEVICE_UNKNOWN, |
| 794 |
/* SYN, SW */ |
| 795 |
.ev = { 0x21 }, |
| 796 |
}, |
| 797 |
{ |
| 798 |
/* Assumed to be a reasonably typical i8042 (PC AT) keyboard */ |
| 799 |
.name = "Thinkpad T520 and X280 keyboards", |
| 800 |
.bus_type = 0x0011, /* BUS_I8042 */ |
| 801 |
.vendor_id = 0x0001, |
| 802 |
.product_id = 0x0001, |
| 803 |
.version = 0xab54, |
| 804 |
.expected = SDL_UDEV_DEVICE_KEYBOARD, |
| 805 |
/* SYN, KEY, MSC, LED, REP */ |
| 806 |
.ev = { 0x13, 0x00, 0x12 }, |
| 807 |
.keys = { |
| 808 |
/* 0x00 */ 0xfe, 0xff, 0xff, 0xff, FFx4, |
| 809 |
/* 0x40 */ 0xff, 0xff, 0xef, 0xff, 0xdf, 0xff, 0xff, 0xfe, |
| 810 |
/* 0x80 */ 0x01, 0xd0, 0x00, 0xf8, 0x78, 0x30, 0x80, 0x03, |
| 811 |
/* 0xc0 */ 0x00, 0x00, 0x00, 0x02, 0x04, 0x00, 0x00, 0x00, |
| 812 |
}, |
| 813 |
}, |
| 814 |
{ |
| 815 |
.name = "Thinkpad X280 sleep button", |
| 816 |
.bus_type = 0x0019, /* BUS_HOST */ |
| 817 |
.vendor_id = 0x0000, |
| 818 |
.product_id = 0x0003, |
| 819 |
.version = 0x0000, |
| 820 |
/* SDL treats KEY_SLEEP as indicating a keyboard */ |
| 821 |
.expected = SDL_UDEV_DEVICE_KEYBOARD, |
| 822 |
/* SYN, KEY */ |
| 823 |
.ev = { 0x03 }, |
| 824 |
.keys = { |
| 825 |
/* 0x00 */ ZEROx8, |
| 826 |
/* 0x40 */ ZEROx8, |
| 827 |
/* KEY_SLEEP */ |
| 828 |
/* 0x80 */ 0x00, 0x40, |
| 829 |
}, |
| 830 |
}, |
| 831 |
{ |
| 832 |
.name = "Thinkpad X280 lid switch", |
| 833 |
.bus_type = 0x0019, /* BUS_HOST */ |
| 834 |
.vendor_id = 0x0000, |
| 835 |
.product_id = 0x0005, |
| 836 |
.version = 0x0000, |
| 837 |
.expected = SDL_UDEV_DEVICE_UNKNOWN, |
| 838 |
/* SYN, SW */ |
| 839 |
.ev = { 0x21 }, |
| 840 |
}, |
| 841 |
{ |
| 842 |
.name = "Thinkpad X280 power button", |
| 843 |
.bus_type = 0x0019, /* BUS_HOST */ |
| 844 |
.vendor_id = 0x0000, |
| 845 |
.product_id = 0x0001, |
| 846 |
.version = 0x0000, |
| 847 |
/* SDL treats KEY_POWER as indicating a keyboard */ |
| 848 |
.expected = SDL_UDEV_DEVICE_KEYBOARD, |
| 849 |
/* SYN, KEY */ |
| 850 |
.ev = { 0x03 }, |
| 851 |
.keys = { |
| 852 |
/* 0x00 */ ZEROx8, |
| 853 |
/* KEY_POWER */ |
| 854 |
/* 0x40 */ ZEROx4, 0x00, 0x00, 0x10, 0x00, |
| 855 |
}, |
| 856 |
}, |
| 857 |
{ |
| 858 |
.name = "Thinkpad X280 video bus", |
| 859 |
.bus_type = 0x0019, /* BUS_HOST */ |
| 860 |
.vendor_id = 0x0000, |
| 861 |
.product_id = 0x0006, |
| 862 |
.version = 0x0000, |
| 863 |
/* SDL treats brightness control, etc. as keyboard keys */ |
| 864 |
.expected = SDL_UDEV_DEVICE_KEYBOARD, |
| 865 |
/* SYN, KEY */ |
| 866 |
.ev = { 0x03 }, |
| 867 |
.keys = { |
| 868 |
/* 0x00 */ ZEROx8, |
| 869 |
/* 0x40 */ ZEROx8, |
| 870 |
/* 0x80 */ ZEROx8, |
| 871 |
/* brightness control, video mode, display off */ |
| 872 |
/* 0xc0 */ ZEROx4, 0x0b, 0x00, 0x3e, 0x00, |
| 873 |
}, |
| 874 |
}, |
| 875 |
{ |
| 876 |
.name = "Thinkpad X280 extra buttons", |
| 877 |
.bus_type = 0x0019, /* BUS_HOST */ |
| 878 |
.vendor_id = 0x17aa, |
| 879 |
.product_id = 0x5054, |
| 880 |
.version = 0x4101, |
| 881 |
.expected = SDL_UDEV_DEVICE_KEYBOARD, |
| 882 |
/* SYN, KEY */ |
| 883 |
.ev = { 0x03 }, |
| 884 |
.keys = { |
| 885 |
/* 0x00 */ ZEROx8, |
| 886 |
/* 0x40 */ ZEROx4, 0x00, 0x00, 0x0e, 0x01, |
| 887 |
/* 0x80 */ 0x00, 0x50, 0x11, 0x51, 0x00, 0x28, 0x00, 0xc0, |
| 888 |
/* 0xc0 */ 0x04, 0x20, 0x10, 0x02, 0x1b, 0x70, 0x01, 0x00, |
| 889 |
/* 0x100 */ ZEROx8, |
| 890 |
/* 0x140 */ ZEROx4, 0x00, 0x00, 0x50, 0x00, |
| 891 |
/* 0x180 */ ZEROx8, |
| 892 |
/* 0x1c0 */ 0x00, 0x00, 0x04, 0x18, ZEROx4, |
| 893 |
/* 0x200 */ ZEROx8, |
| 894 |
/* 0x240 */ 0x40, 0x00, 0x01, 0x00, ZEROx4, |
| 895 |
}, |
| 896 |
}, |
| 897 |
{ |
| 898 |
.name = "Thinkpad USB keyboard with Trackpoint - keyboard", |
| 899 |
.bus_type = 0x0003, |
| 900 |
.vendor_id = 0x17ef, |
| 901 |
.product_id = 0x6009, |
| 902 |
.expected = SDL_UDEV_DEVICE_KEYBOARD, |
| 903 |
/* SYN, KEY, MSC, LED, REP */ |
| 904 |
.ev = { 0x13, 0x00, 0x12 }, |
| 905 |
.keys = { |
| 906 |
/* 0x00 */ 0xfe, 0xff, 0xff, 0xff, FFx4, |
| 907 |
/* 0x40 */ 0xff, 0xff, 0xef, 0xff, 0xdf, 0xff, 0xbe, 0xfe, |
| 908 |
/* 0x80 */ 0xff, 0x57, 0x40, 0xc1, 0x7a, 0x20, 0x9f, 0xff, |
| 909 |
/* 0xc0 */ 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, |
| 910 |
}, |
| 911 |
}, |
| 912 |
{ |
| 913 |
.name = "Thinkpad USB keyboard with Trackpoint - Trackpoint", |
| 914 |
.bus_type = 0x0003, |
| 915 |
.vendor_id = 0x17ef, |
| 916 |
.product_id = 0x6009, |
| 917 |
/* For some reason the special keys like mute and wlan toggle |
| 918 |
* show up here instead of, or in addition to, as part of |
| 919 |
* the keyboard - so both udev and SDL report this as having keys too. */ |
| 920 |
.expected = SDL_UDEV_DEVICE_MOUSE | SDL_UDEV_DEVICE_KEYBOARD, |
| 921 |
/* SYN, KEY, REL, MSC, LED */ |
| 922 |
.ev = { 0x17, 0x00, 0x02 }, |
| 923 |
/* X, Y */ |
| 924 |
.rel = { 0x03 }, |
| 925 |
.keys = { |
| 926 |
/* 0x00 */ ZEROx8, |
| 927 |
/* 0x40 */ ZEROx4, 0x00, 0x00, 0x1e, 0x00, |
| 928 |
/* 0x80 */ 0x00, 0xcc, 0x11, 0x01, 0x78, 0x40, 0x00, 0xc0, |
| 929 |
/* 0xc0 */ 0x00, 0x20, 0x10, 0x00, 0x0b, 0x50, 0x00, 0x00, |
| 930 |
/* Mouse buttons: left, right, middle, "task" */ |
| 931 |
/* 0x100 */ 0x00, 0x00, 0x87, 0x68, ZEROx4, |
| 932 |
/* 0x140 */ ZEROx4, 0x00, 0x00, 0x10, 0x00, |
| 933 |
/* 0x180 */ ZEROx4, 0x00, 0x00, 0x40, 0x00, |
| 934 |
}, |
| 935 |
}, |
| 936 |
{ |
| 937 |
.name = "No information", |
| 938 |
.expected = SDL_UDEV_DEVICE_UNKNOWN, |
| 939 |
} |
| 940 |
}; |
| 941 |
/* *INDENT-ON* */ /* clang-format on */ |
| 942 |
|
| 943 |
/* The Linux kernel provides capability info in EVIOCGBIT and in /sys |
| 944 |
* as an array of unsigned long in native byte order, rather than an array |
| 945 |
* of bytes, an array of native-endian 32-bit words or an array of |
| 946 |
* native-endian 64-bit words like you might have reasonably expected. |
| 947 |
* The order of words in the array is always lowest-valued first: for |
| 948 |
* instance, the first unsigned long in abs[] contains the bit representing |
| 949 |
* absolute axis 0 (ABS_X). |
| 950 |
* |
| 951 |
* The constant arrays above provide test data in little-endian, because |
| 952 |
* that's the easiest representation for hard-coding into a test like this. |
| 953 |
* On a big-endian platform we need to byteswap it, one unsigned long at a |
| 954 |
* time, to match what the kernel would produce. This requires us to choose |
| 955 |
* an appropriate byteswapping function for the architecture's word size. */ |
| 956 |
SDL_COMPILE_TIME_ASSERT(sizeof_long, sizeof(unsigned long) == 4 || sizeof(unsigned long) == 8); |
| 957 |
#define SwapLongLE(X) \ |
| 958 |
((sizeof(unsigned long) == 4) ? SDL_SwapLE32(X) : SDL_SwapLE64(X)) |
| 959 |
|
| 960 |
static int |
| 961 |
run_test(void) |
| 962 |
{ |
| 963 |
int success = 1; |
| 964 |
size_t i; |
| 965 |
|
| 966 |
for (i = 0; i < SDL_arraysize(guess_tests); i++) { |
| 967 |
const GuessTest *t = &guess_tests[i]; |
| 968 |
size_t j; |
| 969 |
int actual; |
| 970 |
struct |
| 971 |
{ |
| 972 |
unsigned long ev[NBITS(EV_MAX)]; |
| 973 |
unsigned long abs[NBITS(ABS_MAX)]; |
| 974 |
unsigned long keys[NBITS(KEY_MAX)]; |
| 975 |
unsigned long rel[NBITS(REL_MAX)]; |
| 976 |
} caps = {}; |
| 977 |
|
| 978 |
printf("%s...\n", t->name); |
| 979 |
|
| 980 |
memset(&caps, '\0', sizeof(caps)); |
| 981 |
memcpy(caps.ev, t->ev, sizeof(t->ev)); |
| 982 |
memcpy(caps.keys, t->keys, sizeof(t->keys)); |
| 983 |
memcpy(caps.abs, t->abs, sizeof(t->abs)); |
| 984 |
memcpy(caps.rel, t->rel, sizeof(t->rel)); |
| 985 |
|
| 986 |
for (j = 0; j < SDL_arraysize(caps.ev); j++) { |
| 987 |
caps.ev[j] = SwapLongLE(caps.ev[j]); |
| 988 |
} |
| 989 |
|
| 990 |
for (j = 0; j < SDL_arraysize(caps.keys); j++) { |
| 991 |
caps.keys[j] = SwapLongLE(caps.keys[j]); |
| 992 |
} |
| 993 |
|
| 994 |
for (j = 0; j < SDL_arraysize(caps.abs); j++) { |
| 995 |
caps.abs[j] = SwapLongLE(caps.abs[j]); |
| 996 |
} |
| 997 |
|
| 998 |
for (j = 0; j < SDL_arraysize(caps.rel); j++) { |
| 999 |
caps.rel[j] = SwapLongLE(caps.rel[j]); |
| 1000 |
} |
| 1001 |
|
| 1002 |
actual = SDL_EVDEV_GuessDeviceClass(caps.ev, caps.abs, caps.keys, |
| 1003 |
caps.rel); |
| 1004 |
|
| 1005 |
if (actual == t->expected) { |
| 1006 |
printf("\tOK\n"); |
| 1007 |
} else { |
| 1008 |
printf("\tExpected 0x%08x\n", t->expected); |
| 1009 |
|
| 1010 |
for (j = 0; device_classes[j].code != 0; j++) { |
| 1011 |
if (t->expected & device_classes[j].code) { |
| 1012 |
printf("\t\t%s\n", device_classes[j].name); |
| 1013 |
} |
| 1014 |
} |
| 1015 |
|
| 1016 |
printf("\tGot 0x%08x\n", actual); |
| 1017 |
|
| 1018 |
for (j = 0; device_classes[j].code != 0; j++) { |
| 1019 |
if (actual & device_classes[j].code) { |
| 1020 |
printf("\t\t%s\n", device_classes[j].name); |
| 1021 |
} |
| 1022 |
} |
| 1023 |
|
| 1024 |
success = 0; |
| 1025 |
} |
| 1026 |
} |
| 1027 |
|
| 1028 |
return success; |
| 1029 |
} |
| 1030 |
|
| 1031 |
#else /* !(HAVE_LIBUDEV_H || defined(SDL_JOYSTICK_LINUX)) */ |
| 1032 |
|
| 1033 |
#include "SDL.h" |
| 1034 |
|
| 1035 |
static int |
| 1036 |
run_test(void) |
| 1037 |
{ |
| 1038 |
printf("SDL compiled without evdev capability check.\n"); |
| 1039 |
return 1; |
| 1040 |
} |
| 1041 |
|
| 1042 |
#endif |
| 1043 |
|
| 1044 |
int main(int argc, char *argv[]) |
| 1045 |
{ |
| 1046 |
return run_test() ? 0 : 1; |
| 1047 |
} |