From 69c807ef534904aa29f7ecf254b02be6f86618f8 Mon Sep 17 00:00:00 2001 From: Leonardo Brondani Schenkel Date: Wed, 4 Jan 2023 16:58:49 +0100 Subject: [PATCH 01/26] Input: xpad - improve name of 8BitDo controller 2dc8:3106 8BitDo Pro 2 Wired Controller shares the same USB identifier (2dc8:3106) as a different device, so amend name to reflect that and reduce confusion as the user might think the controller was misdetected. I have personally tested it and I can confirm that Pro 2 Wired will also not work in XTYPE_XBOXONE mode (buton presses won't register), therefore XTYPE_XBOX360 remains appropriate. Signed-off-by: Leonardo Brondani Schenkel --- xpad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xpad.c b/xpad.c index 7bb6c04..7405432 100644 --- a/xpad.c +++ b/xpad.c @@ -373,7 +373,7 @@ static const struct xpad_device { { 0x294b, 0x3303, "Snakebyte GAMEPAD BASE X", 0, XTYPE_XBOXONE }, { 0x294b, 0x3404, "Snakebyte GAMEPAD RGB X", 0, XTYPE_XBOXONE }, { 0x2dc8, 0x2000, "8BitDo Pro 2 Wired Controller fox Xbox", 0, XTYPE_XBOXONE }, - { 0x2dc8, 0x3106, "8BitDo Pro 2 Wired Controller", 0, XTYPE_XBOX360 }, + { 0x2dc8, 0x3106, "8BitDo Ultimate Wireless / Pro 2 Wired Controller", 0, XTYPE_XBOX360 }, { 0x2dc8, 0x310a, "8BitDo Ultimate 2C Wireless Controller", 0, XTYPE_XBOX360 }, { 0x2e24, 0x0652, "Hyperkin Duke X-Box One pad", 0, XTYPE_XBOXONE }, { 0x31e3, 0x1100, "Wooting One", 0, XTYPE_XBOX360 }, From 651a2568412e208fb30f6c9737c99769cb8f46b6 Mon Sep 17 00:00:00 2001 From: jdarn <109807817+jdarn@users.noreply.github.com> Date: Wed, 12 Apr 2023 18:57:01 -0400 Subject: [PATCH 02/26] Input: xpad - add support for 8BitDo Ultimate bluetooth/hall effect variant --- xpad.c | 1 + 1 file changed, 1 insertion(+) diff --git a/xpad.c b/xpad.c index 7405432..8b55fa4 100644 --- a/xpad.c +++ b/xpad.c @@ -374,6 +374,7 @@ static const struct xpad_device { { 0x294b, 0x3404, "Snakebyte GAMEPAD RGB X", 0, XTYPE_XBOXONE }, { 0x2dc8, 0x2000, "8BitDo Pro 2 Wired Controller fox Xbox", 0, XTYPE_XBOXONE }, { 0x2dc8, 0x3106, "8BitDo Ultimate Wireless / Pro 2 Wired Controller", 0, XTYPE_XBOX360 }, + { 0x2dc8, 0x3109, "8BitDo Ultimate Wireless Bluetooth", 0, XTYPE_XBOX360 }, { 0x2dc8, 0x310a, "8BitDo Ultimate 2C Wireless Controller", 0, XTYPE_XBOX360 }, { 0x2e24, 0x0652, "Hyperkin Duke X-Box One pad", 0, XTYPE_XBOXONE }, { 0x31e3, 0x1100, "Wooting One", 0, XTYPE_XBOX360 }, From 6d8bceca1c1f4eb8676aac04185e30cfda16c691 Mon Sep 17 00:00:00 2001 From: Jack Greiner Date: Wed, 28 Jun 2023 00:06:11 -0400 Subject: [PATCH 03/26] Input: xpad - add support for wooting two he (arm) Signed-off-by: Jack Greiner --- xpad.c | 1 + 1 file changed, 1 insertion(+) diff --git a/xpad.c b/xpad.c index 8b55fa4..98c9d7b 100644 --- a/xpad.c +++ b/xpad.c @@ -381,6 +381,7 @@ static const struct xpad_device { { 0x31e3, 0x1200, "Wooting Two", 0, XTYPE_XBOX360 }, { 0x31e3, 0x1210, "Wooting Lekker", 0, XTYPE_XBOX360 }, { 0x31e3, 0x1220, "Wooting Two HE", 0, XTYPE_XBOX360 }, + { 0x31e3, 0x1230, "Wooting Two HE (ARM)", 0, XTYPE_XBOX360 }, { 0x31e3, 0x1300, "Wooting 60HE (AVR)", 0, XTYPE_XBOX360 }, { 0x31e3, 0x1310, "Wooting 60HE (ARM)", 0, XTYPE_XBOX360 }, { 0x3285, 0x0607, "Nacon GC-100", 0, XTYPE_XBOX360 }, From 4fce6caaf2612da30ac3cd28f2e819f23447414a Mon Sep 17 00:00:00 2001 From: Jocelyne Jones Date: Sun, 2 Jul 2023 21:03:05 +0100 Subject: [PATCH 04/26] Input: xpad - add support for SCUF Instinct --- xpad.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xpad.c b/xpad.c index 98c9d7b..4d205b6 100644 --- a/xpad.c +++ b/xpad.c @@ -377,6 +377,7 @@ static const struct xpad_device { { 0x2dc8, 0x3109, "8BitDo Ultimate Wireless Bluetooth", 0, XTYPE_XBOX360 }, { 0x2dc8, 0x310a, "8BitDo Ultimate 2C Wireless Controller", 0, XTYPE_XBOX360 }, { 0x2e24, 0x0652, "Hyperkin Duke X-Box One pad", 0, XTYPE_XBOXONE }, + { 0x2e95, 0x0504, "SCUF Gaming Controller", MAP_SELECT_BUTTON, XTYPE_XBOXONE }, { 0x31e3, 0x1100, "Wooting One", 0, XTYPE_XBOX360 }, { 0x31e3, 0x1200, "Wooting Two", 0, XTYPE_XBOX360 }, { 0x31e3, 0x1210, "Wooting Lekker", 0, XTYPE_XBOX360 }, @@ -530,6 +531,7 @@ static const struct usb_device_id xpad_table[] = { XPAD_XBOXONE_VENDOR(0x2dc8), /* 8BitDo Pro 2 Wired Controller for Xbox */ XPAD_XBOXONE_VENDOR(0x2e24), /* Hyperkin Duke Xbox One pad */ XPAD_XBOX360_VENDOR(0x2f24), /* GameSir controllers */ + XPAD_XBOXONE_VENDOR(0x2e95), /* SCUF Gaming Controller */ XPAD_XBOX360_VENDOR(0x31e3), /* Wooting Keyboards */ XPAD_XBOX360_VENDOR(0x3285), /* Nacon GC-100 */ XPAD_XBOX360_VENDOR(0x3537), /* GameSir Controllers */ From 7d2f1714411186470eb03661e04c4efeeaf6617c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20G=C3=B6rgens?= Date: Thu, 23 Nov 2023 00:11:40 +0100 Subject: [PATCH 05/26] Input: xpad - add Black Shark Green Ghost controller support --- xpad.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xpad.c b/xpad.c index 4d205b6..229df2f 100644 --- a/xpad.c +++ b/xpad.c @@ -388,6 +388,7 @@ static const struct xpad_device { { 0x3285, 0x0607, "Nacon GC-100", 0, XTYPE_XBOX360 }, { 0x3537, 0x1004, "GameSir T4 Kaleid", 0, XTYPE_XBOX360 }, { 0x3767, 0x0101, "Fanatec Speedster 3 Forceshock Wheel", 0, XTYPE_XBOX }, + { 0x413d, 0x2104, "Black Shark Green Ghost Gamepad", 0, XTYPE_XBOX360 }, { 0xffff, 0xffff, "Chinese-made Xbox Controller", 0, XTYPE_XBOX }, { 0x0000, 0x0000, "Generic X-Box pad", 0, XTYPE_UNKNOWN } }; @@ -536,6 +537,7 @@ static const struct usb_device_id xpad_table[] = { XPAD_XBOX360_VENDOR(0x3285), /* Nacon GC-100 */ XPAD_XBOX360_VENDOR(0x3537), /* GameSir Controllers */ XPAD_XBOXONE_VENDOR(0x3537), /* GameSir Controllers */ + XPAD_XBOX360_VENDOR(0x413d), /* Black Shark Green Ghost Controller */ { } }; From 3880e067a84c4f4864be50f3f23f139af67d0775 Mon Sep 17 00:00:00 2001 From: Kikismine <66830108+Kikismine@users.noreply.github.com> Date: Tue, 8 Oct 2024 17:33:23 +0200 Subject: [PATCH 06/26] Input: xpad - add Hori Racing Wheel Overdrive for Xbox Series X --- xpad.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xpad.c b/xpad.c index 229df2f..8200097 100644 --- a/xpad.c +++ b/xpad.c @@ -275,6 +275,8 @@ static const struct xpad_device { { 0x0f0d, 0x0078, "Hori Real Arcade Pro V Kai Xbox One", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE }, { 0x0f0d, 0x00c5, "Hori Fighting Commander ONE", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE }, { 0x0f0d, 0x00dc, "HORIPAD FPS for Nintendo Switch", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, + { 0x0f0d, 0x0152, "Hori Racing Wheel Overdrive for Xbox Series X", 0, XTYPE_XBOXONE }, + { 0x0f0d, 0x0151, "Hori Racing Wheel Overdrive for Xbox Series X", 0, XTYPE_XBOXONE }, { 0x0f30, 0x010b, "Philips Recoil", 0, XTYPE_XBOX }, { 0x0f30, 0x0202, "Joytech Advanced Controller", 0, XTYPE_XBOX }, { 0x0f30, 0x8888, "BigBen XBMiniPad Controller", 0, XTYPE_XBOX }, From d0fb190bbc98166b374982c65535401914fbc636 Mon Sep 17 00:00:00 2001 From: Javier Zepeda <18448386+javichz@users.noreply.github.com> Date: Tue, 8 Oct 2024 09:33:53 -0600 Subject: [PATCH 07/26] Input: xpad - add support for Nacon Pro Compact Model NC7271 --- xpad.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xpad.c b/xpad.c index 8200097..942e3cb 100644 --- a/xpad.c +++ b/xpad.c @@ -387,7 +387,9 @@ static const struct xpad_device { { 0x31e3, 0x1230, "Wooting Two HE (ARM)", 0, XTYPE_XBOX360 }, { 0x31e3, 0x1300, "Wooting 60HE (AVR)", 0, XTYPE_XBOX360 }, { 0x31e3, 0x1310, "Wooting 60HE (ARM)", 0, XTYPE_XBOX360 }, + { 0x3285, 0x0603, "Nacon Pro Compact controller for Xbox", 0, XTYPE_XBOXONE }, { 0x3285, 0x0607, "Nacon GC-100", 0, XTYPE_XBOX360 }, + { 0x3285, 0x0614, "Nacon Pro Compact", 0, XTYPE_XBOXONE }, { 0x3537, 0x1004, "GameSir T4 Kaleid", 0, XTYPE_XBOX360 }, { 0x3767, 0x0101, "Fanatec Speedster 3 Forceshock Wheel", 0, XTYPE_XBOX }, { 0x413d, 0x2104, "Black Shark Green Ghost Gamepad", 0, XTYPE_XBOX360 }, From b99fe36cdf36b7c1fc0d1d9c20398412ab798c53 Mon Sep 17 00:00:00 2001 From: Andrei Ilyashenko Date: Tue, 8 Oct 2024 11:35:47 -0400 Subject: [PATCH 08/26] Input: xpad - add support for Xbox ONE liquid metal controller I found that my controller wasn't working with this driver. The LED would light up and it could rumble but was not registering any button presses or joystick movements. I suspected the problem might be that it was not being sent some required init packet so I tried sending the packets being used in xboxone_init_packets and found that sending xboxone_pdp_auth got the controller working. At least for my controller xboxone_pdp_led_on was not strictly necessary but I decided to follow the same pattern used by the other two controllers. --- xpad.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xpad.c b/xpad.c index 942e3cb..2a011b1 100644 --- a/xpad.c +++ b/xpad.c @@ -694,7 +694,9 @@ static const struct xboxone_init_packet xboxone_init_packets[] = { XBOXONE_INIT_PKT(0x045e, 0x0b00, xboxone_s_init), XBOXONE_INIT_PKT(0x045e, 0x0b00, extra_input_packet_init), XBOXONE_INIT_PKT(0x0e6f, 0x0000, xboxone_pdp_led_on), + XBOXONE_INIT_PKT(0x20d6, 0xa01a, xboxone_pdp_led_on), XBOXONE_INIT_PKT(0x0e6f, 0x0000, xboxone_pdp_auth), + XBOXONE_INIT_PKT(0x20d6, 0xa01a, xboxone_pdp_auth), XBOXONE_INIT_PKT(0x24c6, 0x541a, xboxone_rumblebegin_init), XBOXONE_INIT_PKT(0x24c6, 0x542a, xboxone_rumblebegin_init), XBOXONE_INIT_PKT(0x24c6, 0x543a, xboxone_rumblebegin_init), From d6ec2c8897a4846a52c1ca3aec12a1f64ec8910d Mon Sep 17 00:00:00 2001 From: Martin Stolpe Date: Tue, 1 Oct 2024 20:36:08 +0200 Subject: [PATCH 09/26] Input: xpad - add USB ID for Nacon Revolution5 Pro --- xpad.c | 1 + 1 file changed, 1 insertion(+) diff --git a/xpad.c b/xpad.c index 2a011b1..72c4657 100644 --- a/xpad.c +++ b/xpad.c @@ -390,6 +390,7 @@ static const struct xpad_device { { 0x3285, 0x0603, "Nacon Pro Compact controller for Xbox", 0, XTYPE_XBOXONE }, { 0x3285, 0x0607, "Nacon GC-100", 0, XTYPE_XBOX360 }, { 0x3285, 0x0614, "Nacon Pro Compact", 0, XTYPE_XBOXONE }, + { 0x3285, 0x0662, "Nacon Revolution5 Pro", 0, XTYPE_XBOX360 }, { 0x3537, 0x1004, "GameSir T4 Kaleid", 0, XTYPE_XBOX360 }, { 0x3767, 0x0101, "Fanatec Speedster 3 Forceshock Wheel", 0, XTYPE_XBOX }, { 0x413d, 0x2104, "Black Shark Green Ghost Gamepad", 0, XTYPE_XBOX360 }, From cdb911dcafb79ccc40602a60de58c42fb73397db Mon Sep 17 00:00:00 2001 From: Thijs Reus Date: Sat, 26 Nov 2022 19:34:13 +0100 Subject: [PATCH 10/26] Input: xpad - added Turtle Beach Recon support from the diff from https://www.spinics.net/lists/linux-input/msg75512.html --- xpad.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xpad.c b/xpad.c index 72c4657..86e8b03 100644 --- a/xpad.c +++ b/xpad.c @@ -176,6 +176,7 @@ static const struct xpad_device { { 0x06a3, 0x0200, "Saitek Racing Wheel", 0, XTYPE_XBOX }, { 0x06a3, 0x0201, "Saitek Adrenalin", 0, XTYPE_XBOX }, { 0x06a3, 0xf51a, "Saitek P3600", 0, XTYPE_XBOX360 }, + { 0x0738, 0x4503, "Mad Catz Racing Wheel", 0, XTYPE_XBOXONE }, { 0x0738, 0x4506, "Mad Catz 4506 Wireless Controller", 0, XTYPE_XBOX }, { 0x0738, 0x4516, "Mad Catz Control Pad", 0, XTYPE_XBOX }, { 0x0738, 0x4520, "Mad Catz Control Pad Pro", 0, XTYPE_XBOX }, @@ -283,6 +284,7 @@ static const struct xpad_device { { 0x102c, 0xff0c, "Joytech Wireless Advanced Controller", 0, XTYPE_XBOX }, { 0x1038, 0x1430, "SteelSeries Stratus Duo", 0, XTYPE_XBOX360 }, { 0x1038, 0x1431, "SteelSeries Stratus Duo", 0, XTYPE_XBOX360 }, + { 0x10f5, 0x7005, "Turtle Beach Recon Controller", 0, XTYPE_XBOXONE }, { 0x11c9, 0x55f0, "Nacon GC-100XF", 0, XTYPE_XBOX360 }, { 0x11ff, 0x0511, "PXN V900", 0, XTYPE_XBOX360 }, { 0x1209, 0x2882, "Ardwiino Controller", 0, XTYPE_XBOX360 }, @@ -366,6 +368,7 @@ static const struct xpad_device { { 0x24c6, 0x5510, "Hori Fighting Commander ONE (Xbox 360/PC Mode)", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, { 0x24c6, 0x551a, "PowerA FUSION Pro Controller", 0, XTYPE_XBOXONE }, { 0x24c6, 0x561a, "PowerA FUSION Controller", 0, XTYPE_XBOXONE }, + { 0x24c6, 0x581a, "ThrustMaster XB1 Classic Controller", 0, XTYPE_XBOXONE }, { 0x24c6, 0x5b00, "ThrustMaster Ferrari 458 Racing Wheel", 0, XTYPE_XBOX360 }, { 0x24c6, 0x5b02, "Thrustmaster, Inc. GPX Controller", 0, XTYPE_XBOX360 }, { 0x24c6, 0x5b03, "Thrustmaster Ferrari 458 Racing Wheel", 0, XTYPE_XBOX360 }, From 1a6a0aed4af48eced53197e065e437f105129bdc Mon Sep 17 00:00:00 2001 From: Matheos Mattsson Date: Fri, 20 Dec 2024 20:03:24 +0200 Subject: [PATCH 11/26] Input: xpad - add support for Nacon Evol-X Xbox One Controller --- xpad.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xpad.c b/xpad.c index 86e8b03..28cc24f 100644 --- a/xpad.c +++ b/xpad.c @@ -394,6 +394,7 @@ static const struct xpad_device { { 0x3285, 0x0607, "Nacon GC-100", 0, XTYPE_XBOX360 }, { 0x3285, 0x0614, "Nacon Pro Compact", 0, XTYPE_XBOXONE }, { 0x3285, 0x0662, "Nacon Revolution5 Pro", 0, XTYPE_XBOX360 }, + { 0x3285, 0x0663, "Nacon Evol-X", 0, XTYPE_XBOXONE }, { 0x3537, 0x1004, "GameSir T4 Kaleid", 0, XTYPE_XBOX360 }, { 0x3767, 0x0101, "Fanatec Speedster 3 Forceshock Wheel", 0, XTYPE_XBOX }, { 0x413d, 0x2104, "Black Shark Green Ghost Gamepad", 0, XTYPE_XBOX360 }, @@ -543,6 +544,7 @@ static const struct usb_device_id xpad_table[] = { XPAD_XBOXONE_VENDOR(0x2e95), /* SCUF Gaming Controller */ XPAD_XBOX360_VENDOR(0x31e3), /* Wooting Keyboards */ XPAD_XBOX360_VENDOR(0x3285), /* Nacon GC-100 */ + XPAD_XBOXONE_VENDOR(0x3285), /* Nacon Evol-X */ XPAD_XBOX360_VENDOR(0x3537), /* GameSir Controllers */ XPAD_XBOXONE_VENDOR(0x3537), /* GameSir Controllers */ XPAD_XBOX360_VENDOR(0x413d), /* Black Shark Green Ghost Controller */ From 226caa7d0a239e58b71566a499748a6deefc021d Mon Sep 17 00:00:00 2001 From: Greg Savage Date: Tue, 12 Nov 2024 00:21:35 -0500 Subject: [PATCH 12/26] Input: xpad - add support for PDP Mirror's Edge controller --- xpad.c | 1 + 1 file changed, 1 insertion(+) diff --git a/xpad.c b/xpad.c index 28cc24f..e00c7f4 100644 --- a/xpad.c +++ b/xpad.c @@ -238,6 +238,7 @@ static const struct xpad_device { { 0x0e6f, 0x0146, "Rock Candy Wired Controller for Xbox One", 0, XTYPE_XBOXONE }, { 0x0e6f, 0x0147, "PDP Marvel Xbox One Controller", 0, XTYPE_XBOXONE }, { 0x0e6f, 0x015c, "PDP Xbox One Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE }, + { 0x0e6f, 0x015d, "PDP Mirror's Edge Official Wired Controller for Xbox One", XTYPE_XBOXONE }, { 0x0e6f, 0x0161, "PDP Xbox One Controller", 0, XTYPE_XBOXONE }, { 0x0e6f, 0x0162, "PDP Xbox One Controller", 0, XTYPE_XBOXONE }, { 0x0e6f, 0x0163, "PDP Xbox One Controller", 0, XTYPE_XBOXONE }, From 1292201db3fe377c3fb080091c8a0d82394d09a1 Mon Sep 17 00:00:00 2001 From: Fernando Petros Date: Sun, 17 Nov 2024 10:48:35 +0000 Subject: [PATCH 13/26] Input: xpad - add support for Thrustmaster ESWAP X2 ELDEN RING --- xpad.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xpad.c b/xpad.c index e00c7f4..2a5bc92 100644 --- a/xpad.c +++ b/xpad.c @@ -140,6 +140,7 @@ static const struct xpad_device { { 0x044f, 0x0f00, "Thrustmaster Wheel", 0, XTYPE_XBOX }, { 0x044f, 0x0f03, "Thrustmaster Wheel", 0, XTYPE_XBOX }, { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX }, + { 0x044f, 0xd01e, "ThrustMaster, Inc. ESWAP X 2 ELDEN RING EDITION", 0, XTYPE_XBOXONE }, { 0x044f, 0x0f10, "Thrustmaster Modena GT Wheel", 0, XTYPE_XBOX }, { 0x044f, 0xb326, "Thrustmaster Gamepad GP XID", 0, XTYPE_XBOX360 }, { 0x045e, 0x0202, "Microsoft X-Box pad v1 (US)", 0, XTYPE_XBOX }, @@ -497,6 +498,7 @@ static const struct usb_device_id xpad_table[] = { XPAD_XBOX360_VENDOR(0x03f0), /* HP HyperX Xbox 360 controllers */ XPAD_XBOXONE_VENDOR(0x03f0), /* HP HyperX Xbox One controllers */ XPAD_XBOX360_VENDOR(0x044f), /* Thrustmaster Xbox 360 controllers */ + XPAD_XBOXONE_VENDOR(0x044f), /* Thrustmaster Xbox One controllers */ XPAD_XBOX360_VENDOR(0x045e), /* Microsoft Xbox 360 controllers */ XPAD_XBOXONE_VENDOR(0x045e), /* Microsoft Xbox One controllers */ XPAD_XBOX360_VENDOR(0x046d), /* Logitech Xbox 360-style controllers */ From c981866a2ab7d070ce0d883abbcd1c2a21658a6a Mon Sep 17 00:00:00 2001 From: Daniel Tobias Date: Tue, 10 May 2016 00:31:56 +1000 Subject: [PATCH 14/26] xpad: print received packets if DEBUG_VERBOSE Signed-off-by: Daniel Tobias --- xpad.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/xpad.c b/xpad.c index 2a5bc92..9ce75dc 100644 --- a/xpad.c +++ b/xpad.c @@ -1198,6 +1198,13 @@ static void xpad_irq_in(struct urb *urb) goto exit; } +#if defined(DEBUG_VERBOSE) + /* If you set rowsize to larger than 32 it defaults to 16? + * Otherwise I would set it to XPAD_PKT_LEN V + */ + print_hex_dump(KERN_DEBUG, "xpad-dbg: ", DUMP_PREFIX_OFFSET, 32, 1, xpad->idata, XPAD_PKT_LEN, 0); +#endif + switch (xpad->xtype) { case XTYPE_XBOX360: xpad360_process_packet(xpad, xpad->dev, 0, xpad->idata); From 13f1c3b76ca3056f0d830e1b9901347fa1d002ae Mon Sep 17 00:00:00 2001 From: Pavel Rojtberg Date: Sun, 5 Jul 2015 15:41:30 +0200 Subject: [PATCH 15/26] add code to enable debug outputs --- xpad.c | 1 + 1 file changed, 1 insertion(+) diff --git a/xpad.c b/xpad.c index 9ce75dc..f3d1b1c 100644 --- a/xpad.c +++ b/xpad.c @@ -61,6 +61,7 @@ * Later changes can be tracked in SCM. */ +// #define DEBUG #include #include #include From 4c5e998a5633195d181ab0cb7b975bb11ca58875 Mon Sep 17 00:00:00 2001 From: Pavel Rojtberg Date: Wed, 24 Jun 2015 12:47:17 +0200 Subject: [PATCH 16/26] add README.md Signed-off-by: Daniel Tobias Signed-off-by: Jonathan Signed-off-by: Matt Sturgeon --- README.md | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..8986f09 --- /dev/null +++ b/README.md @@ -0,0 +1,95 @@ +[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/O5O514FGIG) + +# Updated Xpad Linux Kernel Driver +Driver for the Xbox/ Xbox 360/ Xbox 360 Wireless/ Xbox One Controllers + +This driver includes the latest changes in the upstream linux kernel and additionally carries the following staging changes: + +* support for more compatible devices +* support for xbox360 class controllers, that need initialisation +* support Guitar Hero Live xbox one controller + +## Xbox One Controllers +This driver is only used if you connect the controller via USB. + +**Connecting via Bluetooth** +If you get past the pairing issues, the controller will operate in the [generic-HID bluetooth profile](https://en.wikipedia.org/wiki/List_of_Bluetooth_profiles#Human_Interface_Device_Profile_(HID)). +The xpad driver will not be used. + +**Connecting via XBox One Wireless Adapter (WiFi)** +The adapter needs daemon in userspace, see: [medusalix/xow](https://github.com/medusalix/xow) +Opinion: rather get a controller that supports bluetooth. + + +# Installing +``` +sudo git clone https://github.com/paroj/xpad.git /usr/src/xpad-0.4 +sudo dkms install -m xpad -v 0.4 +``` +# Updating +``` +cd /usr/src/xpad-0.4 +sudo git fetch +sudo git checkout origin/master +sudo dkms remove -m xpad -v 0.4 --all +sudo dkms install -m xpad -v 0.4 +``` +# Removing +``` +sudo dkms remove -m xpad -v 0.4 --all +sudo rm -rf /usr/src/xpad-0.4 +``` +# Usage +This driver creates three devices for each attached gamepad + +1. /dev/input/js**N** + * example `jstest /dev/input/js0` +2. /sys/class/leds/xpad**N**/brightness + * example `echo COMMAND > /sys/class/leds/xpad0/brightness` where COMMAND is one of + * 0: off + * 1: all blink, then previous setting + * 2: 1/top-left blink, then on + * 3: 2/top-right blink, then on + * 4: 3/bottom-left blink, then on + * 5: 4/bottom-right blink, then on + * 6: 1/top-left on + * 7: 2/top-right on + * 8: 3/bottom-left on + * 9: 4/bottom-right on + * 10: rotate + * 11: blink, based on previous setting + * 12: slow blink, based on previous setting + * 13: rotate with two lights + * 14: persistent slow all blink + * 15: blink once, then previous setting +3. the generic event device + * example `fftest /dev/input/by-id/usb-*360*event*` + +# Debugging +As a regular unpriveledged user + +Setup console to display kernel log. +`dmesg --level=debug --follow` + +Open a new console and access the device with jstest. +`jstest /dev/input/jsX` + +Interact with the device and observe that data packets recieved from device are printed to kernel log. +``` +[ 3968.772128] xpad-dbg: 00000000: 20 00 b5 0e 00 00 00 00 00 00 0c 03 04 fd 6c 01 40 fe 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +[ 3968.772135] xpad-dbg: 00000020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +[ 3968.804137] xpad-dbg: 00000000: 20 00 b6 0e 00 00 00 00 00 00 0c 03 04 fd 6c 01 fc fd 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +[ 3968.804145] xpad-dbg: 00000020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +[ 3969.152120] xpad-dbg: 00000000: 20 00 b7 0e 00 00 00 00 00 00 0c 03 04 fd 6c 01 b8 fd 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +[ 3969.152129] xpad-dbg: 00000020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +``` + +Save dmesg buffer and attach to bug report, don't forget to describe button sequences in bug report. +`dmesg --level=debug > dmesg.txt` + +Ctrl+C to close interactive console sessions when finished. + +# Sending Upstream + +1. `git format-patch --cover-letter upstream..master` +2. `git send-email --to xxx *.patch` From 52d580b206f298162851f2aaff0d9fcccf3f8989 Mon Sep 17 00:00:00 2001 From: Pavel Rojtberg Date: Sun, 27 Sep 2015 23:57:46 +0200 Subject: [PATCH 17/26] add stress_urb_out.sh --- stress_urb_out.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100755 stress_urb_out.sh diff --git a/stress_urb_out.sh b/stress_urb_out.sh new file mode 100755 index 0000000..2e5c235 --- /dev/null +++ b/stress_urb_out.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# stress test irq_urb_out. provokes URB request dropping. +# script by Laura Abbott +# see: http://www.spinics.net/lists/linux-input/msg40477.html + +while true; do + for i in $(seq 0 5); do + echo $i > /sys/class/leds/xpad0/subsystem/xpad0/brightness + done +done From 76d4a5e3b7913f7fb7b5174000c621c3aa7781ff Mon Sep 17 00:00:00 2001 From: Pavel Rojtberg Date: Sun, 8 Dec 2019 13:44:36 +0100 Subject: [PATCH 18/26] add PR template --- .github/pull_request_template.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/pull_request_template.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..17be172 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,13 @@ + \ No newline at end of file From a185f88be82a9ce48381e698fc8863b1f459294b Mon Sep 17 00:00:00 2001 From: Pavel Rojtberg Date: Mon, 5 Sep 2022 18:35:42 +0200 Subject: [PATCH 19/26] add CI build --- .github/workflows/ci-build.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/ci-build.yml diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml new file mode 100644 index 0000000..460600d --- /dev/null +++ b/.github/workflows/ci-build.yml @@ -0,0 +1,19 @@ +name: CI Build +on: + push: + branches: [master] + pull_request: + branches: [master] +jobs: + linux: + runs-on: ubuntu-22.04 + steps: + - name: Install Dependencies + run: | + sudo apt update + sudo apt install -y dkms + - uses: actions/checkout@v2 + - name: Build + run: | + sudo ln -s `pwd` /usr/src/xpad-0.4 + sudo dkms install -m xpad -v 0.4 From 5e751f74a4bfd925854eb9b161fe7141a09fe0d3 Mon Sep 17 00:00:00 2001 From: Davide Garberi Date: Sat, 22 Oct 2022 17:49:16 +0200 Subject: [PATCH 20/26] input: xpad - Switch to workqueue for xpad360w button poweroff This allows to turn off the pad without having to release the Xbox (mode) button Signed-off-by: Davide Garberi --- xpad.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/xpad.c b/xpad.c index f3d1b1c..37f53fc 100644 --- a/xpad.c +++ b/xpad.c @@ -765,6 +765,7 @@ struct usb_xpad { int pad_nr; /* the order x360 pads were attached */ const char *name; /* name of the device */ struct work_struct work; /* init/remove device from callback */ + struct delayed_work poweroff_work; /* work struct for poweroff on mode long press */ time64_t mode_btn_down_ts; }; @@ -927,20 +928,29 @@ static void xpad360_process_packet(struct usb_xpad *xpad, struct input_dev *dev, /* XBOX360W controllers can't be turned off without driver assistance */ if (xpad->xtype == XTYPE_XBOX360W) { - if (xpad->mode_btn_down_ts > 0 && xpad->pad_present && - ((ktime_get_seconds() - xpad->mode_btn_down_ts) >= - XPAD360W_POWEROFF_TIMEOUT)) { - xpad360w_poweroff_controller(xpad); - xpad->mode_btn_down_ts = 0; - return; + if (data[3] & BIT(2)) { + if (xpad->mode_btn_down_ts == 0) + xpad->mode_btn_down_ts = ktime_get_seconds(); + schedule_delayed_work(&xpad->poweroff_work, msecs_to_jiffies(0)); + } else { + xpad->mode_btn_down_ts = 0; } + } +} - /* mode button down/up */ - if (data[3] & BIT(2)) - xpad->mode_btn_down_ts = ktime_get_seconds(); - else - xpad->mode_btn_down_ts = 0; +static void xpad360w_poweroff_work(struct work_struct *work) { + struct usb_xpad *xpad = container_of(to_delayed_work(work), struct usb_xpad, poweroff_work); + + if (xpad->mode_btn_down_ts == 0) + return; + + if ((ktime_get_seconds() - xpad->mode_btn_down_ts) >= XPAD360W_POWEROFF_TIMEOUT) { + xpad360w_poweroff_controller(xpad); + xpad->mode_btn_down_ts = 0; + return; } + + schedule_delayed_work(&xpad->poweroff_work, msecs_to_jiffies(200)); } static void xpad_presence_work(struct work_struct *work) @@ -1833,6 +1843,8 @@ static int xpad360w_start_input(struct usb_xpad *xpad) return error; } + INIT_DELAYED_WORK(&xpad->poweroff_work, xpad360w_poweroff_work); + return 0; } @@ -1842,6 +1854,7 @@ static void xpad360w_stop_input(struct usb_xpad *xpad) /* Make sure we are done with presence work if it was scheduled */ flush_work(&xpad->work); + flush_delayed_work(&xpad->poweroff_work); } static int xpad_open(struct input_dev *dev) From 83ec36aa7d99ff0126696b1f55d6122da8b20572 Mon Sep 17 00:00:00 2001 From: Leonardo Brondani Schenkel Date: Mon, 9 Jan 2023 17:44:39 +0100 Subject: [PATCH 21/26] Support KEY_RECORD for 8BitDo Pro 2...for Xbox This controller is a "Series S|X": it has the "share" button below the big Xbox button. However, it reports the status of that button in a different offset than the official controller. The button is still recognized by official Microsoft driver in Windows, so it looks like that both offsets are used in the wild. Signed-off-by: Leonardo Brondani Schenkel --- xpad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xpad.c b/xpad.c index 37f53fc..90f1cfe 100644 --- a/xpad.c +++ b/xpad.c @@ -1069,7 +1069,7 @@ static void xpadone_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char input_report_key(dev, BTN_START, data[4] & BIT(2)); input_report_key(dev, BTN_SELECT, data[4] & BIT(3)); if (xpad->mapping & MAP_SELECT_BUTTON) - input_report_key(dev, KEY_RECORD, data[22] & BIT(0)); + input_report_key(dev, KEY_RECORD, data[22] & BIT(0) || /* 8BitDo: */ data[18] & BIT(0)); /* buttons A,B,X,Y */ input_report_key(dev, BTN_A, data[4] & BIT(4)); From e3cafc2a8beb1f96719661b8d601f9402e30ed5a Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Sun, 15 Aug 2021 01:47:17 +0200 Subject: [PATCH 22/26] Input: xpad - initialize 360 controllers Many knockoff brands emulating the XBOX 360 controller do not properly send data unless configured correctly. Examples include the Gamesir G3w and the Fantech GP11 Shooter. Protocol inspection of communication with other operating systems reveals a sequence of control messages that can be used to initialize the controllers sufficiently to send proper data. Some of these controllers only require one and may break with further, some may require all three. This change adds a quirks field that allows specifying these initialization packets. Note that it also removes an unused field from the controller type table. Signed-off-by: Darvin Delgado Signed-off-by: Vicki Pfau --- xpad.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/xpad.c b/xpad.c index 90f1cfe..14e94d3 100644 --- a/xpad.c +++ b/xpad.c @@ -105,6 +105,12 @@ #define PKT_XBE2_FW_5_EARLY 3 #define PKT_XBE2_FW_5_11 4 +#define QUIRK_360_START_PKT_1 (1 << 0) +#define QUIRK_360_START_PKT_2 (1 << 1) +#define QUIRK_360_START_PKT_3 (1 << 2) +#define QUIRK_360_START (QUIRK_360_START_PKT_1 | \ + QUIRK_360_START_PKT_2 | QUIRK_360_START_PKT_3) + static bool dpad_to_buttons; module_param(dpad_to_buttons, bool, S_IRUGO); MODULE_PARM_DESC(dpad_to_buttons, "Map D-PAD to buttons rather than axes for unknown pads"); @@ -127,6 +133,7 @@ static const struct xpad_device { char *name; u8 mapping; u8 xtype; + u8 quirks; } xpad_device[] = { /* Please keep this list sorted by vendor and product ID. */ { 0x0079, 0x18d4, "GPD Win 2 X-Box Controller", 0, XTYPE_XBOX360 }, @@ -169,6 +176,7 @@ static const struct xpad_device { { 0x046d, 0xca8a, "Logitech Precision Vibration Feedback Wheel", 0, XTYPE_XBOX }, { 0x046d, 0xcaa3, "Logitech DriveFx Racing Wheel", 0, XTYPE_XBOX360 }, { 0x056e, 0x2004, "Elecom JC-U3613M", 0, XTYPE_XBOX360 }, + { 0x05ac, 0x055b, "Gamesir-G3w", 0, XTYPE_XBOX360, QUIRK_360_START }, { 0x05fd, 0x1007, "Mad Catz Controller (unverified)", 0, XTYPE_XBOX }, { 0x05fd, 0x107a, "InterAct 'PowerPad Pro' X-Box pad (Germany)", 0, XTYPE_XBOX }, { 0x05fe, 0x3030, "Chic Controller", 0, XTYPE_XBOX }, @@ -763,6 +771,7 @@ struct usb_xpad { int xtype; /* type of xbox device */ int packet_type; /* type of the extended packet */ int pad_nr; /* the order x360 pads were attached */ + int quirks; const char *name; /* name of the device */ struct work_struct work; /* init/remove device from callback */ struct delayed_work poweroff_work; /* work struct for poweroff on mode long press */ @@ -1483,6 +1492,98 @@ static int xpad_start_xbox_one(struct usb_xpad *xpad) return xpad_try_sending_next_out_packet(xpad); } +static int xpad_start_xbox_360(struct usb_xpad *xpad) +{ + int status; + + char *data = kzalloc(20, GFP_KERNEL); + + int TIMEOUT = 100; + + /* + this init sequence is needed for the gamesir g3w controller + and for shanwan controllers in xpad mode. + Unfortunately, in this mode they identify as 0x045e, 0x028e, so we + have to inspect the manufacturer string. + Sending this sequence to other controllers will break initialization. + */ + bool is_shanwan = xpad->udev->manufacturer && strcasecmp("shanwan", xpad->udev->manufacturer) == 0; + if (!(xpad->quirks & QUIRK_360_START) && !is_shanwan) { + status = 0; + goto err_free_ctrl_data; + } + + if ((xpad->quirks & QUIRK_360_START_PKT_1) || is_shanwan) { + status = usb_control_msg(xpad->udev, + usb_rcvctrlpipe(xpad->udev, 0), + 0x1, 0xc1, + cpu_to_le16(0x100), cpu_to_le16(0x0), data, cpu_to_le16(20), + TIMEOUT); + +#ifdef DEBUG + dev_dbg(&xpad->intf->dev, + "%s - control message 1 returned %d\n", __func__, status); +#endif + + if (status < 0) { + goto err_free_ctrl_data; + } +#ifdef DEBUG + else { + print_hex_dump(KERN_DEBUG, "xpad-dbg: ", DUMP_PREFIX_OFFSET, 32, 1, data, 20, 0); + } +#endif + } + + if ((xpad->quirks & QUIRK_360_START_PKT_2) || is_shanwan) { + status = usb_control_msg(xpad->udev, + usb_rcvctrlpipe(xpad->udev, 0), + 0x1, 0xc1, + cpu_to_le16(0x0), cpu_to_le16(0x0), data, cpu_to_le16(8), + TIMEOUT); +#ifdef DEBUG + dev_dbg(&xpad->intf->dev, + "%s - control message 2 returned %d\n", __func__, status); +#endif + + if (status < 0) { + goto err_free_ctrl_data; + } +#ifdef DEBUG + else { + print_hex_dump(KERN_DEBUG, "xpad-dbg: ", DUMP_PREFIX_OFFSET, 32, 1, data, 8, 0); + } +#endif + } + + if ((xpad->quirks & QUIRK_360_START_PKT_3) || is_shanwan) { + status = usb_control_msg(xpad->udev, + usb_rcvctrlpipe(xpad->udev, 0), + 0x1, 0xc0, + cpu_to_le16(0x0), cpu_to_le16(0x0), data, cpu_to_le16(4), + TIMEOUT); +#ifdef DEBUG + dev_dbg(&xpad->intf->dev, + "%s - control message 3 returned %d\n", __func__, status); +#endif + + if (status < 0) { + goto err_free_ctrl_data; + } +#ifdef DEBUG + else { + print_hex_dump(KERN_DEBUG, "xpad-dbg: ", DUMP_PREFIX_OFFSET, 32, 1, data, 4, 0); + } +#endif + } + + status = 0; + +err_free_ctrl_data: + kfree(data); + return status; +} + static void xpadone_ack_mode_report(struct usb_xpad *xpad, u8 seq_num) { struct xpad_output_packet *packet = @@ -1755,6 +1856,12 @@ static int xpad_start_input(struct usb_xpad *xpad) { int error; + if (xpad->xtype == XTYPE_XBOX360) { + error = xpad_start_xbox_360(xpad); + if (error) + return error; + } + if (usb_submit_urb(xpad->irq_in, GFP_KERNEL)) return -EIO; @@ -2063,6 +2170,7 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id xpad->mapping = xpad_device[i].mapping; xpad->xtype = xpad_device[i].xtype; xpad->name = xpad_device[i].name; + xpad->quirks = xpad_device[i].quirks; xpad->packet_type = PKT_XB; INIT_WORK(&xpad->work, xpad_presence_work); From 5eaa1156d96f9ab6d7bf84df145bd00ad4dd479d Mon Sep 17 00:00:00 2001 From: Daniel Nguyen <56515021+dynamix1337@users.noreply.github.com> Date: Sat, 22 Oct 2022 11:54:44 -0400 Subject: [PATCH 23/26] Input: xpad - add support for GHL Xbox One controller --- xpad.c | 166 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 163 insertions(+), 3 deletions(-) diff --git a/xpad.c b/xpad.c index 14e94d3..75f9594 100644 --- a/xpad.c +++ b/xpad.c @@ -71,9 +71,15 @@ #include #include #include +#include #define XPAD_PKT_LEN 64 +/* The Guitar Hero Live (GHL) Xbox One dongles require a poke + * every 8 seconds. + */ +#define GHL_GUITAR_POKE_INTERVAL 8 /* In seconds */ + /* * xbox d-pads should map to buttons, as is required for DDR pads * but we map them to axes when possible to simplify things @@ -108,6 +114,7 @@ #define QUIRK_360_START_PKT_1 (1 << 0) #define QUIRK_360_START_PKT_2 (1 << 1) #define QUIRK_360_START_PKT_3 (1 << 2) +#define QUIRK_GHL_XBOXONE (1 << 3) #define QUIRK_360_START (QUIRK_360_START_PKT_1 | \ QUIRK_360_START_PKT_2 | QUIRK_360_START_PKT_3) @@ -303,6 +310,7 @@ static const struct xpad_device { { 0x12ab, 0x0301, "PDP AFTERGLOW AX.1", 0, XTYPE_XBOX360 }, { 0x12ab, 0x0303, "Mortal Kombat Klassic FightStick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, { 0x12ab, 0x8809, "Xbox DDR dancepad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, + { 0x1430, 0x079B, "RedOctane GHL Controller", 0, XTYPE_XBOXONE, QUIRK_GHL_XBOXONE }, { 0x1430, 0x4748, "RedOctane Guitar Hero X-plorer", 0, XTYPE_XBOX360 }, { 0x1430, 0x8888, "TX6500+ Dance Pad (first generation)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, { 0x1430, 0xf801, "RedOctane Controller", 0, XTYPE_XBOX360 }, @@ -470,6 +478,12 @@ static const signed short xpad_btn_paddles[] = { -1 /* terminating entry */ }; +/* used for GHL dpad mapping */ +static const struct {int x; int y; } dpad_mapping[] = { + {0, -1}, {1, -1}, {1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, + {0, 0} +}; + /* * Xbox 360 has a vendor-specific class, so we cannot match it with only * USB_INTERFACE_INFO (also specifically refused by USB subsystem), so we @@ -531,6 +545,7 @@ static const struct usb_device_id xpad_table[] = { XPAD_XBOX360_VENDOR(0x1209), /* Ardwiino Controllers */ XPAD_XBOX360_VENDOR(0x12ab), /* Xbox 360 dance pads */ XPAD_XBOX360_VENDOR(0x1430), /* RedOctane Xbox 360 controllers */ + XPAD_XBOXONE_VENDOR(0x1430), /* RedOctane X-Box One controllers */ XPAD_XBOX360_VENDOR(0x146b), /* Bigben Interactive controllers */ XPAD_XBOX360_VENDOR(0x1532), /* Razer Sabertooth */ XPAD_XBOXONE_VENDOR(0x1532), /* Razer Wildcat */ @@ -698,6 +713,11 @@ static const u8 xboxone_rumbleend_init[] = { 0x00, GIP_MOTOR_ALL, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +/* GHL Xbox One magic data */ +static const char ghl_xboxone_magic_data[] = { + 0x22, 0x00, 0x00, 0x08, 0x02, 0x08, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + /* * This specifies the selection of init packets that a gamepad * will be sent on init *and* the order in which they will be @@ -707,13 +727,16 @@ static const u8 xboxone_rumbleend_init[] = { static const struct xboxone_init_packet xboxone_init_packets[] = { XBOXONE_INIT_PKT(0x0e6f, 0x0165, xboxone_hori_ack_id), XBOXONE_INIT_PKT(0x0f0d, 0x0067, xboxone_hori_ack_id), + XBOXONE_INIT_PKT(0x1430, 0x079b, xboxone_hori_ack_id), XBOXONE_INIT_PKT(0x0000, 0x0000, xboxone_power_on), XBOXONE_INIT_PKT(0x045e, 0x02ea, xboxone_s_init), XBOXONE_INIT_PKT(0x045e, 0x0b00, xboxone_s_init), XBOXONE_INIT_PKT(0x045e, 0x0b00, extra_input_packet_init), XBOXONE_INIT_PKT(0x0e6f, 0x0000, xboxone_pdp_led_on), + XBOXONE_INIT_PKT(0x1430, 0x079b, xboxone_pdp_led_on), XBOXONE_INIT_PKT(0x20d6, 0xa01a, xboxone_pdp_led_on), XBOXONE_INIT_PKT(0x0e6f, 0x0000, xboxone_pdp_auth), + XBOXONE_INIT_PKT(0x1430, 0x079b, xboxone_pdp_auth), XBOXONE_INIT_PKT(0x20d6, 0xa01a, xboxone_pdp_auth), XBOXONE_INIT_PKT(0x24c6, 0x541a, xboxone_rumblebegin_init), XBOXONE_INIT_PKT(0x24c6, 0x542a, xboxone_rumblebegin_init), @@ -776,6 +799,8 @@ struct usb_xpad { struct work_struct work; /* init/remove device from callback */ struct delayed_work poweroff_work; /* work struct for poweroff on mode long press */ time64_t mode_btn_down_ts; + struct urb *ghl_urb; /* URB for GHL Xbox One magic data */ + struct timer_list ghl_poke_timer; /* Timer for periodic poke of GHL magic data */ }; static int xpad_init_input(struct usb_xpad *xpad); @@ -783,6 +808,63 @@ static void xpad_deinit_input(struct usb_xpad *xpad); static void xpadone_ack_mode_report(struct usb_xpad *xpad, u8 seq_num); static void xpad360w_poweroff_controller(struct usb_xpad *xpad); +/* + * ghl_magic_poke_cb + * + * Call back function that resets the timer for the next magic data poke. + */ +static void ghl_magic_poke_cb(struct urb *urb) +{ + struct usb_xpad *xpad = urb->context; + + if (urb->status < 0) + pr_warn("URB transfer failed.\n"); + + mod_timer(&xpad->ghl_poke_timer, jiffies + GHL_GUITAR_POKE_INTERVAL*HZ); +} + +/* + * ghl_magic_poke + * + * Submits the GHL magic_data URB. + */ +static void ghl_magic_poke(struct timer_list *t) +{ + int ret; + struct usb_xpad *xpad = from_timer(xpad, t, ghl_poke_timer); + + ret = usb_submit_urb(xpad->ghl_urb, GFP_ATOMIC); + if (ret < 0) + pr_warn("URB transfer failed.\n"); +} + +/* + * ghl_init_urb + * + * Prepares the interrupt URB for GHL magic_data. + */ +static int ghl_init_urb(struct usb_xpad *xpad, struct usb_device *usbdev, + const char ghl_magic_data[], u16 poke_size, struct usb_endpoint_descriptor *ep_irq_out) +{ + u8 *databuf; + unsigned int pipe; + + pipe = usb_sndintpipe(usbdev, ep_irq_out->bEndpointAddress); + + databuf = devm_kzalloc(&xpad->udev->dev, poke_size, GFP_ATOMIC); + if (databuf == NULL) + return -ENOMEM; + + memcpy(databuf, ghl_magic_data, poke_size); + + usb_fill_int_urb( + xpad->ghl_urb, usbdev, pipe, + databuf, poke_size, + ghl_magic_poke_cb, xpad, ep_irq_out->bInterval); + + return 0; +} + /* * xpad_process_packet * @@ -1040,6 +1122,7 @@ static void xpadone_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char { struct input_dev *dev = xpad->dev; bool do_sync = false; + int dpad_value; /* the xbox button has its own special report */ if (data[0] == GIP_CMD_VIRTUAL_KEY) { @@ -1186,6 +1269,48 @@ static void xpadone_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char } } + do_sync = true; + + } else if (data[0] == 0X21) { /* The main valid packet type for GHL inputs */ + /* Mapping chosen to be coherent with GHL dongles of other consoles */ + + /* The 6 fret buttons */ + input_report_key(dev, BTN_B, data[4] & BIT(1)); + input_report_key(dev, BTN_X, data[4] & BIT(2)); + input_report_key(dev, BTN_Y, data[4] & BIT(3)); + input_report_key(dev, BTN_A, data[4] & BIT(0)); + input_report_key(dev, BTN_TL, data[4] & BIT(4)); + input_report_key(dev, BTN_TR, data[4] & BIT(5)); + + /* D-pad */ + dpad_value = data[6] & 0xF; + if (dpad_value > 7) + dpad_value = 8; + + input_report_abs(dev, ABS_HAT0X, dpad_mapping[dpad_value].x); + input_report_abs(dev, ABS_HAT0Y, dpad_mapping[dpad_value].y); + + /* Strum bar */ + input_report_abs(dev, ABS_Y, ((data[8] - 0x80) << 9)); + + /* Tilt Sensor */ + input_report_abs(dev, ABS_Z, ((data[9] - 0x80) << 9)); + + /* Whammy bar */ + input_report_abs(dev, ABS_RZ, ((data[10] - 0x80) << 9)); + + /* Power Button */ + input_report_key(dev, BTN_THUMBR, data[5] & BIT(4)); + + /* GHTV button */ + input_report_key(dev, BTN_START, data[5] & BIT(2)); + + /* Hero Power button */ + input_report_key(dev, BTN_MODE, data[5] & BIT(0)); + + /* Pause button */ + input_report_key(dev, BTN_THUMBL, data[5] & BIT(1)); + do_sync = true; } @@ -1985,15 +2110,29 @@ static void xpad_set_up_abs(struct input_dev *input_dev, signed short abs) switch (abs) { case ABS_X: case ABS_Y: + /* GHL Strum bar */ + if ((xpad->xtype == XTYPE_XBOXONE) && (xpad->quirks & QUIRK_GHL_XBOXONE)) { + input_set_abs_params(input_dev, abs, -32767, 32767, 0, 0); + break; + } case ABS_RX: case ABS_RY: /* the two sticks */ input_set_abs_params(input_dev, abs, -32768, 32767, 16, 128); break; case ABS_Z: + /* GHL Tilt sensor */ + if ((xpad->xtype == XTYPE_XBOXONE) && (xpad->quirks & QUIRK_GHL_XBOXONE)) { + input_set_abs_params(input_dev, abs, -32767, 32767, 0, 0); + break; + } case ABS_RZ: /* the triggers (if mapped to axes) */ - if (xpad->xtype == XTYPE_XBOXONE) - input_set_abs_params(input_dev, abs, 0, 1023, 0, 0); - else + if (xpad->xtype == XTYPE_XBOXONE) { + /* GHL Whammy bar */ + if (xpad->quirks & QUIRK_GHL_XBOXONE) + input_set_abs_params(input_dev, abs, -32767, 32767, 0, 0); + else + input_set_abs_params(input_dev, abs, 0, 1023, 0, 0); + } else input_set_abs_params(input_dev, abs, 0, 255, 0, 0); break; case ABS_HAT0X: @@ -2293,6 +2432,21 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id if (error) goto err_deinit_output; } + + if (xpad->quirks & QUIRK_GHL_XBOXONE) { + + xpad->ghl_urb = usb_alloc_urb(0, GFP_ATOMIC); + if (!xpad->ghl_urb) + return -ENOMEM; + + error = ghl_init_urb(xpad, udev, ghl_xboxone_magic_data, ARRAY_SIZE(ghl_xboxone_magic_data), ep_irq_out); + + if (error) + return error; + + timer_setup(&xpad->ghl_poke_timer, ghl_magic_poke, 0); + mod_timer(&xpad->ghl_poke_timer, jiffies + GHL_GUITAR_POKE_INTERVAL*HZ); + } return 0; err_deinit_output: @@ -2324,6 +2478,12 @@ static void xpad_disconnect(struct usb_interface *intf) xpad_deinit_output(xpad); usb_free_urb(xpad->irq_in); + + if (xpad->quirks & QUIRK_GHL_XBOXONE) { + usb_free_urb(xpad->ghl_urb); + del_timer_sync(&xpad->ghl_poke_timer); + } + usb_free_coherent(xpad->udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); From 65a91642ee53d6fc4afaf0497c615f44858c4e24 Mon Sep 17 00:00:00 2001 From: Pavel Rojtberg Date: Wed, 9 Oct 2024 14:36:38 +0200 Subject: [PATCH 24/26] enable compilation on pre 6.1 kernels --- xpad.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/xpad.c b/xpad.c index 75f9594..7eafbb4 100644 --- a/xpad.c +++ b/xpad.c @@ -73,6 +73,11 @@ #include #include +// enable compilation on pre 6.1 kernels +#ifndef ABS_PROFILE +#define ABS_PROFILE ABS_MISC +#endif + #define XPAD_PKT_LEN 64 /* The Guitar Hero Live (GHL) Xbox One dongles require a poke From af6ff9bbb10f0194003f9247c3d173a5d421b5bc Mon Sep 17 00:00:00 2001 From: Nilton Perim Neto Date: Mon, 6 Jan 2025 19:28:07 -0300 Subject: [PATCH 25/26] Input: xpad - added unofficial Xbox 360 wireless receiver clone I've added the DeviceID of a very popular Xbox 360 Wireless Receiver. Although it mimics the Microsoft's VendorID, it is in fact a clone. Taking into account that the original Microsoft Receiver is not being manufactured anymore, this drive can solve dpad issues encontered by those who still use the original 360 Wireless controller but are using a receiver clone. Signed-off-by: Nilton Perim Neto niltonperimneto@gmail.com --- xpad.c | 1 + 1 file changed, 1 insertion(+) diff --git a/xpad.c b/xpad.c index 7eafbb4..d74dff1 100644 --- a/xpad.c +++ b/xpad.c @@ -171,6 +171,7 @@ static const struct xpad_device { { 0x045e, 0x028e, "Microsoft X-Box 360 pad", 0, XTYPE_XBOX360 }, { 0x045e, 0x028f, "Microsoft X-Box 360 pad v2", 0, XTYPE_XBOX360 }, { 0x045e, 0x0291, "Xbox 360 Wireless Receiver (XBOX)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W }, + { 0x045e, 0x02a9, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W }, /* unofficial */ { 0x045e, 0x02d1, "Microsoft X-Box One pad", 0, XTYPE_XBOXONE }, { 0x045e, 0x02dd, "Microsoft X-Box One pad (Firmware 2015)", 0, XTYPE_XBOXONE }, { 0x045e, 0x02e3, "Microsoft X-Box One Elite pad", MAP_PADDLES, XTYPE_XBOXONE }, From 448c2acaad80389727dd70764d3cfdab4b250376 Mon Sep 17 00:00:00 2001 From: Cryowatt Date: Sat, 11 Jan 2025 17:03:22 -0800 Subject: [PATCH 26/26] Add support for Keychron HE keyboards --- xpad.c | 1 + 1 file changed, 1 insertion(+) diff --git a/xpad.c b/xpad.c index d74dff1..de85f63 100644 --- a/xpad.c +++ b/xpad.c @@ -578,6 +578,7 @@ static const struct usb_device_id xpad_table[] = { XPAD_XBOX360_VENDOR(0x31e3), /* Wooting Keyboards */ XPAD_XBOX360_VENDOR(0x3285), /* Nacon GC-100 */ XPAD_XBOXONE_VENDOR(0x3285), /* Nacon Evol-X */ + XPAD_XBOX360_VENDOR(0x3434), /* Keychron Keyboards */ XPAD_XBOX360_VENDOR(0x3537), /* GameSir Controllers */ XPAD_XBOXONE_VENDOR(0x3537), /* GameSir Controllers */ XPAD_XBOX360_VENDOR(0x413d), /* Black Shark Green Ghost Controller */