Add leader_add_user callback

This commit is contained in:
willbsp 2024-08-11 10:38:11 +01:00
parent 019b6f67b2
commit 0de31e3318
3 changed files with 22 additions and 0 deletions

View File

@ -154,6 +154,16 @@ User callback, invoked when the leader sequence ends.
---
### `bool leader_add_user(void)` {#api-leader-add-user}
User callback, invoked when a keycode is added to the leader sequence.
#### Return Value {#api-leader-sequence-add-return}
`true` to finish the key sequence, `false` to continue.
---
### `void leader_start(void)` {#api-leader-start}
Begin the leader sequence, resetting the buffer and timer.

View File

@ -21,6 +21,8 @@ __attribute__((weak)) void leader_start_user(void) {}
__attribute__((weak)) void leader_end_user(void) {}
__attribute__((weak)) bool leader_add_user(void) { return false; }
void leader_start(void) {
if (leading) {
return;
@ -61,6 +63,9 @@ bool leader_sequence_add(uint16_t keycode) {
leader_sequence[leader_sequence_size] = keycode;
leader_sequence_size++;
if (leader_add_user()) {
leader_end();
}
return true;
}

View File

@ -21,6 +21,13 @@ void leader_start_user(void);
*/
void leader_end_user(void);
/**
* \brief User callback, invoked when a keycode is added to the leader sequence.
*
* \return `true` to finish the key sequence, `false` to continue.
*/
bool leader_add_user(void);
/**
* Begin the leader sequence, resetting the buffer and timer.
*/