diff options
author | fauxpark <fauxpark@gmail.com> | 2019-10-16 10:02:09 +1100 |
---|---|---|
committer | Joel Challis <git@zvecr.com> | 2019-10-16 00:02:09 +0100 |
commit | 63f4806d7a67100fdf37b5f557ceb9d0982c0775 (patch) | |
tree | c942f96e391b32e91753516fe0b07af639fc5b97 /quantum | |
parent | 45225190794b438129d5b27d4fe5b756fdf2efc4 (diff) | |
download | firmware-63f4806d7a67100fdf37b5f557ceb9d0982c0775.tar.gz firmware-63f4806d7a67100fdf37b5f557ceb9d0982c0775.tar.bz2 firmware-63f4806d7a67100fdf37b5f557ceb9d0982c0775.zip |
Fix bug in `do_code16()` (#6935)
* Fix bug in `do_code16()`
* Remove qk_ mods functions
Diffstat (limited to 'quantum')
-rw-r--r-- | quantum/quantum.c | 50 |
1 files changed, 17 insertions, 33 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c index f4999456e..e615cfc0f 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -85,44 +85,28 @@ static void do_code16(uint16_t code, void (*f)(uint8_t)) { return; } - if (code & QK_LCTL) f(KC_LCTL); - if (code & QK_LSFT) f(KC_LSFT); - if (code & QK_LALT) f(KC_LALT); - if (code & QK_LGUI) f(KC_LGUI); + uint8_t mods_to_send = 0; - if (code < QK_RMODS_MIN) return; - - if (code & QK_RCTL) f(KC_RCTL); - if (code & QK_RSFT) f(KC_RSFT); - if (code & QK_RALT) f(KC_RALT); - if (code & QK_RGUI) f(KC_RGUI); -} - -static inline void qk_register_weak_mods(uint8_t kc) { - add_weak_mods(MOD_BIT(kc)); - send_keyboard_report(); -} - -static inline void qk_unregister_weak_mods(uint8_t kc) { - del_weak_mods(MOD_BIT(kc)); - send_keyboard_report(); -} - -static inline void qk_register_mods(uint8_t kc) { - add_weak_mods(MOD_BIT(kc)); - send_keyboard_report(); -} + if (code & QK_RMODS_MIN) { // Right mod flag is set + if (code & QK_LCTL) mods_to_send |= MOD_BIT(KC_RCTL); + if (code & QK_LSFT) mods_to_send |= MOD_BIT(KC_RSFT); + if (code & QK_LALT) mods_to_send |= MOD_BIT(KC_RALT); + if (code & QK_LGUI) mods_to_send |= MOD_BIT(KC_RGUI); + } else { + if (code & QK_LCTL) mods_to_send |= MOD_BIT(KC_LCTL); + if (code & QK_LSFT) mods_to_send |= MOD_BIT(KC_LSFT); + if (code & QK_LALT) mods_to_send |= MOD_BIT(KC_LALT); + if (code & QK_LGUI) mods_to_send |= MOD_BIT(KC_LGUI); + } -static inline void qk_unregister_mods(uint8_t kc) { - del_weak_mods(MOD_BIT(kc)); - send_keyboard_report(); + f(mods_to_send); } void register_code16(uint16_t code) { if (IS_MOD(code) || code == KC_NO) { - do_code16(code, qk_register_mods); + do_code16(code, register_mods); } else { - do_code16(code, qk_register_weak_mods); + do_code16(code, register_weak_mods); } register_code(code); } @@ -130,9 +114,9 @@ void register_code16(uint16_t code) { void unregister_code16(uint16_t code) { unregister_code(code); if (IS_MOD(code) || code == KC_NO) { - do_code16(code, qk_unregister_mods); + do_code16(code, unregister_mods); } else { - do_code16(code, qk_unregister_weak_mods); + do_code16(code, unregister_weak_mods); } } |