aboutsummaryrefslogtreecommitdiffstats
path: root/quantum
diff options
context:
space:
mode:
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))