mdqinc / SDL_GameControllerDB

A community sourced database of game controller mappings to be used with SDL2 Game Controller functionality
http://libsdl.org
zlib License
1.38k stars 520 forks source link

Duplicated/conflicting GUIDs for the DragonRise/PC TWIN SHOCK controllers #202

Open Swyter opened 6 years ago

Swyter commented 6 years ago

Turns out that many generic Chinese controllers based on the same PC TWIN SHOCK board from DragonRise Inc. share the same USB vendor (0x0079) and product (0x0006) identifiers, but they also use slightly different button layouts, causing conflicts because the SDL2 gamepad GUID cannot distinguish between them.

My NGS Phantom mainly conflicts with #86 in Linux, and the "G-Shark GS-GP702" in Windows. Funnily enough in macOS looks like the GUID is slightly different, for some reason.

These are the correct mappings for Linux, macOS and Windows:

03000000790000000600000010010000,NGS Phantom---LNX,a:b2,b:b3,x:b0,y:b1,back:b8,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:b6,righttrigger:b7,platform:Linux,
03000000790000000600000007010000,NGS Phantom---MAC,a:b2,b:b3,x:b0,y:b1,back:b8,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:b6,righttrigger:b7,platform:Mac OS X,
03000000790000000600000000000000,NGS Phantom---WIN,a:b2,b:b3,x:b0,y:b1,back:b8,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a4,lefttrigger:b6,righttrigger:b7,platform:Windows,

I ship a game with these community mappings and I'm having trouble playing with my own controller because everything is subtly broken.

PS: Maybe Ryan C. Gordon can add some additional optional bits to tell them apart. Maybe by optionally matching by VID/PID/Version/Revision/Firmware instead of only VID/PID.

imagen

Swyter commented 6 years ago

@panzergame @DanielGibson If you guys own some of the conflicting controllers, can you dump some USB stats to see if the name/version/revision/firmware fields are somewhat different?

I used USBDeview (https://www.nirsoft.net/utils/usb_devices_view.html), but a good old lsusb -v -d0079:0006 should be enough.

Swyter commented 6 years ago

This is my lsusb report:

[swyter@osgiliath ~]$ lsusb -v -d0079:0006

Bus 007 Device 002: ID 0079:0006 DragonRise Inc. PC TWIN SHOCK Gamepad
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.00
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x0079 DragonRise Inc.
  idProduct          0x0006 PC TWIN SHOCK Gamepad
  bcdDevice            1.07
  iManufacturer           1 DragonRise Inc.  
  iProduct                2 Generic   USB  Joystick  
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           41
    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         3 Human Interface Device
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.10
          bCountryCode           33 US
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength     101
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval              10
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval              10
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x0000
  (Bus Powered)
Swyter commented 6 years ago

I have opened a thread in the SDL2 Development board: https://discourse.libsdl.org/t/duplicated-conflicting-guids-for-the-dragonrise-pc-twin-shock-controllers/24112

Akaricchi commented 6 years ago

I can confirm this issue. I own a ~10 years old dualshock-style controller and a flight stick that share this GUID.

Topway faux-dualshock (not sure about the model):

# lsusb -vd 0079:0006

Bus 005 Device 004: ID 0079:0006 DragonRise Inc. PC TWIN SHOCK Gamepad
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.00
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x0079 DragonRise Inc.
  idProduct          0x0006 PC TWIN SHOCK Gamepad
  bcdDevice            1.07
  iManufacturer           1 DragonRise Inc.  
  iProduct                2 Generic   USB  Joystick  
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           41
    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         3 Human Interface Device
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.10
          bCountryCode           33 US
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength     101
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval              10
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval              10
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x0000
  (Bus Powered)

Defender Cobra R4:

Bus 005 Device 004: ID 0079:0006 DragonRise Inc. PC TWIN SHOCK Gamepad
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.00
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x0079 DragonRise Inc.
  idProduct          0x0006 PC TWIN SHOCK Gamepad
  bcdDevice            1.07
  iManufacturer           1 DragonRise Inc.  
  iProduct                2 Generic   USB  Joystick  
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           41
    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         3 Human Interface Device
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.10
          bCountryCode           33 US
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength     101
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval              10
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval              10

The difference is very minimal, unfortunately:

1c1
< Bus 005 Device 004: ID 0079:0006 DragonRise Inc. PC TWIN SHOCK Gamepad
---
> Bus 005 Device 005: ID 0079:0006 DragonRise Inc. PC TWIN SHOCK Gamepad
5c5
<   bcdUSB               1.00
---
>   bcdUSB               1.10
12,13c12,13
<   bcdDevice            1.07
<   iManufacturer           1 DragonRise Inc.  
---
>   bcdDevice            1.09
>   iManufacturer           0 

I don't think you can differentiate them based on that.

p-groarke commented 6 years ago

I don't want to close this issue for the moment, however this database doesn't have any (direct) ties to SDL itself :/ We are a community effort. As such, problems with the format have to be resolved on the SDL side of things.

@Swyter Opening a thread on the SDL forums is the right course of action.

For the db, we've had issues popping up about that specific controller from time to time. When it is changed, then a new issue will popup from another user complaining his mappings are broken. etc. while (true) ping_pong_issues();

Since the macOS mapping GUID is different, I will happily accept a PR with it. For the other platform mappings, the best resolution currently is to offer button remapping in your game. It isn't ideal, but it is still a highly recommended thing to do as our mappings are provided by the community and there are probably some messed up mappings in the db.

Feel free to keep discussing in this issue thread. Sorry I can't be of more help.

DanielGibson commented 6 years ago

Trust CXT24 gamepad (https://www.trust.com/en/product/17416-gxt-24-compact-gamepad):

Bus 003 Device 120: ID 0079:0006 DragonRise Inc. PC TWIN SHOCK Gamepad
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x0079 DragonRise Inc.
  idProduct          0x0006 PC TWIN SHOCK Gamepad
  bcdDevice            1.07
  iManufacturer           1 DragonRise Inc.  
  iProduct                2 Generic   USB  Joystick  
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           41
    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         3 Human Interface Device
      bInterfaceSubClass      0 No Subclass
      bInterfaceProtocol      0 None
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.10
          bCountryCode           33 US
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength     101
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval              10
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval              10
Device Status:     0x0000
  (Bus Powered)
p-groarke commented 6 years ago

Was this ever solved in SDL? Going to close the issue now, you can reopen if you need to.

clebercasali commented 5 years ago

Hello, as reported here: https://discourse.libsdl.org/t/different-game-controllers-with-the-same-guid/25773... I have two devices have the same GUID under Linux, same vendor/product id, but they’re not exactly the same. One is from Dragonrise, the other is actually from Microntek.

    Bus 002 Device 012: ID 0079:0006 DragonRise Inc. PC TWIN SHOCK Gamepad
    Device Descriptor:
    bLength 18
    bDescriptorType 1
    bcdUSB 1.00
    bDeviceClass 0 (Defined at Interface level)
    bDeviceSubClass 0
    bDeviceProtocol 0
    bMaxPacketSize0 8
    idVendor 0x0079 DragonRise Inc.
    idProduct 0x0006 PC TWIN SHOCK Gamepad
    bcdDevice 1.07
    iManufacturer 1 DragonRise Inc.
    iProduct 2 Generic USB Joystick
    iSerial 0
    bNumConfigurations 1
    Configuration Descriptor:
    bLength 9
    bDescriptorType 2
    wTotalLength 41
    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 3 Human Interface Device
    bInterfaceSubClass 0 No Subclass
    bInterfaceProtocol 0 None
    iInterface 0
    HID Device Descriptor:
    bLength 9
    bDescriptorType 33
    bcdHID 1.10
    bCountryCode 33 US
    bNumDescriptors 1
    bDescriptorType 34 Report
    wDescriptorLength 101
    Report Descriptors:
    ** UNAVAILABLE **
    Endpoint Descriptor:
    bLength 7
    bDescriptorType 5
    bEndpointAddress 0x81 EP 1 IN
    bmAttributes 3
    Transfer Type Interrupt
    Synch Type None
    Usage Type Data
    wMaxPacketSize 0x0008 1x 8 bytes
    bInterval 10
    Endpoint Descriptor:
    bLength 7
    bDescriptorType 5
    bEndpointAddress 0x01 EP 1 OUT
    bmAttributes 3
    Transfer Type Interrupt
    Synch Type None
    Usage Type Data
    wMaxPacketSize 0x0008 1x 8 bytes
    bInterval 10
    Device Status: 0x0000
    (Bus Powered)
    Bus 002 Device 013: ID 0079:0006 DragonRise Inc. PC TWIN SHOCK Gamepad
    Device Descriptor:
    bLength 18
    bDescriptorType 1
    bcdUSB 1.00
    bDeviceClass 0 (Defined at Interface level)
    bDeviceSubClass 0
    bDeviceProtocol 0
    bMaxPacketSize0 8
    idVendor 0x0079 DragonRise Inc.
    idProduct 0x0006 PC TWIN SHOCK Gamepad
    bcdDevice 1.07
    iManufacturer 1 Microntek
    iProduct 2 USB Joystick
    iSerial 0
    bNumConfigurations 1
    Configuration Descriptor:
    bLength 9
    bDescriptorType 2
    wTotalLength 41
    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 3 Human Interface Device
    bInterfaceSubClass 0 No Subclass
    bInterfaceProtocol 0 None
    iInterface 0
    HID Device Descriptor:
    bLength 9
    bDescriptorType 33
    bcdHID 1.10
    bCountryCode 33 US
    bNumDescriptors 1
    bDescriptorType 34 Report
    wDescriptorLength 107
    Report Descriptors:
    ** UNAVAILABLE **
    Endpoint Descriptor:
    bLength 7
    bDescriptorType 5
    bEndpointAddress 0x81 EP 1 IN
    bmAttributes 3
    Transfer Type Interrupt
    Synch Type None
    Usage Type Data
    wMaxPacketSize 0x0008 1x 8 bytes
    bInterval 10
    Endpoint Descriptor:
    bLength 7
    bDescriptorType 5
    bEndpointAddress 0x01 EP 1 OUT
    bmAttributes 3
    Transfer Type Interrupt
    Synch Type None
    Usage Type Data
    wMaxPacketSize 0x0008 1x 8 bytes
    bInterval 10
    Device Status: 0x0000
    (Bus Powered)
p-groarke commented 5 years ago

@clebercasali That's unfortunate, but it has to be resolved in SDL. We have no ties with SDL, we only provide community contributed mappings here.

clebercasali commented 5 years ago

Hi! Is there any official word from SDL on this? I couldn't find it.

p-groarke commented 5 years ago

I haven't heard anything new either. I guess the best way would be to open a bug ticket on their tracker. Hopefully this gets resolved at some point.

clebercasali commented 5 years ago

https://bugzilla.libsdl.org/show_bug.cgi?id=4545 Well, let's see what happens.

Swyter commented 2 years ago

I just found that for some reason the microcontroller of my gamepad seems to dump the entire configurable memory block (its 0x200 bytes of EEPROM? that wrap around) if I request the string descriptor with the index set to 3, 7 or 11. So it probably uses the two lowest bits to signal that.

# swy: install pyusb (pacman -S python-pyusb) and run python3 as sudo
>>> import usb.core, usb.control, usb.util, binascii
>>> dev = usb.core.find(idVendor=0x0079, idProduct=0x0006)

>>> binascii.hexlify(usb.control.get_descriptor(dev, 0x400, usb.util.DESC_TYPE_DEVICE, 0))
b'120100010000000879000600070101020001'
>>> binascii.hexlify(usb.control.get_descriptor(dev, 0x400, usb.util.DESC_TYPE_CONFIG, 0))
b'0902290001010080fa0904000002030000000921100121012265000705810308000a0705010308000a'

>>> binascii.hexlify(usb.control.get_descriptor(dev, 0x1000, usb.util.DESC_TYPE_STRING, 0))
b'04030904'
>>> binascii.hexlify(usb.control.get_descriptor(dev, 0x400, usb.util.DESC_TYPE_STRING, 1))
b'240344007200610067006f006e005200690073006500200049006e0063002e0020002000'
>>> binascii.hexlify(usb.control.get_descriptor(dev, 0x400, usb.util.DESC_TYPE_STRING, 2))
b'3403470065006e006500720069006300200020002000550053004200200020004a006f00790073007400690063006b0020002000'
>>> binascii.hexlify(usb.control.get_descriptor(dev, 0x400, usb.util.DESC_TYPE_STRING, 3))
b'120100010000000879000600070101020001ffffffffffff0902290001010080fa0904000002030000000921100121012265000705810308000a0705010308000affffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04030904ffffffff240344007200610067006f006e005200690073006500200049006e0063002e0020002000ffffffffffffffffffffffff3403470065006e006500720069006300200020002000550053004200200020004a006f00790073007400690063006b0020002000ffffffffffffffffffffffff05010904a101a10275089505150026ff00350046ff00093009310932093209358102750495012507463b0165140939814265007501950c2501450105091901290c81020600ff750195082501450109018102c0a1027508950746ff0026ff0009029102c0c0ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff120100010000000879000600070101020001ffffffffffff0902290001010080fa0904000002030000000921100121012265000705810308000a0705010308000affffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04030904ffffffff240344007200610067006f006e005200690073006500200049006e0063002e0020002000ffffffffffffffffffffffff3403470065006e006500720069006300200020002000550053004200200020004a006f00790073007400690063006b0020002000ffffffffffffffffffffffff05010904a101a10275089505150026ff00350046ff00093009310932093209358102750495012507463b0165140939814265007501950c2501450105091901290c81020600ff750195082501450109018102c0a1027508950746ff0026ff0009029102c0c0ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'

That contains at least;

  1. the device descriptor: 120100010000000879000600070101020001
  2. the configuration descriptor: 0902290001010080fa0904000002030000000921100121012265000705810308000a0705010308000a
  3. the string descriptor with the serial number 0904, which for some reason doesn't get dumped via lsusb: 04030904
  4. the vendor string, DragonRise Inc.: 240344007200610067006f006e005200690073006500200049006e0063002e0020002000
  5. the product string, Generic USB Joystick: 3403470065006e006500720069006300200020002000550053004200200020004a006f00790073007400690063006b0020002000
  6. the HID descriptor: 05010904A101A10275089505150026FF00350046FF00093009310932093209358102750495012507463B0165140939814265007501950C2501450105091901290C81020600FF750195082501450109018102C0A1027508950746FF0026FF0009029102C0C0

I wonder if we can hash that and maybe get some unique identifier from it. As you can see the data seems to wrap/end at offset 0x200. After that the data repeats.

0000h: 12 01 00 01 00 00 00 08 79 00 06 00 07 01 01 02  ........y....... 
0010h: 00 01 FF FF FF FF FF FF 09 02 29 00 01 01 00 80  ..ÿÿÿÿÿÿ..)....€ 
0020h: FA 09 04 00 00 02 03 00 00 00 09 21 10 01 21 01  ú..........!..!. 
0030h: 22 65 00 07 05 81 03 08 00 0A 07 05 01 03 08 00  "e.............. 
0040h: 0A FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF  .ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 
0050h: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 
0060h: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 
0070h: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 
0080h: FF FF FF FF FF FF FF FF 04 03 09 04 FF FF FF FF  ÿÿÿÿÿÿÿÿ....ÿÿÿÿ 
0090h: 24 03 44 00 72 00 61 00 67 00 6F 00 6E 00 52 00  $.D.r.a.g.o.n.R. 
00A0h: 69 00 73 00 65 00 20 00 49 00 6E 00 63 00 2E 00  i.s.e. .I.n.c... 
00B0h: 20 00 20 00 FF FF FF FF FF FF FF FF FF FF FF FF   . .ÿÿÿÿÿÿÿÿÿÿÿÿ 
00C0h: 34 03 47 00 65 00 6E 00 65 00 72 00 69 00 63 00  4.G.e.n.e.r.i.c. 
00D0h: 20 00 20 00 20 00 55 00 53 00 42 00 20 00 20 00   . . .U.S.B. . . 
00E0h: 4A 00 6F 00 79 00 73 00 74 00 69 00 63 00 6B 00  J.o.y.s.t.i.c.k. 
00F0h: 20 00 20 00 FF FF FF FF FF FF FF FF FF FF FF FF   . .ÿÿÿÿÿÿÿÿÿÿÿÿ 
0100h: 05 01 09 04 A1 01 A1 02 75 08 95 05 15 00 26 FF  ....¡.¡.u.•...&ÿ 
0110h: 00 35 00 46 FF 00 09 30 09 31 09 32 09 32 09 35  .5.Fÿ..0.1.2.2.5 
0120h: 81 02 75 04 95 01 25 07 46 3B 01 65 14 09 39 81  ..u.•.%.F;.e..9. 
0130h: 42 65 00 75 01 95 0C 25 01 45 01 05 09 19 01 29  Be.u.•.%.E.....) 
0140h: 0C 81 02 06 00 FF 75 01 95 08 25 01 45 01 09 01  .....ÿu.•.%.E... 
0150h: 81 02 C0 A1 02 75 08 95 07 46 FF 00 26 FF 00 09  ..À¡.u.•.Fÿ.&ÿ.. 
0160h: 02 91 02 C0 C0 FF FF FF FF FF FF FF FF FF FF FF  .‘.ÀÀÿÿÿÿÿÿÿÿÿÿÿ 
0170h: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 
0180h: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 
0190h: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 
01A0h: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 
01B0h: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 
01C0h: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 
01D0h: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 
01E0h: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 
01F0h: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 
0200h: 12 01 00 01 00 00 00 08 79 00 06 00 07 01 01 02  ........y....... 
0210h: 00 01 FF FF FF FF FF FF 09 02 29 00 01 01 00 80  ..ÿÿÿÿÿÿ..)....€ 
0220h: FA 09 04 00 00 02 03 00 00 00 09 21 10 01 21 01  ú..........!..!. 
0230h: 22 65 00 07 05 81 03 08 00 0A 07 05 01 03 08 00  "e.............. 
0240h: 0A FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF  .ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 
0250h: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 
0260h: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 
0270h: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 
0280h: FF FF FF FF FF FF FF FF 04 03 09 04 FF FF FF FF  ÿÿÿÿÿÿÿÿ....ÿÿÿÿ 
0290h: 24 03 44 00 72 00 61 00 67 00 6F 00 6E 00 52 00  $.D.r.a.g.o.n.R. 
02A0h: 69 00 73 00 65 00 20 00 49 00 6E 00 63 00 2E 00  i.s.e. .I.n.c... 
02B0h: 20 00 20 00 FF FF FF FF FF FF FF FF FF FF FF FF   . .ÿÿÿÿÿÿÿÿÿÿÿÿ 
02C0h: 34 03 47 00 65 00 6E 00 65 00 72 00 69 00 63 00  4.G.e.n.e.r.i.c. 
02D0h: 20 00 20 00 20 00 55 00 53 00 42 00 20 00 20 00   . . .U.S.B. . . 
02E0h: 4A 00 6F 00 79 00 73 00 74 00 69 00 63 00 6B 00  J.o.y.s.t.i.c.k. 
02F0h: 20 00 20 00 FF FF FF FF FF FF FF FF FF FF FF FF   . .ÿÿÿÿÿÿÿÿÿÿÿÿ 
0300h: 05 01 09 04 A1 01 A1 02 75 08 95 05 15 00 26 FF  ....¡.¡.u.•...&ÿ 
0310h: 00 35 00 46 FF 00 09 30 09 31 09 32 09 32 09 35  .5.Fÿ..0.1.2.2.5 
0320h: 81 02 75 04 95 01 25 07 46 3B 01 65 14 09 39 81  ..u.•.%.F;.e..9. 
0330h: 42 65 00 75 01 95 0C 25 01 45 01 05 09 19 01 29  Be.u.•.%.E.....) 
0340h: 0C 81 02 06 00 FF 75 01 95 08 25 01 45 01 09 01  .....ÿu.•.%.E... 
0350h: 81 02 C0 A1 02 75 08 95 07 46 FF 00 26 FF 00 09  ..À¡.u.•.Fÿ.&ÿ.. 
0360h: 02 91 02 C0 C0 FF FF FF FF FF FF FF FF FF FF FF  .‘.ÀÀÿÿÿÿÿÿÿÿÿÿÿ 
0370h: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 
0380h: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 
0390h: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 
03A0h: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 
03B0h: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 
03C0h: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 
03D0h: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 
03E0h: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 
03F0h: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 

Here is the normally/manually dumped HID descriptor:

$ sudo usbhid-dump --model 0079:0006
004:002:000:DESCRIPTOR         1658298926.755106
 05 01 09 04 A1 01 A1 02 75 08 95 05 15 00 26 FF
 00 35 00 46 FF 00 09 30 09 31 09 32 09 32 09 35
 81 02 75 04 95 01 25 07 46 3B 01 65 14 09 39 81
 42 65 00 75 01 95 0C 25 01 45 01 05 09 19 01 29
 0C 81 02 06 00 FF 75 01 95 08 25 01 45 01 09 01
 81 02 C0 A1 02 75 08 95 07 46 FF 00 26 FF 00 09
 02 91 02 C0 C0
Swyter commented 2 years ago

If anyone here wants to give it another go and dump their DragonRise gamepad EEPROMs, please run these commands and paste their results here, together with the marketing/model name for your pad and the SDL2 button map. Mine is an NGS Phantom: sudo usbhid-dump --model 0079:0006 sudo lsusb -vvvvvd 0079:0006 sudo python3 dragonrise-pc-twin-shock-dumper.py (https://gist.github.com/Swyter/26c754c6f04b13ecb8a7cf145878d045)

CC: @DanielGibson, @Akaricchi, @clebercasali.

Akaricchi commented 2 years ago

If anyone here wants to give it another go and dump their DragonRise gamepad EEPROMs, please run these commands and paste their results here, together with the marketing/model name for your pad and the SDL2 button map. Mine is an NGS Phantom: sudo usbhid-dump --model 0079:0006 sudo lsusb -vvvvvd 0079:0006 sudo python3 dragonrise-pc-twin-shock-dumper.py (https://gist.github.com/Swyter/26c754c6f04b13ecb8a7cf145878d045)

CC: @DanielGibson, @Akaricchi.

Sorry, can't do. Left mine in Ukraine as I fled from the war. Interesting find though.

Swyter commented 2 years ago

Well, if this whole EEPROM-dumping mechanism is successful I can use it to make the required generate-an-unique-mapping GUID changes on the SDL2 side as a quirk/workaround.

But yeah, thanks for reopening. Made me look into this again.

offalynne commented 2 years ago

It’s a neat quirk but seems rather impractical to pursue from a maintenance perspective. Good luck !

Swyter commented 2 years ago

Not really, SDL2 already has low-level libusb/hidapi support for stuff like force feedback. It boils down to a check for this VID/PID pair and a hid_get_indexed_string(3) call to grab the memory block from the device, then you just hash it with CRC32 or something else that SDL2 is already using and hopefully you can replace some GUID bytes with it so that each board has their own. Easy, 20 lines tops.

The problem is knowing if these boards (and their memory dumps) are actually different internally, that's why I want samples from other people's gamepads.

--

I opened my gamepad and saw the bare die wirebonded to the phenolic (read: hardened paper) circuit board under a black epoxy blob, so I don't expect much. That's like musical-greeting-card, cheap-toy-from-the-nineties or smartcard-level packaging; as cheap as it gets.

slouken commented 2 years ago

We're collecting more information on the upstream bug https://github.com/libsdl-org/SDL/issues/3197, can people please post a description of their controller and the output of this script:

#!/bin/bash
DIR=/sys/bus/usb/devices/$(ls -R /sys/bus/usb/devices/* | grep js$1 | cut -d$'\n' -f2 | cut -d: -f1 | awk -F/ '{print $NF}')
IMANUFACTURER=$(cat $DIR/manufacturer)
IPRODUCT=$(cat $DIR/product)
ISERIAL=$(cat $DIR/serial)
IVERSION=$(cat $DIR/version | xargs)
SIGNATURE="$IMANUFACTURER:$IPRODUCT:$ISERIAL:$IVERSION"
echo $SIGNATURE
Swyter commented 2 years ago

Please also share your HID reports and run the following Python script, if possible: sudo usbhid-dump --model 0079:0006 sudo lsusb -vvvvvd 0079:0006 sudo python3 dragonrise-pc-twin-shock-dumper.py (https://gist.github.com/Swyter/26c754c6f04b13ecb8a7cf145878d045)

rlueckl commented 2 years ago

I have this exact same problem. I bought 2x DragonRise Inc. "Generic USB Joystick" controller from AliExpress. I'm on Linux Mint with RetroArch/EmulationStation. Both controllers have the same exact name, ID, etc. and therefore can't be distinguished by the software. The only "'unique" thing I could find is the USB port number (where the controller is plugged in).

Attached are the outputs of the commands (controller 1 was connected to Bus 003, controller 2 was connected to Bus 004):

bus003_addr004.txt bus004_addr003.txt lsusb.txt usbhid_dump.txt

Any help would be appreciated.

rlueckl commented 2 years ago

I've found a usable workaround - in case anyone wants to use the same controller with the same amount of buttons: just wire up the buttons to the board in the exact same order. Then configure one of them in RetroArch - because the buttons are wired up the same, both controllers will work (separately).

I've also tried using (the legacy) linuxraw input option which uses /dev/input/jsX in RetroArch, but since the controllers still have the same name, RetroArch will write the same .cfg and overwrite one with the other.

AliceLR commented 2 years ago

There's a similar situation with "Piranha xtreme", "Trust GX 28", and a Snakebyte SB00566 controller that I found a while back. VirtualBox IDs it as MY-POWER CO.,LTD. 2In1 USB Joystick and it is almost certainly another generic board with varying button layouts between products. Does this need to be reported upstream as well?

https://github.com/gabomdq/SDL_GameControllerDB/pull/30 https://github.com/gabomdq/SDL_GameControllerDB/issues/61

The devices dir for this doesn't contain a manufacturer or serial file, just the following (Fedora 36):

bustype:    0003
vendor:     0e8f
product:    0003
version:    0110

The Windows entry now lists it as "PS3 Controller": 030000008f0e00000300000000000000 The Linux entry lists this as "PS3 Controller": 030000008f0e00000300000010010000

slouken commented 2 years ago

What we should probably do is remove both entries and add new mappings including the CRC. Do you have any of the affected devices?

AliceLR commented 2 years ago

Yes, I still have the Snakebyte SB00566. What should I do?

I edited the Python script to force it to use the correct device and tried again. This is the output:

MY-POWER CO.,LTD.:2In1 USB Joystick::1.00

Side note: I tried this on in Mac OS 10.6 and got 030000004c0500006802000000010000, which looks like a legitimate DualShock 3 ID. I need to diagnose boot issues in my Mac OS 10.13 device so no confirmation from that yet :(

edit: usable portions of the outputs of the other recommended commands:

$ sudo usbhid-dump --model 0E8F:0003
002:004:000:DESCRIPTOR         1666044074.468433
 05 01 09 04 A1 01 A1 02 75 08 95 05 15 00 26 FF
 00 35 00 46 FF 00 09 32 09 35 09 30 09 31 09 00
 81 02 75 04 95 01 25 07 46 3B 01 65 14 09 39 81
 42 65 00 75 01 95 0C 25 01 45 01 05 09 19 01 29
 0C 81 02 06 00 FF 75 01 95 08 25 01 45 01 09 01
 81 02 C0 A1 02 75 08 95 04 46 FF 00 26 FF 00 09
 02 91 02 75 08 95 04 09 02 B1 02 C0 C0
$ sudo lsusb -vvvvvd 0E8F:0003

Bus 002 Device 004: ID 0e8f:0003 GreenAsia Inc. MaxFire Blaze2
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.00
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x0e8f GreenAsia Inc.
  idProduct          0x0003 MaxFire Blaze2
  bcdDevice            1.09
  iManufacturer           1 MY-POWER CO.,LTD.
  iProduct                2 2In1 USB Joystick
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0029
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.10
          bCountryCode           33 US
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength     109
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval              10
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval              10
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x0000
  (Bus Powered)
$ sudo ./dragonrise-pc-twin-shock-dumper.py 
[* dumping] DEVICE ID 0e8f:0003 on Bus 002 Address 005 =================
 bLength                :   0x12 (18 bytes)
 bDescriptorType        :    0x1 Device
 bcdUSB                 :  0x100 USB 1.0
 bDeviceClass           :    0x0 Specified at interface
 bDeviceSubClass        :    0x0
 bDeviceProtocol        :    0x0
 bMaxPacketSize0        :   0x40 (64 bytes)
 idVendor               : 0x0e8f
 idProduct              : 0x0003
 bcdDevice              :  0x109 Device 1.09
 iManufacturer          :    0x1 MY-POWER CO.,LTD.
 iProduct               :    0x2 2In1 USB Joystick
 iSerialNumber          :    0x0 
 bNumConfigurations     :    0x1
  CONFIGURATION 1: 100 mA ==================================
   bLength              :    0x9 (9 bytes)
   bDescriptorType      :    0x2 Configuration
   wTotalLength         :   0x29 (41 bytes)
   bNumInterfaces       :    0x1
   bConfigurationValue  :    0x1
   iConfiguration       :    0x0 
   bmAttributes         :   0x80 Bus Powered
   bMaxPower            :   0x32 (100 mA)
    INTERFACE 0: Human Interface Device ====================
     bLength            :    0x9 (9 bytes)
     bDescriptorType    :    0x4 Interface
     bInterfaceNumber   :    0x0
     bAlternateSetting  :    0x0
     bNumEndpoints      :    0x2
     bInterfaceClass    :    0x3 Human Interface Device
     bInterfaceSubClass :    0x0
     bInterfaceProtocol :    0x0
     iInterface         :    0x0 
      ENDPOINT 0x81: Interrupt IN ==========================
       bLength          :    0x7 (7 bytes)
       bDescriptorType  :    0x5 Endpoint
       bEndpointAddress :   0x81 IN
       bmAttributes     :    0x3 Interrupt
       wMaxPacketSize   :    0x8 (8 bytes)
       bInterval        :    0xa
      ENDPOINT 0x2: Interrupt OUT ==========================
       bLength          :    0x7 (7 bytes)
       bDescriptorType  :    0x5 Endpoint
       bEndpointAddress :    0x2 OUT
       bmAttributes     :    0x3 Interrupt
       wMaxPacketSize   :    0x8 (8 bytes)
       bInterval        :    0xa
DESC_TYPE_DEVICE 0 b'12010001000000408f0e0300090101020001'
DESC_TYPE_CONFIG 0 b'090229000101008032090400000203000000092110012101226d000705810308000a0705020308000a'
DESC_TYPE_STRING 0 b'04030904'
DESC_TYPE_STRING 1 b'24034d0059002d0050004f00570045005200200043004f002e002c004c00540044002e00'
DESC_TYPE_STRING 2 b'2403320049006e003100200055005300420020004a006f00790073007400690063006b00'
AliceLR commented 2 years ago

Mac OS 10.13 GUID is 030000008f0e00000300000009010000, "2 In 1 Joystick", which looks much more correct.

edit: also, the mappings seem correct for my specific controller except for the Windows mapping, which incorrectly assigns righty:a5 instead of righty:a3.

offalynne commented 1 year ago

Since the goal of mapping is normalizing the layout and there is no viable "norm" here, we (as well as the upstream project) are omitting mappings for this VID+PID and calling the issue closed.

Valve has usage data via Steam Input and so could provide a suggestion for the most useful mapping based on user submitted data, but they do not publicize that information.

slouken commented 1 year ago

We're removing upstream mappings for this controller as well: https://github.com/libsdl-org/SDL/commit/673bc5764942e3f645f1ff7d64f3d6a2059e3cdb