Project

General

Profile

Emulator Issues #12126

some usb controllers are incorrectly determined to be the same device in settings

Added by steel93 4 months ago. Updated 8 days ago.

Status:
Fixed
Priority:
Normal
Assignee:
-
% Done:

0%

Operating system:
Linux
Issue type:
Bug
Milestone:
Current
Regression:
Yes
Relates to usability:
No
Relates to performance:
No
Easy:
No
Relates to maintainability:
No
Regression start:
5.0-11484
Fixed in:
5.0-12665

Description

Game Name?

Any

Game ID? (right click the game in the game list, Properties, Info tab)

Any

MD5 Hash? (right click the game in the game list, Properties, Verify tab, Verify Integrity button)

N/A

What's the problem? Describe what went wrong.

On Linux, offbrand usb controllers that report the same serial number in dmesg will be incorrectly determined to be the same device. Multiple controllers can not be configured in dolphin. This was broken in commit: ac907ef977a1dc2ae4a7acc1ca9f56f1ea21d9cf

Github PR: https://github.com/dolphin-emu/dolphin/pull/8473

What steps will reproduce the problem?

  • Obtain more than 1 controller that reports the same serial number (I am currently using usb n64 controllers from amazon, yes n64 controllers)

  • Plug multiple controllers in, launch dolphin-emu. Go to settings and only one evdev device shows up in the dropdown to configure.

Is the issue present in the latest development version? For future reference, please also write down the version number of the latest development version.

Yes (any commit after the one above).

Is the issue present in the latest stable version?

Yes (on arch linux AUR, on debian buster repos, no)

If the issue isn't present in the latest stable version, which is the first broken version? (You can find the first broken version by bisecting. Windows users can use the tool https://forums.dolphin-emu.org/Thread-green-notice-development-thread-unofficial-dolphin-bisection-tool-for-finding-broken-builds and anyone who is building Dolphin on their own can use git bisect.)

Commit ac907ef977a1dc2ae4a7acc1ca9f56f1ea21d9cf

If your issue is a graphical issue, please attach screenshots and record a three frame fifolog of the issue if possible. Screenshots showing what it is supposed to look like from either console or older builds of Dolphin will help too. For more information on how to use the fifoplayer, please check here: https://wiki.dolphin-emu.org/index.php?title=FifoPlayer

[Attach any fifologs if possible, write a description of fifologs and screenshots here to assist people unfamiliar with the game.]

N/A

What are your PC specifications? (CPU, GPU, Operating System, more)

Arch Linux, kernel 5.6.15.

Is there anything else that can help developers narrow down the issue? (e.g. logs, screenshots,
configuration files, savefiles, savestates)

Checking out the commit prior to the evdev change and compiling dolphin from source correctly shows all controllers as evdev 0,1,2,3 etc.

Running evtest on linux shows that all controllers are uniquely identified by their /dev/input/event numbers and can be separately tested. Dmesg reports the same product/vendor id and serial number for each controller. Yes, these are offbrand cheap controllers that should report a unique serial number, however I am betting that a lot of other 3rd party chinese usb controllers don't do this though and this issue will affect more users.

Turning on logging in dolphin GUI also reports that the controllers are being combined. The line number for the log: https://github.com/dolphin-emu/dolphin/blob/4fc8674a7ad7ccafe426db3532b4482907ffff6a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp#L250

Perhaps a environment variable, configuration option, or cli flag to disable the device merging, or perhaps a setting that displays all /dev/input/event devices to choose from would be appropriate. Maybe there's a way in linux udev to report a different serial number to the kernel over usb, and we can simply direct users to a udev rule workaround.

This might be hard to reproduce without purchasing the right hardware and I am willing to try and work on a solution to this.

History

#1 Updated by JosJuice 4 months ago

  • Regression start set to 5.0-11484
  • Regression changed from No to Yes
  • Milestone set to Current
  • Operating system Linux added
  • Operating system deleted (N/A)

#2 Updated by Techjar 4 months ago

The devices all have the same name, correct?

#3 Updated by steel93 4 months ago

dmesg output for 2 controllers:

