summaryrefslogtreecommitdiffstats
path: root/quantum
diff options
context:
space:
mode:
authorSjB <steve@sagacity.ca>2017-01-29 18:06:24 +0100
committerSjB <steve@sagacity.ca>2017-01-29 18:29:43 +0100
commitf644b9a07a34ae19a6014b08db656a4eeca1dcda (patch)
tree5c2e1337433e5bd96c62f26a829589d970fd9b97 /quantum
parent2b3859937b1e7f96b684408d31ff12a4e682f7ee (diff)
downloadqmk_firmware-f644b9a07a34ae19a6014b08db656a4eeca1dcda.tar.gz
qmk_firmware-f644b9a07a34ae19a6014b08db656a4eeca1dcda.tar.xz
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.
Diffstat (limited to 'quantum')
-rw-r--r--quantum/quantum.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c
index 1767faed4..0aecd238e 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))