libretro / RetroArch

Cross-platform, sophisticated frontend for the libretro API. Licensed GPLv3.
http://www.libretro.com
GNU General Public License v3.0
9.78k stars 1.77k forks source link

Duplicate udev id collision for two different controllers (vendor: 121 and product: 6172) #14867

Closed thingsiplay closed 1 year ago

thingsiplay commented 1 year ago

Description

After a new Linux OS install on same hardware, with reusing the .config/retroarch folder and updating through Online Updater, I noticed a new controller setting colliding with an existing one. One of my controllers is the Mayflash Fightstick F500 and it worked fine 2 weeks ago or so. After inspecting, I found out the file in "autoconfig/udev/SPEEDLINK COMPETITION PRO Game Controller for Android .cfg" (note the space in filename before extension too) will be used automatically instead the correct "autoconfig/udev/Mayflash_Arcade_Fightstick_F300_CONSOLE.cfg". Both have

input_vendor_id = "121"
input_product_id = "6172"

Deleting the Speedlink config solves the problem.

Expected behavior

Autoconfig should use the Mayflash config file instead Speedlink config.

Actual behavior

The wrong Speedlink config will be used for my controller.

Steps to reproduce the bug

  1. "Update Controller Profiles" with Online Updater.
  2. Start RetroArch with the Mayflash Arcade Fightstick F500 controller plugged in.

Bisect Results

This started recently in the last few days or weeks (no exact time). It must

Version/Commit

Environment information

OS: EndeavourOS Linux x86_64 
Kernel: 5.15.88-2-lts 
Uptime: 34 mins 
Packages: 913 (pacman) 
Shell: bash 5.1.16 
Resolution: 2560x1440 
WM: Qtile 
Theme: Arc-Dark [GTK2/3] 
Icons: Papirus-Dark [GTK2/3] 
Terminal: xfce4-terminal 
Terminal Font: Cascadia Code 13 
CPU: Intel Xeon E3-1230 v3 (8) @ 3.700GHz 
GPU: NVIDIA GeForce GTX 1070 
Memory: 1619MiB / 15949MiB 
bslenul commented 1 year ago

IIRC RetroArch checks VID/PID first, then device name, maybe your F500 device name doesn't match any of these 2 autoconfigs? Have you tried creating a new autoconfig for it? If it uses a different device name you could even submit it to the autoconfig repo: https://github.com/libretro/retroarch-joypad-autoconfig

thingsiplay commented 1 year ago

I am not sure what you mean or if you misunderstood me. The config "Mayflash_Arcade_Fightstick_F300_CONSOLE.cfg" matches my controller (since 2 years or so). Buttons and display name are correct. It's just the other config matches from id too and takes higher priority over the "correct" one. When I delete the other config, then it works just fine as before.

Sorry if this was the wrong place to ask. I didn't realize there was a repo for the controller configs. Should I open an issue there?

bslenul commented 1 year ago

What I'm saying is that if device name doesn't match I guess RA just picks the latest autoconfig found, why did it pick the correct one previously however, no idea :x But yeah, I'd recommend creating a new autoconfig to see if it uses a different device name, and if it's different, submit it to the autoconfig repo.

If the device name of the new autoconfig matches however, it might be a RA bug, so the issue being here would be fine I guess.

thingsiplay commented 1 year ago

I just tried it (hopefully did it correctly). I deleted both mentioned files and run RetroArch. It had no button configuration, but had the correct name in Device Index. When I "Save Controller Profile" then it creates following file:

Filename: ". MAYFLASH Arcade Fightstick F500.cfg"

input_driver = "udev"
input_device = ". MAYFLASH Arcade Fightstick F500"
input_vendor_id = "121"
input_product_id = "6172"

So both id's are the same as those from both config files that come with RetroArch.

Edit: The device name from the config file that comes with RetroArch is:

input_device = "MAYFLASH Arcade Fightstick F300/F500 V2"

which is the correct one, but does not match 100% literally, as it is used by two different generation of controllers. Mine is the F500 variant. So if RetroArch checks the device name, it would not match here. Is there a way to ignore specific autoconfig files?

bslenul commented 1 year ago

Is there a way to ignore specific autoconfig files?

If you leave these 3 autoconfigs (the 2 existing ones + the one you've created), RA should now pick the proper one since the VID/PID and the device name match.

Now I'd recommend adding a display name to your new autoconfig (e.g. input_device_display_name = "MAYFLASH Arcade Fightstick F500") and labels for the buttons like

input_up_btn_label = "D-Pad Up" input_down_btn_label = "D-Pad Down" input_left_btn_label = "D-Pad Left" input_right_btn_label = "D-Pad Right"

and so on for ABXY, Start, Select, etc. so it looks nicer, then submit it to the autoconfig repo :)

thingsiplay commented 1 year ago

It does not. So here what I do:

  1. Make sure that both RetroArch configurations are in place.
  2. Delete (move) the wrong one out of the folder, so only the correct one is left.
  3. Create a Profile in GUI with Save Controller Profile.
  4. The new file have no button configuration.
  5. Changing any button or display_name in the file have no impact. RetroArch "seems" to ignore it, even after reload.
  6. This is evident when I re add the previously "deleted" wrong Speedlink file, as a restart of RetroArch would still take that.

That's where I am currently. It seems to ignore the Saved and Created Profile. Otherwise I would just copy the button configuration into it.

Edit: Is it even correct that two different products from different vendors have the same product id and vendor id? One from Speedlink for Android and the other an arcade stick from Mayflash. Maybe the newly added Speedlink device have wrong id? Because previously I think only the Mayflash config file was there and it was correctly picked up. I am using RetroArch with this device since 2 years or so on my PC.

bslenul commented 1 year ago

Just to make sure, can you try saving this as a .cfg in your udev folder:

input_driver = "udev"
input_device = ". MAYFLASH Arcade Fightstick F500"
input_device_display_name = "MAYFLASH Arcade Fightstick F500"
input_vendor_id = "121"
input_product_id = "6172"

input_select_btn = "10"
input_start_btn = "11"
input_menu_toggle_btn = "12"
input_up_btn = "h0up"
input_down_btn = "h0down"
input_left_btn = "h0left"
input_right_btn = "h0right"
input_y_btn = "3"
input_x_btn = "4"
input_b_btn = "0"
input_a_btn = "1"
input_l_btn = "6"
input_r_btn = "7"
input_l2_btn = "8"
input_r2_btn = "9"
input_l_x_plus_axis = "+0"
input_l_x_minus_axis = "-0"
input_l_y_plus_axis = "-1"
input_l_y_minus_axis = "+1"
input_r_x_plus_axis = "+2"
input_r_x_minus_axis = "-2"
input_r_y_plus_axis = "-3"
input_r_y_minus_axis = "+3"

If it's still not picking up this one then I have no idea.

thingsiplay commented 1 year ago

I basically had this. Here the steps I did now:

  1. Delete autoconfig/udev folder.
  2. Start RetroArch and Update Controller Profiles.
  3. Save your suggested config file as autoconfig/udev/. MAYFLASH Arcde Fightstick F500.cfg .
  4. Restart RetroArch.
  5. Check what profile got picked up, and it is the wrong one named Speedlink.

In other words, it picks the wrong profile over the user created one. Sounds like a bug?

bslenul commented 1 year ago

Sounds like a bug?

To me, yes. If there's an autoconfig with only VID/PID matching and another one with VID/PID + device name matching, it should pick the latter.

Or the . MAYFLASH Arcade Fightstick F500 reported device name is incorrect for whatever reason, can't remember exactly how you can double check that on Linux, maybe lsusb -v | grep iProduct on a terminal.

thingsiplay commented 1 year ago
$ lsusb -v 2>/dev/null | grep MAY
Bus 003 Device 005: ID 0079:181c DragonRise Inc. MAYFLASH Arcade Fightstick F500
  iProduct                2 MAYFLASH Arcade Fightstick F500

