All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vernon Di Carlo <vernondicarlo@gmail.com>
To: dmitry.torokhov@gmail.com
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	Vernon Di Carlo <vernondicarlo@gmail.com>
Subject: [PATCH] Input: xpad - fix button mapping on Razer Atrox Xbox One
Date: Fri,  7 Aug 2026 09:14:19 -0500	[thread overview]
Message-ID: <20260807141419.7930-1-vernondicarlo@gmail.com> (raw)

The Razer Atrox Arcade Stick for Xbox One (1532:0a00) does not use
the standard Xbox One input layout for its shoulder and trigger
buttons.

USB captures show that LB and RB are reported in bits 5 and 4 of
byte 5 respectively, opposite to the standard Xbox One mapping.
The digital LT and RT states are reported in bits 7 and 6 of byte
22 instead of the standard analog trigger fields.

As a result, xpad currently reports LB and RB swapped and does not
report LT or RT at all.

Add an Atrox-specific mapping quirk to swap LB/RB and report LT/RT
from their actual locations.

Tested with a Razer Atrox Arcade Stick for Xbox One, USB ID
1532:0a00.

Signed-off-by: Vernon Di Carlo <vernondicarlo@gmail.com>
---
 drivers/input/joystick/xpad.c | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index feb8f368f..b9daa334e 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -50,6 +50,7 @@
 #define MAP_PADDLES			BIT(4)
 #define MAP_PROFILE_BUTTON		BIT(5)
 #define MAP_SHARE_OFFSET		BIT(6)
+#define MAP_ATROX			BIT(7)
 
 #define DANCEPAD_MAP_CONFIG	(MAP_DPAD_TO_BUTTONS |			\
 				MAP_TRIGGERS_TO_BUTTONS | MAP_STICKS_TO_NULL)
@@ -280,7 +281,8 @@ static const struct xpad_device {
 	{ 0x1430, 0xf801, "RedOctane Controller", 0, XTYPE_XBOX360 },
 	{ 0x146b, 0x0601, "BigBen Interactive XBOX 360 Controller", 0, XTYPE_XBOX360 },
 	{ 0x146b, 0x0604, "Bigben Interactive DAIJA Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
-	{ 0x1532, 0x0a00, "Razer Atrox Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE },
+	{ 0x1532, 0x0a00, "Razer Atrox Arcade Stick",
+	  MAP_TRIGGERS_TO_BUTTONS | MAP_ATROX, XTYPE_XBOXONE },
 	{ 0x1532, 0x0a03, "Razer Wildcat", 0, XTYPE_XBOXONE },
 	{ 0x1532, 0x0a29, "Razer Wolverine V2", 0, XTYPE_XBOXONE },
 	{ 0x1532, 0x0a57, "Razer Wolverine V3 Pro (Wired)", 0, XTYPE_XBOX360 },
@@ -1110,8 +1112,13 @@ static void xpadone_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char
 		}
 
 		/* TL/TR */
-		input_report_key(dev, BTN_TL,	data[5] & BIT(4));
-		input_report_key(dev, BTN_TR,	data[5] & BIT(5));
+		if (xpad->mapping & MAP_ATROX) {
+			input_report_key(dev, BTN_TL, data[5] & BIT(5));
+			input_report_key(dev, BTN_TR, data[5] & BIT(4));
+		} else {
+			input_report_key(dev, BTN_TL, data[5] & BIT(4));
+			input_report_key(dev, BTN_TR, data[5] & BIT(5));
+		}
 
 		/* stick press left/right */
 		input_report_key(dev, BTN_THUMBL, data[5] & BIT(6));
@@ -1133,10 +1140,15 @@ static void xpadone_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char
 
 		/* triggers left/right */
 		if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) {
-			input_report_key(dev, BTN_TL2,
-					(__u16) le16_to_cpup((__le16 *)(data + 6)));
-			input_report_key(dev, BTN_TR2,
-					(__u16) le16_to_cpup((__le16 *)(data + 8)));
+			if ((xpad->mapping & MAP_ATROX) && len > 22) {
+				input_report_key(dev, BTN_TL2, data[22] & BIT(7));
+				input_report_key(dev, BTN_TR2, data[22] & BIT(6));
+			} else {
+				input_report_key(dev, BTN_TL2,
+						(__u16) le16_to_cpup((__le16 *)(data + 6)));
+				input_report_key(dev, BTN_TR2,
+						(__u16) le16_to_cpup((__le16 *)(data + 8)));
+			}
 		} else {
 			input_report_abs(dev, ABS_Z,
 					(__u16) le16_to_cpup((__le16 *)(data + 6)));
-- 
2.53.0


             reply	other threads:[~2026-08-07 14:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-07 14:14 Vernon Di Carlo [this message]
2026-08-07 14:22 ` [PATCH] Input: xpad - fix button mapping on Razer Atrox Xbox One sashiko-bot
2026-08-07 14:41 ` [PATCH v2] " Vernon Di Carlo
2026-08-07 14:58   ` sashiko-bot

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=20260807141419.7930-1-vernondicarlo@gmail.com \
    --to=vernondicarlo@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@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.