Skip to content

Commit

Permalink
catch crossover bilateral combinations with timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
sunaku committed Oct 28, 2022
1 parent 2e0e480 commit ab8d095
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
6 changes: 6 additions & 0 deletions docs/tap_hold.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 15 additions & 3 deletions tmk_core/common/action.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int retro_tapping_counter = 0;
# include <fauxclicky.h>
#endif

#if (BILATERAL_COMBINATIONS + 0)
#if (BILATERAL_COMBINATIONS + BILATERAL_COMBINATIONS_CROSSOVER + 0)
# include "quantum.h"
#endif

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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();
}
}
Expand Down

0 comments on commit ab8d095

Please sign in to comment.