linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] HID: support the NACON / BigBen PS4 / PC Compact controller
@ 2022-12-23 17:21 Giuseppe Bilotta
  2022-12-27 16:28 ` Roderick Colenbrander
  0 siblings, 1 reply; 4+ messages in thread
From: Giuseppe Bilotta @ 2022-12-23 17:21 UTC (permalink / raw)
  To: Linux Input ML
  Cc: Giuseppe Bilotta, Dmitry Torokhov, Jiri Kosina, Roderick Colenbrander

---

I have recently come into possession of a NACON / Big Ben Interactive
USB wired PC Compact controller (USB vendor:device 146b:0603).
This is advertised as an «officially licensed PS4™ wired controller»
that «also boasts full compatibility with PC games».

It is supposed to be similar to a DualShock 4 controller except for the
lack of built-in speaker, light bar and “SIXAXIS” motion sensor.
In particular, in addition to the typical gamepad goodies, it has a
built-in touchpad and an audio jack.

As things are currently, the Linux kernel automatically matches it with
the xpad driver, that detects this as a “Generic X-Box controller”.
This kind of works, but in addition to minor issues such as the default
axis mapping being wrong (which could be fixed in the xpad driver),
the major downside for the xpad driver binding to the controller
is that it fails to expose the touchpad and the audio jack.

My hope was to let the xpad driver skip this device, and to manage it
through the hid subsystem, expecting the hid-sony and/or hid-playstation
drivers to be able to manage it.

However, I obviously don't understand enough about how the hid driver
manages the bindings, and so far I've been at a loss about making this
work. The hack to ignore the device in xpad works, although it's a
horrible hack that probably shouldn't be needed in the first place,
but the HID subsystem doesn't seem to pick up the device.
This patch is my very poor (and currently NOT WORKING) attempt,
and since I'm obviously going at this all wrong, I'd be glad for
any recommendations on how to approach this.

Cheers,

Giuseppe Bilotta


 drivers/hid/hid-ids.h         | 1 +
 drivers/hid/hid-playstation.c | 5 ++++-
 drivers/hid/hid-quirks.c      | 1 +
 drivers/hid/hid-sony.c        | 3 +++
 drivers/input/joystick/xpad.c | 5 +++++
 5 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 82713ef3aaa6..78d993415071 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -250,6 +250,7 @@
 #define USB_VENDOR_ID_BETOP_2185V2BFM	0x20bc
 
 #define USB_VENDOR_ID_BIGBEN	0x146b
+#define USB_DEVICE_ID_BIGBEN_PC_COMPACT_CONTROLLER	0x0603
 #define USB_DEVICE_ID_BIGBEN_PS3OFMINIPAD	0x0902
 
 #define USB_VENDOR_ID_BTC		0x046e
diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c
index f399bf0d3c8c..8302394479bd 100644
--- a/drivers/hid/hid-playstation.c
+++ b/drivers/hid/hid-playstation.c
@@ -2589,7 +2589,8 @@ static int ps_probe(struct hid_device *hdev, const struct hid_device_id *id)
 		goto err_stop;
 	}
 
-	if (hdev->product == USB_DEVICE_ID_SONY_PS4_CONTROLLER ||
+	if (hdev->product == USB_DEVICE_ID_BIGBEN_PC_COMPACT_CONTROLLER ||
+		hdev->product == USB_DEVICE_ID_SONY_PS4_CONTROLLER ||
 		hdev->product == USB_DEVICE_ID_SONY_PS4_CONTROLLER_2 ||
 		hdev->product == USB_DEVICE_ID_SONY_PS4_CONTROLLER_DONGLE) {
 		dev = dualshock4_create(hdev);
@@ -2632,6 +2633,8 @@ static void ps_remove(struct hid_device *hdev)
 }
 
 static const struct hid_device_id ps_devices[] = {
+	/* NACON / BigBen Interact Wired PC Compact controller */
+	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_BIGBEN, USB_DEVICE_ID_BIGBEN_PC_COMPACT_CONTROLLER) },
 	/* Sony DualShock 4 controllers for PS4 */
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER) },
diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c
index 0e9702c7f7d6..fa9503257621 100644
--- a/drivers/hid/hid-quirks.c
+++ b/drivers/hid/hid-quirks.c
@@ -639,6 +639,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
 	{ HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_5_PRO) },
 #endif
 #if IS_ENABLED(CONFIG_HID_SONY)
+	{ HID_USB_DEVICE(USB_VENDOR_ID_BIGBEN, USB_DEVICE_ID_BIGBEN_PC_COMPACT_CONTROLLER) },
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_PS3) },
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SMK, USB_DEVICE_ID_SMK_PS3_BDREMOTE) },
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SMK, USB_DEVICE_ID_SMK_NSG_MR5U_REMOTE) },
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index 13125997ab5e..4f5d5643dd19 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -3180,6 +3180,9 @@ static const struct hid_device_id sony_devices[] = {
 	/* SMK-Link PS3 BD Remote Control */
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SMK, USB_DEVICE_ID_SMK_PS3_BDREMOTE),
 		.driver_data = PS3REMOTE },
+	/* NACON / BigBen Interact Wired PC Compact controller */
+	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_BIGBEN, USB_DEVICE_ID_BIGBEN_PC_COMPACT_CONTROLLER),
+		.driver_data = DUALSHOCK4_CONTROLLER_USB },
 	/* Sony Dualshock 4 controllers for PS4 */
 	{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER),
 		.driver_data = DUALSHOCK4_CONTROLLER_USB },
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 2959d80f7fdb..d3d3ce84bd6c 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -92,6 +92,7 @@
 #define XTYPE_XBOX360W    2
 #define XTYPE_XBOXONE     3
 #define XTYPE_UNKNOWN     4
+#define XTYPE_NOTXBOX     0xff
 
 /* Send power-off packet to xpad360w after holding the mode button for this many
  * seconds
@@ -281,6 +282,7 @@ static const struct xpad_device {
 	{ 0x1430, 0x8888, "TX6500+ Dance Pad (first generation)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
 	{ 0x1430, 0xf801, "RedOctane Controller", 0, XTYPE_XBOX360 },
 	{ 0x146b, 0x0601, "BigBen Interactive XBOX 360 Controller", 0, XTYPE_XBOX360 },
+	{ 0x146b, 0x0603, "BigBen Interactive PC Compact Controller", 0, XTYPE_NOTXBOX },
 	{ 0x146b, 0x0604, "Bigben Interactive DAIJA Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
 	{ 0x1532, 0x0037, "Razer Sabertooth", 0, XTYPE_XBOX360 },
 	{ 0x1532, 0x0a00, "Razer Atrox Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE },
@@ -1951,6 +1953,9 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
 			break;
 	}
 
+	if (xpad_device[i].xtype == XTYPE_NOTXBOX)
+		return -ENODEV;
+
 	xpad = kzalloc(sizeof(struct usb_xpad), GFP_KERNEL);
 	if (!xpad)
 		return -ENOMEM;
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [RFC PATCH] HID: support the NACON / BigBen PS4 / PC Compact controller
  2022-12-23 17:21 [RFC PATCH] HID: support the NACON / BigBen PS4 / PC Compact controller Giuseppe Bilotta
@ 2022-12-27 16:28 ` Roderick Colenbrander
  2023-01-22 11:43   ` Giuseppe Bilotta
  0 siblings, 1 reply; 4+ messages in thread
From: Roderick Colenbrander @ 2022-12-27 16:28 UTC (permalink / raw)
  To: Giuseppe Bilotta
  Cc: Linux Input ML, Dmitry Torokhov, Jiri Kosina, Roderick Colenbrander

Hi Giuseppe,

Thanks for your work so far. My first thought was 'yikes what an ugly
device'. I'm not really sure what the best way of handling it is.

First is the device a HID device? It would normally be picked up by
hid-generic. You can try dumping the HID descriptors.

It is a bit ugly if the device has to spawn multiple drivers. My
initial gut feeling would have been to complete the support within the
xpad driver. My understanding of our licensed controllers is that the
HID protocol they use is different from the DS4 protocol, so it is
really like handling an entire new device needing its own HID report
parsing. So, no matter what each driver would have needed some changes
to deal with the device properly and it is probably smallest in xpad.
You mention access flipping and then the touchpad.

Thanks,
Roderick

On Fri, Dec 23, 2022 at 9:25 AM Giuseppe Bilotta
<giuseppe.bilotta@gmail.com> wrote:
>
> ---
>
> I have recently come into possession of a NACON / Big Ben Interactive
> USB wired PC Compact controller (USB vendor:device 146b:0603).
> This is advertised as an «officially licensed PS4™ wired controller»
> that «also boasts full compatibility with PC games».
>
> It is supposed to be similar to a DualShock 4 controller except for the
> lack of built-in speaker, light bar and “SIXAXIS” motion sensor.
> In particular, in addition to the typical gamepad goodies, it has a
> built-in touchpad and an audio jack.
>
> As things are currently, the Linux kernel automatically matches it with
> the xpad driver, that detects this as a “Generic X-Box controller”.
> This kind of works, but in addition to minor issues such as the default
> axis mapping being wrong (which could be fixed in the xpad driver),
> the major downside for the xpad driver binding to the controller
> is that it fails to expose the touchpad and the audio jack.
>
> My hope was to let the xpad driver skip this device, and to manage it
> through the hid subsystem, expecting the hid-sony and/or hid-playstation
> drivers to be able to manage it.
>
> However, I obviously don't understand enough about how the hid driver
> manages the bindings, and so far I've been at a loss about making this
> work. The hack to ignore the device in xpad works, although it's a
> horrible hack that probably shouldn't be needed in the first place,
> but the HID subsystem doesn't seem to pick up the device.
> This patch is my very poor (and currently NOT WORKING) attempt,
> and since I'm obviously going at this all wrong, I'd be glad for
> any recommendations on how to approach this.
>
> Cheers,
>
> Giuseppe Bilotta
>
>
>  drivers/hid/hid-ids.h         | 1 +
>  drivers/hid/hid-playstation.c | 5 ++++-
>  drivers/hid/hid-quirks.c      | 1 +
>  drivers/hid/hid-sony.c        | 3 +++
>  drivers/input/joystick/xpad.c | 5 +++++
>  5 files changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
> index 82713ef3aaa6..78d993415071 100644
> --- a/drivers/hid/hid-ids.h
> +++ b/drivers/hid/hid-ids.h
> @@ -250,6 +250,7 @@
>  #define USB_VENDOR_ID_BETOP_2185V2BFM  0x20bc
>
>  #define USB_VENDOR_ID_BIGBEN   0x146b
> +#define USB_DEVICE_ID_BIGBEN_PC_COMPACT_CONTROLLER     0x0603
>  #define USB_DEVICE_ID_BIGBEN_PS3OFMINIPAD      0x0902
>
>  #define USB_VENDOR_ID_BTC              0x046e
> diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c
> index f399bf0d3c8c..8302394479bd 100644
> --- a/drivers/hid/hid-playstation.c
> +++ b/drivers/hid/hid-playstation.c
> @@ -2589,7 +2589,8 @@ static int ps_probe(struct hid_device *hdev, const struct hid_device_id *id)
>                 goto err_stop;
>         }
>
> -       if (hdev->product == USB_DEVICE_ID_SONY_PS4_CONTROLLER ||
> +       if (hdev->product == USB_DEVICE_ID_BIGBEN_PC_COMPACT_CONTROLLER ||
> +               hdev->product == USB_DEVICE_ID_SONY_PS4_CONTROLLER ||
>                 hdev->product == USB_DEVICE_ID_SONY_PS4_CONTROLLER_2 ||
>                 hdev->product == USB_DEVICE_ID_SONY_PS4_CONTROLLER_DONGLE) {
>                 dev = dualshock4_create(hdev);
> @@ -2632,6 +2633,8 @@ static void ps_remove(struct hid_device *hdev)
>  }
>
>  static const struct hid_device_id ps_devices[] = {
> +       /* NACON / BigBen Interact Wired PC Compact controller */
> +       { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_BIGBEN, USB_DEVICE_ID_BIGBEN_PC_COMPACT_CONTROLLER) },
>         /* Sony DualShock 4 controllers for PS4 */
>         { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER) },
>         { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER) },
> diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c
> index 0e9702c7f7d6..fa9503257621 100644
> --- a/drivers/hid/hid-quirks.c
> +++ b/drivers/hid/hid-quirks.c
> @@ -639,6 +639,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
>         { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_5_PRO) },
>  #endif
>  #if IS_ENABLED(CONFIG_HID_SONY)
> +       { HID_USB_DEVICE(USB_VENDOR_ID_BIGBEN, USB_DEVICE_ID_BIGBEN_PC_COMPACT_CONTROLLER) },
>         { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_PS3) },
>         { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SMK, USB_DEVICE_ID_SMK_PS3_BDREMOTE) },
>         { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SMK, USB_DEVICE_ID_SMK_NSG_MR5U_REMOTE) },
> diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
> index 13125997ab5e..4f5d5643dd19 100644
> --- a/drivers/hid/hid-sony.c
> +++ b/drivers/hid/hid-sony.c
> @@ -3180,6 +3180,9 @@ static const struct hid_device_id sony_devices[] = {
>         /* SMK-Link PS3 BD Remote Control */
>         { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SMK, USB_DEVICE_ID_SMK_PS3_BDREMOTE),
>                 .driver_data = PS3REMOTE },
> +       /* NACON / BigBen Interact Wired PC Compact controller */
> +       { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_BIGBEN, USB_DEVICE_ID_BIGBEN_PC_COMPACT_CONTROLLER),
> +               .driver_data = DUALSHOCK4_CONTROLLER_USB },
>         /* Sony Dualshock 4 controllers for PS4 */
>         { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER),
>                 .driver_data = DUALSHOCK4_CONTROLLER_USB },
> diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
> index 2959d80f7fdb..d3d3ce84bd6c 100644
> --- a/drivers/input/joystick/xpad.c
> +++ b/drivers/input/joystick/xpad.c
> @@ -92,6 +92,7 @@
>  #define XTYPE_XBOX360W    2
>  #define XTYPE_XBOXONE     3
>  #define XTYPE_UNKNOWN     4
> +#define XTYPE_NOTXBOX     0xff
>
>  /* Send power-off packet to xpad360w after holding the mode button for this many
>   * seconds
> @@ -281,6 +282,7 @@ static const struct xpad_device {
>         { 0x1430, 0x8888, "TX6500+ Dance Pad (first generation)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
>         { 0x1430, 0xf801, "RedOctane Controller", 0, XTYPE_XBOX360 },
>         { 0x146b, 0x0601, "BigBen Interactive XBOX 360 Controller", 0, XTYPE_XBOX360 },
> +       { 0x146b, 0x0603, "BigBen Interactive PC Compact Controller", 0, XTYPE_NOTXBOX },
>         { 0x146b, 0x0604, "Bigben Interactive DAIJA Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
>         { 0x1532, 0x0037, "Razer Sabertooth", 0, XTYPE_XBOX360 },
>         { 0x1532, 0x0a00, "Razer Atrox Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE },
> @@ -1951,6 +1953,9 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
>                         break;
>         }
>
> +       if (xpad_device[i].xtype == XTYPE_NOTXBOX)
> +               return -ENODEV;
> +
>         xpad = kzalloc(sizeof(struct usb_xpad), GFP_KERNEL);
>         if (!xpad)
>                 return -ENOMEM;
> --
> 2.39.0
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC PATCH] HID: support the NACON / BigBen PS4 / PC Compact controller
  2022-12-27 16:28 ` Roderick Colenbrander