WOW! That's it! I just tried to use the device id "DragonRise Inc. MAYFLASH Arcade Fightstick F500" and Edit: ~(it works! So this is not a bug in RetroArch then. Thank you, this was the important tip.)~ it only halfway works, explained in following comments.

thingsiplay commented 1 year ago

Oh no, it only works halfway. I forgot that I deleted the Speedlink configuration. Adding it back, will have higher priority. When naming input_device = "DragonRise Inc. MAYFLASH Arcade Fightstick F500" in my custom .cfg file, then it will have higher priority over the existing Mayflash .cfg from RetroArch itself. But as soon as I copy the wrong Speedlink back to udev folder (which would be when updating), that file takes priority over the other Mayflash .cfg.

Here the lsusb info about the device:

Bus 003 Device 005: ID 0079:181c DragonRise Inc. MAYFLASH Arcade Fightstick F500
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x0079 DragonRise Inc.
  idProduct          0x181c 
  bcdDevice            1.00
  iManufacturer           1 .
  iProduct                2 MAYFLASH Arcade Fightstick F500
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0029
    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.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength     123
         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     0x0040  1x 64 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     0x0040  1x 64 bytes
        bInterval              10
bslenul commented 1 year ago

Hmm, and what about just input_device = "MAYFLASH Arcade Fightstick F500" in the .cfg? So without DragonRise Inc. or . before.

If it still doesn't work, try dmesg in terminal, near the end you should see an "input:" line, does it have a different name there?

I'm asking because I just boot my Linux VM to test, and with my X1 controller I have Xbox One Controller with lsusb and X-Box One pad with dmesg.

thingsiplay commented 1 year ago

Without "Dragon" or a dot only does not work either... at least, it has higher priority over the other Mayflash configs, but as soon as the Speedlink one is added, that takes priority still.

$ sudo dmesg | grep -E "MAY|F500"
[    3.733654] usb 3-9.2: Product: MAYFLASH Arcade Fightstick F500
[    5.465112] input: . MAYFLASH Arcade Fightstick F500 as /devices/pci0000:00/0000:00:14.0/usb3/3-9/3-9.2/3-9.2:1.0/0003:0079:181C.0005/input/input9
[    5.465173] hid-generic 0003:0079:181C.0005: input,hidraw4: USB HID v1.11 Gamepad [. MAYFLASH Arcade Fightstick F500] on usb-0000:00:14.0-9.2/input0

Searching for $ sudo dmesg | grep Dragon is just empty, so nothing Dragon related there. And here if I filter by "input":

