From: SjB Date: Sun, 29 Jan 2017 17:06:24 +0000 (-0500) Subject: registering a weak_mods when using register_code16 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=f644b9a07a34ae19a6014b08db656a4eeca1dcda;p=qmk_firmware.git registering a weak_mods when using register_code16 Scenario: Locking the KC_LSHIFT, and then using a tap dance key that registers a S(KC_9) will unregister the KC_LSHIFT. The tap dance or any keycode that is registered should not have the side effect of cancelling a locked moditifier. We should be using a similar logic as the TMK codes in tmk_core/comman/action.c:158. --- diff --git a/quantum/quantum.c b/quantum/quantum.c index 1767faed4..0aecd238e 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -33,22 +33,42 @@ static void do_code16 (uint16_t code, void (*f) (uint8_t)) { 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) { - register_mods(MOD_BIT(kc)); + add_weak_mods(MOD_BIT(kc)); + send_keyboard_report(); } static inline void qk_unregister_mods(uint8_t kc) { - unregister_mods(MOD_BIT(kc)); + del_weak_mods(MOD_BIT(kc)); + send_keyboard_report(); } void register_code16 (uint16_t code) { - do_code16 (code, qk_register_mods); + if (IS_MOD(code) || code == KC_NO) { + do_code16 (code, qk_register_mods); + } else { + do_code16 (code, qk_register_weak_mods); + } register_code (code); } void unregister_code16 (uint16_t code) { unregister_code (code); - do_code16 (code, qk_unregister_mods); + if (IS_MOD(code) || code == KC_NO) { + do_code16 (code, qk_unregister_mods); + } else { + do_code16 (code, qk_unregister_weak_mods); + } } __attribute__ ((weak))