@ 2023-01-22 11:43   ` Giuseppe Bilotta
  2023-01-24  0:46     ` Roderick Colenbrander
  0 siblings, 1 reply; 4+ messages in thread
From: Giuseppe Bilotta @ 2023-01-22 11:43 UTC (permalink / raw)
  To: Roderick Colenbrander
  Cc: Linux Input ML, Dmitry Torokhov, Jiri Kosina, Roderick Colenbrander

Hello Roderick,

I'm terribly sorry for the late reply, it's a bit of a busy period for
me and I have had less time than I wished to test things.

> Thanks for your work so far. My first thought was 'yikes what an ugly
> device'. I'm not really sure what the best way of handling it is.

The patch is beyond ugly (in addition to not working). But I'm barely
treading water here, I'm way out of my element, hence why I came to
the ML looking for help 8-)

> First is the device a HID device? It would normally be picked up by
> hid-generic. You can try dumping the HID descriptors.

I'm afraid this is not the case, at least as far as I can tell. Again,
keep in mind I'm not even exactly sure how to check these things out,
so please bear with me, and feel free to direct me to appropriate
resources.
What I have tried is to first plug the pad in with xpad blacklisted,
and lsusb -vs the device, which gave me:

--8<-----------------
Bus 001 Device 006: ID 146b:0603 BigBen Interactive PC Compact Controller
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass          255 Vendor Specific Class
  bDeviceSubClass       255 Vendor Specific Subclass
  bDeviceProtocol       255 Vendor Specific Protocol
  bMaxPacketSize0        64
  idVendor           0x146b BigBen Interactive
  idProduct          0x0603
  bcdDevice            1.00
  iManufacturer           1 Bigben Interactive
  iProduct                2 PC Compact Controller
  iSerial                 3 58B00422
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0031
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              500mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass     93
      bInterfaceProtocol      1
      iInterface              0
      ** UNRECOGNIZED:  11 21 00 01 01 25 81 14 00 00 00 00 13 02 08 03 03
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               4
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               8
Device Status:     0x0000
  (Bus Powered)