$ sudo dmesg | grep input
[    0.374013] input: Power Button as /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0C:00/input/input0
[    0.374052] input: Sleep Button as /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0E:00/input/input1
[    0.374083] input: Power Button as /devices/LNXSYSTM:00/LNXPWRBN:00/input/input2
[    5.315724] input: Logitech G502 HERO Gaming Mouse as /devices/pci0000:00/0000:00:14.0/usb3/3-13/3-13:1.0/0003:046D:C08B.0001/input/input3
[    5.316494] hid-generic 0003:046D:C08B.0001: input,hidraw0: USB HID v1.11 Mouse [Logitech G502 HERO Gaming Mouse] on usb-0000:00:14.0-13/input0
[    5.317673] input: Logitech G502 HERO Gaming Mouse Keyboard as /devices/pci0000:00/0000:00:14.0/usb3/3-13/3-13:1.1/0003:046D:C08B.0002/input/input4
[    5.382019] hid-generic 0003:046D:C08B.0002: input,hiddev96,hidraw1: USB HID v1.11 Keyboard [Logitech G502 HERO Gaming Mouse] on usb-0000:00:14.0-13/input1
[    5.383676] input: ASUS Xonar U7 MKII as /devices/pci0000:00/0000:00:1c.6/0000:0a:00.0/usb5/5-2/5-2:1.4/0003:0B05:183C.0003/input/input7
[    5.461947] hid-generic 0003:0B05:183C.0003: input,hidraw2: USB HID v1.00 Device [ASUS Xonar U7 MKII] on usb-0000:0a:00.0-2/input4
[    5.464223] input: USB,2-axis 8-button gamepad   as /devices/pci0000:00/0000:00:14.0/usb3/3-9/3-9.1/3-9.1:1.0/0003:0583:2060.0004/input/input8
[    5.464419] hid-generic 0003:0583:2060.0004: input,hidraw3: USB HID v1.10 Joystick [USB,2-axis 8-button gamepad  ] on usb-0000:00:14.0-9.1/input0
[    5.465112] input: . MAYFLASH Arcade Fightstick F500 as /devices/pci0000:00/0000:00:14.0/usb3/3-9/3-9.2/3-9.2:1.0/0003:0079:181C.0005/input/input9
[    5.465173] hid-generic 0003:0079:181C.0005: input,hidraw4: USB HID v1.11 Gamepad [. MAYFLASH Arcade Fightstick F500] on usb-0000:00:14.0-9.2/input0
[    5.628196] input: PC Speaker as /devices/platform/pcspkr/input/input10
[    5.768483] input: HDA NVidia HDMI/DP,pcm=3 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input11
[    5.768551] input: HDA NVidia HDMI/DP,pcm=7 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input12
[    5.768611] input: HDA NVidia HDMI/DP,pcm=8 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input13
[    5.768656] input: HDA NVidia HDMI/DP,pcm=9 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input14
[    5.768703] input: HDA NVidia HDMI/DP,pcm=10 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input15
[    5.768742] input: HDA NVidia HDMI/DP,pcm=11 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input16
[    5.768784] input: HDA NVidia HDMI/DP,pcm=12 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input17
[    5.925073] snd_hda_codec_realtek hdaudioC0D0:    inputs:
[    5.998810] input: HDA Intel PCH Rear Mic as /devices/pci0000:00/0000:00:1b.0/sound/card0/input18
[    5.998870] input: HDA Intel PCH Line as /devices/pci0000:00/0000:00:1b.0/sound/card0/input19
[    5.998907] input: HDA Intel PCH Line Out Front as /devices/pci0000:00/0000:00:1b.0/sound/card0/input20
[    5.998944] input: HDA Intel PCH Line Out Surround as /devices/pci0000:00/0000:00:1b.0/sound/card0/input21
[    5.998993] input: HDA Intel PCH Line Out CLFE as /devices/pci0000:00/0000:00:1b.0/sound/card0/input22
[    6.010530] input: ROCCAT ROCCAT Ryos MK Pro as /devices/pci0000:00/0000:00:14.0/usb3/3-9/3-9.4/3-9.4.3/3-9.4.3:1.0/0003:1E7D:3232.0006/input/input23
[    6.071985] ryos 0003:1E7D:3232.0006: input,hidraw5: USB HID v1.11 Keyboard [ROCCAT ROCCAT Ryos MK Pro] on usb-0000:00:14.0-9.4.3/input0
[    6.072407] input: ROCCAT ROCCAT Ryos MK Pro as /devices/pci0000:00/0000:00:14.0/usb3/3-9/3-9.4/3-9.4.3/3-9.4.3:1.1/0003:1E7D:3232.0007/input/input24
[    6.142060] ryos 0003:1E7D:3232.0007: input,hiddev97,hidraw6: USB HID v1.11 Pointer [ROCCAT ROCCAT Ryos MK Pro] on usb-0000:00:14.0-9.4.3/input1

I also have two other gamepads setup, one Buffalo USB SNES and XBox One S with xone driver. They work as intended. Just mentioning it, if I can test something for comparison. Otherwise ignore this last paragraph.

bslenul commented 1 year ago

