RetroArch icon indicating copy to clipboard operation
RetroArch copied to clipboard

[feature request] Use gamepad serial to uniquely identify pads

Open hizzlekizzle opened this issue 4 years ago • 2 comments

Description

Currently, vid, pid and device name are the only fields we use to identify gamepads. This can be a problem when a controller goes to sleep and the driver/OS never informs RetroArch that the pad has disconnected, since it will show up as a brand new pad when it wakes back up. If we included the serial, we could uniquely identify pads to know when the same controller has reconnected, as well as potentially enable gamepad-specific remaps.

Expected behavior

When controllers go to sleep and wake back up, RetroArch sees that it's the same controller and returns it to its previous control state.

Actual behavior

RetroArch thinks it's a new controller and drops it into P2, P3, P4 ... each time it reconnects.

Steps to reproduce the bug

  1. connect a bluetooth controller
  2. let it go to sleep and then wake it back up
  3. it will be dropped into the P2 slot instead of P1, and you will no longer be able to control the game/menu

Bisect Results

has always happened

Version/Commit

You can find this information under Information/System Information

  • RetroArch: 1.9.10 stable

Environment information

  • OS: ubuntu bionic, but it happens everywhere
  • Compiler: gcc

hizzlekizzle avatar Oct 03 '21 19:10 hizzlekizzle

This is a good idea however I could be wrong here but if its like the rest of the gamepad stuff the serials will be identical too on the cheaper stuff. Might be wrong though hope that is the case have you compared the serials on two identical controllers?

udevadm info -a -n

should list all the info worth checking its unique before moving forward

ghost avatar Oct 04 '21 13:10 ghost

On Linux using udev, we could use the uniq attribute (which is persistent) as it seems the serial is the same per device type

udevadm info -a  /sys/devices/XXX/inputX  --no-pager | grep -E 'uniq|serial' (getting path from dmesg)
udevadm info -a  -n /dev/input/js0  --no-pager | grep -E 'uniq|serial'

Unfortunately, it seems not all joypad controllers provide the uniq attribute.

I could check at least DS4 and Switch Pro provide it.

@zoltanvb Do you think it will be possible to add to udev joypad driver the uniq attribute if defined for the (dis)connect process ?

Thank you.

P.S = SDL2 GUID seems to be unique per model, not per device.

gouchi avatar May 29 '25 12:05 gouchi