Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leader: remove qk_ prefix #19304

Merged
merged 1 commit into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/feature_leader_key.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,18 @@ While, this may be fine for most, if you want to specify the whole keycode (eg,

## Customization

The Leader Key feature has some additional customization to how the Leader Key feature works. It has two functions that can be called at certain parts of the process. Namely `leader_start()` and `leader_end()`.
The Leader Key feature has some additional customization to how the Leader Key feature works. It has two functions that can be called at certain parts of the process. Namely `leader_start_user()` and `leader_end_user()`.

The `leader_start()` function is called when you tap the `QK_LEAD` key, and the `leader_end()` function is called when either the leader sequence is completed, or the leader timeout is hit.
The `leader_start_user()` function is called when you tap the `QK_LEAD` key, and the `leader_end_user()` function is called when either the leader sequence is completed, or the leader timeout is hit.

You can add these functions to your code (`keymap.c` usually) to add feedback to the Leader sequences (such as beeping or playing music).

```c
void leader_start(void) {
void leader_start_user(void) {
// sequence started
}

void leader_end(void) {
void leader_end_user(void) {
// sequence ended (no success/failure detection)
}
```
Expand Down Expand Up @@ -139,13 +139,13 @@ void matrix_scan_user(void) {
}
}

void leader_start(void) {
void leader_start_user(void) {
#ifdef AUDIO_ENABLE
PLAY_SONG(leader_start);
#endif
}

void leader_end(void) {
void leader_end_user(void) {
if (did_leader_succeed) {
#ifdef AUDIO_ENABLE
PLAY_SONG(leader_succeed);
Expand Down
2 changes: 1 addition & 1 deletion keyboards/dz60/keymaps/jdelkins/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ int ctl_state = 0;
void ctl_finished(qk_tap_dance_state_t *state, void *user_data) {
ctl_state = cur_dance(state);
switch (ctl_state) {
case SINGLE_TAP: qk_leader_start(); break;
case SINGLE_TAP: leader_start(); break;
case SINGLE_HOLD: register_code(KC_LCTL); break;
case DOUBLE_TAP: tap_code(KC_RCTL); break;
case DOUBLE_HOLD: register_code(KC_RCTL); break;
Expand Down
4 changes: 2 additions & 2 deletions keyboards/dztech/dz65rgb/keymaps/drootz/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -708,11 +708,11 @@ void matrix_scan_user(void)
}
}

void leader_start(void) {
void leader_start_user(void) {
isLeader = true;
}

void leader_end(void) {
void leader_end_user(void) {
isLeader = false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void none_lead_finished(qk_tap_dance_state_t *state, void *user_data) {
break;

case DOUBLE_TAP:
qk_leader_start();
leader_start();
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion keyboards/massdrop/alt/keymaps/jdelkins/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ int ctl_state = 0;
void ctl_finished(qk_tap_dance_state_t *state, void *user_data) {
ctl_state = cur_dance(state);
switch(ctl_state) {
case SINGLE_TAP: qk_leader_start(); break;
case SINGLE_TAP: leader_start(); break;
case SINGLE_HOLD: register_code(KC_LCTL); break;
case DOUBLE_TAP: tap_code(KC_RCTL); break;
case DOUBLE_HOLD: register_code(KC_RCTL); break;
Expand Down
2 changes: 1 addition & 1 deletion keyboards/planck/keymaps/jdelkins/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ int ctl_state = 0;
void ctl_finished(qk_tap_dance_state_t *state, void *user_data) {
ctl_state = cur_dance(state);
switch (ctl_state) {
case SINGLE_TAP: qk_leader_start(); break;
case SINGLE_TAP: leader_start(); break;
case SINGLE_HOLD: register_code(KC_LCTL); break;
case DOUBLE_TAP: tap_code(KC_RCTL); break;
case DOUBLE_HOLD: register_code(KC_RCTL); break;
Expand Down
4 changes: 2 additions & 2 deletions keyboards/planck/keymaps/rootiest/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1395,13 +1395,13 @@ bool get_permissive_hold(uint16_t keycode, keyrecord_t* record) {
* by playing sound at different stages of the leader chord
*/
// Called when you tap the Leader key
void leader_start(void) {
void leader_start_user(void) {
#ifdef AUDIO_ENABLE
PLAY_SONG(leader_started);
#endif
}
// Called when either the leader sequence is completed, or the leader timeout is hit
void leader_end(void) {
void leader_end_user(void) {
if (did_leader_succeed) {
#ifdef AUDIO_ENABLE
PLAY_SONG(leader_succeed);
Expand Down
2 changes: 1 addition & 1 deletion keyboards/planck/keymaps/yhaliaw/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void matrix_scan_user(void) {
}
}

void leader_end(void) {
void leader_end_user(void) {
// Plays sound on if leader sequence found.
if (leader_found) {
#ifdef AUDIO_ENABLE
Expand Down
4 changes: 2 additions & 2 deletions keyboards/preonic/keymaps/pcurt854/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,13 +469,13 @@ void matrix_scan_user(void) {
}
}

void leader_start(void) {
void leader_start_user(void) {
#ifdef AUDIO_ENABLE
PLAY_SONG(leader_start_song);
#endif
}

void leader_end(void) {
void leader_end_user(void) {
if (did_leader_succeed) {
#ifdef AUDIO_ENABLE
PLAY_SONG(leader_succeed_song);
Expand Down
2 changes: 1 addition & 1 deletion keyboards/preonic/keymaps/yhaliaw/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ void matrix_scan_user(void) {
}
}

void leader_end(void) {
void leader_end_user(void) {
// Plays sound on if leader sequence found.
if (leader_found) {
#ifdef AUDIO_ENABLE
Expand Down
42 changes: 21 additions & 21 deletions quantum/process_keycode/process_leader.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifdef LEADER_ENABLE
#include "process_leader.h"
#include <string.h>

# include "process_leader.h"
# include <string.h>

# ifndef LEADER_TIMEOUT
# define LEADER_TIMEOUT 300
# endif
#ifndef LEADER_TIMEOUT
# define LEADER_TIMEOUT 300
#endif

__attribute__((weak)) void leader_start(void) {}
__attribute__((weak)) void leader_start_user(void) {}

__attribute__((weak)) void leader_end(void) {}
__attribute__((weak)) void leader_end_user(void) {}

// Leader key stuff
bool leading = false;
Expand All @@ -34,52 +32,54 @@ uint16_t leader_time = 0;
uint16_t leader_sequence[5] = {0, 0, 0, 0, 0};
uint8_t leader_sequence_size = 0;

void qk_leader_start(void) {
void leader_start(void) {
if (leading) {
return;
}
leader_start();
leader_start_user();
leading = true;
leader_time = timer_read();
leader_sequence_size = 0;
memset(leader_sequence, 0, sizeof(leader_sequence));
}

void leader_end(void) {
leader_end_user();
}

bool process_leader(uint16_t keycode, keyrecord_t *record) {
// Leader key set-up
if (record->event.pressed) {
if (leading) {
# ifndef LEADER_NO_TIMEOUT
#ifndef LEADER_NO_TIMEOUT
if (timer_elapsed(leader_time) < LEADER_TIMEOUT)
# endif // LEADER_NO_TIMEOUT
#endif // LEADER_NO_TIMEOUT
{
# ifndef LEADER_KEY_STRICT_KEY_PROCESSING
#ifndef LEADER_KEY_STRICT_KEY_PROCESSING
if (IS_QK_MOD_TAP(keycode)) {
keycode = QK_MOD_TAP_GET_TAP_KEYCODE(keycode);
} else if (IS_QK_LAYER_TAP(keycode)) {
keycode = QK_LAYER_TAP_GET_TAP_KEYCODE(keycode);
}
# endif // LEADER_KEY_STRICT_KEY_PROCESSING
#endif // LEADER_KEY_STRICT_KEY_PROCESSING
if (leader_sequence_size < ARRAY_SIZE(leader_sequence)) {
leader_sequence[leader_sequence_size] = keycode;
leader_sequence_size++;
} else {
leading = false;
leader_end();
leader_end_user();
return true;
}
# ifdef LEADER_PER_KEY_TIMING
#ifdef LEADER_PER_KEY_TIMING
leader_time = timer_read();
# endif
#endif
return false;
}
} else {
if (keycode == QK_LEADER) {
qk_leader_start();
leader_start();
}
}
}
return true;
}

#endif
4 changes: 3 additions & 1 deletion quantum/process_keycode/process_leader.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@

bool process_leader(uint16_t keycode, keyrecord_t *record);

void leader_start_user(void);
void leader_end_user(void);

void leader_start(void);
void leader_end(void);
void qk_leader_start(void);

#define SEQ_ONE_KEY(key) if (leader_sequence[0] == (key) && leader_sequence[1] == 0 && leader_sequence[2] == 0 && leader_sequence[3] == 0 && leader_sequence[4] == 0)
#define SEQ_TWO_KEYS(key1, key2) if (leader_sequence[0] == (key1) && leader_sequence[1] == (key2) && leader_sequence[2] == 0 && leader_sequence[3] == 0 && leader_sequence[4] == 0)
Expand Down
4 changes: 2 additions & 2 deletions users/danielo515/danielo515.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ bool onMac = true;
LEADER_EXTERNS();
# ifdef RGBLIGHT_ENABLE

void leader_start() { rgblight_setrgb_range(5, 100, 199, 10, 15); };
void leader_start_user() { rgblight_setrgb_range(5, 100, 199, 10, 15); };

void leader_end() { rgblight_setrgb_range(200, 200, 255, 10, 15); };
void leader_end_user() { rgblight_setrgb_range(200, 200, 255, 10, 15); };
# endif

void matrix_scan_user(void) {
Expand Down
4 changes: 2 additions & 2 deletions users/kuchosauronad0/leader.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ void matrix_scan_user(void) {
// matrix_scan_keymap();
}

void leader_start(void) {
void leader_start_user(void) {
#ifdef RGBLIGHT_ENABLE
rgblight_savebase();
rgblight_mode_noeeprom(1);
rgblight_sethsv_noeeprom(HSV_GOLDENROD);
#endif
}

void leader_end(void) {
void leader_end_user(void) {
// pick color depending of success /fail
// fade leader_start from 100 to 0
// fade new color from 0 to 100 to 0
Expand Down