diff options
author | Okke Formsma <okke@formsma.nl> | 2021-01-22 17:00:19 +0100 |
---|---|---|
committer | Pete Johanson <peter@peterjohanson.com> | 2021-01-24 23:30:41 -0500 |
commit | 7b7701ae90469b920cd78e2ab7aca0c470140b7a (patch) | |
tree | b4fade597239b5f0df24197faea3413e305a636f /app/src/hid.c | |
parent | 0c30b49063c79be2416453f4544795922efad74f (diff) |
feature(modifiers): add explicit modifiers
this makes LS(LEFT_CONTROL) work as if shift and control were both
pressed explicitly. Previously, the left shift would have been released
as soon as another key was pressed. The implicit behavior is useful in
case of LS(NUMBER_1) when rolling over to other keys.
Also see #361.
Diffstat (limited to 'app/src/hid.c')
-rw-r--r-- | app/src/hid.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/app/src/hid.c b/app/src/hid.c index 65eabd9..7ab080e 100644 --- a/app/src/hid.c +++ b/app/src/hid.c @@ -51,6 +51,24 @@ int zmk_hid_unregister_mod(zmk_mod_t modifier) { return 0; } +int zmk_hid_register_mods(zmk_mod_flags_t modifiers) { + for (zmk_mod_t i = 0; i < 8; i++) { + if (modifiers & (1 << i)) { + zmk_hid_register_mod(i); + } + } + return 0; +} + +int zmk_hid_unregister_mods(zmk_mod_flags_t modifiers) { + for (zmk_mod_t i = 0; i < 8; i++) { + if (modifiers & (1 << i)) { + zmk_hid_unregister_mod(i); + } + } + return 0; +} + #define TOGGLE_KEYBOARD(match, val) \ for (int idx = 0; idx < ZMK_HID_KEYBOARD_NKRO_SIZE; idx++) { \ if (keyboard_report.body.keys[idx] != match) { \ |