--8<-----------------

I also tried running usbhid-dump, that claimed there were “No matching
HID interfaces”.

If I enable the xpad module shipping with my Debian sid distribution
(6.0.12-1 from 2022-12-09), there's no difference on the lsusb and
usbhid-dump outputs,
even though xpad seems to detect and bind with the device:

--8<-----------------
[Jan23 05:33] usb 1-1: new full-speed USB device number 7 using xhci_hcd
[  +0.149801] usb 1-1: New USB device found, idVendor=146b,
idProduct=0603, bcdDevice= 1.00
[  +0.000017] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  +0.000008] usb 1-1: Product: PC Compact Controller
[  +0.000006] usb 1-1: Manufacturer: Bigben Interactive
[  +0.000006] usb 1-1: SerialNumber: 58B00422
[  +0.068217] input: Generic X-Box pad as
/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/input/input35
[  +0.000114] usbcore: registered new interface driver xpad
--8<-----------------

Is there some other tool I can use to inspect the HID descriptors or
check which protocols are supported, possibly depending on the device
initialization?
(I have other gamepads whose behavior seems to depend on
initialization sequence, so this may be the case for this device too?)

> It is a bit ugly if the device has to spawn multiple drivers. My
> initial gut feeling would have been to complete the support within the
> xpad driver. My understanding of our licensed controllers is that the
> HID protocol they use is different from the DS4 protocol, so it is
> really like handling an entire new device needing its own HID report
> parsing. So, no matter what each driver would have needed some changes
> to deal with the device properly and it is probably smallest in xpad.

I don't have enough knowledge to know exactly what would be better,
but I would expect the protocol to be closer to the PS one than the
XBOX one,
even though out of the box it kind of works with xpad (modulo the
issues I mentioned).
I also have no idea how similar or different the PS and XBOX protocols
are, so it might just be that for the limited use and testing I've
done they match.

> You mention access flipping and then the touchpad.

Axes mapping is weird, but I think my original issue was actually with
jstest-gtk not using the correct information. The CLI jstest seems to
report things correctly.
The “touchpad” is a rectangular area above the joysticks and between
the DPAD and the box/triangle/x/o buttons. I'm not entirely surely if
it's a touchpad or something else,
but it seems to be clickable “everywhere”. It's not detected or
exposed by the xpad driver in any way, but  assume it would be
accessible in the protocol.
There's also something that looks like an audio jack.

I can run tests on this thing, but I really don't know what to try next.

Thank you for your reply, and looking forward for things to try,
Giuseppe Bilotta


>
> Thanks,
> Roderick
>
> On Fri, Dec 23, 2022 at 9:25 AM Giuseppe Bilotta
> <giuseppe.bilotta@gmail.com> wrote:
> >
> > ---
> >
> > I have recently come into possession of a NACON / Big Ben Interactive
> > USB wired PC Compact controller (USB vendor:device 146b:0603).
> > This is advertised as an «officially licensed PS4™ wired controller»
> > that «also boasts full compatibility with PC games».
> >
> > It is supposed to be similar to a DualShock 4 controller except for the
> > lack of built-in speaker, light bar and “SIXAXIS” motion sensor.
> > In particular, in addition to the typical gamepad goodies, it has a
> > built-in touchpad and an audio jack.
> >
> > As things are currently, the Linux kernel automatically matches it with
> > the xpad driver, that detects this as a “Generic X-Box controller”.
> > This kind of works, but in addition to minor issues such as the default
> > axis mapping being wrong (which could be fixed in the xpad driver),
> > the major downside for the xpad driver binding to the controller
> > is that it fails to expose the touchpad and the audio jack.
> >
> > My hope was to let the xpad driver skip this device, and to manage it
> > through the hid subsystem, expecting the hid-sony and/or hid-playstation
> > drivers to be able to manage it.
> >
> > However, I obviously don't understand enough about how the hid driver
> > manages the bindings, and so far I've been at a loss about making this
> > work. The hack to ignore the device in xpad works, although it's a
> > horrible hack that probably shouldn't be needed in the first place,
> > but the HID subsystem doesn't seem to pick up the device.
> > This patch is my very poor (and currently NOT WORKING) attempt,
> > and since I'm obviously going at this all wrong, I'd be glad for
> > any recommendations on how to approach this.
> >
> > Cheers,
> >
> > Giuseppe Bilotta
> >
> >
> >  drivers/hid/hid-ids.h         | 1 +
> >  drivers/hid/hid-playstation.c | 5 ++++-
> >  drivers/hid/hid-quirks.c      | 1 +
> >  drivers/hid/hid-sony.c        | 3 +++
> >  drivers/input/joystick/xpad.c | 5 +++++
> >  5 files changed, 14 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
> > index 82713ef3aaa6..78d993415071 100644
> > --- a/drivers/hid/hid-ids.h
> > +++ b/drivers/hid/hid-ids.h
> > @@ -250,6 +250,7 @@
> >  #define USB_VENDOR_ID_BETOP_2185V2BFM  0x20bc
> >
> >  #define USB_VENDOR_ID_BIGBEN   0x146b
> > +#define USB_DEVICE_ID_BIGBEN_PC_COMPACT_CONTROLLER     0x0603
> >  #define USB_DEVICE_ID_BIGBEN_PS3OFMINIPAD      0x0902
> >
> >  #define USB_VENDOR_ID_BTC              0x046e
> > diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c
> > index f399bf0d3c8c..8302394479bd 100644
> > --- a/drivers/hid/hid-playstation.c
> > +++ b/drivers/hid/hid-playstation.c
> > @@ -2589,7 +2589,8 @@ static int ps_probe(struct hid_device *hdev, const struct hid_device_id *id)
> >                 goto err_stop;
> >         }
> >
> > -       if (hdev->product == USB_DEVICE_ID_SONY_PS4_CONTROLLER ||
> > +       if (hdev->product == USB_DEVICE_ID_BIGBEN_PC_COMPACT_CONTROLLER ||
> > +               hdev->product == USB_DEVICE_ID_SONY_PS4_CONTROLLER ||
> >                 hdev->product == USB_DEVICE_ID_SONY_PS4_CONTROLLER_2 ||
> >                 hdev->product == USB_DEVICE_ID_SONY_PS4_CONTROLLER_DONGLE) {
> >                 dev = dualshock4_create(hdev);
> > @@ -2632,6 +2633,8 @@ static void ps_remove(struct hid_device *hdev)
> >  }
> >
> >  static const struct hid_device_id ps_devices[] = {
> > +       /* NACON / BigBen Interact Wired PC Compact controller */
> > +       { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_BIGBEN, USB_DEVICE_ID_BIGBEN_PC_COMPACT_CONTROLLER) },
> >         /* Sony DualShock 4 controllers for PS4 */
> >         { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER) },
> >         { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER) },
> > diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c
> > index 0e9702c7f7d6..fa9503257621 100644
> > --- a/drivers/hid/hid-quirks.c
> > +++ b/drivers/hid/hid-quirks.c
> > @@ -639,6 +639,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
> >         { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_5_PRO) },
> >  #endif
> >  #if IS_ENABLED(CONFIG_HID_SONY)
> > +       { HID_USB_DEVICE(USB_VENDOR_ID_BIGBEN, USB_DEVICE_ID_BIGBEN_PC_COMPACT_CONTROLLER) },
> >         { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_PS3) },
> >         { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SMK, USB_DEVICE_ID_SMK_PS3_BDREMOTE) },
> >         { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SMK, USB_DEVICE_ID_SMK_NSG_MR5U_REMOTE) },
> > diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
> > index 13125997ab5e..4f5d5643dd19 100644
> > --- a/drivers/hid/hid-sony.c
> > +++ b/drivers/hid/hid-sony.c
> > @@ -3180,6 +3180,9 @@ static const struct hid_device_id sony_devices[] = {
> >         /* SMK-Link PS3 BD Remote Control */
> >         { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SMK, USB_DEVICE_ID_SMK_PS3_BDREMOTE),
> >                 .driver_data = PS3REMOTE },
> > +       /* NACON / BigBen Interact Wired PC Compact controller */
> > +       { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_BIGBEN, USB_DEVICE_ID_BIGBEN_PC_COMPACT_CONTROLLER),
> > +               .driver_data = DUALSHOCK4_CONTROLLER_USB },
> >         /* Sony Dualshock 4 controllers for PS4 */
> >         { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER),
> >                 .driver_data = DUALSHOCK4_CONTROLLER_USB },
> > diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
> > index 2959d80f7fdb..d3d3ce84bd6c 100644
> > --- a/drivers/input/joystick/xpad.c
> > +++ b/drivers/input/joystick/xpad.c
> > @@ -92,6 +92,7 @@
> >  #define XTYPE_XBOX360W    2
> >  #define XTYPE_XBOXONE     3
> >  #define XTYPE_UNKNOWN     4
> > +#define XTYPE_NOTXBOX     0xff
> >
> >  /* Send power-off packet to xpad360w after holding the mode button for this many
> >   * seconds
> > @@ -281,6 +282,7 @@ static const struct xpad_device {
> >         { 0x1430, 0x8888, "TX6500+ Dance Pad (first generation)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
> >         { 0x1430, 0xf801, "RedOctane Controller", 0, XTYPE_XBOX360 },
> >         { 0x146b, 0x0601, "BigBen Interactive XBOX 360 Controller", 0, XTYPE_XBOX360 },
> > +       { 0x146b, 0x0603, "BigBen Interactive PC Compact Controller", 0, XTYPE_NOTXBOX },
> >         { 0x146b, 0x0604, "Bigben Interactive DAIJA Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
> >         { 0x1532, 0x0037, "Razer Sabertooth", 0, XTYPE_XBOX360 },
> >         { 0x1532, 0x0a00, "Razer Atrox Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE },
> > @@ -1951,6 +1953,9 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
> >                         break;
> >         }
> >
> > +       if (xpad_device[i].xtype == XTYPE_NOTXBOX)
> > +               return -ENODEV;
> > +
> >         xpad = kzalloc(sizeof(struct usb_xpad), GFP_KERNEL);
> >         if (!xpad)
> >                 return -ENOMEM;
> > --
> > 2.39.0
> >



-- 
Giuseppe "Oblomov" Bilotta

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC PATCH] HID: support the NACON / BigBen PS4 / PC Compact controller
  2023-01-22 11:43   ` Giuseppe Bilotta
@ 2023-01-24  0:46     ` Roderick Colenbrander
  0 siblings, 0 replies; 4+ messages in thread
From: Roderick Colenbrander @ 2023-01-24  0:46 UTC (permalink / raw)
  To: Giuseppe Bilotta
  Cc: Linux Input ML, Dmitry Torokhov, Jiri Kosina, Roderick Colenbrander

Hi Giuseppe,

On Sun, Jan 22, 2023 at 3:43 AM Giuseppe Bilotta
<giuseppe.bilotta@gmail.com> wrote:
>
> Hello Roderick,
>
> I'm terribly sorry for the late reply, it's a bit of a busy period for
> me and I have had less time than I wished to test things.
>
> > Thanks for your work so far. My first thought was 'yikes what an ugly
> > device'. I'm not really sure what the best way of handling it is.
>
> The patch is beyond ugly (in addition to not working). But I'm barely
> treading water here, I'm way out of my element, hence why I came to
> the ML looking for help 8-)
>
> > First is the device a HID device? It would normally be picked up by
> > hid-generic. You can try dumping the HID descriptors.
>
> I'm afraid this is not the case, at least as far as I can tell. Again,
> keep in mind I'm not even exactly sure how to check these things out,
> so please bear with me, and feel free to direct me to appropriate
> resources.
> What I have tried is to first plug the pad in with xpad blacklisted,
> and lsusb -vs the device, which gave me:
>
> --8<-----------------
> Bus 001 Device 006: ID 146b:0603 BigBen Interactive PC Compact Controller
> Device Descriptor:
>   bLength                18
>   bDescriptorType         1
>   bcdUSB               2.00
>   bDeviceClass          255 Vendor Specific Class
>   bDeviceSubClass       255 Vendor Specific Subclass
>   bDeviceProtocol       255 Vendor Specific Protocol
>   bMaxPacketSize0        64
>   idVendor           0x146b BigBen Interactive
>   idProduct          0x0603
>   bcdDevice            1.00
>   iManufacturer           1 Bigben Interactive
>   iProduct                2 PC Compact Controller
>   iSerial                 3 58B00422
>   bNumConfigurations      1
>   Configuration Descriptor:
>     bLength                 9
>     bDescriptorType         2
>     wTotalLength       0x0031
>     bNumInterfaces          1
>     bConfigurationValue     1
>     iConfiguration          0
>     bmAttributes         0x80
>       (Bus Powered)
>     MaxPower              500mA
>     Interface Descriptor:
>       bLength                 9
>       bDescriptorType         4
>       bInterfaceNumber        0
>       bAlternateSetting       0
>       bNumEndpoints           2
>       bInterfaceClass       255 Vendor Specific Class

You would normally expect bInterfaceClass to be 3 for 'Human Interface
Device'. I recall Xbox controllers in general have this at a vendor
specific value as they are not actual HID devices (with the exception
of in Bluetooth mode recently).

So it is not a formal HID device.

>       bInterfaceSubClass     93
>       bInterfaceProtocol      1
>       iInterface              0
>       ** UNRECOGNIZED:  11 21 00 01 01 25 81 14 00 00 00 00 13 02 08 03 03
>       Endpoint Descriptor:
>         bLength                 7
>         bDescriptorType         5
>         bEndpointAddress     0x81  EP 1 IN
>         bmAttributes            3
>           Transfer Type            Interrupt
>           Synch Type               None
>           Usage Type               Data
>         wMaxPacketSize     0x0040  1x 64 bytes
>         bInterval               4
>       Endpoint Descriptor:
>         bLength                 7
>         bDescriptorType         5
>         bEndpointAddress     0x02  EP 2 OUT
>         bmAttributes            3
>           Transfer Type            Interrupt
>           Synch Type               None
>           Usage Type               Data
>         wMaxPacketSize     0x0040  1x 64 bytes
>         bInterval               8
> Device Status:     0x0000
>   (Bus Powered)
> --8<-----------------
>
> I also tried running usbhid-dump, that claimed there were “No matching
> HID interfaces”.
>
> If I enable the xpad module shipping with my Debian sid distribution
> (6.0.12-1 from 2022-12-09), there's no difference on the lsusb and
> usbhid-dump outputs,
> even though xpad seems to detect and bind with the device:
>
> --8<-----------------
> [Jan23 05:33] usb 1-1: new full-speed USB device number 7 using xhci_hcd
> [  +0.149801] usb 1-1: New USB device found, idVendor=146b,
> idProduct=0603, bcdDevice= 1.00
> [  +0.000017] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
> [  +0.000008] usb 1-1: Product: PC Compact Controller
> [  +0.000006] usb 1-1: Manufacturer: Bigben Interactive
> [  +0.000006] usb 1-1: SerialNumber: 58B00422
> [  +0.068217] input: Generic X-Box pad as
> /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/input/input35
> [  +0.000114] usbcore: registered new interface driver xpad
> --8<-----------------
>
> Is there some other tool I can use to inspect the HID descriptors or
> check which protocols are supported, possibly depending on the device
> initialization?

The device doesn't seem to be a HID device, which is why there are no
descriptors. I haven't looked at the Xbox protocol in detail, but I
recall Xbox compatible devices report some magic value in some USB
descriptor, which is picked up by drivers and hence no need for a
formal driver unless overrides are needed.

> (I have other gamepads whose behavior seems to depend on
> initialization sequence, so this may be the case for this device too?)
>
> > It is a bit ugly if the device has to spawn multiple drivers. My
> > initial gut feeling would have been to complete the support within the
> > xpad driver. My understanding of our licensed controllers is that the
> > HID protocol they use is different from the DS4 protocol, so it is
> > really like handling an entire new device needing its own HID report
> > parsing. So, no matter what each driver would have needed some changes
> > to deal with the device properly and it is probably smallest in xpad.
>
> I don't have enough knowledge to know exactly what would be better,
> but I would expect the protocol to be closer to the PS one than the
> XBOX one,
> even though out of the box it kind of works with xpad (modulo the
> issues I mentioned).
> I also have no idea how similar or different the PS and XBOX protocols
> are, so it might just be that for the limited use and testing I've
> done they match.

So far it looks like the device is not a HID device, but only a USB
device. If true, you can't leverage the HID drivers and need to be in
a classic input driver such as xpad.

I'm honestly not sure how this device is working on PlayStation if it
is one of BigBen's licensed PlayStation compatible controllers. Our PS
input stack is all HID based (at least to my knowledge).

>
> > You mention access flipping and then the touchpad.
>
> Axes mapping is weird, but I think my original issue was actually with
> jstest-gtk not using the correct information. The CLI jstest seems to
> report things correctly.
> The “touchpad” is a rectangular area above the joysticks and between
> the DPAD and the box/triangle/x/o buttons. I'm not entirely surely if
> it's a touchpad or something else,
> but it seems to be clickable “everywhere”. It's not detected or
> exposed by the xpad driver in any way, but  assume it would be
> accessible in the protocol.
> There's also something that looks like an audio jack.
>

The key question is to figure out how this touchpad works. Maybe some
people in the community documented this somewhere.

> I can run tests on this thing, but I really don't know what to try next.
>
> Thank you for your reply, and looking forward for things to try,
> Giuseppe Bilotta
>
>

Thanks,
Roderick

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-01-24  0:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-23 17:21 [RFC PATCH] HID: support the NACON / BigBen PS4 / PC Compact controller Giuseppe Bilotta
2022-12-27 16:28 ` Roderick Colenbrander
2023-01-22 11:43   ` Giuseppe Bilotta
2023-01-24  0:46     ` Roderick Colenbrander

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).