diff --git a/docs/tap_hold.md b/docs/tap_hold.md index 0e1b6bc59698..ad3efa603e06 100644 --- a/docs/tap_hold.md +++ b/docs/tap_hold.md @@ -211,6 +211,12 @@ To delay the registration of modifiers (such as `KC_LGUI` and `KC_RGUI`, which a DEFERRED_EXEC_ENABLE = yes ``` +To enable *crossover* bilateral combinations (which start on one side of the keyboard and cross over to the other side, such as `RSFT_T(KC_J)` and `LGUI_T(KC_A)` in the word "jam"), add the following line to your `config.h` and define a value: hold times greater than that value will permit crossover bilateral combinations. For example, if you typed `RSFT_T(KC_J)` and `LGUI_T(KC_A)` faster than the defined value, the keys `KC_J` and `KC_A` would be sent to the computer. In contrast, if you typed slower than the defined value, the keys `RSFT(KC_A)` would be sent to the computer. + +```c +#define BILATERAL_COMBINATIONS_CROSSOVER 75 +``` + To monitor activations in the background, enable debugging, enable the console, enable terminal bell, add `#define DEBUG_ACTION` to `config.h`, and use something like the following shell command line: ```sh diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c index eef3cd28b186..ca19a6f781f6 100644 --- a/tmk_core/common/action.c +++ b/tmk_core/common/action.c @@ -47,7 +47,7 @@ int retro_tapping_counter = 0; # include #endif -#if (BILATERAL_COMBINATIONS + 0) +#if (BILATERAL_COMBINATIONS + BILATERAL_COMBINATIONS_CROSSOVER + 0) # include "quantum.h" #endif @@ -231,7 +231,7 @@ static struct { uint8_t tap; uint8_t mods; bool left; -# if (BILATERAL_COMBINATIONS + 0) +# if (BILATERAL_COMBINATIONS + BILATERAL_COMBINATIONS_CROSSOVER + 0) uint16_t time; # endif # if (BILATERAL_COMBINATIONS_DEFERMODS + 0) @@ -267,7 +267,7 @@ static void bilateral_combinations_hold(action_t action, keyevent_t event) { bilateral_combinations.tap = action.layer_tap.code; bilateral_combinations.mods = (action.kind.id == ACT_LMODS_TAP) ? action.key.mods : action.key.mods << 4; bilateral_combinations.left = bilateral_combinations_left(event.key); -# if (BILATERAL_COMBINATIONS + 0) +# if (BILATERAL_COMBINATIONS + BILATERAL_COMBINATIONS_CROSSOVER + 0) bilateral_combinations.time = event.time; # endif # if (BILATERAL_COMBINATIONS_DEFERMODS + 0) @@ -304,6 +304,18 @@ static void bilateral_combinations_tap(keyevent_t event) { unregister_mods(bilateral_combinations.mods); tap_code(bilateral_combinations.tap); } +# if (BILATERAL_COMBINATIONS_CROSSOVER + 0) + else { + if (TIMER_DIFF_16(event.time, bilateral_combinations.time) > BILATERAL_COMBINATIONS_CROSSOVER) { + dprint("BILATERAL_COMBINATIONS_CROSSOVER: timeout\n"); + bilateral_combinations_clear(); + return; + } + dprint("BILATERAL_COMBINATIONS_CROSSOVER: change\n"); + unregister_mods(bilateral_combinations.mods); + tap_code(bilateral_combinations.tap); + } +# endif bilateral_combinations_clear(); } }