OK so dmesg outputs that same name as before (". MAYFLASH Arcade Fightstick F500"), so this should be the correct "input_device" name to use 🤔

One last thing to check, idk why I didn't think of it sooner: in RA, go to Main Menu > Information > System Information and check the "Port 1 Device Name" from here.

thingsiplay commented 1 year ago

https://i.imgur.com/vNFIDAf.png - with the custom .cfg and both RetroArch .cfg files in place. It shows the device name as ". MAYFLASH Arcade Fightstick F500", but below it the device config display name is the Speedlink .cfg file.

https://i.imgur.com/n5bhzRV.png - with the custom .cfg and RetroArch Mayflash .cfg, but the Speedlink .cfg file deleted. Device name is same and othis time it choose the custom .cfg file correctly.

bslenul commented 1 year ago

OK, so yeah it should definitely pick the .cfg with these name/vid/pid inside:

input_device = ". MAYFLASH Arcade Fightstick F500" input_vendor_id = "121" input_product_id = "6172"

I have absolutely no idea why it does not, sorry :x

As a workaround I guess you could just save the autoconfig as ZMAYFLASH Arcade Fightstick F500.cfg, with a "Z" at the beginning of the filename to make sure it is scanned after the "SPEEDLINK" one, then it should use the one you want.

thingsiplay commented 1 year ago

Wait a minute, something happened. It seems to work correctly now. I was experimenting with changing the id in Speedlink .cfg and such and suddenly it works. To make sure it works:

  1. Deleted the udev folder.
  2. Start RetroArch and Update Controller Profiles.
  3. Save the custom config file (below) as autoconfig/udev/Mayflash_Arcade_Fightstick_F500_CONSOLE.cfg
  4. Restart RetroArch. (multiple times to make sure)
  5. It picks up the custom .cfg file correctly. Even with both RetroArch .cfg files in place too.

I have no idea why it does pick it up now. Is there maybe a cache? Maybe I forced to update the cache when changing the id in the Speedlink file? Because otherwise nothing changed, as I deleted and redownloaded the udev "folder" and just copied the same config as before.

_Mayflash_Arcade_Fightstick_F500CONSOLE.cfg:

input_driver = "udev"
input_device = ". MAYFLASH Arcade Fightstick F500"
input_device_display_name = "MAYFLASH Arcade Fightstick F500 (CONSOLE)"
input_vendor_id = "121"
input_product_id = "6172"

input_select_btn = "10"
input_start_btn = "11"
input_menu_toggle_btn = "12"
#
input_up_btn = "h0up"
input_down_btn = "h0down"
input_left_btn = "h0left"
input_right_btn = "h0right"
#
input_y_btn = "3"
input_x_btn = "4"
input_b_btn = "0"
input_a_btn = "1"
#
input_l_btn = "6"
input_r_btn = "7"
input_l2_btn = "8"
input_r2_btn = "9"
#
input_l_x_plus_axis = "+0"
input_l_x_minus_axis = "-0"
input_l_y_plus_axis = "-1"
input_l_y_minus_axis = "+1"
input_r_x_plus_axis = "+2"
input_r_x_minus_axis = "-2"
input_r_y_plus_axis = "-3"
input_r_y_minus_axis = "+3"
bslenul commented 1 year ago

Well thats... weird 😅 I'm not aware of any cache for autoconfigs, AFAIK they're scanned every time RA starts.

In any case, not sure what happened but I'm glad you got it to work! :+1:

thingsiplay commented 1 year ago

Thank you so much for your patience! You gave good tips to look for. I just tested to delete my config and "force" RetroArch to pick the wrong candidate. Then put the custom .cfg back and it works just fine now. Maybe there is a bug, but its really good at hiding? Or it is something on my side I did not correctly, whatever that is.

So what should I do now? Closing and forget it? If this bug comes back, I will reopen this issue, guess.

bslenul commented 1 year ago

Close and reopen if it comes back (or even open a new issue, might be easier to read without all the replies :D ) sounds good to me!