Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Find alternative names for a bluetooth joypad on Windows to work around forged PID/VID #8857

Open
Dwedit opened this issue May 27, 2019 · 37 comments

Comments

@Dwedit
Copy link
Contributor

Dwedit commented May 27, 2019

Description

This is on my Windows 10 machine.

Some versions of the 8bitdo SN30 game pad are masquerading as an XBOX 360 controller, and are using a fake Vendor and Product ID to match that gamepad.

When I look around in Device Manager, I see two separate devices that refer to the same piece of hardware:

This one in Human Interface Devices:

Name: "Bluetooth XINPUT compatible input device"
Instance path: "BTHENUM\{00001124-0000-1000-8000-00805F9B34FB}_VID&0002045E_PID&02E0\7&26E1B50A&0&E417D89795FA_C00000000"
Vendor ID: 0x45E, Product ID: 0x2E0 (forging an XBOX 360 controller)
Bus reported device description: "Xbox Bluetooth Gamepad"
Bluetooth Device Address: E417D89795FA

And this one in Bluetooth Devices:

Name: "8Bitdo SNES30 GamePad(x)"
Instance path: "BTHENUM\DEV_E417D89795FA\7&26E1B50A&0&BLUETOOTHDEVICE_E417D89795FA"
Bluetooth Vendor ID: 0x45E, Bluetooth Product ID: 0x2E0
Bluetooth Device Address: E417D89795FA

The instance paths are not identical, but they share these parts: 7&26E1B50A&0& and E417D89795FA, and the Bluetooth Device Addresses (which are supposed to be unique) are exact matches. Therefore, it is safe to consider those two to be the exact same piece of hardware.

When RetroArch detects this controller, it will assume that it has the full set of XBOX 360 controls, and will assume the gamepad has a both a separate D-PAD and Left Analog stick. Meanwhile, the actual controller assigns the D-PAD to be the left analog stick, and has nothing mapped to the D-PAD controls. This causes cores which use D-PADs, but no analog controls to not accept input unless you do some remapping first.

While there is a system in place to set default options for controllers which do not conform properly, it was hampered by not being able to distinguish between two different controllers with identical VID/PID, and identical display names. Adding a second name (Bus-reported device description) and a third name (Matching Friendly Name from the Bluetooth device) could help distinguish them.

@Dwedit
Copy link
Contributor Author

Dwedit commented Jun 28, 2019

I just made a little Windows Console program that enumerates the DirectInput devices, then outputs their associated hardware device information.

This is what it outputs when it sees the joypad:

DirectInput Device Index 1
VID = 0x045E, PID = 0x02E0
Report ID = 0
Device Instance Path: BTHENUM\{00001124-0000-1000-8000-00805f9b34fb}_VID&0002045e_PID&02e0\7&26e1b50a&0&E417D89795FA_C00000000
  Friendly Name: Bluetooth XINPUT compatible input device
  Bus-Reported Name: Xbox Bluetooth Gamepad
  Bluetooth VID = 0x045E, PID = 0x02E0
  Bluetooth Address = E417D89795FA
    Bluetooth Device Instance Path: BTHENUM\{00001200-0000-1000-8000-00805f9b34fb}_VID&0002045e_PID&02e0\7&26e1b50a&0&E417D89795FA_C00000000
    Bluetooth Friendly Name: Device Identification Service
    Bluetooth Device Instance Path: BTHENUM\Dev_E417D89795FA\7&26e1b50a&0&BluetoothDevice_E417D89795FA
    Bluetooth Friendly Name: 8Bitdo SNES30 GamePad(x)
Device Instance Path: HID\{00001124-0000-1000-8000-00805f9b34fb}&VID_045e&PID_02e0&IG_00\8&7074921&1&0000
  Friendly Name: HID-compliant game controller

So it's finding 4 different names for the joypad:
Bluetooth XINPUT compatible input device
Xbox Bluetooth Gamepad
HID-compliant game controller
8Bitdo SNES30 GamePad(x)

