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.
This commit is contained in:
parent
2b3859937b
commit
f644b9a07a
@ -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) {
|
||||
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);
|
||||
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 New Issue
Block a user