Fix stuck hold-actions when modifiers change before key release#8097
Open
MadeByGabe wants to merge 1 commit into
Open
Fix stuck hold-actions when modifiers change before key release#8097MadeByGabe wants to merge 1 commit into
MadeByGabe wants to merge 1 commit into
Conversation
Key-release actions are dispatched from the engine's https://github.com/beyond-all-reason/RecoilEngine/blob/2186ee490c027eb2993ce2f67b98d4978ded142e/rts/System/SpringApp.cpp#L1175-L1180, but the engine resets the modifier states before emitting the key up. For a modified bind (e.g. Shift+key), if the modifiers no longer match at release time the bound action never gets into that list and its release handler never runs. Capture the actions each physical key triggers at press time (keyed by scancode) and dispatch those on release, independent of the modifier state. Fall back to the engine list only when nothing was captured, preserving existing behaviour. Fixes CommandInsert getting stuck in insert mode on 'Shift+key' binds beyond-all-reason#7994
2 tasks
Contributor
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.
actionHandler:KeyActionbuilt its release dispatch from the engine-providedactionswhich the engine recomputes from the current modifier state at release time.Let's consider a modified bind (e.g.
Shift+n): If I releasednwhile still holding shift, the engine's release dispatch containedshift+nand the release handler ran since it was registered toshift+n.But if I released
Shiftfirst, only then releasedn, the engine's release dispatch contained onlynand the release handler never ran since the handler was expecting shift+n.The action was stuck in its hold state.
Same if we changed the modifiers for example by alt-tabbing away, or by simply holding ctrl then releasing shift, etc...
Work done
Capture the action list each key triggers at press time(keyed by scancode), and use those on release.
The engine's list is used only as a fallback when nothing was captured.
Test steps
Shift+sc_n commandinsert prepend_betweenI tested all widgets which register hold-style actions, the only issue I found was with
gui_overview_cam_tab_hold.luawhich doesn't work as expected but not because of this fix, it doesn't work correctly without the fix either (neithergui_overview_keep_camera_position.luathough that's unrelated).Relevant other PR: #7994
I'm not 100% confident in this fix, I don't know if there are any other edge cases that could cause issues, or that I even understand the engine's behavior well enough to be sure this is a complete/correct fix.
AI / LLM usage statement:
Claude Opus 4.8 validated my reasoning and fix.