Fix joystick button toggle actions repeating indefinitely #16807
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
Fix joystick button toggle actions repeating indefinitely
When a joystick button was pressed, toggle actions (like minimap, camera mode) would repeat continuously instead of triggering once.
The issue was that
m_keys_pressed[i]was set to true when a button was pressed, but was never reset to false when the button state remained unchanged or was released. This caused toggle actions to be re-triggered every frame.Now properly reset
m_keys_pressed[i]to false when the button is not in a "just pressed" state, ensuring toggle actions only fire once per button press.Details
Goal: Fix joystick toggle button behavior to match keyboard behavior (single activation per press)
How it works:
elsebranch to resetm_keys_pressed[i] = falsewhen button is not in "just pressed" stateIssue resolved: Fixes unreported bug where any joystick button mapped to a toggle action (MINIMAP, CAMERA_MODE, FREEMOVE, etc.) would continuously trigger every frame instead of once per press
Why needed:
AI disclosure: Claude (Anthropic) was used to help identify the root cause and suggest the fix during debugging session
To do
This PR is Ready for Review.
How to test
Example config to test:
Press the mapped button and verify the action toggles once, not continuously.