Meanwhile, RetroArch just calls it "XInput Controller".

@andres-asm
Copy link
Contributor

RetroArch doesn't do anything BT, it just gets the device via HID.

That Xinput Controller is probably because they used to use the same VID and PID as the original MS ones so it's just using the builtin autoconf (ie: the name is misleading and not obtained via any API)

@andres-asm
Copy link
Contributor

I thnk you can get the HID name from information/system information

@Dwedit
Copy link
Contributor Author

Dwedit commented Jun 28, 2019

I checked that screen, it's still just the same name shown elsewhere. Only the VID/PID is useful information there, the rest is referring to what configuration file it loaded.

@andres-asm
Copy link
Contributor

andres-asm commented Jun 29, 2019 via email

@Dwedit
Copy link
Contributor Author

Dwedit commented Jun 29, 2019

Can't see the images here on github's issue tracker.

If you're talking about the name shown in Device Manager vs the Bluetooth Settings app, then that's what I have taken.

@andres-asm
Copy link
Contributor

image

image

@Dwedit
Copy link
Contributor Author

Dwedit commented Jun 29, 2019

Yep, in my second message, it listed "Bluetooth Friendly Name: 8Bitdo SNES30 GamePad(x)" for my controller. That's what it shows in the Bluetooth Settings app.

@Dwedit
Copy link
Contributor Author

Dwedit commented Jun 29, 2019

When you ask DirectInput for information about the controller, you get these:

  • Some arbitrary UUID that has nothing to do with device information, but is unique to the controller
  • VID and PID
  • Friendly Name
  • Report ID

When you ask Windows for device information using the CfgMgr32 API, you can get these:

  • Device Instance ID, a complicated string that formats VID/PID in various different ways
  • Friendly Name
  • Bus-Reported Name
  • Parent Device
  • Bluetooth VID/PID (Same PID/VID. but not formatted in any complicated way)
  • Bluetooth Address
  • Device Class GUID

Then you can also enumerate Bluetooth devices which match the Bluetooth Address, and get additional names from there.

One problem with this approach is that you end up with a real XBOX 360 controller and the 8BitDo controller plugged in at the same time, it might not be possible to determine which DirectInput device corresponds to which Bluetooth device.

@Dwedit
Copy link
Contributor Author

Dwedit commented Jun 29, 2019

The other thing I was looking into was detecting the drivers used by DS4Windows, so it can identify that the Joypad is a DualShock4.

It fakes an XBOX 360 controller (VID 0x045E, PID 0x028E) connected by USB. But on a normal USB device, you can keep taking its parent, and eventually see a USB Root Hub. On the faked USB device, you will eventually see a parent of "ROOT\UNKNOWN\0000", and the location is listed as "Virtual Gamepad Emulation Bus".

There is also another HID device (VID 0x054C, PID 0x05C4), and it is linked to the Bluetooth device. I think it's the actual PS4 controller. This is not the device that XInput sees. The only thing that clearly links it to the virtual XBOX 360 controller is that it was plugged in at the same date and time.

@andres-asm
Copy link
Contributor

IMHO adding other variables would be great as a tie breaker.
For friendly names RA allows you to have one already.

Good thing that someone is looking into this again.

@Dwedit
Copy link
Contributor Author

Dwedit commented Jun 29, 2019

Then there's the hard part... What would need to be done in RetroArch's input autoconfig system to allow it to use the four different names it can find for a Joypad?

The four names are "Name", "Friendly Name", "Bus Reported Name", and "Bluetooth Name".

@andres-asm
Copy link
Contributor

andres-asm commented Jun 29, 2019 via email

@Dwedit
Copy link
Contributor Author

Dwedit commented Jun 29, 2019

Think I'll just simplify it, simply scan the BT devices for the same VID and PID as the joypad and take the first match.

@FoxyMonty
Copy link

