Re: [PATCH] Input: xpad - fix button mapping on Razer Atrox Xbox One

[email protected] Fri, 07 Aug 2026 14:22:04 +0000
Newsgroups org.kernel.vger.linux-input
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Incorrect fallback logic for short packets on Razer Atrox Xbox One controllers
--

--- Patch [1]: [PATCH] Input: xpad - fix button mapping on Razer Atrox Xbox One ---
commit 13a313431546b71a3cf1a1ca198625dd7324af1f
Author: Vernon Di Carlo <[email protected]>

Input: xpad - fix button mapping on Razer Atrox Xbox One

This commit adds a specific mapping quirk for the Razer Atrox Arcade Stick
to swap LB/RB and correctly report the digital LT/RT states from byte 22.

> diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
> index feb8f368f834e..b9daa334e038b 100644
> --- a/drivers/input/joystick/xpad.c
> +++ b/drivers/input/joystick/xpad.c
[ ... ]
> @@ -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 {

[Severity: Medium]
If a Razer Atrox controller sends a packet with a length of 22 bytes or
fewer, won't this fall through to the else block?

Does this cause the driver to incorrectly interpret data[6] and data[8]
as trigger states and report spurious trigger events for this device?

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

-- 
Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=1