[106953.227666] usb 1-13: new full-speed USB device number 5 using xhci_hcd
[106953.547807] usb 1-13: New USB device found, idVendor=2563, idProduct=0575, bcdDevice= 1.00
[106953.547809] usb 1-13: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[106953.547811] usb 1-13: Product: Controller (Dinput)
[106953.547813] usb 1-13: Manufacturer: SWITCH CO.,LTD.
[106953.547814] usb 1-13: SerialNumber: AZ-RB-N64P-215 H0
[106953.569189] input: SWITCH CO.,LTD. Controller (Dinput) as /devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-13/1-13:1.0/0003:2563:0575.0011/input/input47
[106953.569478] hid-generic 0003:2563:0575.0011: input,hidraw10: USB HID v1.11 Gamepad [SWITCH CO.,LTD. Controller (Dinput)] on usb-0000:01:00.0-13/input0
[106957.074200] usb 1-12: new full-speed USB device number 6 using xhci_hcd
[106957.394304] usb 1-12: New USB device found, idVendor=2563, idProduct=0575, bcdDevice= 1.00
[106957.394307] usb 1-12: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[106957.394309] usb 1-12: Product: Controller (Dinput)
[106957.394310] usb 1-12: Manufacturer: SWITCH CO.,LTD.
[106957.394311] usb 1-12: SerialNumber: AZ-RB-N64P-215 H0
[106957.416665] input: SWITCH CO.,LTD. Controller (Dinput) as /devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-12/1-12:1.0/0003:2563:0575.0012/input/input48
[106957.416806] hid-generic 0003:2563:0575.0012: input,hidraw11: USB HID v1.11 Gamepad [SWITCH CO.,LTD. Controller (Dinput)] on usb-0000:01:00.0-12/input0
$ udevadm info /dev/input/event265
P: /devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-13/1-13:1.0/0003:2563:0575.0011/input/input47/event265
N: input/event265
L: 0
S: input/by-id/usb-SWITCH_CO._LTD._Controller__Dinput__AZ-RB-N64P-215_H0-event-joystick
S: input/by-path/pci-0000:01:00.0-usb-0:13:1.0-event-joystick
E: DEVPATH=/devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-13/1-13:1.0/0003:2563:0575.0011/input/input47/event265
E: DEVNAME=/dev/input/event265
E: MAJOR=13
E: MINOR=265
E: SUBSYSTEM=input
E: USEC_INITIALIZED=106952233329
E: ID_INPUT=1
E: ID_INPUT_JOYSTICK=1
E: ID_VENDOR=SWITCH_CO._LTD.
E: ID_VENDOR_ENC=SWITCH\x20CO.\x2cLTD.
E: ID_VENDOR_ID=2563
E: ID_MODEL=Controller__Dinput_
E: ID_MODEL_ENC=Controller\x20\x28Dinput\x29
E: ID_MODEL_ID=0575
E: ID_REVISION=0100
E: ID_SERIAL=SWITCH_CO._LTD._Controller__Dinput__AZ-RB-N64P-215_H0
E: ID_SERIAL_SHORT=AZ-RB-N64P-215_H0
E: ID_TYPE=hid
E: ID_BUS=usb
E: ID_USB_INTERFACES=:030000:
E: ID_USB_INTERFACE_NUM=00
E: ID_USB_DRIVER=usbhid
E: ID_PATH=pci-0000:01:00.0-usb-0:13:1.0
E: ID_PATH_TAG=pci-0000_01_00_0-usb-0_13_1_0
E: ID_FOR_SEAT=input-pci-0000_01_00_0-usb-0_13_1_0
E: LIBINPUT_DEVICE_GROUP=3/2563/575:usb-0000:01:00.0-13
E: DEVLINKS=/dev/input/by-id/usb-SWITCH_CO._LTD._Controller__Dinput__AZ-RB-N64P-215_H0-event-joystick /dev/input/by-path/pci-0000:01:00.0-usb-0:13:1.0-event-joystick
E: TAGS=:uaccess:seat:
$ udevadm info /dev/input/event266
P: /devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-12/1-12:1.0/0003:2563:0575.0012/input/input48/event266
N: input/event266
L: 0
S: input/by-id/usb-SWITCH_CO._LTD._Controller__Dinput__AZ-RB-N64P-215_H0-event-joystick
S: input/by-path/pci-0000:01:00.0-usb-0:12:1.0-event-joystick
E: DEVPATH=/devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-12/1-12:1.0/0003:2563:0575.0012/input/input48/event266
E: DEVNAME=/dev/input/event266
E: MAJOR=13
E: MINOR=266
E: SUBSYSTEM=input
E: USEC_INITIALIZED=106956073621
E: ID_INPUT=1
E: ID_INPUT_JOYSTICK=1
E: ID_VENDOR=SWITCH_CO._LTD.
E: ID_VENDOR_ENC=SWITCH\x20CO.\x2cLTD.
E: ID_VENDOR_ID=2563
E: ID_MODEL=Controller__Dinput_
E: ID_MODEL_ENC=Controller\x20\x28Dinput\x29
E: ID_MODEL_ID=0575
E: ID_REVISION=0100
E: ID_SERIAL=SWITCH_CO._LTD._Controller__Dinput__AZ-RB-N64P-215_H0
E: ID_SERIAL_SHORT=AZ-RB-N64P-215_H0
E: ID_TYPE=hid
E: ID_BUS=usb
E: ID_USB_INTERFACES=:030000:
E: ID_USB_INTERFACE_NUM=00
E: ID_USB_DRIVER=usbhid
E: ID_PATH=pci-0000:01:00.0-usb-0:12:1.0
E: ID_PATH_TAG=pci-0000_01_00_0-usb-0_12_1_0
E: ID_FOR_SEAT=input-pci-0000_01_00_0-usb-0_12_1_0
E: LIBINPUT_DEVICE_GROUP=3/2563/575:usb-0000:01:00.0-12
E: DEVLINKS=/dev/input/by-id/usb-SWITCH_CO._LTD._Controller__Dinput__AZ-RB-N64P-215_H0-event-joystick /dev/input/by-path/pci-0000:01:00.0-usb-0:12:1.0-event-joystick
E: TAGS=:uaccess:seat:

The following hacky patch works around the issue in master:

diff --git a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp
index c825da6b7b..0e2249dcff 100644
--- a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp
@@ -245,7 +245,7 @@ static void AddDeviceNode(const char* devnode)

   const auto uniq = libevdev_get_uniq(dev);
   auto evdev_device = FindDeviceWithUniqueID(uniq);
-  if (evdev_device)
+  if (false)
   {
     NOTICE_LOG(SERIALINTERFACE, "evdev combining devices with unique id: %s", uniq);

Let me know if there's other info I can provide.

#4 Updated by Techjar 4 months ago

Yeah looks like it to me. I also like how the identical serial numbers breaks the /dev/input/by-id system.

#5 Updated by Techjar 4 months ago

Pull and build this PR and see if it fixes your issue. https://github.com/dolphin-emu/dolphin/pull/8840

#6 Updated by steel93 4 months ago

That works! Thanks for the quick help!

#7 Updated by JosJuice 4 months ago

  • Status changed from New to Fix pending

#8 Updated by Billiard26 8 days ago

  • Fixed in set to 5.0-12665
  • Status changed from Fix pending to Fixed

Also available in: Atom PDF