Changed LEADER_NO_TIMEOUT_N to LEADER_NO_TIMEOUT_FOR_N_KEYSTOKES for clarity

This commit is contained in:
Mr-Asmodaeus 2024-11-16 15:02:10 +00:00
parent 5ed3b5301e
commit d60d0cebee
2 changed files with 8 additions and 12 deletions

View File

@ -89,9 +89,9 @@ Now, after you hit the leader key, you will have an infinite amount of time to s
Aditionally, you may want to disable the timeout for additional keystrokes after the leader key. Aditionally, you may want to disable the timeout for additional keystrokes after the leader key.
Add the following to your `config.h`: Add the following to your `config.h`:
```c ```c
#define LEADER_NO_TIMEOUT_N <Number of keystrokes including leader> #define LEADER_NO_TIMEOUT_FOR_N_KEYSTOKES <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. Use with care, since sequences shorter than LEADER_NO_TIMEOUT_FOR_N_KEYSTOKES will not timeout, and thus will not terminate unless leader_end() is called.
### Strict Key Processing {#strict-key-processing} ### Strict Key Processing {#strict-key-processing}

View File

@ -11,6 +11,10 @@
# define LEADER_TIMEOUT 300 # define LEADER_TIMEOUT 300
#endif #endif
#if defined(LEADER_NO_TIMEOUT) && !defined(LEADER_NO_TIMEOUT_FOR_N_KEYSTOKES)
# define LEADER_NO_TIMEOUT_FOR_N_KEYSTOKES 1
#endif
// Leader key stuff // Leader key stuff
bool leading = false; bool leading = false;
uint16_t leader_time = 0; uint16_t leader_time = 0;
@ -53,11 +57,7 @@ bool leader_sequence_add(uint16_t keycode) {
} }
#if defined(LEADER_NO_TIMEOUT) #if defined(LEADER_NO_TIMEOUT)
# if defined(LEADER_NO_TIMEOUT_N) if (leader_sequence_size < LEADER_NO_TIMEOUT_FOR_N_KEYSTOKES) {
if (leader_sequence_size < LEADER_NO_TIMEOUT_N - 1) {
# else
if (leader_sequence_size == 0) {
# endif
leader_reset_timer(); leader_reset_timer();
} }
#endif #endif
@ -70,11 +70,7 @@ bool leader_sequence_add(uint16_t keycode) {
bool leader_sequence_timed_out(void) { bool leader_sequence_timed_out(void) {
#if defined(LEADER_NO_TIMEOUT) #if defined(LEADER_NO_TIMEOUT)
# if defined(LEADER_NO_TIMEOUT_N) return leader_sequence_size >= LEADER_NO_TIMEOUT_FOR_N_KEYSTOKES && timer_elapsed(leader_time) > LEADER_TIMEOUT;
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 #else
return timer_elapsed(leader_time) > LEADER_TIMEOUT; return timer_elapsed(leader_time) > LEADER_TIMEOUT;
#endif #endif