Skip to content

Conversation

@thierry-f-78
Copy link
Contributor

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:

  • Added else branch to reset m_keys_pressed[i] = false when button is not in "just pressed" state
  • This ensures the flag is only true for exactly one frame when transitioning from unpressed to pressed

Issue 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:

  • Makes joystick controls usable for toggle actions
  • Brings joystick behavior in line with keyboard input handling
  • Essential for proper gamepad support

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.

  • Fix identified and implemented
  • Tested with joystick/gamepad controllers (PS5 DualSense support is in a separate PR)
  • Verified toggle actions (minimap, camera mode, fly mode) now trigger once per button press

How to test

  1. Connect a joystick/gamepad to your system
  2. Map any button to a toggle action (e.g., MINIMAP on D-pad, CAMERA_MODE on face button)
  3. Before fix: Press and release the button → action toggles rapidly multiple times
  4. After fix: Press and release the button → action toggles exactly once
  5. Test with multiple toggle actions: MINIMAP, CAMERA_MODE, FREEMOVE, TOGGLE_HUD, etc.

Example config to test:

joystick_type = xbox  # or auto
# Map button to a toggle action in settings

Press the mapped button and verify the action toggles once, not continuously.

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.
@sfan5 sfan5 added the Trivial The change is a trivial bug fix, documentation or maintenance change, as per the Git Guidelines label Jan 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bugfix 🐛 PRs that fix a bug @ Client / Controls / Input Trivial The change is a trivial bug fix, documentation or maintenance change, as per the Git Guidelines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants