Input ports on macOS are assigned in an arbitrary order, causing joypad index settings to break
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 14.1k
- Forks
- 2.2k
- Avg merge
- 7h 35m
- Merged PRs (30d)
- 51
Description
Description
When RetroArch starts up, the input ports are assigned to a seemingly random device each time. This means that the input_playerN_joypad_index settings are useless, and there's no apparent way to assign a specific controller to any port that will persist between invocations of RetroArch.
Expected behavior
When RetroArch starts up, each port is consistently assigned to the same controller given its input_playerN_joypad_index setting.
Further, RetroArch's input driver will enumerate the connected controllers in the same, consistent order each time it starts up.
Actual behavior
The port mappings keep changing each time RetroArch starts up.
Steps to reproduce the bug
- Connect two controllers to a mac system
- Start RetroArch and observe the order of the controllers in the process output, something like:
[INFO] Port 0: Controller A.
[INFO] Port 1: Controller B. - Restart Retroarch several times, and observe that the order will eventually change:
[INFO] Port 0: Controller B.
[INFO] Port 1: Controller A.
Bisect Results
This bug appears to have been introduced with RetroArch 1.9.8. I've been unable to trigger it in 1.9.7 and can easily trigger it in 1.9.8. I can't narrow down which commit introduces it as I'm not set up to build.
Edit: After looking through RetroArch's code and looking at the history of input/drivers_hid/iohidmanager_hid.c which I believe is the code that sets up controllers on macOS, the only two commits could be the culprit are ce4fce1 and 35c2ec9. It looks like a recent fix for a macOS controller duplication bug has introduced a new bug so that controllers are not ordered deterministically.
Version/Commit
- RetroArch: 1.19.12, build date: Oct 24 2021. (Official build)
Environment information
- OS: macOS 10.14.6
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading input/drivers_hid/iohidmanager_hid.c and comparing the controller-enumeration changes in commits ce4fce1 and 35c2ec9. Reproduce the issue with two controllers on macOS, then verify that port assignments and input_playerN_joypad_index mappings remain consistent across repeated launches.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, macos
- Domain
- desktop, operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100