testevdev: Add raw HID report descriptors where available

We don't currently use these in our device-classification heuristic,
but it could be a useful input in future.

Thanks to Sam Lantinga, Ben Fradella, kevenwyld and schlegp for
providing some of these.

Signed-off-by: Simon McVittie <smcv@collabora.com>
main
Simon McVittie 2023-06-15 19:46:35 +01:00 committed by Sam Lantinga
parent 2b7556fea2
commit 3772d6cc99
1 changed files with 192 additions and 0 deletions

View File

@ -72,6 +72,8 @@ typedef struct
uint8_t props[INPUT_PROP_MAX / 8];
int expected;
const char *todo;
size_t hid_report_descriptor_length;
const unsigned char *hid_report_descriptor;
} GuessTest;
/*
@ -89,6 +91,184 @@ typedef struct
#define FFx4 0xff, 0xff, 0xff, 0xff
#define FFx8 FFx4, FFx4
static unsigned char xbox_one_elite_2_hid_report_descriptor[] =
{
/* Generic Desktop / Game Pad, Generic Desktop / Keyboard */
0x05, 0x01, 0x09, 0x05, 0xa1, 0x01, 0x85, 0x01,
0x09, 0x01, 0xa1, 0x00, 0x09, 0x30, 0x09, 0x31,
0x15, 0x00, 0x27, 0xff, 0xff, 0x00, 0x00, 0x95,
0x02, 0x75, 0x10, 0x81, 0x02, 0xc0, 0x09, 0x01,
0xa1, 0x00, 0x09, 0x32, 0x09, 0x35, 0x15, 0x00,
0x27, 0xff, 0xff, 0x00, 0x00, 0x95, 0x02, 0x75,
0x10, 0x81, 0x02, 0xc0, 0x05, 0x02, 0x09, 0xc5,
0x15, 0x00, 0x26, 0xff, 0x03, 0x95, 0x01, 0x75,
0x0a, 0x81, 0x02, 0x15, 0x00, 0x25, 0x00, 0x75,
0x06, 0x95, 0x01, 0x81, 0x03, 0x05, 0x02, 0x09,
0xc4, 0x15, 0x00, 0x26, 0xff, 0x03, 0x95, 0x01,
0x75, 0x0a, 0x81, 0x02, 0x15, 0x00, 0x25, 0x00,
0x75, 0x06, 0x95, 0x01, 0x81, 0x03, 0x05, 0x01,
0x09, 0x39, 0x15, 0x01, 0x25, 0x08, 0x35, 0x00,
0x46, 0x3b, 0x01, 0x66, 0x14, 0x00, 0x75, 0x04,
0x95, 0x01, 0x81, 0x42, 0x75, 0x04, 0x95, 0x01,
0x15, 0x00, 0x25, 0x00, 0x35, 0x00, 0x45, 0x00,
0x65, 0x00, 0x81, 0x03, 0x05, 0x09, 0x19, 0x01,
0x29, 0x0f, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01,
0x95, 0x0f, 0x81, 0x02, 0x15, 0x00, 0x25, 0x00,
0x75, 0x01, 0x95, 0x01, 0x81, 0x03, 0x05, 0x0c,
0x0a, 0xb2, 0x00, 0x15, 0x00, 0x25, 0x01, 0x95,
0x01, 0x75, 0x01, 0x81, 0x02, 0x15, 0x00, 0x25,
0x00, 0x75, 0x07, 0x95, 0x01, 0x81, 0x03, 0x05,
0x0c, 0x09, 0x01, 0xa1, 0x01, 0x0a, 0x85, 0x00,
0x15, 0x00, 0x26, 0xff, 0x00, 0x95, 0x01, 0x75,
0x08, 0x81, 0x02, 0x0a, 0x99, 0x00, 0x15, 0x00,
0x26, 0xff, 0x00, 0x95, 0x01, 0x75, 0x04, 0x81,
0x02, 0x15, 0x00, 0x25, 0x00, 0x95, 0x01, 0x75,
0x04, 0x81, 0x03, 0x0a, 0x81, 0x00, 0x15, 0x00,
0x26, 0xff, 0x00, 0x95, 0x01, 0x75, 0x04, 0x81,
0x02, 0x15, 0x00, 0x25, 0x00, 0x95, 0x01, 0x75,
0x04, 0x81, 0x03, 0xc0, 0x05, 0x0f, 0x09, 0x21,
0x85, 0x03, 0xa1, 0x02, 0x09, 0x97, 0x15, 0x00,
0x25, 0x01, 0x75, 0x04, 0x95, 0x01, 0x91, 0x02,
0x15, 0x00, 0x25, 0x00, 0x75, 0x04, 0x95, 0x01,
0x91, 0x03, 0x09, 0x70, 0x15, 0x00, 0x25, 0x64,
0x75, 0x08, 0x95, 0x04, 0x91, 0x02, 0x09, 0x50,
0x66, 0x01, 0x10, 0x55, 0x0e, 0x15, 0x00, 0x26,
0xff, 0x00, 0x75, 0x08, 0x95, 0x01, 0x91, 0x02,
0x09, 0xa7, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75,
0x08, 0x95, 0x01, 0x91, 0x02, 0x65, 0x00, 0x55,
0x00, 0x09, 0x7c, 0x15, 0x00, 0x26, 0xff, 0x00,
0x75, 0x08, 0x95, 0x01, 0x91, 0x02, 0xc0, 0x05,
0x0c, 0x09, 0x01, 0x85, 0x0c, 0xa1, 0x01, 0x0a,
0x9e, 0x00, 0x15, 0x00, 0x26, 0xff, 0x00, 0x95,
0x01, 0x75, 0x08, 0x81, 0x02, 0x0a, 0xa1, 0x00,
0x15, 0x00, 0x26, 0xff, 0x00, 0x95, 0x01, 0x75,
0x08, 0x81, 0x02, 0x0a, 0xa2, 0x00, 0x15, 0x00,
0x26, 0xff, 0x00, 0x95, 0x01, 0x75, 0x08, 0x81,
0x02, 0x0a, 0xa3, 0x00, 0x15, 0x00, 0x26, 0xff,
0x00, 0x95, 0x01, 0x75, 0x08, 0x81, 0x02, 0xc0,
0xc0, 0x05, 0x01, 0x09, 0x06, 0xa1, 0x01, 0x85,
0x05, 0x05, 0x07, 0x19, 0xe0, 0x29, 0xe7, 0x15,
0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x08, 0x81,
0x02, 0x95, 0x01, 0x75, 0x08, 0x81, 0x03, 0x95,
0x06, 0x75, 0x08, 0x15, 0x00, 0x25, 0x65, 0x05,
0x07, 0x19, 0x00, 0x29, 0x65, 0x81, 0x00, 0xc0,
};
SDL_COMPILE_TIME_ASSERT (xbox_one_elite_2, sizeof (xbox_one_elite_2_hid_report_descriptor) == 0720);
static unsigned char ps3_hid_report_descriptor[] =
{
/* Generic Desktop / Joystick */
0x05, 0x01, 0x09, 0x04, 0xa1, 0x01, 0xa1, 0x02,
0x85, 0x01, 0x75, 0x08, 0x95, 0x01, 0x15, 0x00,
0x26, 0xff, 0x00, 0x81, 0x03, 0x75, 0x01, 0x95,
0x13, 0x15, 0x00, 0x25, 0x01, 0x35, 0x00, 0x45,
0x01, 0x05, 0x09, 0x19, 0x01, 0x29, 0x13, 0x81,
0x02, 0x75, 0x01, 0x95, 0x0d, 0x06, 0x00, 0xff,
0x81, 0x03, 0x15, 0x00, 0x26, 0xff, 0x00, 0x05,
0x01, 0x09, 0x01, 0xa1, 0x00, 0x75, 0x08, 0x95,
0x04, 0x35, 0x00, 0x46, 0xff, 0x00, 0x09, 0x30,
0x09, 0x31, 0x09, 0x32, 0x09, 0x35, 0x81, 0x02,
0xc0, 0x05, 0x01, 0x75, 0x08, 0x95, 0x27, 0x09,
0x01, 0x81, 0x02, 0x75, 0x08, 0x95, 0x30, 0x09,
0x01, 0x91, 0x02, 0x75, 0x08, 0x95, 0x30, 0x09,
0x01, 0xb1, 0x02, 0xc0, 0xa1, 0x02, 0x85, 0x02,
0x75, 0x08, 0x95, 0x30, 0x09, 0x01, 0xb1, 0x02,
0xc0, 0xa1, 0x02, 0x85, 0xee, 0x75, 0x08, 0x95,
0x30, 0x09, 0x01, 0xb1, 0x02, 0xc0, 0xa1, 0x02,
0x85, 0xef, 0x75, 0x08, 0x95, 0x30, 0x09, 0x01,
0xb1, 0x02, 0xc0, 0xc0, 0x00,
};
SDL_COMPILE_TIME_ASSERT (ps3, sizeof (ps3_hid_report_descriptor) == 149);
static unsigned char vrs_pedals_hid_report_descriptor[] =
{
/* Generic Desktop / Joystick */
0x05, 0x01, 0x09, 0x04, 0xa1, 0x01, 0x05, 0x01,
0xa1, 0x02, 0x85, 0x01, 0x09, 0x30, 0x09, 0x31,
0x09, 0x32, 0x15, 0x00, 0x27, 0xff, 0xff, 0x00,
0x00, 0x35, 0x00, 0x47, 0xff, 0xff, 0x00, 0x00,
0x75, 0x10, 0x95, 0x03, 0x81, 0x02, 0x06, 0x00,
0xff, 0x09, 0x01, 0x95, 0x39, 0x75, 0x08, 0x26,
0xff, 0x00, 0x15, 0x00, 0x81, 0x02, 0xc0, 0x06,
0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x64,
0x95, 0x3f, 0x75, 0x08, 0x26, 0xff, 0x00, 0x15,
0x00, 0x09, 0x01, 0x91, 0x02, 0x85, 0x65, 0x95,
0x3f, 0x75, 0x08, 0x26, 0xff, 0x00, 0x15, 0x00,
0x09, 0x01, 0x81, 0x02, 0xc0, 0xc0,
};
SDL_COMPILE_TIME_ASSERT (vrs_pedals, sizeof (vrs_pedals_hid_report_descriptor) == 0136);
static unsigned char thinkpad_usb_keyboard_hid_report_descriptor[] =
{
/* Generic Desktop / Keyboard */
0x05, 0x01, 0x09, 0x06, 0xa1, 0x01, 0x05, 0x07,
0x19, 0xe0, 0x29, 0xe7, 0x15, 0x00, 0x25, 0x01,
0x95, 0x08, 0x75, 0x01, 0x81, 0x02, 0x95, 0x08,
0x75, 0x01, 0x81, 0x01, 0x05, 0x08, 0x19, 0x01,
0x29, 0x03, 0x95, 0x03, 0x75, 0x01, 0x91, 0x02,
0x95, 0x01, 0x75, 0x05, 0x91, 0x01, 0x05, 0x07,
0x19, 0x00, 0x2a, 0xff, 0x00, 0x15, 0x00, 0x26,
0xff, 0x00, 0x95, 0x06, 0x75, 0x08, 0x81, 0x00,
0xc0,
};
SDL_COMPILE_TIME_ASSERT (thinkpad_usb_keyboard, sizeof (thinkpad_usb_keyboard_hid_report_descriptor) == 65);
static unsigned char thinkpad_usb_trackpoint_hid_report_descriptor[] =
{
/* Generic Desktop / Mouse, Generic Desktop / System Control,
* Consumer Devices / Consumer Control */
0x05, 0x01, 0x09, 0x02, 0xa1, 0x01, 0x85, 0x01,
0x09, 0x01, 0xa1, 0x00, 0x05, 0x09, 0x19, 0x01,
0x29, 0x03, 0x15, 0x00, 0x25, 0x01, 0x95, 0x03,
0x75, 0x01, 0x81, 0x02, 0x95, 0x01, 0x75, 0x05,
0x81, 0x01, 0x05, 0x01, 0x09, 0x30, 0x09, 0x31,
0x15, 0x81, 0x25, 0x7f, 0x95, 0x02, 0x75, 0x08,
0x81, 0x06, 0xc0, 0xc0, 0x05, 0x01, 0x09, 0x80,
0xa1, 0x01, 0x85, 0x02, 0x05, 0x01, 0x15, 0x00,
0x25, 0x01, 0x95, 0x08, 0x75, 0x01, 0x19, 0x81,
0x29, 0x88, 0x81, 0x02, 0xc0, 0x05, 0x0c, 0x09,
0x01, 0xa1, 0x01, 0x85, 0x03, 0x95, 0x08, 0x75,
0x01, 0x15, 0x00, 0x25, 0x01, 0x09, 0xe9, 0x09,
0xea, 0x09, 0xe2, 0x09, 0xb7, 0x09, 0xcd, 0x09,
0xb5, 0x09, 0xb6, 0x0a, 0x94, 0x01, 0x81, 0x02,
0x09, 0x03, 0xa1, 0x02, 0x05, 0x09, 0x19, 0x10,
0x29, 0x17, 0x81, 0x02, 0x05, 0x09, 0x19, 0x18,
0x29, 0x1f, 0x81, 0x02, 0xc0, 0x05, 0x08, 0x95,
0x02, 0x09, 0x09, 0x09, 0x21, 0x91, 0x02, 0x95,
0x01, 0x75, 0x06, 0x91, 0x03, 0xc0, 0x06, 0x01,
0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x04, 0x95,
0x01, 0x75, 0x08, 0x15, 0x00, 0x26, 0xff, 0x00,
0x09, 0x20, 0xb1, 0x03, 0x09, 0x21, 0xb1, 0x03,
0x09, 0x22, 0xb1, 0x03, 0x09, 0x23, 0xb1, 0x03,
0xc0,
};
SDL_COMPILE_TIME_ASSERT (thinkpad_usb_trackpoint, sizeof (thinkpad_usb_trackpoint_hid_report_descriptor) == 185);
static unsigned char heusinkveld_pedals_hid_report_descriptor[] =
{
/* Generic Desktop / Joystick */
0x05, 0x01, 0x09, 0x04, 0xa1, 0x01, 0x09, 0x33,
0x09, 0x34, 0x09, 0x35, 0x15, 0x00, 0x26, 0xff,
0x0f, 0x85, 0x01, 0x75, 0x10, 0x95, 0x03, 0x81,
0x02, 0x09, 0x00, 0x75, 0x10, 0x95, 0x06, 0x82,
0x01, 0x01, 0x85, 0x02, 0x75, 0x10, 0x95, 0x03,
0x09, 0x00, 0x09, 0x00, 0xb1, 0x02, 0x85, 0x03,
0x75, 0x08, 0x95, 0x03, 0x09, 0x00, 0x82, 0x01,
0x01, 0xc0,
};
SDL_COMPILE_TIME_ASSERT (heusinkveld_pedals, sizeof (heusinkveld_pedals_hid_report_descriptor) == 072);
static unsigned char fanatec_handbrake_hid_report_descriptor[] =
{
/* Generic Desktop / Joystick */
0x05, 0x01, 0x09, 0x04, 0xa1, 0x01, 0x15, 0x00,
0x26, 0xff, 0x00, 0x95, 0x01, 0x75, 0x08, 0x09,
0x30, 0x81, 0x02, 0x06, 0x00, 0xff, 0x09, 0x01,
0x95, 0x03, 0x81, 0x02, 0x06, 0x00, 0xff, 0x09,
0x01, 0x95, 0x02, 0x91, 0x02, 0xc0,
};
SDL_COMPILE_TIME_ASSERT (fanatec_handbrake, sizeof (fanatec_handbrake_hid_report_descriptor) == 046);
/* Test-cases derived from real devices or from Linux kernel source */
/* *INDENT-OFF* */ /* clang-format off */
static const GuessTest guess_tests[] =
@ -183,6 +363,8 @@ static const GuessTest guess_tests[] =
* advertised, but are not generated in practice. */
/* 0x100 */ ZEROx4, 0x00, 0x00, 0xff, 0x7f,
},
.hid_report_descriptor_length = sizeof (xbox_one_elite_2_hid_report_descriptor),
.hid_report_descriptor = &xbox_one_elite_2_hid_report_descriptor[0],
},
{
.name = "X-Box One S via Bluetooth",
@ -379,6 +561,8 @@ static const GuessTest guess_tests[] =
/* Digital dpad */
/* 0x200 */ ZEROx4, 0x0f, 0x00, 0x00, 0x00,
},
.hid_report_descriptor_length = sizeof (ps3_hid_report_descriptor),
.hid_report_descriptor = &ps3_hid_report_descriptor[0],
},
{
.name = "DualShock 3 - accelerometer",
@ -392,6 +576,8 @@ static const GuessTest guess_tests[] =
.abs = { 0x07 },
/* ACCELEROMETER */
.props = { 0x40 },
.hid_report_descriptor_length = sizeof (ps3_hid_report_descriptor),
.hid_report_descriptor = &ps3_hid_report_descriptor[0],
},
{
.name = "Steam Controller - gamepad",
@ -1322,6 +1508,8 @@ static const GuessTest guess_tests[] =
/* 0x80 */ 0xff, 0x57, 0x40, 0xc1, 0x7a, 0x20, 0x9f, 0xff,
/* 0xc0 */ 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
},
.hid_report_descriptor_length = sizeof (thinkpad_usb_keyboard_hid_report_descriptor),
.hid_report_descriptor = &thinkpad_usb_keyboard_hid_report_descriptor[0],
},
{
.name = "Thinkpad USB keyboard with Trackpoint - Trackpoint",
@ -1346,6 +1534,8 @@ static const GuessTest guess_tests[] =
/* 0x140 */ ZEROx4, 0x00, 0x00, 0x10, 0x00,
/* 0x180 */ ZEROx4, 0x00, 0x00, 0x40, 0x00,
},
.hid_report_descriptor_length = sizeof (thinkpad_usb_trackpoint_hid_report_descriptor),
.hid_report_descriptor = &thinkpad_usb_trackpoint_hid_report_descriptor[0],
},
{ /* https://github.com/ValveSoftware/Proton/issues/5126 */
.name = "Smarty Co. VRS DirectForce Pro Pedals",
@ -1430,6 +1620,8 @@ static const GuessTest guess_tests[] =
.ev = { 0x09 },
/* X only */
.abs = { 0x01 },
.hid_report_descriptor_length = sizeof (fanatec_handbrake_hid_report_descriptor),
.hid_report_descriptor = &fanatec_handbrake_hid_report_descriptor[0],
},
{
.name = "No information",