Re: Input: xpad - add more Xbox one controller IDs
From: Cameron Gutman <hidden>
Date: 2021-11-14 21:14:45
On 11/14/21 14:37, Benjamin Valentin wrote:
On Sun, 14 Nov 2021 20:51:22 +0100 Benjamin Valentin [off-list ref] wrote:quoted
The problem is that the gamepad then gets assigned the type XTYPE_UNKNOWN which excludes it from all run-time code path switches.Ah sorry for the noise. xpad_probe() already takes care of detecting the gamepad type for the XTYPE_UNKNOWN case. And this works for my Xbox 360 pad - not sure what's wrong with jstest, but that is unrelated.
Ah okay good, that's what I was expecting.
quoted hunk ↗ jump to hunk
To avoid that confusion, how aboutdiff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c index 4c914f75a902..155ee644295d 100644 --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c @@ -1783,14 +1785,19 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id if (xpad->xtype == XTYPE_UNKNOWN) { if (intf->cur_altsetting->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC) { - if (intf->cur_altsetting->desc.bInterfaceProtocol == 129) + if (intf->cur_altsetting->desc.bInterfaceProtocol == 129) { xpad->xtype = XTYPE_XBOX360W; - else if (intf->cur_altsetting->desc.bInterfaceProtocol == 208) + xpad->name = "Generic Xbox 360 wireless pad"; + } else if (intf->cur_altsetting->desc.bInterfaceProtocol == 208) { xpad->xtype = XTYPE_XBOXONE; - else + xpad->name = "Generic Xbox One pad"; + } else { xpad->xtype = XTYPE_XBOX360; + xpad->name = "Generic Xbox 360 pad"; + } } else { xpad->xtype = XTYPE_XBOX; + xpad->name = "Generic Xbox classic pad"; } if (dpad_to_buttons)
I like this idea. There's a small risk of causing userspace breakages for games matching "Generic X-Box pad" by name, but we already run that risk each time we update xpad_devices[] anyway. You might even consider dropping "Generic" from the name and just call them "Xbox One gamepad" or similar. Can you also replace "Generic X-Box pad" with NULL in xpad_devices[]? I don't think it would ever be used anymore after this change. Regards, Cameron