1
0
Fork 0

Merge pull request #1030 from SjB/refactor_register_code16

speeding up (un)register_code16
This commit is contained in:
Jack Humbert 2017-02-06 17:06:53 -05:00 committed by GitHub
commit 246d2583ff

View file

@ -33,14 +33,42 @@ static void do_code16 (uint16_t code, void (*f) (uint8_t)) {
f(KC_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();
}
static inline void qk_unregister_mods(uint8_t kc) {
del_weak_mods(MOD_BIT(kc));
send_keyboard_report();
}
void register_code16 (uint16_t code) { 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); register_code (code);
} }
void unregister_code16 (uint16_t code) { void unregister_code16 (uint16_t code) {
unregister_code (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)) __attribute__ ((weak))