From d60d0cebee52cbb10885636055f3548964b071eb Mon Sep 17 00:00:00 2001 From: Mr-Asmodaeus Date: Sat, 16 Nov 2024 15:02:10 +0000 Subject: [PATCH] Changed LEADER_NO_TIMEOUT_N to LEADER_NO_TIMEOUT_FOR_N_KEYSTOKES for clarity --- docs/features/leader_key.md | 4 ++-- quantum/leader.c | 16 ++++++---------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/docs/features/leader_key.md b/docs/features/leader_key.md index 42f05bc544d..902ccd0c013 100644 --- a/docs/features/leader_key.md +++ b/docs/features/leader_key.md @@ -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. Add the following to your `config.h`: ```c -#define LEADER_NO_TIMEOUT_N +#define LEADER_NO_TIMEOUT_FOR_N_KEYSTOKES ``` -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} diff --git a/quantum/leader.c b/quantum/leader.c index 17bd75c8453..7d0927c4db8 100644 --- a/quantum/leader.c +++ b/quantum/leader.c @@ -11,6 +11,10 @@ # define LEADER_TIMEOUT 300 #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 bool leading = false; 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_N) - if (leader_sequence_size < LEADER_NO_TIMEOUT_N - 1) { -# else - if (leader_sequence_size == 0) { -# endif + if (leader_sequence_size < LEADER_NO_TIMEOUT_FOR_N_KEYSTOKES) { leader_reset_timer(); } #endif @@ -70,11 +70,7 @@ 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 + return leader_sequence_size >= LEADER_NO_TIMEOUT_FOR_N_KEYSTOKES && timer_elapsed(leader_time) > LEADER_TIMEOUT; #else return timer_elapsed(leader_time) > LEADER_TIMEOUT; #endif