We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4545 - Different game controllers, different mappings, same GUID
Summary: Different game controllers, different mappings, same GUID
Status: WAITING
Alias: None
Product: SDL
Classification: Unclassified
Component: joystick (show other bugs)
Version: 2.0.5
Hardware: x86_64 Linux
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-12 18:22 UTC by landeel
Modified: 2019-12-15 18:53 UTC (History)
3 users (show)

See Also:


Attachments
ngs-phantom-usb-descriptor-dump.zip (1.72 KB, application/x-zip-compressed)
2019-06-12 16:20 UTC, Ismael Ferreras Morezuelas (Swyter)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description landeel 2019-03-12 18:22:36 UTC
Hello, as reported here: https://discourse.libsdl.org/t/different-game-controllers-with-the-same-guid/25773...
I have two devices that 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)

They have different "iManufacturer", "iProduct" and "wDescriptorLength".

Also they have differences in the right stick axis mappings, which is the cause of my problems.

Is it possible for SDL to tell them apart, so I could use both at the same time, with the different mappings?
Comment 1 landeel 2019-03-12 21:16:54 UTC
Maybe you could allow something like that:

"03000000790000000600000010010000,DragonRise Inc. Generic USB Joystick,platform:Linux,iManufacturer:DragonRise Inc.,iProduct:Generic USB Joystick,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b3,y:b0,"
Comment 2 Ismael Ferreras Morezuelas (Swyter) 2019-03-13 14:24:44 UTC
See also this bug with more information about conflicting gamepads and their lsusb dumps: https://github.com/gabomdq/SDL_GameControllerDB/issues/202

Matching SDL2 Discourse thread: https://discourse.libsdl.org/t/duplicated-conflicting-guids-for-the-dragonrise-pc-twin-shock-controllers/24112/5

I guess we could add some extra discriminators other than VID and PID, these cheap no-name Chinese DirectShow gamepads are everywhere.

Unfortunately the USB descriptor reports are almost *completely* identical in most of the cases. At least they should have used different strings or descriptor sizes so that we could checksum them, but they even botched that.

Let me know if you need more data dumps from my controller.
Comment 3 landeel 2019-03-13 21:05:03 UTC
Funny fact: retroarch can tell my gamepads apart using the udev driver.
Comment 4 Ismael Ferreras Morezuelas (Swyter) 2019-03-13 21:12:14 UTC
I think I have compared the lsusb dumps for five or six controllers and most of them are seemingly identical (minus their physical button layout), your controller is a bit of an outlier and a bit easier to make out, I think.

Maybe there's a different way of finding an universal discriminator that someone that knows more about HID or USB internals can help with.
Comment 5 landeel 2019-03-19 21:25:34 UTC
Those are the mappings:

03000000790000000600000010010000,Microntek 0079:0006,platform:Linux,a:b2,b:b1,x:b3,y:b0,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:a3,lefttrigger:b6,righttrigger:b7,

03000000790000000600000010010000,DragonRise 0079:0006,platform:Linux,a:b2,b:b1,x:b3,y:b0,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,

Another difference, the Dragonrise one has 7 axes and the Microntek one has 6 axes.

Other possible solution would be specifying axes in the reverse order, from last to first.
Maybe something like that:
...,dpup:-a-0,dpdown:+a-0,dpleft:-a-1,dpright:+a-1,rightx:a-3,righty:a-2,...

This way the same mapping would work for both.
Comment 6 Sam Lantinga 2019-06-12 03:21:40 UTC
@Ismael Ferreras Morezuelas (Swyter), do the different devices you have all have the same name as well? If so, is there any other way to differentiate them?
Comment 7 Ismael Ferreras Morezuelas (Swyter) 2019-06-12 16:20:35 UTC
Created attachment 3822 [details]
ngs-phantom-usb-descriptor-dump.zip
Comment 8 Ismael Ferreras Morezuelas (Swyter) 2019-06-12 16:44:22 UTC
Used Thesycon's USB Descriptor Dumper (File > Save to file, and File > Save config descriptor as binary file) and attached it here. Download the tool: https://www.thesycon.de/eng/usb_descriptordumper.shtml

I only own this NGS Phantom gamepad (https://www.ngs.eu/images/productos/G300/NGS_phantom.jpg), the other lsusb reports were provided by other SDL2 community members in the linked GitHub reports and forum threads.

I will try to get a HID report dump from Linux soon-ish, to see if there's something interesting in there that can be check-summed. As you can see, my gamepad seems to have extra spaces in the name, but the Trust CXT24 from @DanielGibson and the Topway faux-dualshock and Defender Cobra R4 from @Akaricchi are also like that.

My lsusb report for the same NGS Phantom is here, you can also see all the other lsusb reports I mentioned after that: https://github.com/gabomdq/SDL_GameControllerDB/issues/202#issuecomment-376948500

Let me know what you think.
Comment 9 Ismael Ferreras Morezuelas (Swyter) 2019-06-12 17:30:17 UTC
Also, notice the messed up physical button layout of this gamepad when compared to most of the others from the same chipset family.

  2    SELECT START LB RB  -NGS Phantom
1   4       9 10    5  6    http://web.archive.org/web/20190612172739if_/https://images-na.ssl-images-amazon.com/images/I/41WaDx-kLYL.jpg
  3                 7  8    http://web.archive.org/web/20190612172723if_/https://images-na.ssl-images-amazon.com/images/I/71042nE1UpL._SL1500_.jpg

  1    SELECT START LB RB  -Topway faux-dualshock models
4   2       9 10    ?  ?    and Trust CXT24 (?)
  3                 ?  ?