All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leonardo Brondani Schenkel <leonardo@schenkel.net>
To: linux-input@vger.kernel.org
Cc: Leonardo Brondani Schenkel <leonardo@schenkel.net>
Subject: [PATCH] xpad: support 'share' button of 8BitDo Pro 2
Date: Sat,  6 Jan 2024 13:11:33 +0100	[thread overview]
Message-ID: <20240106121137.101075-1-leonardo@schenkel.net> (raw)

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 --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));
-- 
2.43.0


                 reply	other threads:[~2024-01-06 12:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240106121137.101075-1-leonardo@schenkel.net \
    --to=leonardo@schenkel.net \
    --cc=linux-input@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.