diff mbox series

xpad: support 'share' button of 8BitDo Pro 2

Message ID 20240106121137.101075-1-leonardo@schenkel.net (mailing list archive)
State New
Headers show
Series xpad: support 'share' button of 8BitDo Pro 2 | expand

Commit Message

Leonardo Brondani Schenkel Jan. 6, 2024, 12:11 p.m. UTC
I have a 8BitDo Pro 2 Wired Controller for Xbox. This is a licensed
"Series S|X" type controller with a 'share' button below the big Xbox
button. The xpad driver has explicit support for this controller but was
not generating any raw input events when this button was pressed.

Analysis of GIP packet dumps showed that this button is reported via
byte 18, not byte 22 that the driver expects. As this is a licensed
product and the button works in Windows with the official Microsoft
drivers, it looks like both bytes are being used in the wild.

Another user confirmed the same findings:
> I can confirm that the official Microsoft controller I have reports
> the Share button in byte 22 (counting GIP_CMD_INPUT as byte 0) and the
> Hori Fighting Commander Octa reports the Share button in byte 18.
https://github.com/medusalix/xone/pull/17#issuecomment-1470807446

Therefore mark this controller as supporting the 'share' button, and
also recognize byte 18 as a 'share' button press. The latter will
benefit similar third-party controllers that report using the same byte.

Signed-off-by: Leonardo Brondani Schenkel <leonardo@schenkel.net>
---
 drivers/input/joystick/xpad.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 1a58629c12b9..3b67c783b7b6 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -357,7 +357,7 @@  static const struct xpad_device {
 	{ 0x24c6, 0x5d04, "Razer Sabertooth", 0, XTYPE_XBOX360 },
 	{ 0x24c6, 0xfafe, "Rock Candy Gamepad for Xbox 360", 0, XTYPE_XBOX360 },
 	{ 0x2563, 0x058d, "OneXPlayer Gamepad", 0, XTYPE_XBOX360 },
-	{ 0x2dc8, 0x2000, "8BitDo Pro 2 Wired Controller fox Xbox", 0, XTYPE_XBOXONE },
+	{ 0x2dc8, 0x2000, "8BitDo Pro 2 Wired Controller for Xbox", MAP_SELECT_BUTTON, XTYPE_XBOXONE },
 	{ 0x2dc8, 0x3106, "8BitDo Pro 2 Wired Controller", 0, XTYPE_XBOX360 },
 	{ 0x31e3, 0x1100, "Wooting One", 0, XTYPE_XBOX360 },
 	{ 0x31e3, 0x1200, "Wooting Two", 0, XTYPE_XBOX360 },
@@ -1008,7 +1008,8 @@  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));
+			/* official controllers use byte 22 and some third-party use byte 18 */
+			input_report_key(dev, KEY_RECORD, data[22] & BIT(0) || data[18] & BIT(0));
 
 		/* buttons A,B,X,Y */
 		input_report_key(dev, BTN_A,	data[4] & BIT(4));