Repository navigation
Route to controller setup when joystick present without saved mapping - #28
Merged
Merged
Conversation
A joystick present with no saved input_mapping.json was routing straight to Parent Menu using the built-in DEFAULT_BUTTONS guess, which is only a starting point and is frequently wrong for a given device's raw SDL button order (confirmed on an Anbernic RG35XX-SP). When the guess is wrong, none of Parent Menu's south_button/start/select actions fire, so the screen looks completely unresponsive with no way to reach the existing "Controller test & setup" / hold-3s calibration flow, since that flow itself lives behind a Parent Menu selection. Now the app detects a connected, uncalibrated joystick and opens the controller setup screen first; keyboard-only (desktop) setups are unaffected since KEYBOARD_SEMANTICS needs no calibration. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RdSir99dM2BXm2oRHnH5Jf
The real cause of the dead Parent Menu on device: every joystick was opened with pygame.joystick.Joystick(i).init() and the object discarded. In pygame 2 the SDL device is closed again when the Joystick object is garbage collected, and SDL only delivers JOYBUTTONDOWN/JOYHATMOTION/ JOYAXISMOTION for open devices — so the controller was detected and logged, then silently closed before the first frame, and no gamepad input (buttons OR hat d-pad) ever reached the app. Retain the objects in a registry keyed by instance id, populated at startup and on JOYDEVICEADDED (main poll, input diagnostic, and calibration screens), and dropped on JOYDEVICEREMOVED. The legacy reviewer in ui.py gets the same fix with a simple list. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RdSir99dM2BXm2oRHnH5Jf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Added logic to detect when a joystick/controller is connected but has no saved button mapping, and automatically route to the input calibration screen instead of the parent menu. This prevents users from being stranded on an unresponsive screen.
Key Changes
run()method that checks if:INPUT_DIAG(controller setup) state instead of the parent menuKEYBOARD_SEMANTICSdoesn't require calibrationImplementation Details
The fix addresses a UX issue where incorrect default button mappings for a specific controller would cause the app to start in an unresponsive state. By forcing calibration first when a joystick is detected without a saved mapping, users can properly configure their controller before proceeding to normal operation.
https://claude.ai/code/session_01RdSir99dM2BXm2oRHnH5Jf