libretro / libretro/RetroArch

Controllers changing GPIO joystick device ID on restart

Open
#17,219 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
14.1k
Forks
2.2k
Avg merge
7h 35m
Merged PRs (30d)
51

Description

Description

Controllers shifting joystick device indexes but not port mappings on restart leading to non-functional controls on both devices.

Expected behavior

GPIO joystick keeps it's configured device/port mapping from joystick.conf. Control mappings remember what device type they were configured for even if their index or port changes such that they stay functional during player drop in/out or restart, without having to rely on auto-configure which could overwrite said mappings.

Actual behavior

The mk_arcade_joystick_rpi is set to map=1 in joystick.conf which, during normal operation, puts the joystick in index 1 port 1 and the controller in index 2 port 2 as intended when a new one is connected. However, on a restart one of several things can happen:

  • Devices switch indexes on opposite ports leaving both inputs with inoperable mappings
  • Devices switch indexes on opposite ports and the inputs work in menus (using default mappings only) but not in any cores

Thinking this might be an Xbox thing or 3rd party controller issue, I tried with a PS4 controller and had the same issues. Connecting all three devices simultaneously then restarting results in even weirder behaviour:

  • Xbox controller seizes index 1
  • PS4 controller is pushed from index 1 to 2
  • Joystick is pushed to index 3
  • PS4 mouse controls are still bound to index 1 despite being Xbox controlled now
  • Button mappings are still bound to their respective ports but unable to function correctly

Then disconnecting the PS4 controller but leaving the Xbox controller and restarting...

  • Xbox keeps index 1 but switches to port 2
  • Joystick switches to index 2 but jumps to port 1
  • Mouse controls reverted to default

Interesting thing to note is that this happens each restart of the RetroArch application without rebooting the Pi itself or changing input device connectivity between restarts. If I leave the flipped indexes, it restarts fine as if that's the preferred order but only if I keep the same controller(s) connected every restart. This would be fine if the devices rebind to their original ports or carries the control mappings over but that never appears to be the case. Auto configure is disabled as it auto-fills the joystick mapping with non-existent or duplicate controls that cannot be removed otherwise.

This may be related, but the turbo button binding is permanently stuck as 'B' for all controllers despite what the config is set to during all this, even if the rest of the controls are seemingly inoperable. There also may be some relation to issue #17113

Going to take another deeper look at this soon with logging enabled to hopefully make sense of this behaviour.

Steps to reproduce the bug
  1. Start RetroArch with only the joystick connected to device index 1 port 1
  2. Connect controller and verify it has connected to device index 2 port 2
  3. Disable auto-config and save mappings for both devices in their respective ports
  4. Restart RetroArch without rebooting the system or disconnecting either device
  5. Check that the device indexes has shifted to incorrect ports and mappings
  6. Start a core and note the controls are no longer functional

Extra: B Turbo button mapping cannot be remapped or disabled during all this for some unknown reason. May be a separate issue.

Bisect Results

This is occurring on a fresh install of Lakka on a RPi 4B+ using mk_arcade_joystick_rpi for the GPIO joystick.

Version/Commit
  • RetroArch: ad8975c
Environment information
  • Hardware:
    • Raspberry Pi 4B+ (4GB)
    • Gulikit KK3 Max
    • PS4 Controller
    • GPIO Joystick (8 buttons, 1 stick)
  • OS: Lakka 5.0 (RetroArch 1.17.0)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the restart sequence with the GPIO joystick, Xbox or PS4 controller, and auto-configuration disabled, using joystick.conf and the listed RetroArch commit. Trace how device indexes, ports, and saved mappings are restored across restarts; done means mappings remain attached to the intended devices and controls work in cores, with the turbo-button behavior clarified separately.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.