X-Git-Url: https://git.friedersdorff.com/?a=blobdiff_plain;f=tmk_core%2Fcommon%2Faction.c;h=ab6e9d895807898fde8b7112eadfb0eb8053b9e1;hb=e109b5504beb9f3e6bee6e381ee601a0cd3fae5f;hp=1f15bd091861735b1b621510edb1e161035896ea;hpb=a3d96d3aa96318d339a67de1085e0ae495d57c84;p=max%2Ftmk_keyboard.git diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c index 1f15bd09..ab6e9d89 100644 --- a/tmk_core/common/action.c +++ b/tmk_core/common/action.c @@ -26,6 +26,8 @@ along with this program. If not, see . #include "action_macro.h" #include "action_util.h" #include "action.h" +#include "hook.h" +#include "wait.h" #ifdef DEBUG_ACTION #include "debug.h" @@ -39,6 +41,7 @@ void action_exec(keyevent_t event) if (!IS_NOEVENT(event)) { dprint("\n---- action_exec: start -----\n"); dprint("EVENT: "); debug_event(event); dprintln(); + hook_matrix_change(event); } keyrecord_t record = { .event = event }; @@ -98,7 +101,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_tap.code) { + switch (action.key.code) { #ifndef NO_ACTION_ONESHOT case MODS_ONESHOT: // Oneshot modifier @@ -131,10 +134,17 @@ void process_action(keyrecord_t *record) case MODS_TAP_TOGGLE: if (event.pressed) { if (tap_count <= TAPPING_TOGGLE) { - register_mods(mods); + if (mods & get_mods()) { + dprint("MODS_TAP_TOGGLE: toggle mods off\n"); + unregister_mods(mods); + } else { + dprint("MODS_TAP_TOGGLE: toggle mods on\n"); + register_mods(mods); + } } } else { if (tap_count < TAPPING_TOGGLE) { + dprint("MODS_TAP_TOGGLE: release : unregister_mods\n"); unregister_mods(mods); } } @@ -237,14 +247,18 @@ void process_action(keyrecord_t *record) case ACT_LAYER_TAP: case ACT_LAYER_TAP_EXT: switch (action.layer_tap.code) { - case 0xe0 ... 0xef: - /* layer On/Off with modifiers(left only) */ + case 0xc0 ... 0xdf: + /* layer On/Off with modifiers */ if (event.pressed) { layer_on(action.layer_tap.val); - register_mods(action.layer_tap.code & 0x0f); + register_mods((action.layer_tap.code & 0x10) ? + (action.layer_tap.code & 0x0f) << 4 : + (action.layer_tap.code & 0x0f)); } else { layer_off(action.layer_tap.val); - unregister_mods(action.layer_tap.code & 0x0f); + unregister_mods((action.layer_tap.code & 0x10) ? + (action.layer_tap.code & 0x0f) << 4 : + (action.layer_tap.code & 0x0f)); } break; case OP_TAP_TOGGLE: @@ -356,6 +370,7 @@ void register_code(uint8_t code) #endif add_key(KC_CAPSLOCK); send_keyboard_report(); + wait_ms(100); del_key(KC_CAPSLOCK); send_keyboard_report(); } @@ -366,6 +381,7 @@ void register_code(uint8_t code) #endif add_key(KC_NUMLOCK); send_keyboard_report(); + wait_ms(100); del_key(KC_NUMLOCK); send_keyboard_report(); } @@ -376,6 +392,7 @@ void register_code(uint8_t code) #endif add_key(KC_SCROLLLOCK); send_keyboard_report(); + wait_ms(100); del_key(KC_SCROLLLOCK); send_keyboard_report(); } @@ -431,6 +448,7 @@ void unregister_code(uint8_t code) #endif add_key(KC_CAPSLOCK); send_keyboard_report(); + wait_ms(100); del_key(KC_CAPSLOCK); send_keyboard_report(); } @@ -441,6 +459,7 @@ void unregister_code(uint8_t code) #endif add_key(KC_NUMLOCK); send_keyboard_report(); + wait_ms(100); del_key(KC_NUMLOCK); send_keyboard_report(); } @@ -451,6 +470,7 @@ void unregister_code(uint8_t code) #endif add_key(KC_SCROLLLOCK); send_keyboard_report(); + wait_ms(100); del_key(KC_SCROLLLOCK); send_keyboard_report(); } @@ -516,10 +536,20 @@ bool is_tap_key(keypos_t key) switch (action.kind.id) { case ACT_LMODS_TAP: case ACT_RMODS_TAP: + switch (action.key.code) { + case MODS_ONESHOT: + case MODS_TAP_TOGGLE: + case KC_A ... KC_EXSEL: // tap key + case KC_LCTRL ... KC_RGUI: // tap key + return true; + } case ACT_LAYER_TAP: case ACT_LAYER_TAP_EXT: switch (action.layer_tap.code) { - case 0x00 ... 0xdf: + case 0xc0 ... 0xdf: // with modifiers + return false; + case KC_A ... KC_EXSEL: // tap key + case KC_LCTRL ... KC_RGUI: // tap key case OP_TAP_TOGGLE: return true; }