All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vicki Pfau <vi@endrift.com>
To: Jiri Kosina <jikos@kernel.org>,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>,
	linux-input@vger.kernel.org, Pavel Rojtberg <rojtberg@gmail.com>
Cc: Vicki Pfau <vi@endrift.com>, Andrey Smirnov <andrew.smirnov@gmail.com>
Subject: [PATCH 1/3] Input: xpad - fix support for some third-party controllers
Date: Fri, 24 Feb 2023 17:21:46 -0800	[thread overview]
Message-ID: <20230225012147.276489-2-vi@endrift.com> (raw)
In-Reply-To: <20230225012147.276489-1-vi@endrift.com>

Some third-party controllers, such as the HORPIAD FPS for Nintendo Switch and
Gamesir-G3w, require a specific packet that the first-party XInput driver sends
before it will start sending reports. It's not currently known what this packet
does, but since the first-party driver always sends it's unlikely that this
could cause issues with existing controllers.

Co-authored-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Vicki Pfau <vi@endrift.com>
---
 drivers/input/joystick/xpad.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 403b57e8176b..04af2213407f 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -265,6 +265,7 @@ static const struct xpad_device {
 	{ 0x0f0d, 0x0067, "HORIPAD ONE", 0, XTYPE_XBOXONE },
 	{ 0x0f0d, 0x0078, "Hori Real Arcade Pro V Kai Xbox One", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE },
 	{ 0x0f0d, 0x00c5, "Hori Fighting Commander ONE", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE },
+	{ 0x0f0d, 0x00dc, "HORIPAD FPS for Nintendo Switch", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
 	{ 0x0f30, 0x010b, "Philips Recoil", 0, XTYPE_XBOX },
 	{ 0x0f30, 0x0202, "Joytech Advanced Controller", 0, XTYPE_XBOX },
 	{ 0x0f30, 0x8888, "BigBen XBMiniPad Controller", 0, XTYPE_XBOX },
@@ -2020,6 +2021,27 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
 		goto err_free_in_urb;
 	}
 
+	if (xpad->xtype == XTYPE_XBOX360) {
+		/* Some third-party controllers Xbox 360-style controllers
+		 * require this message to finish initialization */
+		uint8_t dummy[20];
+		int ret;
+
+		usb_control_msg_recv(udev, 0,
+				     /* bRequest */ 0x01,
+				     /* bmRequestType */
+				     USB_TYPE_VENDOR | USB_DIR_IN |
+				     USB_RECIP_INTERFACE,
+				     /* wValue */ 0x100,
+				     /* wIndex */ 0x00,
+				     dummy, sizeof(dummy),
+				     25,
+				     GFP_KERNEL);
+		if (ret)
+			dev_warn(&xpad->dev->dev,
+				 "unable to receive magic message: %d\n", ret);
+	}
+
 	ep_irq_in = ep_irq_out = NULL;
 
 	for (i = 0; i < 2; i++) {
-- 
2.39.2


  reply	other threads:[~2023-02-25  1:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-25  1:21 [PATCH 0/3] Input: xpad - Additional controller support Vicki Pfau
2023-02-25  1:21 ` Vicki Pfau [this message]
2023-03-23 21:39   ` [PATCH 1/3] Input: xpad - fix support for some third-party controllers Lyude Paul
2023-03-23 22:01     ` Lyude Paul
2023-03-24  1:30   ` Dmitry Torokhov
2023-03-24  4:06     ` Vicki Pfau
2023-02-25  1:21 ` [PATCH 2/3] Input: xpad - remove unused field in VID/PID table Vicki Pfau
2023-03-24  1:33   ` Dmitry Torokhov
2023-02-25  1:21 ` [PATCH 3/3] Input: xpad - Add VID for Turtle Beach controllers Vicki Pfau
2023-03-24  1:33   ` Dmitry Torokhov

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=20230225012147.276489-2-vi@endrift.com \
    --to=vi@endrift.com \
    --cc=andrew.smirnov@gmail.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=rojtberg@gmail.com \
    /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.