Fixed binds without modifiers not matching while a modifier is held - #6597
Conversation
|
im not a big fan of the idea that introducing a new keybind can affect the behavior of an existing keybind, i think a better solution would be to add a toggle into the keybind setting controlling whether to strictly match modifiers |
|
Almost perfect, but one issue. If I have: Module 1 bound to C and I press Ctrl + Shift+ C, then module 1 will toggle, but I think it should be module 2. If you fix this, I will merge. |
|
I've tried fixing this issue myself a couple times and getting all the edge cases lined up might not be worth the effort and added complexity. This fixes the actual issues we have and my earlier comment is technically a dispute over behaviour rather than a real bug. Might come back and see if I can make the system perfect but this is good enough for now. |
Type of change
Description
Since 56a7703 ("Fixed modifier keybinds triggering non modifier varients", #6586), a keybind
that has no modifiers only matches when no modifier at all is held:
That breaks two ordinary cases:
1. Binds on a bare modifier key never trigger.
KeyboardHandlerMixindeliberately sets amodifier key's own bit on its press event (the workaround for glfw/glfw#1630), so pressing
Left Alt arrives as
key=342, modifiers=MOD_ALT. A module bound to plain Left Alt thereforenever matches on press. Mine (Free Look on Left Alt) went dead after updating, and only
toggling from the module list still worked. Release does match, but that path only fires for
toggleOnBindRelease.2. Any bind dies while a modifier is held for an unrelated reason. Sneaking holds Shift,
sprinting holds Ctrl. Press a plain bind during either and it no longer matches.
The underlying issue is that #6586 treats a held modifier as disqualifying, when what it
actually wanted is for
Ctrl + Gnot to also trigger a module bound to plainG. That is aquestion of precedence between binds, not of what the bind itself matches, so this moves it to
where the binds are dispatched:
Keybind#matchesgoes back to ignoring modifiers for a bind that has none.Modules#onActionfirst checks whether any module's bind with modifiers matches the event;if one does, binds without modifiers are skipped for that event.
Ctrl + Gstill fires only the chorded bind,Galone still fires the plain one, and plainbinds work again while sneaking, sprinting, or when the bound key is itself a modifier.
Related issues
Regression from #6586 (56a7703).
How Has This Been Tested?
Built and run on 26.2 (production, Fabric) with Free Look bound to plain Left Alt:
Modules#onAction: the press arrives asvalue=342 mods=4and now matches, where before itdid not.
Gand another toCtrl + G:Ctrl + Gtoggles only the chordedmodule,
Galone toggles only the plain one.Checklist: