8000 Route to controller setup when joystick present without saved mapping by jmahmood · Pull Request #28 · jmahmood/CardBrick · GitHub
[go: up one dir, main page]

Skip to content

Route to controller setup when joystick present without saved mapping - #28

Merged
jmahmood merged 2 commits into
masterfrom
claude/install-keypress-registration-bess6q
Jul 8, 2026
Merged

jmahmood merged 2 commits into
masterfrom
claude/install-keypress-registration-bess6q

Conversation

@jmahmood
@jmahmood jmahmood commented Jul 8, 2026
Copy link
Copy Markdown
Owner

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

  • Added a new conditional branch in the run() method that checks if:
    • Input mapping is using default/uncalibrated buttons
    • A joystick device is physically present
  • When both conditions are true, the app now starts in INPUT_DIAG (controller setup) state instead of the parent menu
  • Keyboard-only setups (desktop testing) are unaffected since KEYBOARD_SEMANTICS doesn't require calibration
  • Added a warning log message to inform users why the app is starting in controller setup

Implementation 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

claude added 2 commits July 8, 2026 03:53
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
@jmahmood
jmahmood merged commit 02add70 into master Jul 8, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0