mirror of
https://github.com/openstenoproject/qmk
synced 2024-11-23 00:44:38 +00:00
Merge pull request #1030 from SjB/refactor_register_code16
speeding up (un)register_code16
This commit is contained in:
commit
246d2583ff
1 changed files with 30 additions and 2 deletions
|
@ -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))
|
||||
|
|
Loading…
Reference in a new issue