From cc8e66754b1a5d0c11985cb0feb51ead49668744 Mon Sep 17 00:00:00 2001 From: tmk Date: Tue, 2 Apr 2013 16:09:43 +0900 Subject: Refine ACT_LAYER and ACT_LAYER_TAP - Remove ACT_LAYER_BITOP --- common/action.c | 201 +++++++++++++++++--------------------------------------- 1 file changed, 62 insertions(+), 139 deletions(-) (limited to 'common/action.c') diff --git a/common/action.c b/common/action.c index ef04851b11..596831d4de 100644 --- a/common/action.c +++ b/common/action.c @@ -50,14 +50,19 @@ void action_exec(keyevent_t event) void process_action(keyrecord_t *record) { keyevent_t event = record->event; +#ifndef NO_ACTION_TAPPING uint8_t tap_count = record->tap.count; +#endif if (IS_NOEVENT(event)) { return; } action_t action = layer_switch_get_action(event.key); debug("ACTION: "); debug_action(action); - debug(" keymaps: "); keymap_debug(); - debug(" default_layer: "); debug_dec(default_layer); debug("\n"); +#ifndef NO_ACTION_LAYER + debug(" layer_state: "); layer_debug(); + debug(" default_layer_state: "); default_layer_debug(); +#endif + debug("\n"); switch (action.kind.id) { /* Key and Mods */ @@ -92,7 +97,7 @@ void process_action(keyrecord_t *record) { uint8_t mods = (action.kind.id == ACT_LMODS_TAP) ? action.key.mods : action.key.mods<<4; - switch (action.layer.code) { + switch (action.layer_tap.code) { #ifndef NO_ACTION_ONESHOT case 0x00: // Oneshot modifier @@ -200,163 +205,86 @@ void process_action(keyrecord_t *record) #endif #ifndef NO_ACTION_LAYER case ACT_LAYER: - case ACT_LAYER1: - switch (action.layer.code) { - /* Keymap clear */ - case OP_RESET: - switch (action.layer.val & 0x03) { - case 0: - // NOTE: reserved - keymap_clear(); - break; - case ON_PRESS: - if (event.pressed) { - keymap_clear(); - } - break; - case ON_RELEASE: - if (!event.pressed) { - keymap_clear(); - } - break; - case ON_BOTH: - keymap_clear(); - break; - /* NOTE: 4-7 rserved */ + if (action.layer_bitop.on == 0) { + /* Default Layer Bitwise Operation */ + if (!event.pressed) { + uint8_t shift = action.layer_bitop.part*4; + uint32_t bits = ((uint32_t)action.layer_bitop.bits)< 0) { debug("KEYMAP_TAP_KEY: Tap: register_code\n"); - register_code(action.layer.code); + register_code(action.layer_tap.code); } else { debug("KEYMAP_TAP_KEY: No tap: On on press\n"); - keymap_on(action.layer.val); + layer_on(action.layer_tap.val); } } else { if (tap_count > 0) { debug("KEYMAP_TAP_KEY: Tap: unregister_code\n"); - unregister_code(action.layer.code); + unregister_code(action.layer_tap.code); } else { debug("KEYMAP_TAP_KEY: No tap: Off on release\n"); - keymap_off(action.layer.val); + layer_off(action.layer_tap.val); } } break; } break; + #endif #endif /* Extentions */ #ifndef NO_ACTION_MACRO @@ -508,15 +436,9 @@ bool is_tap_key(key_t key) switch (action.kind.id) { case ACT_LMODS_TAP: case ACT_RMODS_TAP: + case ACT_LAYER_TAP: + case ACT_LAYER_TAP1: return true; - case ACT_LAYER: - switch (action.layer.code) { - case 0x04 ... 0xEF: /* tap key */ - case OP_INV: - return true; - default: - return false; - } case ACT_MACRO: case ACT_FUNCTION: if (action.func.opt & FUNC_TAP) { return true; } @@ -555,7 +477,8 @@ void debug_action(action_t action) case ACT_USAGE: debug("ACT_USAGE"); break; case ACT_MOUSEKEY: debug("ACT_MOUSEKEY"); break; case ACT_LAYER: debug("ACT_LAYER"); break; - case ACT_LAYER_BITOP: debug("ACT_LAYER_BITOP"); break; + case ACT_LAYER_TAP: debug("ACT_LAYER_TAP"); break; + case ACT_LAYER_TAP1: debug("ACT_LAYER_TAP1"); break; case ACT_MACRO: debug("ACT_MACRO"); break; case ACT_COMMAND: debug("ACT_COMMAND"); break; case ACT_FUNCTION: debug("ACT_FUNCTION"); break; -- cgit v1.2.3