Added a definable LEADER_NO_TIMEOUT_N to leader_key.c that allows disabling the timeout for the first N keystrokes in leader key sequences.

This commit is contained in:
Mr-Asmodaeus 2024-11-09 19:04:01 +00:00
parent f156e57f8e
commit 64382bbdfa
2 changed files with 18 additions and 0 deletions

View File

@ -84,6 +84,16 @@ To remove the stress this situation produces to your hands, you can disable the
Now, after you hit the leader key, you will have an infinite amount of time to start the rest of the sequence, allowing you to properly position your hands to type the rest of the sequence comfortably. This way you can configure a very short `LEADER_TIMEOUT`, but still have plenty of time to position your hands.
### Disabling Timeout for aditional keystrokes {#disabling-timeout-more-keystrokes}
Aditionally, you may want to disable the timeout for additional keystrokes after the leader key.
Add the following to your `config.h`:
```c
#define LEADER_NO_TIMEOUT_N <Number of keystrokes including leader>
```
Use with care, since sequences shorter than LEADER_NO_TIMEOUT_N will not timeout, and thus will not terminate unless leader_end() is called.
### Strict Key Processing {#strict-key-processing}
By default, only the "tap keycode" portions of [Mod-Taps](../mod_tap) and [Layer Taps](../feature_layers#switching-and-toggling-layers) are added to the sequence buffer. This means if you press eg. `LT(3, KC_A)` as part of a sequence, `KC_A` will be added to the buffer, rather than the entire `LT(3, KC_A)` keycode.

View File

@ -53,7 +53,11 @@ bool leader_sequence_add(uint16_t keycode) {
}
#if defined(LEADER_NO_TIMEOUT)
# if defined(LEADER_NO_TIMEOUT_N)
if (leader_sequence_size < LEADER_NO_TIMEOUT_N - 1) {
# else
if (leader_sequence_size == 0) {
# endif
leader_reset_timer();
}
#endif
@ -66,7 +70,11 @@ bool leader_sequence_add(uint16_t keycode) {
bool leader_sequence_timed_out(void) {
#if defined(LEADER_NO_TIMEOUT)
# if defined(LEADER_NO_TIMEOUT_N)
return leader_sequence_size > LEADER_NO_TIMEOUT_N - 1 && timer_elapsed(leader_time) > LEADER_TIMEOUT;
# else
return leader_sequence_size > 0 && timer_elapsed(leader_time) > LEADER_TIMEOUT;
# endif
#else
return timer_elapsed(leader_time) > LEADER_TIMEOUT;
#endif