Skip to content

Commit

Permalink
testevdev: Add X-Box One S controller via xpadneo 0.9.x
Browse files Browse the repository at this point in the history
This is an out-of-tree driver providing an alternative interface to
X-Box gamepads. Compared with the in-kernel driver, it adds four
pseudo-buttons used to indicate which profile is active, and an
optional "misc" axis that combines the two triggers into a rudder.

Partially addresses libsdl-org#7823

Signed-off-by: Simon McVittie <[email protected]>
  • Loading branch information
smcv committed Jun 21, 2024
1 parent 6e53a36 commit f9916e6
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions test/testevdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,47 @@ static unsigned char fanatec_handbrake_hid_report_descriptor[] =
};
SDL_COMPILE_TIME_ASSERT (fanatec_handbrake, sizeof (fanatec_handbrake_hid_report_descriptor) == 046);

static unsigned char xpadneo09_xb1s_hid_report_descriptor[] =
{
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, 0x33, 0x09, 0x34, 0x15, 0x00,
0x27, 0xff, 0xff, 0x00, 0x00, 0x95, 0x02, 0x75,
0x10, 0x81, 0x02, 0xc0, 0x05, 0x01, 0x09, 0x32,
0x15, 0x00, 0x26, 0xff, 0x03, 0x95, 0x01, 0x75,
0x0a, 0x81, 0x02, 0x15, 0x00, 0x25, 0x00, 0x75,
0x06, 0x95, 0x01, 0x81, 0x03, 0x05, 0x01, 0x09,
0x35, 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, 0x0c, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01,
0x95, 0x0c, 0x81, 0x02, 0x15, 0x00, 0x25, 0x00,
0x75, 0x01, 0x95, 0x04, 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,
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, 0xc0,
};
SDL_COMPILE_TIME_ASSERT (xpadneo09_xb1s, sizeof (xpadneo09_xb1s_hid_report_descriptor) == 283);

/* Test-cases derived from real devices or from Linux kernel source */
/* *INDENT-OFF* */ /* clang-format off */
static const GuessTest guess_tests[] =
Expand Down Expand Up @@ -425,6 +466,37 @@ static const GuessTest guess_tests[] =
/* 0x100 */ ZEROx4, 0x00, 0x00, 0xdb, 0x7c,
},
},
{
.name = "X-Box One S via xpadneo 0.9.x",
/* Reference: https://github.com/libsdl-org/SDL/issues/7823 */
.eviocgname = "Xbox Wireless Controller",
.bus_type = 0x0005,
.vendor_id = 0x045e,
.product_id = 0x028e,
.version = 0x1130,
.expected = SDL_UDEV_DEVICE_JOYSTICK,
/* SYN, KEY, ABS, MSC, FF */
.ev = { 0x1b },
/* X, Y, Z, RX, RY, RZ, HAT0X, HAT0Y
* plus MISC as a deprecated axis reporting (rz - z) */
.abs = { 0x3f, 0x00, 0x03, 0x00, 0x00, 0x01 },
.keys = {
/* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
/* A, B, X, Y, TL, TR, SELECT, START, MODE, THUMBL, THUMBR */
/* 0x100 */ ZEROx4, 0x00, 0x00, 0xdb, 0x7c,
/* 0x140 */ ZEROx8,
/* 0x180 */ ZEROx8,
/* 0x1c0 */ ZEROx8,
/* 0x200 */ ZEROx8,
/* 0x240 */ ZEROx8,
/* 0x280 */ ZEROx8,
/* BTN_TRIGGER_HAPPY33 up to BTN_TRIGGER_HAPPY36 inclusive:
* used to represent the current profile */
/* 0x2c0 */ ZEROx4, 0xf0,
},
.hid_report_descriptor_length = sizeof (xpadneo09_xb1s_hid_report_descriptor),
.hid_report_descriptor = &xpadneo09_xb1s_hid_report_descriptor[0],
},
{
.name = "DualSense (PS5) - gamepad",
.bus_type = 0x0003,
Expand Down

0 comments on commit f9916e6

Please sign in to comment.