From: Benjamin Valentin <benpicco@googlemail.com>
To: Cameron Gutman <aicommander@gmail.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
linux-input@vger.kernel.org, Lee Jones <lee.jones@linaro.org>
Subject: [PATCH 1/2] Input: xpad - name unknown gamepads according to device type
Date: Tue, 16 Nov 2021 17:23:34 +0100 [thread overview]
Message-ID: <20211116172334.06578aaf@rechenknecht2k11> (raw)
In-Reply-To: <3b25f4b1-3ec0-0878-99bc-0da06ce7c2f2@gmail.com>
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 --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)
--
2.32.0
next prev parent reply other threads:[~2021-11-16 16:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-13 13:11 [PATCH] Input: xpad - Poweroff XBOX360W on mode button long press Benjamin Valentin
2021-11-14 1:52 ` Cameron Gutman
2021-11-14 19:23 ` [PATCH v2] " Benjamin Valentin
2021-11-16 16:23 ` Benjamin Valentin [this message]
2021-11-16 16:25 ` [PATCH 2/2] Input: xpad - drop checks for XTYPE_UNKNOWN Benjamin Valentin
2022-01-05 11:53 ` [RESEND][PATCH v2] Input: xpad - Poweroff XBOX360W on mode button long press Benjamin Valentin
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=20211116172334.06578aaf@rechenknecht2k11 \
--to=benpicco@googlemail.com \
--cc=aicommander@gmail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=lee.jones@linaro.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).