From 0d28787c5cf2173d12f57b397515f91cffaa820a Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Thu, 18 Aug 2016 11:29:53 +0200 Subject: Add a register/unregister_code16 pair of functions These functions register not only the 8bit keycode, but the modifiers too. It doesn't handle the full range of the upper 8bits, just the mods, but that's a good start. Changed the tap-dance pair functions to use these, so one can do: `ACTION_TAP_DANCE_DOUBLE (KC_COLN, KC_SCLN)` ...and that will do the right thing. Signed-off-by: Gergely Nagy --- quantum/quantum.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'quantum/quantum.c') diff --git a/quantum/quantum.c b/quantum/quantum.c index cb1ba04ff..e3a20f43e 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -1,5 +1,42 @@ #include "quantum.h" +static void do_code16 (uint16_t code, void (*f) (uint8_t)) { + switch (code) { + case QK_MODS ... QK_MODS_MAX: + break; + default: + return; + } + + if (code & QK_LCTL) + f(KC_LCTL); + if (code & QK_LSFT) + f(KC_LSFT); + if (code & QK_LALT) + f(KC_LALT); + if (code & QK_LGUI) + f(KC_LGUI); + + if (code & QK_RCTL) + f(KC_RCTL); + if (code & QK_RSFT) + f(KC_RSFT); + if (code & QK_RALT) + f(KC_RALT); + if (code & QK_RGUI) + f(KC_RGUI); +} + +void register_code16 (uint16_t code) { + do_code16 (code, register_code); + register_code (code); +} + +void unregister_code16 (uint16_t code) { + unregister_code (code); + do_code16 (code, unregister_code); +} + __attribute__ ((weak)) bool process_action_kb(keyrecord_t *record) { return true; -- cgit v1.2.3-24-g4f1b