diff options
author | Jack Humbert <jack.humb@gmail.com> | 2017-02-06 17:06:53 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-06 17:06:53 -0500 |
commit | 246d2583ff5ceacdfcd877ac1b29762773dade0b (patch) | |
tree | 5014c7e8f2f4c98ad65adb5e62d79bc1b6abd14f | |
parent | ee386a29d1a8b46f16c5c139db74624f829d9a53 (diff) | |
parent | f644b9a07a34ae19a6014b08db656a4eeca1dcda (diff) | |
download | qmk_firmware-246d2583ff5ceacdfcd877ac1b29762773dade0b.tar.gz qmk_firmware-246d2583ff5ceacdfcd877ac1b29762773dade0b.zip |
Merge pull request #1030 from SjB/refactor_register_code16
speeding up (un)register_code16
-rw-r--r-- | quantum/quantum.c | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c index 63ffe2074e..0aecd238e4 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -33,14 +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) { + add_weak_mods(MOD_BIT(kc)); + send_keyboard_report(); +} + +static inline void qk_unregister_mods(uint8_t kc) { + del_weak_mods(MOD_BIT(kc)); + send_keyboard_report(); +} + void register_code16 (uint16_t code) { - do_code16 (code, register_code); + 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, unregister_code); + if (IS_MOD(code) || code == KC_NO) { + do_code16 (code, qk_unregister_mods); + } else { + do_code16 (code, qk_unregister_weak_mods); + } } __attribute__ ((weak)) |