diff mbox series

[1/2] Input: xpad - name unknown gamepads according to device type

Message ID 20211116172334.06578aaf@rechenknecht2k11 (mailing list archive)
State New, archived
Headers show
Series [1/2] Input: xpad - name unknown gamepads according to device type | expand

Commit Message

Benjamin Valentin Nov. 16, 2021, 4:23 p.m. UTC
Calling any unknown device 'Generic X-Box pad' can lead to confusion
as a user might think the device type was not properly detected.

The different controller generations also have different button numbers
and mappings.

Instead use a device type specific name so it's immediately clear that
the device has been recognized.

This means we can now drop the "Generic X-Box pad" entry.
To allow the entire line to be 0, re-order the device types so that
'UNKNOWN' is 0 now too.

Signed-off-by: Benjamin Valentin <benpicco@googlemail.com>
---
 drivers/input/joystick/xpad.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 4c914f75a902..31a268f43b5b 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -83,11 +83,11 @@ 
 #define DANCEPAD_MAP_CONFIG	(MAP_DPAD_TO_BUTTONS |			\
 				MAP_TRIGGERS_TO_BUTTONS | MAP_STICKS_TO_NULL)
 
-#define XTYPE_XBOX        0
-#define XTYPE_XBOX360     1
-#define XTYPE_XBOX360W    2
-#define XTYPE_XBOXONE     3
-#define XTYPE_UNKNOWN     4
+#define XTYPE_UNKNOWN     0
+#define XTYPE_XBOX        1
+#define XTYPE_XBOX360     2
+#define XTYPE_XBOX360W    3
+#define XTYPE_XBOXONE     4
 
 static bool dpad_to_buttons;
 module_param(dpad_to_buttons, bool, S_IRUGO);
@@ -337,7 +337,7 @@  static const struct xpad_device {
 	{ 0x3285, 0x0607, "Nacon GC-100", 0, XTYPE_XBOX360 },
 	{ 0x3767, 0x0101, "Fanatec Speedster 3 Forceshock Wheel", 0, XTYPE_XBOX },
 	{ 0xffff, 0xffff, "Chinese-made Xbox Controller", 0, XTYPE_XBOX },
-	{ 0x0000, 0x0000, "Generic X-Box pad", 0, XTYPE_UNKNOWN }
+	{ }
 };
 
 /* buttons shared with xbox and xbox360 */
@@ -1783,14 +1783,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 = "Xbox 360 wireless pad";
+			} else if (intf->cur_altsetting->desc.bInterfaceProtocol == 208) {
 				xpad->xtype = XTYPE_XBOXONE;
-			else
+				xpad->name = "Xbox One pad";
+			} else {
 				xpad->xtype = XTYPE_XBOX360;
+				xpad->name = "Xbox 360 pad";
+			}
 		} else {
 			xpad->xtype = XTYPE_XBOX;
+			xpad->name = "Xbox classic pad";
 		}
 
 		if (dpad_to_buttons)