From 2f6c068e0dd7abc3cec1bb72df0b1e96032246f8 Mon Sep 17 00:00:00 2001 From: fauxpark Date: Fri, 9 Aug 2019 06:58:05 +1000 Subject: Extend allowed range of tappable keycodes to include modifiers (#5809) * Extend allowed range of tappable keycodes to include modifiers * Get rid of the magic numbers altogether * Remove some more magic numbers * Extract LM() functionality from ACT_LAYER_TAP * Use ACTION() macro everywhere --- tmk_core/common/action.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'tmk_core/common/action.c') diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c index 5172e8650a..f47fd20fc9 100644 --- a/tmk_core/common/action.c +++ b/tmk_core/common/action.c @@ -437,20 +437,19 @@ void process_action(keyrecord_t *record, action_t action) } } break; + case ACT_LAYER_MODS: + if (event.pressed) { + layer_on(action.layer_mods.layer); + register_mods(action.layer_mods.mods); + } else { + unregister_mods(action.layer_mods.mods); + layer_off(action.layer_mods.layer); + } + break; #ifndef NO_ACTION_TAPPING case ACT_LAYER_TAP: case ACT_LAYER_TAP_EXT: switch (action.layer_tap.code) { - case 0xe0 ... 0xef: - /* layer On/Off with modifiers(left only) */ - if (event.pressed) { - layer_on(action.layer_tap.val); - register_mods(action.layer_tap.code & 0x0f); - } else { - layer_off(action.layer_tap.val); - unregister_mods(action.layer_tap.code & 0x0f); - } - break; case OP_TAP_TOGGLE: /* tap toggle */ if (event.pressed) { @@ -652,6 +651,7 @@ void process_action(keyrecord_t *record, action_t action) // if this event is a layer action, update the leds switch (action.kind.id) { case ACT_LAYER: + case ACT_LAYER_MODS: #ifndef NO_ACTION_TAPPING case ACT_LAYER_TAP: case ACT_LAYER_TAP_EXT: @@ -957,7 +957,7 @@ bool is_tap_action(action_t action) case ACT_LAYER_TAP: case ACT_LAYER_TAP_EXT: switch (action.layer_tap.code) { - case 0x00 ... 0xdf: + case KC_NO ... KC_RGUI: case OP_TAP_TOGGLE: case OP_ONESHOT: return true; @@ -965,7 +965,7 @@ bool is_tap_action(action_t action) return false; case ACT_SWAP_HANDS: switch (action.swap.code) { - case 0x00 ... 0xdf: + case KC_NO ... KC_RGUI: case OP_SH_TAP_TOGGLE: return true; } @@ -1014,6 +1014,7 @@ void debug_action(action_t action) case ACT_USAGE: dprint("ACT_USAGE"); break; case ACT_MOUSEKEY: dprint("ACT_MOUSEKEY"); break; case ACT_LAYER: dprint("ACT_LAYER"); break; + case ACT_LAYER_MODS: dprint("ACT_LAYER_MODS"); break; case ACT_LAYER_TAP: dprint("ACT_LAYER_TAP"); break; case ACT_LAYER_TAP_EXT: dprint("ACT_LAYER_TAP_EXT"); break; case ACT_MACRO: dprint("ACT_MACRO"); break; -- cgit v1.2.1