summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSjB <steve@sagacity.ca>2017-01-29 12:06:24 -0500
committerSjB <steve@sagacity.ca>2017-01-29 12:29:43 -0500
commitf644b9a07a34ae19a6014b08db656a4eeca1dcda (patch)
tree5c2e1337433e5bd96c62f26a829589d970fd9b97
parent2b3859937b1e7f96b684408d31ff12a4e682f7ee (diff)
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.
-rw-r--r--quantum/quantum.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c
index 1767faed42..0aecd238e4 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))