diff mbox series

[1/3] Input: xpad - fix support for some third-party controllers

Message ID 20230225012147.276489-2-vi@endrift.com (mailing list archive)
State New, archived
Headers show
Series Input: xpad - Additional controller support | expand

Commit Message

Vicki Pfau Feb. 25, 2023, 1:21 a.m. UTC
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(+)

Comments

Lyude Paul March 23, 2023, 9:39 p.m. UTC | #1
Hey Dmitry, this patch series seems to have only gotten radio silence as well.
What could we do to get this moving?

On Fri, 2023-02-24 at 17:21 -0800, Vicki Pfau wrote:
> 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++) {
Lyude Paul March 23, 2023, 10:01 p.m. UTC | #2
Ah wnoops, Vicki pointed out I made a mistake here and that this one is still
awaiting reviews from someone. will review in just a moment

On Thu, 2023-03-23 at 17:39 -0400, Lyude Paul wrote:
> Hey Dmitry, this patch series seems to have only gotten radio silence as well.
> What could we do to get this moving?
> 
> On Fri, 2023-02-24 at 17:21 -0800, Vicki Pfau wrote:
> > 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++) {
>
Dmitry Torokhov March 24, 2023, 1:30 a.m. UTC | #3
On Fri, Feb 24, 2023 at 05:21:46PM -0800, Vicki Pfau wrote:
> 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);

You are not setting "ret", how was this tested?

> +	}
> +
>  	ep_irq_in = ep_irq_out = NULL;
>  
>  	for (i = 0; i < 2; i++) {
> -- 
> 2.39.2
>
Vicki Pfau March 24, 2023, 4:06 a.m. UTC | #4
On 3/23/23 18:30, Dmitry Torokhov wrote:
> On Fri, Feb 24, 2023 at 05:21:46PM -0800, Vicki Pfau wrote:
>> 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);
> 
> You are not setting "ret", how was this tested?

Presumably with a stack frame that had that space unwittingly initialized to zero. Good catch, thanks. I've resubmitted with this fixed in v2.

> 
>> +	}
>> +
>>  	ep_irq_in = ep_irq_out = NULL;
>>  
>>  	for (i = 0; i < 2; i++) {
>> -- 
>> 2.39.2
>>
>
diff mbox series

Patch

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