diff options
Diffstat (limited to 'quantum')
33 files changed, 967 insertions, 524 deletions
diff --git a/quantum/action.c b/quantum/action.c index abf9834d2f..f6fbb999c8 100644 --- a/quantum/action.c +++ b/quantum/action.c @@ -16,12 +16,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <limits.h> -#ifdef DEBUG_ACTION -# include "debug.h" -#else -# include "nodebug.h" -#endif - #include "host.h" #include "keycode.h" #include "keyboard.h" @@ -55,8 +49,8 @@ int retro_tapping_counter = 0; # include "process_auto_shift.h" #endif -#ifdef IGNORE_MOD_TAP_INTERRUPT_PER_KEY -__attribute__((weak)) bool get_ignore_mod_tap_interrupt(uint16_t keycode, keyrecord_t *record) { +#ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY +__attribute__((weak)) bool get_hold_on_other_key_press(uint16_t keycode, keyrecord_t *record) { return false; } #endif @@ -76,11 +70,11 @@ __attribute__((weak)) bool pre_process_record_quantum(keyrecord_t *record) { * FIXME: Needs documentation. */ void action_exec(keyevent_t event) { - if (!IS_NOEVENT(event)) { - dprint("\n---- action_exec: start -----\n"); - dprint("EVENT: "); + if (IS_EVENT(event)) { + ac_dprintf("\n---- action_exec: start -----\n"); + ac_dprintf("EVENT: "); debug_event(event); - dprintln(); + ac_dprintf("\n"); #if defined(RETRO_TAPPING) || defined(RETRO_TAPPING_PER_KEY) || (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)) retro_tapping_counter++; #endif @@ -93,7 +87,7 @@ void action_exec(keyevent_t event) { #ifdef SWAP_HANDS_ENABLE // Swap hands handles both keys and encoders, if ENCODER_MAP_ENABLE is defined. - if (!IS_NOEVENT(event)) { + if (IS_EVENT(event)) { process_hand_swap(&event); } #endif @@ -131,8 +125,8 @@ void action_exec(keyevent_t event) { if (IS_NOEVENT(record.event) || pre_process_record_quantum(&record)) { process_record(&record); } - if (!IS_NOEVENT(record.event)) { - dprint("processed: "); + if (IS_EVENT(record.event)) { + ac_dprintf("processed: "); debug_record(record); dprintln(); } @@ -280,15 +274,15 @@ void process_record_handler(keyrecord_t *record) { #else action_t action = store_or_get_action(record->event.pressed, record->event.key); #endif - dprint("ACTION: "); + ac_dprintf("ACTION: "); debug_action(action); #ifndef NO_ACTION_LAYER - dprint(" layer_state: "); + ac_dprintf(" layer_state: "); layer_debug(); - dprint(" default_layer_state: "); + ac_dprintf(" default_layer_state: "); default_layer_debug(); #endif - dprintln(); + ac_dprintf("\n"); process_action(record, action); } @@ -432,14 +426,14 @@ void process_action(keyrecord_t *record, action_t action) { } else { if (event.pressed) { if (tap_count == 0) { - dprint("MODS_TAP: Oneshot: 0\n"); + ac_dprintf("MODS_TAP: Oneshot: 0\n"); register_mods(mods | get_oneshot_mods()); } else if (tap_count == 1) { - dprint("MODS_TAP: Oneshot: start\n"); + ac_dprintf("MODS_TAP: Oneshot: start\n"); set_oneshot_mods(mods | get_oneshot_mods()); # if defined(ONESHOT_TAP_TOGGLE) && ONESHOT_TAP_TOGGLE > 1 } else if (tap_count == ONESHOT_TAP_TOGGLE) { - dprint("MODS_TAP: Toggling oneshot"); + ac_dprintf("MODS_TAP: Toggling oneshot"); register_mods(mods); clear_oneshot_mods(); set_oneshot_locked_mods(mods | get_oneshot_locked_mods()); @@ -484,29 +478,29 @@ void process_action(keyrecord_t *record, action_t action) { default: if (event.pressed) { if (tap_count > 0) { -# if !defined(IGNORE_MOD_TAP_INTERRUPT) || defined(IGNORE_MOD_TAP_INTERRUPT_PER_KEY) +# if !defined(IGNORE_MOD_TAP_INTERRUPT) || defined(HOLD_ON_OTHER_KEY_PRESS_PER_KEY) if ( -# ifdef IGNORE_MOD_TAP_INTERRUPT_PER_KEY - !get_ignore_mod_tap_interrupt(get_event_keycode(record->event, false), record) && +# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY + get_hold_on_other_key_press(get_event_keycode(record->event, false), record) && # endif record->tap.interrupted) { - dprint("mods_tap: tap: cancel: add_mods\n"); + ac_dprintf("mods_tap: tap: cancel: add_mods\n"); // ad hoc: set 0 to cancel tap record->tap.count = 0; register_mods(mods); } else # endif { - dprint("MODS_TAP: Tap: register_code\n"); + ac_dprintf("MODS_TAP: Tap: register_code\n"); register_code(action.key.code); } } else { - dprint("MODS_TAP: No tap: add_mods\n"); + ac_dprintf("MODS_TAP: No tap: add_mods\n"); register_mods(mods); } } else { if (tap_count > 0) { - dprint("MODS_TAP: Tap: unregister_code\n"); + ac_dprintf("MODS_TAP: Tap: unregister_code\n"); if (action.layer_tap.code == KC_CAPS_LOCK) { wait_ms(TAP_HOLD_CAPS_DELAY); } else { @@ -514,7 +508,7 @@ void process_action(keyrecord_t *record, action_t action) { } unregister_code(action.key.code); } else { - dprint("MODS_TAP: No tap: add_mods\n"); + ac_dprintf("MODS_TAP: No tap: add_mods\n"); unregister_mods(mods); } } @@ -666,15 +660,15 @@ void process_action(keyrecord_t *record, action_t action) { /* tap key */ if (event.pressed) { if (tap_count > 0) { - dprint("KEYMAP_TAP_KEY: Tap: register_code\n"); + ac_dprintf("KEYMAP_TAP_KEY: Tap: register_code\n"); register_code(action.layer_tap.code); } else { - dprint("KEYMAP_TAP_KEY: No tap: On on press\n"); + ac_dprintf("KEYMAP_TAP_KEY: No tap: On on press\n"); layer_on(action.layer_tap.val); } } else { if (tap_count > 0) { - dprint("KEYMAP_TAP_KEY: Tap: unregister_code\n"); + ac_dprintf("KEYMAP_TAP_KEY: Tap: unregister_code\n"); if (action.layer_tap.code == KC_CAPS_LOCK) { wait_ms(TAP_HOLD_CAPS_DELAY); } else { @@ -682,7 +676,7 @@ void process_action(keyrecord_t *record, action_t action) { } unregister_code(action.layer_tap.code); } else { - dprint("KEYMAP_TAP_KEY: No tap: Off on release\n"); + ac_dprintf("KEYMAP_TAP_KEY: No tap: Off on release\n"); layer_off(action.layer_tap.val); } } @@ -882,32 +876,15 @@ __attribute__((weak)) void register_code(uint8_t code) { // TODO: should push command_proc out of this block? if (command_proc(code)) return; -#ifndef NO_ACTION_ONESHOT -/* TODO: remove - if (oneshot_state.mods && !oneshot_state.disabled) { - uint8_t tmp_mods = get_mods(); - add_mods(oneshot_state.mods); - - add_key(code); - send_keyboard_report(); - - set_mods(tmp_mods); - send_keyboard_report(); - oneshot_cancel(); - } else -*/ -#endif - { - // Force a new key press if the key is already pressed - // without this, keys with the same keycode, but different - // modifiers will be reported incorrectly, see issue #1708 - if (is_key_pressed(keyboard_report, code)) { - del_key(code); - send_keyboard_report(); - } - add_key(code); + // Force a new key press if the key is already pressed + // without this, keys with the same keycode, but different + // modifiers will be reported incorrectly, see issue #1708 + if (is_key_pressed(keyboard_report, code)) { + del_key(code); send_keyboard_report(); } + add_key(code); + send_keyboard_report(); } else if IS_MOD (code) { add_mods(MOD_BIT(code)); send_keyboard_report(); @@ -1139,7 +1116,7 @@ bool is_tap_action(action_t action) { * FIXME: Needs documentation. */ void debug_event(keyevent_t event) { - dprintf("%04X%c(%u)", (event.key.row << 8 | event.key.col), (event.pressed ? 'd' : 'u'), event.time); + ac_dprintf("%04X%c(%u)", (event.key.row << 8 | event.key.col), (event.pressed ? 'd' : 'u'), event.time); } /** \brief Debug print (FIXME: Needs better description) * @@ -1148,7 +1125,7 @@ void debug_event(keyevent_t event) { void debug_record(keyrecord_t record) { debug_event(record.event); #ifndef NO_ACTION_TAPPING - dprintf(":%u%c", record.tap.count, (record.tap.interrupted ? '-' : ' ')); + ac_dprintf(":%u%c", record.tap.count, (record.tap.interrupted ? '-' : ' ')); #endif } @@ -1159,41 +1136,41 @@ void debug_record(keyrecord_t record) { void debug_action(action_t action) { switch (action.kind.id) { case ACT_LMODS: - dprint("ACT_LMODS"); + ac_dprintf("ACT_LMODS"); break; case ACT_RMODS: - dprint("ACT_RMODS"); + ac_dprintf("ACT_RMODS"); break; case ACT_LMODS_TAP: - dprint("ACT_LMODS_TAP"); + ac_dprintf("ACT_LMODS_TAP"); break; case ACT_RMODS_TAP: - dprint("ACT_RMODS_TAP"); + ac_dprintf("ACT_RMODS_TAP"); break; case ACT_USAGE: - dprint("ACT_USAGE"); + ac_dprintf("ACT_USAGE"); break; case ACT_MOUSEKEY: - dprint("ACT_MOUSEKEY"); + ac_dprintf("ACT_MOUSEKEY"); break; case ACT_LAYER: - dprint("ACT_LAYER"); + ac_dprintf("ACT_LAYER"); break; case ACT_LAYER_MODS: - dprint("ACT_LAYER_MODS"); + ac_dprintf("ACT_LAYER_MODS"); break; case ACT_LAYER_TAP: - dprint("ACT_LAYER_TAP"); + ac_dprintf("ACT_LAYER_TAP"); break; case ACT_LAYER_TAP_EXT: - dprint("ACT_LAYER_TAP_EXT"); + ac_dprintf("ACT_LAYER_TAP_EXT"); break; case ACT_SWAP_HANDS: - dprint("ACT_SWAP_HANDS"); + ac_dprintf("ACT_SWAP_HANDS"); break; default: - dprint("UNKNOWN"); + ac_dprintf("UNKNOWN"); break; } - dprintf("[%X:%02X]", action.kind.param >> 8, action.kind.param & 0xff); + ac_dprintf("[%X:%02X]", action.kind.param >> 8, action.kind.param & 0xff); } diff --git a/quantum/action.h b/quantum/action.h index 2bc46429b2..e4d28ba947 100644 --- a/quantum/action.h +++ b/quantum/action.h @@ -112,7 +112,19 @@ bool is_tap_action(action_t action); void process_record_tap_hint(keyrecord_t *record); #endif -/* debug */ +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Helpers + +#ifdef ACTION_DEBUG +# include "debug.h" +# include "print.h" +# define ac_dprintf(...) dprintf(__VA_ARGS__) +#else +# define ac_dprintf(...) \ + do { \ + } while (0) +#endif + void debug_event(keyevent_t event); void debug_record(keyrecord_t record); void debug_action(action_t action); diff --git a/quantum/action_layer.c b/quantum/action_layer.c index 31cfdfe13a..74e8137920 100644 --- a/quantum/action_layer.c +++ b/quantum/action_layer.c @@ -1,12 +1,6 @@ #include <limits.h> #include <stdint.h> -#ifdef DEBUG_ACTION -# include "debug.h" -#else -# include "nodebug.h" -#endif - #include "keyboard.h" #include "keymap.h" #include "action.h" @@ -39,12 +33,12 @@ __attribute__((weak)) layer_state_t default_layer_state_set_kb(layer_state_t sta */ static void default_layer_state_set(layer_state_t state) { state = default_layer_state_set_kb(state); - debug("default_layer_state: "); + ac_dprintf("default_layer_state: "); default_layer_debug(); - debug(" to "); + ac_dprintf(" to "); default_layer_state = state; default_layer_debug(); - debug("\n"); + ac_dprintf("\n"); #if defined(STRICT_LAYER_RELEASE) clear_keyboard_but_mods(); // To avoid stuck keys #elif defined(SEMI_STRICT_LAYER_RELEASE) @@ -57,7 +51,7 @@ static void default_layer_state_set(layer_state_t state) { * Print out the hex value of the 32-bit default layer state, as well as the value of the highest bit. */ void default_layer_debug(void) { - dprintf("%08lX(%u)", default_layer_state, get_highest_layer(default_layer_state)); + ac_dprintf("%08hX(%u)", default_layer_state, get_highest_layer(default_layer_state)); } /** \brief Default Layer Set @@ -119,12 +113,12 @@ __attribute__((weak)) layer_state_t layer_state_set_kb(layer_state_t state) { */ void layer_state_set(layer_state_t state) { state = layer_state_set_kb(state); - dprint("layer_state: "); + ac_dprintf("layer_state: "); layer_debug(); - dprint(" to "); + ac_dprintf(" to "); layer_state = state; layer_debug(); - dprintln(); + ac_dprintf("\n"); # if defined(STRICT_LAYER_RELEASE) clear_keyboard_but_mods(); // To avoid stuck keys # elif defined(SEMI_STRICT_LAYER_RELEASE) @@ -218,7 +212,7 @@ void layer_xor(layer_state_t state) { * Print out the hex value of the 32-bit layer state, as well as the value of the highest bit. */ void layer_debug(void) { - dprintf("%08lX(%u)", layer_state, get_highest_layer(layer_state)); + ac_dprintf("%08hX(%u)", layer_state, get_highest_layer(layer_state)); } #endif diff --git a/quantum/action_tapping.c b/quantum/action_tapping.c index df3317ac05..821265d399 100644 --- a/quantum/action_tapping.c +++ b/quantum/action_tapping.c @@ -1,12 +1,6 @@ #include <stdint.h> #include <stdbool.h> -#ifdef DEBUG_ACTION -# include "debug.h" -#else -# include "nodebug.h" -#endif - #include "action.h" #include "action_layer.h" #include "action_tapping.h" @@ -15,7 +9,15 @@ #ifndef NO_ACTION_TAPPING -# define IS_TAPPING() !IS_NOEVENT(tapping_key.event) +# if defined(IGNORE_MOD_TAP_INTERRUPT_PER_KEY) +# error "IGNORE_MOD_TAP_INTERRUPT_PER_KEY has been removed; the code needs to be ported to use HOLD_ON_OTHER_KEY_PRESS_PER_KEY instead." +# elif !defined(IGNORE_MOD_TAP_INTERRUPT) +# if !defined(PERMISSIVE_HOLD) && !defined(PERMISSIVE_HOLD_PER_KEY) && !defined(HOLD_ON_OTHER_KEY_PRESS) && !defined(HOLD_ON_OTHER_KEY_PRESS_PER_KEY) +# pragma message "The default behavior of mod-taps will change to mimic IGNORE_MOD_TAP_INTERRUPT in the future.\nIf you wish to keep the old default behavior of mod-taps, please use HOLD_ON_OTHER_KEY_PRESS." +# endif +# endif + +# define IS_TAPPING() IS_EVENT(tapping_key.event) # define IS_TAPPING_PRESSED() (IS_TAPPING() && tapping_key.event.pressed) # define IS_TAPPING_RELEASED() (IS_TAPPING() && !tapping_key.event.pressed) # define IS_TAPPING_KEY(k) (IS_TAPPING() && KEYEQ(tapping_key.event.key, (k))) @@ -25,6 +27,7 @@ # define IS_TAPPING_RECORD(r) (IS_TAPPING() && KEYEQ(tapping_key.event.key, (r->event.key)) && tapping_key.keycode == r->keycode) # endif # define WITHIN_TAPPING_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < GET_TAPPING_TERM(get_record_keycode(&tapping_key, false), &tapping_key)) +# define WITHIN_QUICK_TAP_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < GET_QUICK_TAP_TERM(get_record_keycode(&tapping_key, false), &tapping_key)) # ifdef DYNAMIC_TAPPING_TERM_ENABLE uint16_t g_tapping_term = TAPPING_TERM; @@ -40,9 +43,9 @@ __attribute__((weak)) uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *r } # endif -# ifdef TAPPING_FORCE_HOLD_PER_KEY -__attribute__((weak)) bool get_tapping_force_hold(uint16_t keycode, keyrecord_t *record) { - return false; +# ifdef QUICK_TAP_TERM_PER_KEY +__attribute__((weak)) uint16_t get_quick_tap_term(uint16_t keycode, keyrecord_t *record) { + return QUICK_TAP_TERM; } # endif @@ -82,15 +85,15 @@ static void debug_waiting_buffer(void); */ void action_tapping_process(keyrecord_t record) { if (process_tapping(&record)) { - if (!IS_NOEVENT(record.event)) { - debug("processed: "); + if (IS_EVENT(record.event)) { + ac_dprintf("processed: "); debug_record(record); - debug("\n"); + ac_dprintf("\n"); } } else { if (!waiting_buffer_enq(record)) { // clear all in case of overflow. - debug("OVERFLOW: CLEAR ALL STATES\n"); + ac_dprintf("OVERFLOW: CLEAR ALL STATES\n"); clear_keyboard(); waiting_buffer_clear(); tapping_key = (keyrecord_t){}; @@ -98,25 +101,73 @@ void action_tapping_process(keyrecord_t record) { } // process waiting_buffer - if (!IS_NOEVENT(record.event) && waiting_buffer_head != waiting_buffer_tail) { - debug("---- action_exec: process waiting_buffer -----\n"); + if (IS_EVENT(record.event) && waiting_buffer_head != waiting_buffer_tail) { + ac_dprintf("---- action_exec: process waiting_buffer -----\n"); } for (; waiting_buffer_tail != waiting_buffer_head; waiting_buffer_tail = (waiting_buffer_tail + 1) % WAITING_BUFFER_SIZE) { if (process_tapping(&waiting_buffer[waiting_buffer_tail])) { - debug("processed: waiting_buffer["); - debug_dec(waiting_buffer_tail); - debug("] = "); + ac_dprintf("processed: waiting_buffer[%u] =", waiting_buffer_tail); debug_record(waiting_buffer[waiting_buffer_tail]); - debug("\n\n"); + ac_dprintf("\n\n"); } else { break; } } - if (!IS_NOEVENT(record.event)) { - debug("\n"); + if (IS_EVENT(record.event)) { + ac_dprintf("\n"); } } +/* Some conditionally defined helper macros to keep process_tapping more + * readable. The conditional definition of tapping_keycode and all the + * conditional uses of it are hidden inside macros named TAP_... + */ +# if (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)) || defined(PERMISSIVE_HOLD_PER_KEY) || defined(QUICK_TAP_TERM_PER_KEY) || defined(HOLD_ON_OTHER_KEY_PRESS_PER_KEY) +# define TAP_DEFINE_KEYCODE uint16_t tapping_keycode = get_record_keycode(&tapping_key, false) +# else +# define TAP_DEFINE_KEYCODE +# endif + +# if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT) +# ifdef RETRO_TAPPING_PER_KEY +# define TAP_GET_RETRO_TAPPING get_retro_tapping(tapping_keycode, &tapping_key) +# else +# define TAP_GET_RETRO_TAPPING true +# endif +# define MAYBE_RETRO_SHIFTING(ev) (TAP_GET_RETRO_TAPPING && (RETRO_SHIFT + 0) != 0 && TIMER_DIFF_16((ev).time, tapping_key.event.time) < (RETRO_SHIFT + 0)) +# define TAP_IS_LT IS_QK_LAYER_TAP(tapping_keycode) +# define TAP_IS_MT IS_QK_MOD_TAP(tapping_keycode) +# define TAP_IS_RETRO IS_RETRO(tapping_keycode) +# else +# define TAP_GET_RETRO_TAPPING false +# define MAYBE_RETRO_SHIFTING(ev) false +# define TAP_IS_LT false +# define TAP_IS_MT false +# define TAP_IS_RETRO false +# endif + +# ifdef PERMISSIVE_HOLD_PER_KEY +# define TAP_GET_PERMISSIVE_HOLD get_permissive_hold(tapping_keycode, &tapping_key) +# elif defined(PERMISSIVE_HOLD) +# define TAP_GET_PERMISSIVE_HOLD true +# else +# define TAP_GET_PERMISSIVE_HOLD false +# endif + +# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY +# define TAP_GET_HOLD_ON_OTHER_KEY_PRESS get_hold_on_other_key_press(tapping_keycode, &tapping_key) +# elif defined(HOLD_ON_OTHER_KEY_PRESS) +# define TAP_GET_HOLD_ON_OTHER_KEY_PRESS true +# else +# define TAP_GET_HOLD_ON_OTHER_KEY_PRESS false +# endif + +# if defined(IGNORE_MOD_TAP_INTERRUPT) +# define TAP_GET_IGNORE_MOD_TAP_INTERRUPT true +# else +# define TAP_GET_IGNORE_MOD_TAP_INTERRUPT false +# endif + /** \brief Tapping * * Rule: Tap key is typed(pressed and released) within TAPPING_TERM. @@ -125,31 +176,18 @@ void action_tapping_process(keyrecord_t record) { /* return true when key event is processed or consumed. */ bool process_tapping(keyrecord_t *keyp) { keyevent_t event = keyp->event; -# if (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)) || defined(PERMISSIVE_HOLD_PER_KEY) || defined(TAPPING_FORCE_HOLD_PER_KEY) || defined(HOLD_ON_OTHER_KEY_PRESS_PER_KEY) - uint16_t tapping_keycode = get_record_keycode(&tapping_key, false); -# endif + TAP_DEFINE_KEYCODE; // if tapping if (IS_TAPPING_PRESSED()) { - // clang-format off - if (WITHIN_TAPPING_TERM(event) -# if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT) - || ( -# ifdef RETRO_TAPPING_PER_KEY - get_retro_tapping(tapping_keycode, &tapping_key) && -# endif - (RETRO_SHIFT + 0) != 0 && TIMER_DIFF_16(event.time, tapping_key.event.time) < (RETRO_SHIFT + 0) - ) -# endif - ) { - // clang-format on + if (WITHIN_TAPPING_TERM(event) || MAYBE_RETRO_SHIFTING(event)) { if (tapping_key.tap.count == 0) { if (IS_TAPPING_RECORD(keyp) && !event.pressed) { # if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT) retroshift_swap_times(); # endif // first tap! - debug("Tapping: First tap(0->1).\n"); + ac_dprintf("Tapping: First tap(0->1).\n"); tapping_key.tap.count = 1; debug_tapping_key(); process_record(&tapping_key); @@ -164,73 +202,46 @@ bool process_tapping(keyrecord_t *keyp) { * useful for long TAPPING_TERM but may prevent fast typing. */ // clang-format off -# if defined(PERMISSIVE_HOLD) || defined(PERMISSIVE_HOLD_PER_KEY) || (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)) else if ( ( - IS_RELEASED(event) && waiting_buffer_typed(event) -# ifdef PERMISSIVE_HOLD_PER_KEY - && get_permissive_hold(tapping_keycode, &tapping_key) -# elif defined(PERMISSIVE_HOLD) - && true -# endif + IS_RELEASED(event) && waiting_buffer_typed(event) && + TAP_GET_PERMISSIVE_HOLD ) // Causes nested taps to not wait past TAPPING_TERM/RETRO_SHIFT // unnecessarily and fixes them for Layer Taps. -# if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT) - || ( -# ifdef RETRO_TAPPING_PER_KEY - get_retro_tapping(tapping_keycode, &tapping_key) && -# endif + || (TAP_GET_RETRO_TAPPING && ( // Rolled over the two keys. - ( - ( - false -# if defined(HOLD_ON_OTHER_KEY_PRESS) || defined(HOLD_ON_OTHER_KEY_PRESS_PER_KEY) - || ( - IS_LT(tapping_keycode) -# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY - && get_hold_on_other_key_press(tapping_keycode, &tapping_key) -# endif - ) -# endif -# if !defined(IGNORE_MOD_TAP_INTERRUPT) || defined(IGNORE_MOD_TAP_INTERRUPT_PER_KEY) - || ( - IS_MT(tapping_keycode) -# ifdef IGNORE_MOD_TAP_INTERRUPT_PER_KEY - && !get_ignore_mod_tap_interrupt(tapping_keycode, &tapping_key) -# endif - ) -# endif - ) && tapping_key.tap.interrupted == true + (tapping_key.tap.interrupted == true && ( + (TAP_IS_LT && TAP_GET_HOLD_ON_OTHER_KEY_PRESS) || + (TAP_IS_MT && TAP_GET_HOLD_ON_OTHER_KEY_PRESS) + ) ) // Makes Retro Shift ignore [IGNORE_MOD_TAP_INTERRUPT's // effects on nested taps for MTs and the default // behavior of LTs] below TAPPING_TERM or RETRO_SHIFT. || ( - IS_RETRO(tapping_keycode) + TAP_IS_RETRO && (event.key.col != tapping_key.event.key.col || event.key.row != tapping_key.event.key.row) && IS_RELEASED(event) && waiting_buffer_typed(event) ) ) ) -# endif ) { // clang-format on - debug("Tapping: End. No tap. Interfered by typing key\n"); + ac_dprintf("Tapping: End. No tap. Interfered by typing key\n"); process_record(&tapping_key); tapping_key = (keyrecord_t){}; debug_tapping_key(); // enqueue return false; } -# endif /* Process release event of a key pressed before tapping starts * Without this unexpected repeating will occur with having fast repeating setting * https://github.com/tmk/tmk_keyboard/issues/60 */ else if (IS_RELEASED(event) && !waiting_buffer_typed(event)) { - // Modifier should be retained till end of this tapping. + // Modifier/Layer should be retained till end of this tapping. action_t action = layer_switch_get_action(event.key); switch (action.kind.id) { case ACT_LMODS: @@ -243,28 +254,33 @@ bool process_tapping(keyrecord_t *keyp) { if (action.key.mods && keyp->tap.count == 0) return false; if (IS_MOD(action.key.code)) return false; break; + case ACT_LAYER_TAP: + case ACT_LAYER_TAP_EXT: + switch (action.layer_tap.code) { + case 0 ...(OP_TAP_TOGGLE - 1): + case OP_ON_OFF: + case OP_OFF_ON: + case OP_SET_CLEAR: + return false; + } + break; } // Release of key should be process immediately. - debug("Tapping: release event of a key pressed before tapping\n"); + ac_dprintf("Tapping: release event of a key pressed before tapping\n"); process_record(keyp); return true; } else { // set interrupted flag when other key preesed during tapping if (event.pressed) { t |