linput

Listen to input events
git clone git://git.akobets.xyz/linput
Log | Files | Refs | README | LICENSE

commit 51c814611bc02e7103a6137dc0bf8176c3cc3d30
parent 8d319e372a35d18d6804147138e4eb5992711e07
Author: Artem Kobets <artem@akobets.xyz>
Date:   Sat, 18 Apr 2020 14:54:02 +0300

hotkey match logic fixes

Diffstat:
Mlinput.c | 23++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/linput.c b/linput.c @@ -156,16 +156,25 @@ is_hotkey_active(const struct HotkeyRule *hotkey, int last_key) int k; int match = 1; + if (!is_match_hotkey_mod(hotkey)) + match = 0; + + if (!is_mod(last_key)) { + if (!has_key(hotkey, last_key)) + match = 0; + if (!is_match_hotkey_event(hotkey, last_key)) + match = 0; + } + for (k = 1; match && k < LENGTH(key_state); k++) { - if (k == last_key) { - if (!is_match_hotkey_event(hotkey, k)) - match = 0; - } else if (has_key(hotkey, k)) { + if (k == last_key || is_mod(k)) + /* skip, handled above */ + continue; + + if (has_key(hotkey, k)) { /* all other keys in hotkey should be pressed */ if (key_state[k] == 0) match = 0; - } else if (is_mod(k)) { - /* skip, modifier keys are handled separately */ } else { /* all keys not in hotkey should not be pressed */ if (key_state[k] != 0 && !is_key_ignored(k)) @@ -173,7 +182,7 @@ is_hotkey_active(const struct HotkeyRule *hotkey, int last_key) } } - return match && is_match_hotkey_mod(hotkey); + return match; } void