Has this problem got closer to a solution? Seems to be the issue that I’ve ran into in the past few days.

@Dwedit
Copy link
Contributor Author

Dwedit commented Nov 11, 2020

Thank you for reminding me that this still exists, haven't looked at this at all in over a year.

@FoxyMonty
Copy link

FoxyMonty commented Nov 12, 2020

Been troubleshooting the past few days and finally found this issue.

My friend has the 8bitdo SN30 and 6-button M30.

When launching in RA, the notification says the right model has loaded but binding the controls and saving an autoconfig it creates the same “Bluetooth wireless controller”.

Device manager shows the correct model names.
Running “joy.cpl” shows the controllers as the same Bluetooth wireless controller and one time as “4 axis 12 button joystick with hat switch”.

@Dwedit
Copy link
Contributor Author

Dwedit commented Nov 12, 2020

One issue is that you can't reliably go from an XInput player number to a VID/PID or Device Node. So any time XInput is involved, it's only reliable when there's only one joypad. Otherwise, it's possible to misidentify the device given the XInput player number.

If there's only one device, it's a lot easier.

@Dwedit
Copy link
Contributor Author

Dwedit commented Nov 12, 2020

Just peeked inside of Xinput's code, Ultimately it is calling CreateFileW on a device (like this:)

\\?\hid#{00001124-0000-1000-8000-00805f9b34fb}&vid_045e&pid_02e0&ig_00#8&7074921&2&0000#{ec87f1e3-c13b-4100-b5f7-8b84d54260cb}

After opening it, it communicates with that device.

However, the device that is opened does not correspond with the user number. Asking for Player 2 still opens Player 1's joypad device.

I haven't tested with multiple controllers yet, but if tries to open multiple devices, and the order of opening the device matches the player order, then that would help.

@Dwedit
Copy link
Contributor Author

Dwedit commented Nov 13, 2020

Just tested and confirmed that multiple joypad devices will be read in player number order when you try to use XInput.

@JackBQuick
Copy link

The Xbox Series X|S controller does get the proper PID/VID information when connecting over Bluetooth in xinput mode.

When connecting the X|S controller(Shock Blue) RetroArch sees it as "1118/2835"

The Xbox One controller, is of course 1118/736.

I can easily swap between the two without RetroArch confusing the two.

Both of my Bluetooth Retro-BIt Sega Genesis / Saturn controllers and my 8BitDo SN30 however, also show up as 1118/736. Like it can't find the ID so falls back to a default.

I read that xinput API isn't capable of reading the VIP/PID of devices so... are the Xbox controllers somehow built into Windows so RetroArch can identify them? Is this something that can be leveraged to allow RetorArch to ID these xinput controllers?

I also found this post that seemed to fix the same problem for one developer; would that work here in this case?
microsoft/DirectXTK#169

I hope I've been helpful and thanks for all the awesome work you guys do on RetroArch.

@Dwedit
Copy link
Contributor Author

Dwedit commented Mar 11, 2021

In the meantime, I just wrote a program that will discover the actual device associated with an XInput controller. I'll post more about it soon.

@Dwedit
Copy link
Contributor Author

Dwedit commented Mar 11, 2021

Okay, here is the test program. It is badly in need of testing to see if it works on anyone else's PC. Connect your controllers before running it.

(Note: Updated since the last version, removes "Device Identification Service" matches among other things)

https://www.dwedit.org/files/xinput-test-thingy-v2.7z

Here is an example of what the program outputs:

Joypad #0 is connected.
Device Filename: \\?\hid#{00001124-0000-1000-8000-00805f9b34fb}&vid_045e&pid_02e0&ig_00#8&7074921&2&0000#{ec87f1e3-c13b-4100-b5f7-8b84d54260cb}
Device Instance: HID\{00001124-0000-1000-8000-00805f9b34fb}&VID_045e&PID_02e0&IG_00\8&7074921&2&0000
Friendly name: HID-compliant game controller
Parent Devices:
Device Instance: BTHENUM\{00001124-0000-1000-8000-00805F9B34FB}_VID&0002045E_PID&02E0\7&26E1B50A&0&E417D89795FA_C00000000
Friendly name: Bluetooth XINPUT compatible input device
Bus-Reported name: Xbox Bluetooth Gamepad
Bluetooth Address: E417D89795FA
Matching Bluetooth Device:
Device Instance: BTHENUM\Dev_E417D89795FA\7&26e1b50a&0&BluetoothDevice_E417D89795FA
Friendly name: 8Bitdo SNES30 GamePad(x)
Bus-Reported name: Bluetooth Peripheral Device
Bluetooth Address: E417D89795FA
Joypad #1 is connected.
Device Filename: \\?\usb#vid_045e&pid_028e#1&1a590e2c&1&01#{ec87f1e3-c13b-4100-b5f7-8b84d54260cb}
Device Instance: USB\VID_045E&PID_028E\1&1a590e2c&1&01
Friendly name: Xbox 360 Controller for Windows
Bus-Reported name: Virtual Xbox 360 Controller
Joypad #2 is not connected.
Joypad #3 is not connected.

@JackBQuick
Copy link

Ok so that did not work for me. Instead, it just sent by Bluetooth driver into hiding. Basically, it vanished from Device Manager, but I got it back.

Will try it on a different machine later tonight.

@Dwedit
Copy link
Contributor Author

Dwedit commented Mar 11, 2021

I can't think of any step in my program that could cause a bluetooth driver to "go into hiding"...

What the program does:

  • Load XInput library, and when XInput imports these functions, overrides them (in this process only): CreateFileW, DuplicateHandle, CloseHandle, DevceIoControl, CoCreateInstance. These overrides are only used to keep track of the filename associated with a controller number. and all the overrides pass through to the original code.
  • List all HID devices and Bluetooth devices (just like the device manager would)
  • Run XInput to get information on the 4 controllers.
  • Reads from the registry to relate the filename to the device instance
  • Reads properties of devices (just like the device manager would)

It doesn't try to install or uninstall devices, or anything like that, and doesn't enable or disable any devices. So seeing a problem like that is bizarre.

@JackBQuick
Copy link

It was bizarre.
The drivers were still present, but not visible in device manager. Reinstalling drivers did nothing nor did multiple reboots. It was behaving as if I had flipped a physical switch that turned off Bluetooth, but once I turned it off, and left it unplugged for a while the Bluetooth driver came back. Reddit says it's an issue with my motherboard that many hope will be fixed soon. My only guess is that the app somehow trigger the motherboard bug? (Gigabyte

At any rate I just tried it on my laptop and looks like it worked there.

Had both the SN30 and Retro-bit Genesis Bluetooth controllers connected in xinput mode.

image

@Dwedit
Copy link
Contributor Author

Dwedit commented Mar 12, 2021

Interesting that it can't find a good name for the devices there... What are the devices named on the "Bluetooth & Other Devices" screen?

Edit: looks like it's just pulling up the same device instead of finding an actual matching device, will try to fix.

@JackBQuick
Copy link

And now it just worked on the one that had the Bluetooth glitch, ran it a few times and nothing. Can't replicate the issue that caused the Bluetooth driver to shut itself off.

@JackBQuick
Copy link

JackBQuick commented Mar 12, 2021

On the 2nd test.

Here is the results from your tool.
Windows sees the 4 devices as two 8BitDo SN30 Gamepads and 2 "Retro Bit Bluetooth Controller

image

Joypad #1 is connected.
Device Filename: \\?\hid#{00001124-0000-1000-8000-00805f9b34fb}&vid_045e&pid_02e0&ig_00#9&ba09e0f&0&0000#{ec87f1e3-c13b-4100-b5f7-8b84d54260cb}
Device Instance: HID\{00001124-0000-1000-8000-00805f9b34fb}&VID_045e&PID_02e0&IG_00\9&ba09e0f&0&0000
Friendly name: HID-compliant game controller
Parent Devices:
Device Instance: BTHENUM\{00001124-0000-1000-8000-00805F9B34FB}_VID&0002045E_PID&02E0\8&1D3B9B16&0&E417D84C8F7B_C00000000
Friendly name: Bluetooth XINPUT compatible input device
Bus-Reported name: Xbox Bluetooth Gamepad
Bluetooth Address: E417D84C8F7B
Matching Bluetooth Device:
Device Instance: BTHENUM\Dev_E417D84C8F7B\8&1d3b9b16&0&BluetoothDevice_E417D84C8F7B
Friendly name: 8BitDo SN30 gamepad
Bus-Reported name: Bluetooth Peripheral Device
Bluetooth Address: E417D84C8F7B
Joypad #2 is not connected.
Joypad #3 is connected.
Device Filename: \\?\hid#{00001124-0000-1000-8000-00805f9b34fb}&vid_045e&pid_02e0&ig_00#9&2d42efc0&1&0000#{ec87f1e3-c13b-4100-b5f7-8b84d54260cb}
Device Instance: HID\{00001124-0000-1000-8000-00805f9b34fb}&VID_045e&PID_02e0&IG_00\9&2d42efc0&1&0000
Friendly name: HID-compliant game controller
Parent Devices:
Device Instance: BTHENUM\{00001124-0000-1000-8000-00805F9B34FB}_VID&0002045E_PID&02E0\8&1D3B9B16&0&E417D8EF8E71_C00000000
Friendly name: Bluetooth XINPUT compatible input device
Bus-Reported name: Xbox Bluetooth Gamepad
Bluetooth Address: E417D8EF8E71
Matching Bluetooth Device:
Device Instance: BTHENUM\{00001200-0000-1000-8000-00805f9b34fb}_VID&0002045e_PID&02e0\8&1d3b9b16&0&E417D8EF8E71_C00000000
Friendly name: Device Identification Service
Bus-Reported name: Bluetooth Peripheral Device
Bluetooth Address: E417D8EF8E71```



@Dwedit
Copy link
Contributor Author

Dwedit commented Mar 12, 2021

Try to use triple backquotes ``` at the beginning and end of your log so GitHub doesn't try to reformat it. Usually that key is to the left of the "1" key on the keyboard.

@JackBQuick
Copy link

Also... here's what the Xbox Series X|S and Xbox One controllers look like

image

Device Filename: \\?\hid#{00001812-0000-1000-8000-00805f9b34fb}&dev&vid_5e&pid_0b13&rev_0505&441622b0394a&ig_00#a&c1c6b82&0&0000#{ec87f1e3-c13b-4100-b5f7-8b84d54260cb}
Device Instance: HID\{00001812-0000-1000-8000-00805f9b34fb}&Dev&VID_5e&PID_0b13&REV_0505&441622b0394a&IG_00\a&c1c6b82&0&0000
Friendly name: HID-compliant game controller
Parent Devices:
Device Instance: BTHLEDEVICE\{00001812-0000-1000-8000-00805F9B34FB}_DEV_VID&02045E_PID&0B13_REV&0505_441622B0394A\9&2347B2C0&0&0016
Friendly name: Bluetooth LE XINPUT compatible input device
Bus-Reported name: Bluetooth LE Service {00001812-0000-1000-8000-00805f9b34fb}
Bluetooth Address: 441622b0394a
Joypad #1 is connected.
Device Filename: \\?\hid#{00001124-0000-1000-8000-00805f9b34fb}&vid_045e&pid_02e0&ig_00#9&1a87856&1&0000#{ec87f1e3-c13b-4100-b5f7-8b84d54260cb}
Device Instance: HID\{00001124-0000-1000-8000-00805f9b34fb}&VID_045e&PID_02e0&IG_00\9&1a87856&1&0000
Friendly name: HID-compliant game controller
Parent Devices:
Device Instance: BTHENUM\{00001124-0000-1000-8000-00805F9B34FB}_VID&0002045E_PID&02E0\8&1D3B9B16&0&9CAA1BC341B6_C00000000
Friendly name: Bluetooth XINPUT compatible input device
Bus-Reported name: Xbox Bluetooth Gamepad
Bluetooth Address: 9CAA1BC341B6
Matching Bluetooth Device:
Device Instance: BTHENUM\{00001124-0000-1000-8000-00805f9b34fb}_VID&0002045e_PID&02e0\8&1d3b9b16&0&9CAA1BC341B6_C00000000
Friendly name: Bluetooth XINPUT compatible input device
Bus-Reported name: Xbox Bluetooth Gamepad
Bluetooth Address: 9CAA1BC341B6
Joypad #2 is not connected.
Joypad #3 is not connected.```

@Dwedit
Copy link
Contributor Author

Dwedit commented Mar 12, 2021

Just updated the test tool, now it won't return "Device Identification Service" anymore.

@JackBQuick
Copy link

JackBQuick commented Mar 13, 2021

ok, re-downloaded thingy

image

Device Filename: \\?\hid#{00001812-0000-1000-8000-00805f9b34fb}&dev&vid_5e&pid_0b13&rev_0505&441622b0394a&ig_00#a&c1c6b82&0&0000#{ec87f1e3-c13b-4100-b5f7-8b84d54260cb}
Device Instance: HID\{00001812-0000-1000-8000-00805f9b34fb}&Dev&VID_5e&PID_0b13&REV_0505&441622b0394a&IG_00\a&c1c6b82&0&0000
Friendly name: HID-compliant game controller
Parent Devices:
Device Instance: BTHLEDEVICE\{00001812-0000-1000-8000-00805F9B34FB}_DEV_VID&02045E_PID&0B13_REV&0505_441622B0394A\9&2347B2C0&0&0016
Friendly name: Bluetooth LE XINPUT compatible input device
Bus-Reported name: Bluetooth LE Service {00001812-0000-1000-8000-00805f9b34fb}
Bluetooth Address: 441622b0394a
Joypad #1 is connected.
Device Filename: \\?\hid#{00001124-0000-1000-8000-00805f9b34fb}&vid_045e&pid_02e0&ig_00#9&1a87856&1&0000#{ec87f1e3-c13b-4100-b5f7-8b84d54260cb}
Device Instance: HID\{00001124-0000-1000-8000-00805f9b34fb}&VID_045e&PID_02e0&IG_00\9&1a87856&1&0000
Friendly name: HID-compliant game controller
Parent Devices:
Device Instance: BTHENUM\{00001124-0000-1000-8000-00805F9B34FB}_VID&0002045E_PID&02E0\8&1D3B9B16&0&9CAA1BC341B6_C00000000
Friendly name: Bluetooth XINPUT compatible input device
Bus-Reported name: Xbox Bluetooth Gamepad
Bluetooth Address: 9CAA1BC341B6
Matching Bluetooth Device:
Device Instance: BTHENUM\{00001124-0000-1000-8000-00805f9b34fb}_VID&0002045e_PID&02e0\8&1d3b9b16&0&9CAA1BC341B6_C00000000
Friendly name: Bluetooth XINPUT compatible input device
Bus-Reported name: Xbox Bluetooth Gamepad
Bluetooth Address: 9CAA1BC341B6
Joypad #2 is connected.
Device Filename: \\?\hid#{00001124-0000-1000-8000-00805f9b34fb}&vid_045e&pid_02e0&ig_00#9&2d42efc0&2&0000#{ec87f1e3-c13b-4100-b5f7-8b84d54260cb}
Device Instance: HID\{00001124-0000-1000-8000-00805f9b34fb}&VID_045e&PID_02e0&IG_00\9&2d42efc0&2&0000
Friendly name: HID-compliant game controller
Parent Devices:
Device Instance: BTHENUM\{00001124-0000-1000-8000-00805F9B34FB}_VID&0002045E_PID&02E0\8&1D3B9B16&0&E417D8EF8E71_C00000000
Friendly name: Bluetooth XINPUT compatible input device
Bus-Reported name: Xbox Bluetooth Gamepad
Bluetooth Address: E417D8EF8E71
Matching Bluetooth Device:
Device Instance: BTHENUM\{00001200-0000-1000-8000-00805f9b34fb}_VID&0002045e_PID&02e0\8&1d3b9b16&0&E417D8EF8E71_C00000000
Friendly name: Device Identification Service
Bus-Reported name: Bluetooth Peripheral Device
Bluetooth Address: E417D8EF8E71
Joypad #3 is connected.
Device Filename: \\?\hid#{00001124-0000-1000-8000-00805f9b34fb}&vid_045e&pid_02e0&ig_00#9&2800ad6f&2&0000#{ec87f1e3-c13b-4100-b5f7-8b84d54260cb}
Device Instance: HID\{00001124-0000-1000-8000-00805f9b34fb}&VID_045e&PID_02e0&IG_00\9&2800ad6f&2&0000
Friendly name: HID-compliant game controller
Parent Devices:
Device Instance: BTHENUM\{00001124-0000-1000-8000-00805F9B34FB}_VID&0002045E_PID&02E0\8&1D3B9B16&0&0090E0DA1BAF_C00000000
Friendly name: Bluetooth XINPUT compatible input device
Bus-Reported name: Xbox Bluetooth Gamepad
Bluetooth Address: 0090E0DA1BAF
Matching Bluetooth Device:
Device Instance: BTHENUM\Dev_0090E0DA1BAF\8&1d3b9b16&0&BluetoothDevice_0090E0DA1BAF
Friendly name: Retro Bit Bluetooth Controller
Bus-Reported name: Bluetooth Peripheral Device
Bluetooth Address: 0090E0DA1BAF```

@romjacket
Copy link

Very happy you are working on something like this. Keep up the good work!!!!

Here is the output from my izdtech zd-v108:

Joypad #0 is connected. Device Filename: \\?\usb#vid_045e&pid_028e#5&2c705bfe&0&1#{ec87f1e3-c13b-4100-b5f7-8b84d54260cb} Device Instance: USB\VID_045E&PID_028E\5&2c705bfe&0&1 Friendly name: Xbox 360 Controller for Windows Bus-Reported name: ZD Game For Windows Joypad #1 is not connected. Joypad #2 is not connected. Joypad #3 is not connected.

@JimDickWinn
Copy link

I'd be very interested in this being improved in RetroArch, here's the output from my 2 controllers.

image

Joypad #0 is connected.
Device Filename: \\?\hid#{00001124-0000-1000-8000-00805f9b34fb}&vid_045e&pid_02e0&ig_00#8&4c7d232&0&0000#{ec87f1e3-c13b-4100-b5f7-8b84d54260cb}
Device Instance: HID\{00001124-0000-1000-8000-00805f9b34fb}&VID_045e&PID_02e0&IG_00\8&4c7d232&0&0000
Friendly name: HID-compliant game controller
Parent Devices:
Device Instance: BTHENUM\{00001124-0000-1000-8000-00805F9B34FB}_VID&0002045E_PID&02E0\7&1B66BE44&0&E417D8158B7C_C00000000
Friendly name: Bluetooth XINPUT-compatible input device
Bus-Reported name: Xbox Bluetooth Gamepad
Bluetooth Address: E417D8158B7C
Matching Bluetooth Device:
Device Instance: BTHENUM\Dev_E417D8158B7C\7&1b66be44&0&BluetoothDevice_E417D8158B7C
Friendly name: 8Bitdo SF30 Pro
Bus-Reported name: Bluetooth Peripheral Device
Bluetooth Address: E417D8158B7C
Joypad #1 is connected.
Device Filename: \\?\hid#{00001124-0000-1000-8000-00805f9b34fb}&vid_045e&pid_02e0&ig_00#8&e8dc889&0&0000#{ec87f1e3-c13b-4100-b5f7-8b84d54260cb}
Device Instance: HID\{00001124-0000-1000-8000-00805f9b34fb}&VID_045e&PID_02e0&IG_00\8&e8dc889&0&0000
Friendly name: HID-compliant game controller
Parent Devices:
Device Instance: BTHENUM\{00001124-0000-1000-8000-00805F9B34FB}_VID&0002045E_PID&02E0\7&1B66BE44&0&E417D87330F2_C00000000
Friendly name: Bluetooth XINPUT-compatible input device
Bus-Reported name: Xbox Bluetooth Gamepad
Bluetooth Address: E417D87330F2
Matching Bluetooth Device:
Device Instance: BTHENUM\Dev_E417D87330F2\7&1b66be44&0&BluetoothDevice_E417D87330F2
Friendly name: 8BitDo Arcade Stick
Bus-Reported name: Bluetooth Peripheral Device
Bluetooth Address: E417D87330F2
Joypad #2 is not connected.
Joypad #3 is not connected.

@persechini
Copy link

Any change with this issue? I have a few 8bitdo controllers that always show up as xbox one controllers (I connect them to the pc using xinput mode, dinput mode used for android) and it would be cool if retroarch could distinguish them, even if just for the device index text. With the way things work currently, isn't most of the 8bitdo autoconfig files in the xinput folder pointless?

@DJm00n
Copy link

DJm00n commented Jan 21, 2022

We can use hidden func XInputGetCapabilitiesEx from XInput 1.4 (comes with Windows 8):

typedef struct _XINPUT_CAPABILITIES_EX
{
	XINPUT_CAPABILITIES Capabilities;
	WORD VendorId;
	WORD ProductId;
	WORD VersionNumber;
	WORD unk1;
	DWORD unk2;
} XINPUT_CAPABILITIES_EX, * PXINPUT_CAPABILITIES_EX;

// XInputGetCapabilitiesEx hidden function is available since Windows 8 version of XInput1_4.dll
DWORD XInputGetCapabilitiesEx(DWORD dwUserIndex, PXINPUT_CAPABILITIES_EX pCapabilitiesEx)
{
	DWORD(WINAPI* XInputGetCapabilitiesExFunc)(DWORD unk1, DWORD dwUserIndex, DWORD dwFlags, PXINPUT_CAPABILITIES_EX pCapabilities);
	XInputGetCapabilitiesExFunc = reinterpret_cast<decltype(XInputGetCapabilitiesExFunc)>(::GetProcAddress(::GetModuleHandleW(L"XInput1_4.dll"), (LPCSTR)108));

	if (!XInputGetCapabilitiesExFunc)
		return ERROR_INVALID_FUNCTION;

	return XInputGetCapabilitiesExFunc(1, dwUserIndex, 0, pCapabilitiesEx);
}

....
XINPUT_CAPABILITIES_EX caps;
popMemZeroStruct(caps);

XInputGetCapabilitiesEx(m_UserIndex, &caps);

// Fixup for Wireless Xbox 360 Controller
if (caps.ProductId == 0 && caps.Capabilities.Flags & /*XINPUT_CAPS_WIRELESS*/0x0002)
{
	caps.VendorId = 0x045E;
	caps.ProductId = 0x02A1;
}

m_VendorId = caps.VendorId;
m_ProductId = caps.ProductId;

// Known controller VID/PID list: https://github.com/libsdl-org/SDL/blob/main/src/joystick/controller_type.h

https://gist.github.com/DJm00n/0f0563702f6cf01e8812ebc760a78cf1#file-xinputgetcapabilitiesex-cpp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants