Refactor Leader key feature (#19632)

Co-authored-by: Drashna Jaelre <drashna@live.com>
master
Ryan 2023-02-13 03:19:02 +11:00 committed by GitHub
parent d10350cd2c
commit bbf7a20b33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
77 changed files with 2457 additions and 1968 deletions

View File

@ -1,165 +1,297 @@
# The Leader Key: A New Kind of Modifier # The Leader Key: A New Kind of Modifier :id=the-leader-key
If you've ever used Vim, you know what a Leader key is. If not, you're about to discover a wonderful concept. :) Instead of hitting Alt+Shift+W for example (holding down three keys at the same time), what if you could hit a _sequence_ of keys instead? So you'd hit our special modifier (the Leader key), followed by W and then C (just a rapid succession of keys), and something would happen. If you're a Vim user, you probably know what a Leader key is. In contrast to [Combos](feature_combo.md), the Leader key allows you to hit a *sequence* of up to five keys instead, which triggers some custom functionality once complete.
That's what `QK_LEAD` does. Here's an example: ## Usage :id=usage
1. Pick a key on your keyboard you want to use as the Leader key. Assign it the keycode `QK_LEAD`. This key would be dedicated just for this -- it's a single action key, can't be used for anything else. Add the following to your `rules.mk`:
2. Include the line `#define LEADER_TIMEOUT 300` in your `config.h`. This sets the timeout for the `QK_LEAD` key. Specifically, when you press the `QK_LEAD` key, you only have a certain amount of time to complete the Leader Key sequence. The `300` here sets that to 300ms, and you can increase this value to give you more time to hit the sequence. But any keys pressed during this timeout are intercepted and not sent, so you may want to keep this value low.
* By default, this timeout is how long after pressing `QK_LEAD` to complete your entire sequence. This may be very low for some people. So you may want to increase this timeout. Optionally, you may want to enable the `LEADER_PER_KEY_TIMING` option, which resets the timeout after each key is tapped. This allows you to maintain a low value here, but still be able to use the longer sequences. To enable this option, add `#define LEADER_PER_KEY_TIMING` to your `config.h`.
3. Within your `matrix_scan_user` function, add something like this:
```c
LEADER_EXTERNS();
void matrix_scan_user(void) {
LEADER_DICTIONARY() {
leading = false;
leader_end();
SEQ_ONE_KEY(KC_F) {
// Anything you can do in a macro.
SEND_STRING("QMK is awesome.");
}
SEQ_TWO_KEYS(KC_D, KC_D) {
SEND_STRING(SS_LCTL("a") SS_LCTL("c"));
}
SEQ_THREE_KEYS(KC_D, KC_D, KC_S) {
SEND_STRING("https://start.duckduckgo.com\n");
}
SEQ_TWO_KEYS(KC_A, KC_S) {
register_code(KC_LGUI);
register_code(KC_S);
unregister_code(KC_S);
unregister_code(KC_LGUI);
}
}
}
```
As you can see, you have a few functions. You can use `SEQ_ONE_KEY` for single-key sequences (Leader followed by just one key), and `SEQ_TWO_KEYS`, `SEQ_THREE_KEYS` up to `SEQ_FIVE_KEYS` for longer sequences.
Each of these accepts one or more keycodes as arguments. This is an important point: You can use keycodes from **any layer on your keyboard**. That layer would need to be active for the leader macro to fire, obviously.
## Adding Leader Key Support
To enable Leader Key, add the following line to your keymap's `rules.mk`:
```make ```make
LEADER_ENABLE = yes LEADER_ENABLE = yes
``` ```
Place the following macro in your `keymap.c` or user space source file, before any functional code. It handles declaration of external variables that will be referenced by Leader Key codes that follows: Then add the `QK_LEAD` keycode to your keymap.
## Callbacks :id=callbacks
These callbacks are invoked when the leader sequence begins and ends. In the latter you can implement your custom functionality based on the contents of the sequence buffer.
```c ```c
LEADER_EXTERNS(); void leader_start_user(void) {
// Do something when the leader key is pressed
}
void leader_end_user(void) {
if (leader_sequence_one_key(KC_F)) {
// Leader, f => Types the below string
SEND_STRING("QMK is awesome.");
} else if (leader_sequence_two_keys(KC_D, KC_D)) {
// Leader, d, d => Ctrl+A, Ctrl+C
SEND_STRING(SS_LCTL("a") SS_LCTL("c"));
} else if (leader_sequence_three_keys(KC_D, KC_D, KC_S)) {
// Leader, d, d, s => Types the below string
SEND_STRING("https://start.duckduckgo.com\n");
} else if (leader_sequence_two_keys(KC_A, KC_S)) {
// Leader, a, s => GUI+S
tap_code16(LGUI(KC_S));
}
}
``` ```
## Per Key Timing on Leader keys ## Basic Configuration :id=basic-configuration
Rather than relying on an incredibly high timeout for long leader key strings or those of us without 200wpm typing skills, we can enable per key timing to ensure that each key pressed provides us with more time to finish our stroke. This is incredibly helpful with leader key emulation of tap dance (read: multiple taps of the same key like C, C, C). ### Timeout :id=timeout
This is the amount of time you have to complete a sequence once the leader key has been pressed. The default value is 300 milliseconds, but you can change this by adding the following to your `config.h`:
```c
#define LEADER_TIMEOUT 350
```
### Per-Key Timeout :id=per-key-timeout
Rather than relying on an incredibly high timeout for long leader key strings or those of us without 200 wpm typing skills, you can enable per-key timing to ensure that each key pressed provides you with more time to finish the sequence. This is incredibly helpful with leader key emulation of tap dance (such as multiple taps of the same key like C, C, C).
To enable this, add the following to your `config.h`:
In order to enable this, place this in your `config.h`:
```c ```c
#define LEADER_PER_KEY_TIMING #define LEADER_PER_KEY_TIMING
``` ```
After this, it's recommended that you lower your `LEADER_TIMEOUT` to something less that 300ms. After this, it's recommended that you lower your timeout below 300 ms:
```c ```c
#define LEADER_TIMEOUT 250 #define LEADER_TIMEOUT 250
``` ```
Now, something like this won't seem impossible to do without a 1000MS leader key timeout: Now, something like this won't seem impossible to do without a 1000 millisecond timeout:
```c ```c
SEQ_THREE_KEYS(KC_C, KC_C, KC_C) { if (leader_sequence_three_keys(KC_C, KC_C, KC_C)) {
SEND_STRING("Per key timing is great!!!"); SEND_STRING("Per key timing is great!!!");
} }
``` ```
## Infinite Leader key timeout ### Disabling Initial Timeout :id=disabling-initial-timeout
Sometimes your leader key is not on a comfortable place as the rest of keys on your sequence. Imagine that your leader key is one of your outer top right keys, you may need to reposition your hand just to reach your leader key. Sometimes your leader key may be too far away from the rest of the keys in the sequence. Imagine that your leader key is one of your outer top right keys - you may need to reposition your hand just to reach your leader key. This can make typing the entire sequence on time hard difficult if you are able to type most of the sequence fast. For example, if your sequence is `Leader + asd`, typing `asd` fast is very easy once you have your hands in your home row, but starting the sequence in time after moving your hand out of the home row to reach the leader key and back is not.
This can make typing the entire sequence on time hard even if you are able to type most of the sequence fast. For example, if your sequence is `Leader + asd` typing `asd` fast is very easy once you have your hands in your home row. However starting the sequence in time after moving your hand out of the home row to reach the leader key and back is not.
To remove the stress this situation produces to your hands you can enable an infinite timeout just for the leader key. This means that after you hit the leader key you will have an infinite amount of time to start the rest of the sequence, allowing you to proper position your hands on the best position to type the rest of the sequence comfortably. To remove the stress this situation produces to your hands, you can disable the timeout just for the leader key. Add the following to your `config.h`:
This infinite timeout only affects the leader key, so in our previous example of `Leader + asd` you will have an infinite amount of time between `Leader` and `a`, but once you start the sequence the timeout you have configured (global or per key) will work normally.
This way you can configure a very short `LEADER_TIMEOUT` but still have plenty of time to position your hands.
In order to enable this, place this in your `config.h`:
```c ```c
#define LEADER_NO_TIMEOUT #define LEADER_NO_TIMEOUT
``` ```
## Strict Key Processing 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.
By default, the Leader Key feature will filter the keycode out of [`Mod-Tap`](mod_tap.md) and [`Layer Tap`](feature_layers.md#switching-and-toggling-layers) functions when checking for the Leader sequences. That means if you're using `LT(3, KC_A)`, it will pick this up as `KC_A` for the sequence, rather than `LT(3, KC_A)`, giving a more expected behavior for newer users. ### Strict Key Processing :id=strict-key-processing
While, this may be fine for most, if you want to specify the whole keycode (eg, `LT(3, KC_A)` from the example above) in the sequence, you can enable this by adding `#define LEADER_KEY_STRICT_KEY_PROCESSING` to your `config.h` file. This will then disable the filtering, and you'll need to specify the whole keycode. By default, only the "tap keycode" portions of [Mod-Taps](mod_tap.md) and [Layer Taps](feature_layers.md#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.
## Customization This gives a more expected behaviour for most users, however you may want to change this.
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()`. To enable this, add the following to your `config.h`:
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 ```c
#define LEADER_KEY_STRICT_KEY_PROCESSING
```
## Example :id=example
This example will play the Mario "One Up" sound when you hit `QK_LEAD` to start the leader sequence. When the sequence ends, it will play "All Star" if it completes successfully or "Rick Roll" you if it fails (in other words, no sequence matched).
```c
#ifdef AUDIO_ENABLE
float leader_start_song[][2] = SONG(ONE_UP_SOUND);
float leader_succeed_song[][2] = SONG(ALL_STAR);
float leader_fail_song[][2] = SONG(RICK_ROLL);
#endif
void leader_start_user(void) { void leader_start_user(void) {
// sequence started #ifdef AUDIO_ENABLE
PLAY_SONG(leader_start_song);
#endif
} }
void leader_end_user(void) { void leader_end_user(void) {
// sequence ended (no success/failure detection) bool did_leader_succeed = false;
}
```
### Example if (leader_sequence_one_key(KC_E)) {
This example will play the Mario "One Up" sound when you hit `QK_LEAD` to start the Leader Sequence, and will play "All Star" if it completes successfully or "Rick Roll" you if it fails.
```c
bool did_leader_succeed;
#ifdef AUDIO_ENABLE
float leader_start[][2] = SONG(ONE_UP_SOUND );
float leader_succeed[][2] = SONG(ALL_STAR);
float leader_fail[][2] = SONG(RICK_ROLL);
#endif
LEADER_EXTERNS();
void matrix_scan_user(void) {
LEADER_DICTIONARY() {
did_leader_succeed = leading = false;
SEQ_ONE_KEY(KC_E) {
// Anything you can do in a macro.
SEND_STRING(SS_LCTL(SS_LSFT("t"))); SEND_STRING(SS_LCTL(SS_LSFT("t")));
did_leader_succeed = true; did_leader_succeed = true;
} else } else if (leader_sequence_two_keys(KC_E, KC_D)) {
SEQ_TWO_KEYS(KC_E, KC_D) {
SEND_STRING(SS_LGUI("r") "cmd\n" SS_LCTL("c")); SEND_STRING(SS_LGUI("r") "cmd\n" SS_LCTL("c"));
did_leader_succeed = true; did_leader_succeed = true;
} }
leader_end();
}
}
void leader_start_user(void) {
#ifdef AUDIO_ENABLE #ifdef AUDIO_ENABLE
PLAY_SONG(leader_start);
#endif
}
void leader_end_user(void) {
if (did_leader_succeed) { if (did_leader_succeed) {
#ifdef AUDIO_ENABLE PLAY_SONG(leader_succeed_song);
PLAY_SONG(leader_succeed);
#endif
} else { } else {
#ifdef AUDIO_ENABLE PLAY_SONG(leader_fail_song);
PLAY_SONG(leader_fail);
#endif
} }
#endif
} }
``` ```
## Keycodes :id=keycodes
|Key |Aliases |Description |
|-----------------------|---------|-------------------------|
|`QK_LEADER` |`QK_LEAD`|Begin the leader sequence|
## API :id=api
### `void leader_start_user(void)` :id=api-leader-start-user
User callback, invoked when the leader sequence begins.
---
### `void leader_end_user(void)` :id=api-leader-end-user
User callback, invoked when the leader sequence ends.
---
### `void leader_start(void)` :id=api-leader-start
Begin the leader sequence, resetting the buffer and timer.
---
### `void leader_end(void)` :id=api-leader-end
End the leader sequence.
---
### `bool leader_sequence_active(void)` :id=api-leader-sequence-active
Whether the leader sequence is active.
---
### `bool leader_sequence_add(uint16_t keycode)` :id=api-leader-sequence-add
Add the given keycode to the sequence buffer.
If `LEADER_NO_TIMEOUT` is defined, the timer is reset if the buffer is empty.
#### Arguments :id=api-leader-sequence-add-arguments
- `uint16_t keycode`
The keycode to add.
#### Return Value :id=api-leader-sequence-add-return
`true` if the keycode was added, `false` if the buffer is full.
---
### `bool leader_sequence_timed_out(void)` :id=api-leader-sequence-timed-out
Whether the leader sequence has reached the timeout.
If `LEADER_NO_TIMEOUT` is defined, the buffer must also contain at least one key.
---
### `bool leader_reset_timer(void)` :id=api-leader-reset-timer
Reset the leader sequence timer.
---
### `bool leader_sequence_one_key(uint16_t kc)` :id=api-leader-sequence-one-key
Check the sequence buffer for the given keycode.
#### Arguments :id=api-leader-sequence-one-key-arguments
- `uint16_t kc`
The keycode to check.
#### Return Value :id=api-leader-sequence-one-key-return
`true` if the sequence buffer matches.
---
### `bool leader_sequence_two_keys(uint16_t kc1, uint16_t kc2)` :id=api-leader-sequence-two-keys
Check the sequence buffer for the given keycodes.
#### Arguments :id=api-leader-sequence-two-keys-arguments
- `uint16_t kc1`
The first keycode to check.
- `uint16_t kc2`
The second keycode to check.
#### Return Value :id=api-leader-sequence-two-keys-return
`true` if the sequence buffer matches.
---
### `bool leader_sequence_three_keys(uint16_t kc1, uint16_t kc2, uint16_t kc3)` :id=api-leader-sequence-three-keys
Check the sequence buffer for the given keycodes.
#### Arguments :id=api-leader-sequence-three-keys-arguments
- `uint16_t kc1`
The first keycode to check.
- `uint16_t kc2`
The second keycode to check.
- `uint16_t kc3`
The third keycode to check.
#### Return Value :id=api-leader-sequence-three-keys-return
`true` if the sequence buffer matches.
---
### `bool leader_sequence_four_keys(uint16_t kc1, uint16_t kc2, uint16_t kc3, uint16_t kc4)` :id=api-leader-sequence-four-keys
Check the sequence buffer for the given keycodes.
#### Arguments :id=api-leader-sequence-four-keys-arguments
- `uint16_t kc1`
The first keycode to check.
- `uint16_t kc2`
The second keycode to check.
- `uint16_t kc3`
The third keycode to check.
- `uint16_t kc4`
The fourth keycode to check.
#### Return Value :id=api-leader-sequence-four-keys-return
`true` if the sequence buffer matches.
---
### `bool leader_sequence_five_keys(uint16_t kc1, uint16_t kc2, uint16_t kc3, uint16_t kc4, uint16_t kc5)` :id=api-leader-sequence-five-keys
Check the sequence buffer for the given keycodes.
#### Arguments :id=api-leader-sequence-five-keys-arguments
- `uint16_t kc1`
The first keycode to check.
- `uint16_t kc2`
The second keycode to check.
- `uint16_t kc3`
The third keycode to check.
- `uint16_t kc4`
The fourth keycode to check.
- `uint16_t kc5`
The fifth keycode to check.
#### Return Value :id=api-leader-sequence-five-keys-return
`true` if the sequence buffer matches.

View File

@ -78,44 +78,37 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
) )
}; };
LEADER_EXTERNS(); void leader_end_user(void) {
void matrix_scan_user(void) {
LEADER_DICTIONARY() {
leading = false;
leader_end();
// qq, alt+f4 close window // qq, alt+f4 close window
SEQ_TWO_KEYS(KC_Q, KC_Q) { if (leader_sequence_two_keys(KC_Q, KC_Q)) {
tap_code16(A(KC_F4)); tap_code16(A(KC_F4));
} }
// ee, open explorer // ee, open explorer
SEQ_TWO_KEYS(KC_E, KC_E) { if (leader_sequence_two_keys(KC_E, KC_E)) {
tap_code16(G(KC_E)); tap_code16(G(KC_E));
} }
// rr, windows run prompt // rr, windows run prompt
SEQ_TWO_KEYS(KC_R, KC_R) { if (leader_sequence_two_keys(KC_R, KC_R)) {
tap_code16(G(KC_R)); tap_code16(G(KC_R));
} }
// ww, maximize window // ww, maximize window
SEQ_TWO_KEYS(KC_W, KC_W) { if (leader_sequence_two_keys(KC_W, KC_W)) {
tap_code16(G(KC_UP)); tap_code16(G(KC_UP));
} }
// ss, minimize window // ss, minimize window
SEQ_TWO_KEYS(KC_S, KC_S) { if (leader_sequence_two_keys(KC_S, KC_S)) {
tap_code16(G(KC_DOWN)); tap_code16(G(KC_DOWN));
} }
// <space><space>, toggle desktop // <space><space>, toggle desktop
SEQ_TWO_KEYS(KC_SPC, KC_SPC) { if (leader_sequence_two_keys(KC_SPC, KC_SPC)) {
tap_code16(G(KC_D)); tap_code16(G(KC_D));
} }
} }
}
bool encoder_update_user(uint8_t index, bool clockwise) { bool encoder_update_user(uint8_t index, bool clockwise) {
uint8_t layer = get_highest_layer(layer_state); uint8_t layer = get_highest_layer(layer_state);

View File

@ -229,7 +229,47 @@ void keyboard_post_init_keymap(void) {
bspc_timer = 0; bspc_timer = 0;
} }
LEADER_EXTERNS(); void leader_end_user(void) {
// layer navigation
if (leader_sequence_one_key(KC_R)) { layer_invert(_RPT); }
if (leader_sequence_one_key(KC_G)) { layer_invert(_GAME); }
if (leader_sequence_one_key(KC_K)) { layer_invert(_KP); }
if (leader_sequence_one_key(KC_KP_5)) { layer_invert(_KP); }
// tmux navigation
if (leader_sequence_one_key(KC_L)) { SEND_STRING(SS_LCTL("a") "n"); }
if (leader_sequence_one_key(KC_H)) { SEND_STRING(SS_LCTL("a") "p"); }
if (leader_sequence_one_key(KC_N)) { SEND_STRING(SS_LCTL("a") "c"); }
if (leader_sequence_one_key(KC_W)) { SEND_STRING(SS_LCTL("a") "x"); }
if (leader_sequence_one_key(KC_MINS)) { SEND_STRING(SS_LCTL("a") "-"); }
if (leader_sequence_one_key(KC_QUOT)) { SEND_STRING(SS_LCTL("a") "\""); }
if (leader_sequence_one_key(KC_1)) { SEND_STRING(SS_LCTL("a") "1"); }
if (leader_sequence_one_key(KC_2)) { SEND_STRING(SS_LCTL("a") "2"); }
if (leader_sequence_one_key(KC_3)) { SEND_STRING(SS_LCTL("a") "3"); }
if (leader_sequence_one_key(KC_4)) { SEND_STRING(SS_LCTL("a") "4"); }
if (leader_sequence_one_key(KC_5)) { SEND_STRING(SS_LCTL("a") "5"); }
if (leader_sequence_one_key(KC_6)) { SEND_STRING(SS_LCTL("a") "6"); }
if (leader_sequence_one_key(KC_7)) { SEND_STRING(SS_LCTL("a") "7"); }
if (leader_sequence_one_key(KC_8)) { SEND_STRING(SS_LCTL("a") "8"); }
if (leader_sequence_one_key(KC_9)) { SEND_STRING(SS_LCTL("a") "9"); }
// secrets
if (leader_sequence_two_keys(KC_SCLN, KC_M)) { send_secret_string(0); }
if (leader_sequence_two_keys(KC_SCLN, KC_COMM)) { send_secret_string(1); }
if (leader_sequence_two_keys(KC_SCLN, KC_DOT)) { send_secret_string(2); }
if (leader_sequence_two_keys(KC_SCLN, KC_J)) { send_secret_string(3); }
if (leader_sequence_two_keys(KC_SCLN, KC_K)) { send_secret_string(4); }
if (leader_sequence_two_keys(KC_SCLN, KC_L)) { send_secret_string(5); }
// fast control-C
if (leader_sequence_one_key(KC_C)) { tap_code16(C(KC_C)); }
// neovim: terminal escape
if (leader_sequence_one_key(KC_BSLS)) {
tap_code16(C(KC_BSLS));
tap_code16(C(KC_N));
}
}
void matrix_scan_keymap(void) { void matrix_scan_keymap(void) {
if (rgblight_is_enabled() && timer_elapsed(rgb_timer) > 1000) { if (rgblight_is_enabled() && timer_elapsed(rgb_timer) > 1000) {
@ -248,50 +288,6 @@ void matrix_scan_keymap(void) {
bspc_timer = 0; bspc_timer = 0;
register_code(KC_BSPC); register_code(KC_BSPC);
} }
LEADER_DICTIONARY() {
leading = false;
leader_end();
// layer navigation
SEQ_ONE_KEY(KC_R) { layer_invert(_RPT); }
SEQ_ONE_KEY(KC_G) { layer_invert(_GAME); }
SEQ_ONE_KEY(KC_K) { layer_invert(_KP); }
SEQ_ONE_KEY(KC_KP_5) { layer_invert(_KP); }
// tmux navigation
SEQ_ONE_KEY(KC_L) { SEND_STRING(SS_LCTL("a") "n"); }
SEQ_ONE_KEY(KC_H) { SEND_STRING(SS_LCTL("a") "p"); }
SEQ_ONE_KEY(KC_N) { SEND_STRING(SS_LCTL("a") "c"); }
SEQ_ONE_KEY(KC_W) { SEND_STRING(SS_LCTL("a") "x"); }
SEQ_ONE_KEY(KC_MINS) { SEND_STRING(SS_LCTL("a") "-"); }
SEQ_ONE_KEY(KC_QUOT) { SEND_STRING(SS_LCTL("a") "\""); }
SEQ_ONE_KEY(KC_1) { SEND_STRING(SS_LCTL("a") "1"); }
SEQ_ONE_KEY(KC_2) { SEND_STRING(SS_LCTL("a") "2"); }
SEQ_ONE_KEY(KC_3) { SEND_STRING(SS_LCTL("a") "3"); }
SEQ_ONE_KEY(KC_4) { SEND_STRING(SS_LCTL("a") "4"); }
SEQ_ONE_KEY(KC_5) { SEND_STRING(SS_LCTL("a") "5"); }
SEQ_ONE_KEY(KC_6) { SEND_STRING(SS_LCTL("a") "6"); }
SEQ_ONE_KEY(KC_7) { SEND_STRING(SS_LCTL("a") "7"); }
SEQ_ONE_KEY(KC_8) { SEND_STRING(SS_LCTL("a") "8"); }
SEQ_ONE_KEY(KC_9) { SEND_STRING(SS_LCTL("a") "9"); }
// secrets
SEQ_TWO_KEYS(KC_SCLN, KC_M) { send_secret_string(0); }
SEQ_TWO_KEYS(KC_SCLN, KC_COMM) { send_secret_string(1); }
SEQ_TWO_KEYS(KC_SCLN, KC_DOT) { send_secret_string(2); }
SEQ_TWO_KEYS(KC_SCLN, KC_J) { send_secret_string(3); }
SEQ_TWO_KEYS(KC_SCLN, KC_K) { send_secret_string(4); }
SEQ_TWO_KEYS(KC_SCLN, KC_L) { send_secret_string(5); }
// fast control-C
SEQ_ONE_KEY(KC_C) { tap_code16(C(KC_C)); }
// neovim: terminal escape
SEQ_ONE_KEY(KC_BSLS) {
tap_code16(C(KC_BSLS));
tap_code16(C(KC_N));
}
}
} }
bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {

View File

@ -418,54 +418,52 @@ void ldrkey_send_curlybrace_wrap_selection(void) {
onMac ? SEND_STRING(SS_LGUI(SS_TAP(X_X)) "{}" SS_TAP(X_LEFT) SS_LGUI(SS_TAP(X_V)) SS_TAP(X_RIGHT)) : SEND_STRING(SS_LCTL(SS_TAP(X_X)) "{}" SS_TAP(X_LEFT) SS_LCTL(SS_TAP(X_V)) SS_TAP(X_RIGHT)); onMac ? SEND_STRING(SS_LGUI(SS_TAP(X_X)) "{}" SS_TAP(X_LEFT) SS_LGUI(SS_TAP(X_V)) SS_TAP(X_RIGHT)) : SEND_STRING(SS_LCTL(SS_TAP(X_X)) "{}" SS_TAP(X_LEFT) SS_LCTL(SS_TAP(X_V)) SS_TAP(X_RIGHT));
} }
LEADER_EXTERNS(); void leader_start_user(void) {
isLeader = true;
}
void matrix_scan_user(void) void leader_end_user(void) {
{ isLeader = false;
LEADER_DICTIONARY()
{
leading = false;
leader_end();
/* Sequences on layer _MAIN & _MAC */ /* Sequences on layer _MAIN & _MAC */
/* éÉ => LdrKey > / */ /* éÉ => LdrKey > / */
SEQ_ONE_KEY(KC_SLSH) { if (leader_sequence_one_key(KC_SLSH)) {
send_french_accent(_E, _ACUTE); send_french_accent(_E, _ACUTE);
} }
/* àÀ => LdrKey > A */ /* àÀ => LdrKey > A */
SEQ_ONE_KEY(KC_A) { if (leader_sequence_one_key(KC_A)) {
send_french_accent(_A, _GRAVE); send_french_accent(_A, _GRAVE);
} }
/* èÈ => LdrKey > E */ /* èÈ => LdrKey > E */
SEQ_ONE_KEY(KC_E) { if (leader_sequence_one_key(KC_E)) {
send_french_accent(_E, _GRAVE); send_french_accent(_E, _GRAVE);
} }
/* ùÙ => LdrKey > U */ /* ùÙ => LdrKey > U */
SEQ_ONE_KEY(KC_U) { if (leader_sequence_one_key(KC_U)) {
send_french_accent(_U, _GRAVE); send_french_accent(_U, _GRAVE);
} }
/* â => LdrKey > A > A */ /* â => LdrKey > A > A */
SEQ_TWO_KEYS(KC_A, KC_A) { if (leader_sequence_two_keys(KC_A, KC_A)) {
send_french_accent(_A, _CIRCUMFLEX); send_french_accent(_A, _CIRCUMFLEX);
} }
/* êÊ => LdrKey > E > E */ /* êÊ => LdrKey > E > E */
SEQ_TWO_KEYS(KC_E, KC_E) { if (leader_sequence_two_keys(KC_E, KC_E)) {
send_french_accent(_E, _CIRCUMFLEX); send_french_accent(_E, _CIRCUMFLEX);
} }
/* îÎ => LdrKey > I > I */ /* îÎ => LdrKey > I > I */
SEQ_TWO_KEYS(KC_I, KC_I) { if (leader_sequence_two_keys(KC_I, KC_I)) {
send_french_accent(_I, _CIRCUMFLEX); send_french_accent(_I, _CIRCUMFLEX);
} }
/* ôÔ => LdrKey > O > O */ /* ôÔ => LdrKey > O > O */
SEQ_TWO_KEYS(KC_O, KC_O) { if (leader_sequence_two_keys(KC_O, KC_O)) {
send_french_accent(_O, _CIRCUMFLEX); send_french_accent(_O, _CIRCUMFLEX);
} }
/* ûÛ => LdrKey > U > U */ /* ûÛ => LdrKey > U > U */
SEQ_TWO_KEYS(KC_U, KC_U) { if (leader_sequence_two_keys(KC_U, KC_U)) {
send_french_accent(_U, _CIRCUMFLEX); send_french_accent(_U, _CIRCUMFLEX);
} }
/* çÇ => LdrKey > C */ /* çÇ => LdrKey > C */
SEQ_ONE_KEY(KC_C) { if (leader_sequence_one_key(KC_C)) {
if (onMac) { if (onMac) {
SEND_STRING(SS_LALT("c")); SEND_STRING(SS_LALT("c"));
} else { } else {
@ -473,248 +471,239 @@ void matrix_scan_user(void)
} }
} }
/* CapsLock */ /* CapsLock */
SEQ_ONE_KEY(QK_LEAD) { if (leader_sequence_one_key(QK_LEAD)) {
tap_code(KC_CAPS); tap_code(KC_CAPS);
} }
/* ± => LdrKey > = > - */ /* ± => LdrKey > = > - */
SEQ_TWO_KEYS(KC_EQL, KC_MINS) { if (leader_sequence_two_keys(KC_EQL, KC_MINS)) {
onMac ? SEND_STRING(SS_LALT(SS_LSFT(SS_TAP(X_EQL)))) : SEND_STRING(SS_DOWN(X_LALT) SS_TAP(X_P2) SS_TAP(X_P4) SS_TAP(X_P1) SS_UP(X_LALT)); onMac ? SEND_STRING(SS_LALT(SS_LSFT(SS_TAP(X_EQL)))) : SEND_STRING(SS_DOWN(X_LALT) SS_TAP(X_P2) SS_TAP(X_P4) SS_TAP(X_P1) SS_UP(X_LALT));
} }
/* ≤ => LdrKey > - > = */ /* ≤ => LdrKey > - > = */
SEQ_TWO_KEYS(KC_MINS, KC_EQL) { if (leader_sequence_two_keys(KC_MINS, KC_EQL)) {
onMac ? SEND_STRING(SS_LALT(SS_TAP(X_COMM))) : SEND_STRING(SS_DOWN(X_LALT) SS_TAP(X_P2) SS_TAP(X_P4) SS_TAP(X_P3) SS_UP(X_LALT)); onMac ? SEND_STRING(SS_LALT(SS_TAP(X_COMM))) : SEND_STRING(SS_DOWN(X_LALT) SS_TAP(X_P2) SS_TAP(X_P4) SS_TAP(X_P3) SS_UP(X_LALT));
} }
/* ≥ => LdrKey > = > = */ /* ≥ => LdrKey > = > = */
SEQ_TWO_KEYS(KC_EQL, KC_EQL) { if (leader_sequence_two_keys(KC_EQL, KC_EQL)) {
onMac ? SEND_STRING(SS_LALT(SS_TAP(X_DOT))) : SEND_STRING(SS_DOWN(X_LALT) SS_TAP(X_P2) SS_TAP(X_P4) SS_TAP(X_P2) SS_UP(X_LALT)); onMac ? SEND_STRING(SS_LALT(SS_TAP(X_DOT))) : SEND_STRING(SS_DOWN(X_LALT) SS_TAP(X_P2) SS_TAP(X_P4) SS_TAP(X_P2) SS_UP(X_LALT));
} }
/* <= => LdrKey > , > , */ /* <= => LdrKey > , > , */
SEQ_TWO_KEYS(KC_COMM, KC_COMM) { if (leader_sequence_two_keys(KC_COMM, KC_COMM)) {
SEND_STRING(SS_LSFT(SS_TAP(X_COMM)) SS_TAP(X_SPC) SS_TAP(X_EQL) SS_TAP(X_LEFT) SS_TAP(X_BSPC) SS_TAP(X_RIGHT)); SEND_STRING(SS_LSFT(SS_TAP(X_COMM)) SS_TAP(X_SPC) SS_TAP(X_EQL) SS_TAP(X_LEFT) SS_TAP(X_BSPC) SS_TAP(X_RIGHT));
} }
/* => => LdrKey > . > . */ /* => => LdrKey > . > . */
SEQ_TWO_KEYS(KC_DOT, KC_DOT) { if (leader_sequence_two_keys(KC_DOT, KC_DOT)) {
SEND_STRING("=>"); SEND_STRING("=>");
} }
/* ", " => LdrKey > " " */ /* ", " => LdrKey > " " */
SEQ_ONE_KEY(KC_SPC) { if (leader_sequence_one_key(KC_SPC)) {
SEND_STRING(", "); SEND_STRING(", ");
} }
/* ". " => LdrKey > " " > " " */ /* ". " => LdrKey > " " > " " */
SEQ_TWO_KEYS(KC_SPC, KC_SPC) { if (leader_sequence_two_keys(KC_SPC, KC_SPC)) {
SEND_STRING(". "); SEND_STRING(". ");
} }
/* Backward delete current word (on cursor) */ /* Backward delete current word (on cursor) */
SEQ_TWO_KEYS(KC_BSPC, KC_BSPC) { if (leader_sequence_two_keys(KC_BSPC, KC_BSPC)) {
onMac ? SEND_STRING(SS_LALT(SS_TAP(X_RIGHT)) SS_LALT(SS_LSFT(SS_TAP(X_LEFT))) SS_TAP(X_BSPC)) : SEND_STRING(SS_LCTL(SS_TAP(X_RIGHT)) SS_LCTL(SS_LSFT(SS_TAP(X_LEFT))) SS_TAP(X_BSPC)); onMac ? SEND_STRING(SS_LALT(SS_TAP(X_RIGHT)) SS_LALT(SS_LSFT(SS_TAP(X_LEFT))) SS_TAP(X_BSPC)) : SEND_STRING(SS_LCTL(SS_TAP(X_RIGHT)) SS_LCTL(SS_LSFT(SS_TAP(X_LEFT))) SS_TAP(X_BSPC));
} }
/* Previous word delete */ /* Previous word delete */
SEQ_ONE_KEY(KC_BSPC) { if (leader_sequence_one_key(KC_BSPC)) {
onMac ? SEND_STRING(SS_LALT(SS_LSFT(SS_TAP(X_LEFT))) SS_TAP(X_BSPC)) : SEND_STRING(SS_LCTL(SS_LSFT(SS_TAP(X_LEFT))) SS_TAP(X_BSPC)); onMac ? SEND_STRING(SS_LALT(SS_LSFT(SS_TAP(X_LEFT))) SS_TAP(X_BSPC)) : SEND_STRING(SS_LCTL(SS_LSFT(SS_TAP(X_LEFT))) SS_TAP(X_BSPC));
} }
/* Forward delete current word (on cursor) */ /* Forward delete current word (on cursor) */
SEQ_TWO_KEYS(KC_DEL, KC_DEL) { if (leader_sequence_two_keys(KC_DEL, KC_DEL)) {
onMac ? SEND_STRING(SS_LALT(SS_TAP(X_LEFT)) SS_LALT(SS_LSFT(SS_TAP(X_RIGHT))) SS_TAP(X_DEL)) : SEND_STRING(SS_LCTL(SS_TAP(X_LEFT)) SS_LCTL(SS_LSFT(SS_TAP(X_RIGHT))) SS_TAP(X_DEL)); onMac ? SEND_STRING(SS_LALT(SS_TAP(X_LEFT)) SS_LALT(SS_LSFT(SS_TAP(X_RIGHT))) SS_TAP(X_DEL)) : SEND_STRING(SS_LCTL(SS_TAP(X_LEFT)) SS_LCTL(SS_LSFT(SS_TAP(X_RIGHT))) SS_TAP(X_DEL));
} }
/* Next word delete */ /* Next word delete */
SEQ_ONE_KEY(KC_DEL) { if (leader_sequence_one_key(KC_DEL)) {
onMac ? SEND_STRING(SS_LALT(SS_LSFT(SS_TAP(X_RIGHT))) SS_TAP(X_DEL)): SEND_STRING(SS_LCTL(SS_LSFT(SS_TAP(X_RIGHT))) SS_TAP(X_DEL)); onMac ? SEND_STRING(SS_LALT(SS_LSFT(SS_TAP(X_RIGHT))) SS_TAP(X_DEL)): SEND_STRING(SS_LCTL(SS_LSFT(SS_TAP(X_RIGHT))) SS_TAP(X_DEL));
} }
/* ` => LdrKey > Escape */ /* ` => LdrKey > Escape */
SEQ_ONE_KEY(QK_GESC) { if (leader_sequence_one_key(QK_GESC)) {
SEND_STRING("`"); SEND_STRING("`");
} }
/* ``` => LdrKey > Escape > Escape > Escape */ /* ``` => LdrKey > Escape > Escape > Escape */
SEQ_THREE_KEYS(QK_GESC, QK_GESC, QK_GESC) { if (leader_sequence_three_keys(QK_GESC, QK_GESC, QK_GESC)) {
SEND_STRING("```"); SEND_STRING("```");
} }
/* Printscreen => LdrKey > Insert */ /* Printscreen => LdrKey > Insert */
SEQ_ONE_KEY(KC_INS) { if (leader_sequence_one_key(KC_INS)) {
onMac ? SEND_STRING(SS_LGUI(SS_LSFT(SS_TAP(X_4)))) : SEND_STRING(SS_TAP(X_PSCR)); onMac ? SEND_STRING(SS_LGUI(SS_LSFT(SS_TAP(X_4)))) : SEND_STRING(SS_TAP(X_PSCR));
} }
/* Home => LdrKey > Page Up */ /* Home => LdrKey > Page Up */
SEQ_ONE_KEY(KC_PGUP) { if (leader_sequence_one_key(KC_PGUP)) {
onMac ? SEND_STRING(SS_TAP(X_HOME)) : SEND_STRING(SS_LCTL(SS_TAP(X_HOME))); onMac ? SEND_STRING(SS_TAP(X_HOME)) : SEND_STRING(SS_LCTL(SS_TAP(X_HOME)));
} }
/* End => LdrKey > Page Down */ /* End => LdrKey > Page Down */
SEQ_ONE_KEY(KC_PGDN) { if (leader_sequence_one_key(KC_PGDN)) {
onMac ? SEND_STRING(SS_TAP(X_END)) : SEND_STRING(SS_LCTL(SS_TAP(X_END))); onMac ? SEND_STRING(SS_TAP(X_END)) : SEND_STRING(SS_LCTL(SS_TAP(X_END)));
} }
/* Close Curernt File/Tab => LdrKey > W */ /* Close Curernt File/Tab => LdrKey > W */
SEQ_ONE_KEY(KC_W) { if (leader_sequence_one_key(KC_W)) {
onMac ? SEND_STRING(SS_LGUI(SS_TAP(X_W))) : SEND_STRING(SS_LCTL(SS_TAP(X_W))); onMac ? SEND_STRING(SS_LGUI(SS_TAP(X_W))) : SEND_STRING(SS_LCTL(SS_TAP(X_W)));
} }
/* Close Current App => LdrKey > Q */ /* Close Current App => LdrKey > Q */
SEQ_ONE_KEY(KC_Q) { if (leader_sequence_one_key(KC_Q)) {
onMac ? SEND_STRING(SS_LGUI(SS_TAP(X_Q))) : SEND_STRING(SS_LALT(SS_TAP(X_F4))); onMac ? SEND_STRING(SS_LGUI(SS_TAP(X_Q))) : SEND_STRING(SS_LALT(SS_TAP(X_F4)));
} }
/* " => LdrKey > ' */ /* " => LdrKey > ' */
SEQ_ONE_KEY(KC_QUOT) { if (leader_sequence_one_key(KC_QUOT)) {
SEND_STRING("\""); SEND_STRING("\"");
} }
/* "|" => LdrKey > ' > ' */ /* "|" => LdrKey > ' > ' */
SEQ_TWO_KEYS(KC_QUOT, KC_QUOT) { if (leader_sequence_two_keys(KC_QUOT, KC_QUOT)) {
SEND_STRING("\"\"" SS_TAP(X_LEFT)); SEND_STRING("\"\"" SS_TAP(X_LEFT));
} }
/* "X" wrap => LdrKey > ' > ' > ' */ /* "X" wrap => LdrKey > ' > ' > ' */
SEQ_THREE_KEYS(KC_QUOT, KC_QUOT, KC_QUOT) { if (leader_sequence_three_keys(KC_QUOT, KC_QUOT, KC_QUOT)) {
onMac ? SEND_STRING(SS_LALT(SS_TAP(X_LEFT)) "\"" SS_LALT(SS_TAP(X_RIGHT)) "\"") : SEND_STRING(SS_LCTL(SS_TAP(X_LEFT)) "\"" SS_LCTL(SS_TAP(X_RIGHT)) "\""); onMac ? SEND_STRING(SS_LALT(SS_TAP(X_LEFT)) "\"" SS_LALT(SS_TAP(X_RIGHT)) "\"") : SEND_STRING(SS_LCTL(SS_TAP(X_LEFT)) "\"" SS_LCTL(SS_TAP(X_RIGHT)) "\"");
} }
/* ( => LdrKey > Left Shift */ /* ( => LdrKey > Left Shift */
SEQ_ONE_KEY(KC_LSFT) { if (leader_sequence_one_key(KC_LSFT)) {
SEND_STRING("("); SEND_STRING("(");
} }
/* ) => LdrKey > Right Shift */ /* ) => LdrKey > Right Shift */
SEQ_ONE_KEY(KC_RSFT) { if (leader_sequence_one_key(KC_RSFT)) {
SEND_STRING(")"); SEND_STRING(")");
} }
/* (|) => LdrKey > Left Shift > Left Shift */ /* (|) => LdrKey > Left Shift > Left Shift */
SEQ_TWO_KEYS(KC_LSFT, KC_LSFT) { if (leader_sequence_two_keys(KC_LSFT, KC_LSFT)) {
ldrkey_send_paranthesis_wrap_ini(); ldrkey_send_paranthesis_wrap_ini();
} }
/* (|) => LdrKey > Right Shift > Right Shift */ /* (|) => LdrKey > Right Shift > Right Shift */
SEQ_TWO_KEYS(KC_RSFT, KC_RSFT) { if (leader_sequence_two_keys(KC_RSFT, KC_RSFT)) {
ldrkey_send_paranthesis_wrap_ini(); ldrkey_send_paranthesis_wrap_ini();
} }
/* (X) wrap => LdrKey > Left Shift > W */ /* (X) wrap => LdrKey > Left Shift > W */
SEQ_TWO_KEYS(KC_LSFT, KC_W) { if (leader_sequence_two_keys(KC_LSFT, KC_W)) {
ldrkey_send_paranthesis_wrap_word(); ldrkey_send_paranthesis_wrap_word();
} }
/* (X) wrap => LdrKey > Right Shift > W */ /* (X) wrap => LdrKey > Right Shift > W */
SEQ_TWO_KEYS(KC_RSFT, KC_W) { if (leader_sequence_two_keys(KC_RSFT, KC_W)) {
ldrkey_send_paranthesis_wrap_word(); ldrkey_send_paranthesis_wrap_word();
} }
/* (X) wrap selection => LdrKey > Left Shift > W > W */ /* (X) wrap selection => LdrKey > Left Shift > W > W */
SEQ_THREE_KEYS(KC_LSFT, KC_W, KC_W) { if (leader_sequence_three_keys(KC_LSFT, KC_W, KC_W)) {
ldrkey_send_paranthesis_wrap_selection(); ldrkey_send_paranthesis_wrap_selection();
} }
/* (X) wrap selection => LdrKey > Right Shift > W > W */ /* (X) wrap selection => LdrKey > Right Shift > W > W */
SEQ_THREE_KEYS(KC_RSFT, KC_W, KC_W) { if (leader_sequence_three_keys(KC_RSFT, KC_W, KC_W)) {
ldrkey_send_paranthesis_wrap_selection(); ldrkey_send_paranthesis_wrap_selection();
} }
/* [ => LdrKey > Left CTL */ /* [ => LdrKey > Left CTL */
SEQ_ONE_KEY(KC_LCTL) { if (leader_sequence_one_key(KC_LCTL)) {
SEND_STRING("["); SEND_STRING("[");
} }
/* ] => LdrKey > Right CTL */ /* ] => LdrKey > Right CTL */
SEQ_ONE_KEY(KC_RCTL) { if (leader_sequence_one_key(KC_RCTL)) {
SEND_STRING("]"); SEND_STRING("]");
} }
/* [|] => LdrKey > Left CTL > Left CTL */ /* [|] => LdrKey > Left CTL > Left CTL */
SEQ_TWO_KEYS(KC_LCTL, KC_LCTL) { if (leader_sequence_two_keys(KC_LCTL, KC_LCTL)) {
ldrkey_send_bracket_wrap_ini(); ldrkey_send_bracket_wrap_ini();
} }
/* [|] => LdrKey > Right CTL > Right CTL */ /* [|] => LdrKey > Right CTL > Right CTL */
SEQ_TWO_KEYS(KC_RCTL, KC_RCTL) { if (leader_sequence_two_keys(KC_RCTL, KC_RCTL)) {
ldrkey_send_bracket_wrap_ini(); ldrkey_send_bracket_wrap_ini();
} }
/* [X] wrap => LdrKey > Left CTL > W */ /* [X] wrap => LdrKey > Left CTL > W */
SEQ_TWO_KEYS(KC_LCTL, KC_W) { if (leader_sequence_two_keys(KC_LCTL, KC_W)) {
ldrkey_send_bracket_wrap_word(); ldrkey_send_bracket_wrap_word();
} }
/* [X] wrap => LdrKey > Right CTL > W */ /* [X] wrap => LdrKey > Right CTL > W */
SEQ_TWO_KEYS(KC_RCTL, KC_W) { if (leader_sequence_two_keys(KC_RCTL, KC_W)) {
ldrkey_send_bracket_wrap_word(); ldrkey_send_bracket_wrap_word();
} }
/* [X] wrap selection => LdrKey > Left CTL > W > W */ /* [X] wrap selection => LdrKey > Left CTL > W > W */
SEQ_THREE_KEYS(KC_LCTL, KC_W, KC_W) { if (leader_sequence_three_keys(KC_LCTL, KC_W, KC_W)) {
ldrkey_send_bracket_wrap_selection(); ldrkey_send_bracket_wrap_selection();
} }
/* [X] wrap selection => LdrKey > Right CTL > W > W */ /* [X] wrap selection => LdrKey > Right CTL > W > W */
SEQ_THREE_KEYS(KC_RCTL, KC_W, KC_W) { if (leader_sequence_three_keys(KC_RCTL, KC_W, KC_W)) {
ldrkey_send_bracket_wrap_selection(); ldrkey_send_bracket_wrap_selection();
} }
/* { => LdrKey > Left ALT */ /* { => LdrKey > Left ALT */
SEQ_ONE_KEY(KC_LALT) { if (leader_sequence_one_key(KC_LALT)) {
SEND_STRING("{"); SEND_STRING("{");
} }
/* } => LdrKey > Right ALT */ /* } => LdrKey > Right ALT */
SEQ_ONE_KEY(KC_RALT) { if (leader_sequence_one_key(KC_RALT)) {
SEND_STRING("}"); SEND_STRING("}");
} }
/* {|} => LdrKey > Left ALT > Left ALT */ /* {|} => LdrKey > Left ALT > Left ALT */
SEQ_TWO_KEYS(KC_LALT, KC_LALT) { if (leader_sequence_two_keys(KC_LALT, KC_LALT)) {
ldrkey_send_curlybrace_wrap_ini(); ldrkey_send_curlybrace_wrap_ini();
} }
/* {|} => LdrKey > Right ALT > Right ALT */ /* {|} => LdrKey > Right ALT > Right ALT */
SEQ_TWO_KEYS(KC_RALT, KC_RALT) { if (leader_sequence_two_keys(KC_RALT, KC_RALT)) {
ldrkey_send_curlybrace_wrap_ini(); ldrkey_send_curlybrace_wrap_ini();
} }
/* {X} wrap => LdrKey > Left ALT > W */ /* {X} wrap => LdrKey > Left ALT > W */
SEQ_TWO_KEYS(KC_LALT, KC_W) { if (leader_sequence_two_keys(KC_LALT, KC_W)) {
ldrkey_send_curlybrace_wrap_word(); ldrkey_send_curlybrace_wrap_word();
} }
/* {X} wrap => LdrKey > Right ALT > W */ /* {X} wrap => LdrKey > Right ALT > W */
SEQ_TWO_KEYS(KC_RALT, KC_W) { if (leader_sequence_two_keys(KC_RALT, KC_W)) {
ldrkey_send_curlybrace_wrap_word(); ldrkey_send_curlybrace_wrap_word();
} }
/* {X} wrap selection => LdrKey > Left ALT > W > W */ /* {X} wrap selection => LdrKey > Left ALT > W > W */
SEQ_THREE_KEYS(KC_LALT, KC_W, KC_W) { if (leader_sequence_three_keys(KC_LALT, KC_W, KC_W)) {
ldrkey_send_curlybrace_wrap_selection(); ldrkey_send_curlybrace_wrap_selection();
} }
/* {X} wrap selection => LdrKey > Right ALT > W > W */ /* {X} wrap selection => LdrKey > Right ALT > W > W */
SEQ_THREE_KEYS(KC_RALT, KC_W, KC_W) { if (leader_sequence_three_keys(KC_RALT, KC_W, KC_W)) {
ldrkey_send_curlybrace_wrap_selection(); ldrkey_send_curlybrace_wrap_selection();
} }
/* Select everything on this line before cursor => LdrKey > Left */ /* Select everything on this line before cursor => LdrKey > Left */
SEQ_ONE_KEY(KC_LEFT) { if (leader_sequence_one_key(KC_LEFT)) {
onMac ? SEND_STRING(SS_LSFT(SS_LGUI(SS_TAP(X_LEFT)))) : SEND_STRING(SS_LSFT(SS_TAP(X_HOME))); onMac ? SEND_STRING(SS_LSFT(SS_LGUI(SS_TAP(X_LEFT)))) : SEND_STRING(SS_LSFT(SS_TAP(X_HOME)));
} }
/* Select everything on this line after cursor => LdrKey > Right */ /* Select everything on this line after cursor => LdrKey > Right */
SEQ_ONE_KEY(KC_RIGHT) { if (leader_sequence_one_key(KC_RIGHT)) {
onMac ? SEND_STRING(SS_LSFT(SS_LGUI(SS_TAP(X_RIGHT)))) : SEND_STRING(SS_LSFT(SS_TAP(X_END))); onMac ? SEND_STRING(SS_LSFT(SS_LGUI(SS_TAP(X_RIGHT)))) : SEND_STRING(SS_LSFT(SS_TAP(X_END)));
} }
/* Select everything on this line before cursor and bring on previous line => LdrKey > Left > Left */ /* Select everything on this line before cursor and bring on previous line => LdrKey > Left > Left */
SEQ_TWO_KEYS(KC_LEFT, KC_LEFT) { if (leader_sequence_two_keys(KC_LEFT, KC_LEFT)) {
onMac ? SEND_STRING(SS_LSFT(SS_TAP(X_UP) SS_LGUI(SS_TAP(X_RIGHT)))) : SEND_STRING(SS_LSFT(SS_TAP(X_UP) SS_TAP(X_END))); onMac ? SEND_STRING(SS_LSFT(SS_TAP(X_UP) SS_LGUI(SS_TAP(X_RIGHT)))) : SEND_STRING(SS_LSFT(SS_TAP(X_UP) SS_TAP(X_END)));
} }
/* Select everything on this line => LdrKey > Right > Left */ /* Select everything on this line => LdrKey > Right > Left */
SEQ_TWO_KEYS(KC_RIGHT, KC_LEFT) { if (leader_sequence_two_keys(KC_RIGHT, KC_LEFT)) {
onMac ? SEND_STRING(SS_LGUI(SS_TAP(X_RIGHT) SS_LSFT(SS_LGUI(SS_TAP(X_LEFT))))) : SEND_STRING(SS_TAP(X_END) SS_LSFT(SS_TAP(X_HOME))); onMac ? SEND_STRING(SS_LGUI(SS_TAP(X_RIGHT) SS_LSFT(SS_LGUI(SS_TAP(X_LEFT))))) : SEND_STRING(SS_TAP(X_END) SS_LSFT(SS_TAP(X_HOME)));
} }
/* Select 1x Page Up on the page before the cursor => LdrKey > Up */ /* Select 1x Page Up on the page before the cursor => LdrKey > Up */
SEQ_ONE_KEY(KC_UP) { if (leader_sequence_one_key(KC_UP)) {
SEND_STRING(SS_LSFT(SS_TAP(X_PGUP))); SEND_STRING(SS_LSFT(SS_TAP(X_PGUP)));
} }
/* Select 1x Page Down on the page after the cursor => LdrKey > Down */ /* Select 1x Page Down on the page after the cursor => LdrKey > Down */
SEQ_ONE_KEY(KC_DOWN) { if (leader_sequence_one_key(KC_DOWN)) {
SEND_STRING(SS_LSFT(SS_TAP(X_PGDN))); SEND_STRING(SS_LSFT(SS_TAP(X_PGDN)));
} }
/* Select everything on the page before the cursor => LdrKey > Up > Up */ /* Select everything on the page before the cursor => LdrKey > Up > Up */
SEQ_TWO_KEYS(KC_UP, KC_UP) { if (leader_sequence_two_keys(KC_UP, KC_UP)) {
onMac ? SEND_STRING(SS_LSFT(SS_LGUI(SS_TAP(X_UP)))) : SEND_STRING(SS_LSFT(SS_LCTL(SS_TAP(X_HOME)))); onMac ? SEND_STRING(SS_LSFT(SS_LGUI(SS_TAP(X_UP)))) : SEND_STRING(SS_LSFT(SS_LCTL(SS_TAP(X_HOME))));
} }
/* Select everything on the page after the cursor => LdrKey > Down > Down */ /* Select everything on the page after the cursor => LdrKey > Down > Down */
SEQ_TWO_KEYS(KC_DOWN, KC_DOWN) { if (leader_sequence_two_keys(KC_DOWN, KC_DOWN)) {
onMac ? SEND_STRING(SS_LSFT(SS_LGUI(SS_TAP(X_DOWN)))) : SEND_STRING(SS_LSFT(SS_LCTL(SS_TAP(X_END)))); onMac ? SEND_STRING(SS_LSFT(SS_LGUI(SS_TAP(X_DOWN)))) : SEND_STRING(SS_LSFT(SS_LCTL(SS_TAP(X_END))));
} }
/* HELPER => spit out the url of the layout description page on github */ /* HELPER => spit out the url of the layout description page on github */
SEQ_FIVE_KEYS(QK_GESC, QK_GESC, QK_GESC, QK_GESC, QK_GESC) { if (leader_sequence_five_keys(QK_GESC, QK_GESC, QK_GESC, QK_GESC, QK_GESC)) {
SEND_STRING("https://github.com/qmk/qmk_firmware/tree/master/keyboards/dztech/dz65rgb/keymaps/drootz"); SEND_STRING("https://github.com/qmk/qmk_firmware/tree/master/keyboards/dztech/dz65rgb/keymaps/drootz");
} }
/* google.ca => LdrKey > G > G */ /* google.ca => LdrKey > G > G */
SEQ_TWO_KEYS(KC_G, KC_G) { if (leader_sequence_two_keys(KC_G, KC_G)) {
SEND_STRING("https://google.ca" SS_TAP(X_ENT)); SEND_STRING("https://google.ca" SS_TAP(X_ENT));
} }
/* @gmail => LdrKey > M > L > T */ /* @gmail => LdrKey > M > L > T */
SEQ_THREE_KEYS(KC_M, KC_L, KC_T) { if (leader_sequence_three_keys(KC_M, KC_L, KC_T)) {
SEND_STRING("mailto." SS_TAP(X_D) SS_TAP(X_A) SS_TAP(X_N) SS_TAP(X_I) SS_TAP(X_E) SS_TAP(X_L) SS_TAP(X_R) SS_TAP(X_A) SS_TAP(X_C) SS_TAP(X_I) SS_TAP(X_N) SS_TAP(X_E) "@gmail.com"); SEND_STRING("mailto." SS_TAP(X_D) SS_TAP(X_A) SS_TAP(X_N) SS_TAP(X_I) SS_TAP(X_E) SS_TAP(X_L) SS_TAP(X_R) SS_TAP(X_A) SS_TAP(X_C) SS_TAP(X_I) SS_TAP(X_N) SS_TAP(X_E) "@gmail.com");
} }
/* Show Desktop => LdrKey > D */ /* Show Desktop => LdrKey > D */
SEQ_ONE_KEY(KC_D) { if (leader_sequence_one_key(KC_D)) {
onMac ? SEND_STRING(SS_LGUI(SS_TAP(X_SPC)) "Mission" SS_TAP(X_ENT)) : SEND_STRING(SS_LGUI(SS_TAP(X_D))); onMac ? SEND_STRING(SS_LGUI(SS_TAP(X_SPC)) "Mission" SS_TAP(X_ENT)) : SEND_STRING(SS_LGUI(SS_TAP(X_D)));
} }
} }
}
void leader_start_user(void) {
isLeader = true;
}
void leader_end_user(void) {
isLeader = false;
}
#endif /* LEADER */ #endif /* LEADER */

View File

@ -1,14 +0,0 @@
LEADER_DICTIONARY() {
leading = false;
leader_end();
SEQ_ONE_KEY(TD(APMR_PIPE)) {
register_code(KC_LCTL);
register_code(KC_LSFT);
register_code(KC_U);
unregister_code(KC_U);
unregister_code(KC_LSFT);
unregister_code(KC_LCTL);
}
}

View File

@ -1 +0,0 @@
LEADER_EXTERNS();

View File

@ -1,5 +1,3 @@
#include "../leader/leader_setup.c"
bool MATRIX_SCANNED = false; bool MATRIX_SCANNED = false;
void matrix_scan_user(void) { void matrix_scan_user(void) {
@ -7,6 +5,16 @@ void matrix_scan_user(void) {
rgblight_sethsv_noeeprom(HSV_GREEN); rgblight_sethsv_noeeprom(HSV_GREEN);
MATRIX_SCANNED = true; MATRIX_SCANNED = true;
} }
#include "../leader/leader_dictionary.c"
}; };
void leader_end_user(void) {
if (leader_sequence_one_key(TD(APMR_PIPE))) {
register_code(KC_LCTL);
register_code(KC_LSFT);
register_code(KC_U);
unregister_code(KC_U);
unregister_code(KC_LSFT);
unregister_code(KC_LCTL);
}
}

View File

@ -244,7 +244,30 @@ uint16_t get_quick_tap_term(uint16_t keycode, keyrecord_t *record) {
} }
} }
LEADER_EXTERNS(); void leader_end_user(void) {
if (leader_sequence_one_key(KC_F)) {
SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
}
if (leader_sequence_one_key(KC_S)) {
SEND_STRING ("sudo -i\n");
}
if (leader_sequence_one_key(KC_H)) {
SEND_STRING ("--help\n");
}
if (leader_sequence_two_keys(KC_D, KC_D)) {
SEND_STRING(SS_LGUI("ac"));
/* SEND_STRING(SS_LGUI("a") SS_LGUI("c")); */
}
if (leader_sequence_three_keys(KC_D, KC_D, KC_S)) {
SEND_STRING("https://start.duckduckgo.com\n");
}
if (leader_sequence_two_keys(KC_A, KC_S)) {
register_code(KC_LGUI);
register_code(KC_S);
unregister_code(KC_S);
unregister_code(KC_LGUI);
}
}
void matrix_scan_user(void) { void matrix_scan_user(void) {
if (is_alt_tab_active) { if (is_alt_tab_active) {
@ -253,31 +276,4 @@ void matrix_scan_user(void) {
is_alt_tab_active = false; is_alt_tab_active = false;
} }
} }
LEADER_DICTIONARY() {
leading = false;
leader_end();
SEQ_ONE_KEY(KC_F) {
SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
}
SEQ_ONE_KEY(KC_S) {
SEND_STRING ("sudo -i\n");
}
SEQ_ONE_KEY(KC_H) {
SEND_STRING ("--help\n");
}
SEQ_TWO_KEYS(KC_D, KC_D) {
SEND_STRING(SS_LGUI("ac"));
/* SEND_STRING(SS_LGUI("a") SS_LGUI("c")); */
}
SEQ_THREE_KEYS(KC_D, KC_D, KC_S) {
SEND_STRING("https://start.duckduckgo.com\n");
}
SEQ_TWO_KEYS(KC_A, KC_S) {
register_code(KC_LGUI);
register_code(KC_S);
unregister_code(KC_S);
unregister_code(KC_LGUI);
}
}
} }

View File

@ -49,20 +49,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
) )
}; };
void matrix_init_user(void) { void leader_end_user() {
}
LEADER_EXTERNS();
void matrix_scan_user(void) {
LEADER_DICTIONARY() {
leading = false;
leader_end();
// Close a program in i3wm // Close a program in i3wm
SEQ_ONE_KEY(KC_Q) { if (leader_sequence_one_key(KC_Q)) {
register_code(KC_LGUI); register_code(KC_LGUI);
register_code(KC_LSFT); register_code(KC_LSFT);
register_code(KC_Q); register_code(KC_Q);
@ -71,7 +60,7 @@ void matrix_scan_user(void) {
unregister_code(KC_LGUI); unregister_code(KC_LGUI);
} }
// Exit i3wm // Exit i3wm
SEQ_ONE_KEY(KC_E) { if (leader_sequence_one_key(KC_E)) {
register_code(KC_LGUI); register_code(KC_LGUI);
register_code(KC_LSFT); register_code(KC_LSFT);
register_code(KC_E); register_code(KC_E);
@ -80,7 +69,7 @@ void matrix_scan_user(void) {
unregister_code(KC_LGUI); unregister_code(KC_LGUI);
} }
// Copy selected text in suckless terminal // Copy selected text in suckless terminal
SEQ_ONE_KEY(KC_C) { if (leader_sequence_one_key(KC_C)) {
register_code(KC_LCTL); register_code(KC_LCTL);
register_code(KC_LSFT); register_code(KC_LSFT);
register_code(KC_C); register_code(KC_C);
@ -89,7 +78,7 @@ void matrix_scan_user(void) {
unregister_code(KC_LCTL); unregister_code(KC_LCTL);
} }
// Paste text in suckless terminal // Paste text in suckless terminal
SEQ_ONE_KEY(KC_V) { if (leader_sequence_one_key(KC_V)) {
register_code(KC_LCTL); register_code(KC_LCTL);
register_code(KC_LSFT); register_code(KC_LSFT);
register_code(KC_V); register_code(KC_V);
@ -98,18 +87,18 @@ void matrix_scan_user(void) {
unregister_code(KC_LCTL); unregister_code(KC_LCTL);
} }
// FZF shortcut to fuzzy switch directories // FZF shortcut to fuzzy switch directories
SEQ_ONE_KEY(KC_D) { if (leader_sequence_one_key(KC_D)) {
register_code(KC_LALT); register_code(KC_LALT);
register_code(KC_C); register_code(KC_C);
unregister_code(KC_C); unregister_code(KC_C);
unregister_code(KC_LALT); unregister_code(KC_LALT);
} }
// Send keys to bring up fuzzy process kill // Send keys to bring up fuzzy process kill
SEQ_ONE_KEY(KC_K) { if (leader_sequence_one_key(KC_K)) {
SEND_STRING("kill " SS_TAP(X_TAB)); SEND_STRING("kill " SS_TAP(X_TAB));
} }
// Send keys to start neovim and fuzzy search for filename // Send keys to start neovim and fuzzy search for filename
SEQ_ONE_KEY(KC_T) { if (leader_sequence_one_key(KC_T)) {
SEND_STRING("nvim "); SEND_STRING("nvim ");
register_code(KC_LCTL); register_code(KC_LCTL);
register_code(KC_T); register_code(KC_T);
@ -117,7 +106,7 @@ void matrix_scan_user(void) {
unregister_code(KC_LCTL); unregister_code(KC_LCTL);
} }
// Switch between windows in tmux // Switch between windows in tmux
SEQ_ONE_KEY(KC_L) { if (leader_sequence_one_key(KC_L)) {
register_code(KC_LCTL); register_code(KC_LCTL);
register_code(KC_B); register_code(KC_B);
unregister_code(KC_B); unregister_code(KC_B);
@ -126,12 +115,3 @@ void matrix_scan_user(void) {
unregister_code(KC_L); unregister_code(KC_L);
} }
} }
}
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
return true;
}
void led_set_user(uint8_t usb_led) {
}

View File

@ -42,25 +42,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
_______, KC_VOLD, KC_VOLU, KC_MUTE, KC_PSCR, _______, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_LEFT, KC_RGHT, _______, KC_PENT, _______, KC_VOLD, KC_VOLU, KC_MUTE, KC_PSCR, _______, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_LEFT, KC_RGHT, _______, KC_PENT,
_______, _______, _______, _______, _______, _______, KC_PPLS, KC_PMNS, KC_END, KC_PGDN, KC_DOWN, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_PPLS, KC_PMNS, KC_END, KC_PGDN, KC_DOWN, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______)}; _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______)};
/*void matrix_scan_user(void) {
LEADER_DICTIONARY() {
leading = false;
leader_end();
SEQ_ONE_KEY(KC_RSFT) {
register_code(KC_S);
unregister_code(KC_S);
}
SEQ_TWO_KEYS(KC_A, KC_S) {
register_code(KC_H);
unregister_code(KC_H);
}
SEQ_THREE_KEYS(KC_A, KC_S, KC_D) {
register_code(KC_LGUI);
register_code(KC_S);
unregister_code(KC_S);
unregister_code(KC_LGUI);
}
}
}*/

View File

@ -181,15 +181,8 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
), ),
}; };
LEADER_EXTERNS(); void leader_end_user(void) {
if (leader_sequence_one_key(KC_U)) {
void matrix_scan_user(void) {
LEADER_DICTIONARY() {
leading = false;
leader_end();
SEQ_ONE_KEY(KC_U) {
SEND_STRING(":luvu:\n"); SEND_STRING(":luvu:\n");
} }
} }
}

View File

@ -255,22 +255,8 @@ L06 -> <TBD>: UNSPECIFIED
}; };
void leader_end_user(void) {
// Runs just one time when the keyboard initializes. if (leader_sequence_one_key(KC_1)) {
void matrix_init_user(void) {
set_unicode_input_mode(UNICODE_MODE_LINUX);
};
LEADER_EXTERNS();
// Runs constantly in the background, in a loop.
void matrix_scan_user(void) {
LEADER_DICTIONARY() {
leading = false;
leader_end();
SEQ_ONE_KEY (KC_1) {
// ¯\_(ツ)_/¯ // ¯\_(ツ)_/¯
unicode_input_start(); register_hex(0xaf); unicode_input_finish(); unicode_input_start(); register_hex(0xaf); unicode_input_finish();
register_code (KC_RALT); TAP_ONCE (KC_MINS); unregister_code (KC_RALT); register_code (KC_RALT); TAP_ONCE (KC_MINS); unregister_code (KC_RALT);
@ -280,7 +266,7 @@ void matrix_scan_user(void) {
unicode_input_start (); register_hex(0xaf); unicode_input_finish(); unicode_input_start (); register_hex(0xaf); unicode_input_finish();
} }
SEQ_ONE_KEY (KC_2) { if (leader_sequence_one_key(KC_2)) {
// 凸(ツ)凸 // 凸(ツ)凸
unicode_input_start(); register_hex(0x51F8); unicode_input_finish(); unicode_input_start(); register_hex(0x51F8); unicode_input_finish();
register_code (KC_RSFT); TAP_ONCE (KC_8); unregister_code (KC_RSFT); register_code (KC_RSFT); TAP_ONCE (KC_8); unregister_code (KC_RSFT);
@ -289,4 +275,9 @@ void matrix_scan_user(void) {
unicode_input_start (); register_hex(0x51F8); unicode_input_finish(); unicode_input_start (); register_hex(0x51F8); unicode_input_finish();
} }
} }
}
// Runs just one time when the keyboard initializes.
void matrix_init_user(void) {
set_unicode_input_mode(UNICODE_MODE_LINUX);
};

View File

@ -32,9 +32,6 @@ enum custom_keycodes {
#define MW_L KC_MS_WH_LEFT #define MW_L KC_MS_WH_LEFT
#define MW_R KC_MS_WH_RIGHT #define MW_R KC_MS_WH_RIGHT
//// only uncomment the below line when you enable leader key in rules.mk
//LEADER_EXTERNS();
//Tap Dance Declarations //Tap Dance Declarations
enum { enum {
TD_SCL = 0 TD_SCL = 0

View File

@ -76,68 +76,62 @@ static bool wiggle_mouse;
static uint16_t wiggle_timer; static uint16_t wiggle_timer;
static uint16_t next_wiggle; static uint16_t next_wiggle;
void leader_end_user(void) {
LEADER_EXTERNS(); if (leader_sequence_one_key(QK_LEAD)) {
void matrix_scan_user(void) {
LEADER_DICTIONARY() {
leading = false;
leader_end();
SEQ_ONE_KEY(QK_LEAD) {
tap_code(KC_CAPS); tap_code(KC_CAPS);
} }
SEQ_FOUR_KEYS(KC_I, KC_D, KC_L, KC_E) { if (leader_sequence_four_keys(KC_I, KC_D, KC_L, KC_E)) {
wiggle_mouse = !wiggle_mouse; wiggle_mouse = !wiggle_mouse;
wiggle_timer = timer_read(); wiggle_timer = timer_read();
} }
SEQ_TWO_KEYS(KC_O, KC_K) { if (leader_sequence_two_keys(KC_O, KC_K)) {
send_unicode_string("👍"); send_unicode_string("👍");
} }
SEQ_THREE_KEYS(KC_S, KC_A, KC_D) { if (leader_sequence_three_keys(KC_S, KC_A, KC_D)) {
send_unicode_string("😞"); send_unicode_string("😞");
} }
SEQ_FIVE_KEYS(KC_C, KC_H, KC_E, KC_C, KC_K) { if (leader_sequence_five_keys(KC_C, KC_H, KC_E, KC_C, KC_K)) {
send_unicode_string(""); send_unicode_string("");
} }
SEQ_FIVE_KEYS(KC_C, KC_R, KC_O, KC_S, KC_S) { if (leader_sequence_five_keys(KC_C, KC_R, KC_O, KC_S, KC_S)) {
send_unicode_string(""); send_unicode_string("");
} }
SEQ_FIVE_KEYS(KC_T, KC_H, KC_A, KC_N, KC_K) { if (leader_sequence_five_keys(KC_T, KC_H, KC_A, KC_N, KC_K)) {
send_unicode_string("🙏"); send_unicode_string("🙏");
} }
SEQ_FIVE_KEYS(KC_S, KC_M, KC_I, KC_L, KC_E) { if (leader_sequence_five_keys(KC_S, KC_M, KC_I, KC_L, KC_E)) {
send_unicode_string("😊"); send_unicode_string("😊");
} }
SEQ_FIVE_KEYS(KC_P, KC_A, KC_R, KC_T, KC_Y) { if (leader_sequence_five_keys(KC_P, KC_A, KC_R, KC_T, KC_Y)) {
send_unicode_string("🎉"); send_unicode_string("🎉");
} }
SEQ_FOUR_KEYS(KC_E, KC_Y, KC_E, KC_S) { if (leader_sequence_four_keys(KC_E, KC_Y, KC_E, KC_S)) {
send_unicode_string("(ಠ_ಠ)"); send_unicode_string("(ಠ_ಠ)");
} }
SEQ_FIVE_KEYS(KC_M, KC_A, KC_G, KC_I, KC_C) { if (leader_sequence_five_keys(KC_M, KC_A, KC_G, KC_I, KC_C)) {
send_unicode_string("(ಠ_ಠ) 🪄 ⠁⭒*.✫.*⭒⠁"); send_unicode_string("(ಠ_ಠ) 🪄 ⠁⭒*.✫.*⭒⠁");
} }
SEQ_FIVE_KEYS(KC_T, KC_A, KC_B, KC_L, KC_E) { if (leader_sequence_five_keys(KC_T, KC_A, KC_B, KC_L, KC_E)) {
send_unicode_string("(ノಠ痊ಠ)ノ彡┻━┻"); send_unicode_string("(ノಠ痊ಠ)ノ彡┻━┻");
} }
SEQ_FIVE_KEYS(KC_S, KC_H, KC_R, KC_U, KC_G) { if (leader_sequence_five_keys(KC_S, KC_H, KC_R, KC_U, KC_G)) {
send_unicode_string("¯\\_(ツ)_/¯"); send_unicode_string("¯\\_(ツ)_/¯");
} }
} }
void matrix_scan_user(void) {
if (wiggle_mouse && timer_elapsed(wiggle_timer) > next_wiggle) { if (wiggle_mouse && timer_elapsed(wiggle_timer) > next_wiggle) {
wiggle_timer = timer_read(); wiggle_timer = timer_read();

View File

@ -446,27 +446,18 @@ bool rgb_matrix_indicators_user(void) {
return false; return false;
} }
#ifdef LEADER_ENABLE void leader_end_user(void) {
LEADER_EXTERNS(); if (leader_sequence_one_key(KC_F)) {
void matrix_scan_user(void) {
LEADER_DICTIONARY() {
leading = false;
leader_end();
SEQ_ONE_KEY(KC_F) {
// Anything you can do in a macro. // Anything you can do in a macro.
SEND_STRING("QMK is awesome."); SEND_STRING("QMK is awesome.");
} }
SEQ_TWO_KEYS(KC_D, KC_D) { if (leader_sequence_two_keys(KC_D, KC_D)) {
SEND_STRING(SS_LCTL("a") SS_LCTL("c")); SEND_STRING(SS_LCTL("a") SS_LCTL("c"));
} }
SEQ_TWO_KEYS(KC_S, KC_S) { if (leader_sequence_two_keys(KC_S, KC_S)) {
SEND_STRING(SS_LCTL("v")); SEND_STRING(SS_LCTL("v"));
} }
SEQ_THREE_KEYS(KC_D, KC_D, KC_S) { if (leader_sequence_three_keys(KC_D, KC_D, KC_S)) {
SEND_STRING("https://start.duckduckgo.com\n"); SEND_STRING("https://start.duckduckgo.com\n");
} }
} }
}
#endif

View File

@ -255,24 +255,15 @@ bool rgb_matrix_indicators_user(void) {
return false; return false;
} }
#ifdef LEADER_ENABLE void leader_end_user(void) {
LEADER_EXTERNS(); if (leader_sequence_one_key(KC_F)) {
//SEND_STRING seems to be local dependent.
//For swiss-german layout I have to send "ctrl+." to get ":"
void matrix_scan_user(void) {
LEADER_DICTIONARY() {
leading = false;
leader_end();
SEQ_ONE_KEY(KC_F) {
// Anything you can do in a macro. // Anything you can do in a macro.
SEND_STRING("QMK is awesome."); SEND_STRING("QMK is awesome.");
} }
SEQ_TWO_KEYS(KC_D, KC_D) { if (leader_sequence_two_keys(KC_D, KC_D)) {
SEND_STRING(SS_LCTL("a") SS_LCTL("c")); SEND_STRING(SS_LCTL("a") SS_LCTL("c"));
} }
SEQ_THREE_KEYS(KC_D, KC_D, KC_S) { if (leader_sequence_three_keys(KC_D, KC_D, KC_S)) {
SEND_STRING("https"); SEND_STRING("https");
register_code(KC_LSFT); register_code(KC_LSFT);
SEND_STRING(".77"); SEND_STRING(".77");
@ -280,5 +271,3 @@ void matrix_scan_user(void) {
SEND_STRING("start.duckduckgo.com\n"); SEND_STRING("start.duckduckgo.com\n");
} }
} }
}
#endif

View File

@ -256,6 +256,54 @@ static void set_rgb_layer(int layer) {
} }
} }
void leader_end_user(void) {
if (leader_sequence_one_key(KC_K)) {
layer_invert(_KP);
}
if (leader_sequence_one_key(KC_G)) {
layer_invert(_GAME);
}
if (leader_sequence_one_key(KC_KP_5)) {
layer_invert(_KP);
}
if (leader_sequence_two_keys(KC_SCLN, KC_1)) {
send_secret_string(0);
}
if (leader_sequence_two_keys(KC_SCLN, KC_2)) {
send_secret_string(1);
}
if (leader_sequence_two_keys(KC_SCLN, KC_3)) {
send_secret_string(2);
}
if (leader_sequence_two_keys(KC_SCLN, KC_4)) {
send_secret_string(3);
}
if (leader_sequence_two_keys(KC_SCLN, KC_5)) {
send_secret_string(4);
}
if (leader_sequence_two_keys(KC_SCLN, KC_6)) {
send_secret_string(5);
}
if (leader_sequence_two_keys(KC_SCLN, KC_M)) {
send_secret_string(0);
}
if (leader_sequence_two_keys(KC_SCLN, KC_COMM)) {
send_secret_string(1);
}
if (leader_sequence_two_keys(KC_SCLN, KC_DOT)) {
send_secret_string(2);
}
if (leader_sequence_two_keys(KC_SCLN, KC_J)) {
send_secret_string(3);
}
if (leader_sequence_two_keys(KC_SCLN, KC_K)) {
send_secret_string(4);
}
if (leader_sequence_two_keys(KC_SCLN, KC_L)) {
send_secret_string(5);
}
}
// Runs just one time when the keyboard initializes. // Runs just one time when the keyboard initializes.
void matrix_init_keymap(void) { void matrix_init_keymap(void) {
// force numlock on upon startup // force numlock on upon startup
@ -264,8 +312,6 @@ void matrix_init_keymap(void) {
} }
}; };
LEADER_EXTERNS();
// Runs constantly in the background, in a loop. // Runs constantly in the background, in a loop.
void matrix_scan_keymap(void) { void matrix_scan_keymap(void) {
if (rgb_matrix_get_flags() != LED_FLAG_NONE && timer_elapsed(rgb_timer) > 1000) { if (rgb_matrix_get_flags() != LED_FLAG_NONE && timer_elapsed(rgb_timer) > 1000) {
@ -282,56 +328,6 @@ void matrix_scan_keymap(void) {
else else
rgb_matrix_set_color(15, 0, 0, 0); rgb_matrix_set_color(15, 0, 0, 0);
} }
LEADER_DICTIONARY() {
leading = false;
leader_end();
SEQ_ONE_KEY(KC_K) {
layer_invert(_KP);
}
SEQ_ONE_KEY(KC_G) {
layer_invert(_GAME);
}
SEQ_ONE_KEY(KC_KP_5) {
layer_invert(_KP);
}
SEQ_TWO_KEYS(KC_SCLN, KC_1) {
send_secret_string(0);
}
SEQ_TWO_KEYS(KC_SCLN, KC_2) {
send_secret_string(1);
}
SEQ_TWO_KEYS(KC_SCLN, KC_3) {
send_secret_string(2);
}
SEQ_TWO_KEYS(KC_SCLN, KC_4) {
send_secret_string(3);
}
SEQ_TWO_KEYS(KC_SCLN, KC_5) {
send_secret_string(4);
}
SEQ_TWO_KEYS(KC_SCLN, KC_6) {
send_secret_string(5);
}
SEQ_TWO_KEYS(KC_SCLN, KC_M) {
send_secret_string(0);
}
SEQ_TWO_KEYS(KC_SCLN, KC_COMM) {
send_secret_string(1);
}
SEQ_TWO_KEYS(KC_SCLN, KC_DOT) {
send_secret_string(2);
}
SEQ_TWO_KEYS(KC_SCLN, KC_J) {
send_secret_string(3);
}
SEQ_TWO_KEYS(KC_SCLN, KC_K) {
send_secret_string(4);
}
SEQ_TWO_KEYS(KC_SCLN, KC_L) {
send_secret_string(5);
}
}
}; };
layer_state_t layer_state_set_keymap(layer_state_t state) { layer_state_t layer_state_set_keymap(layer_state_t state) {

View File

@ -130,18 +130,11 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
return true; return true;
}; };
LEADER_EXTERNS(); void leader_end_user(void) {
if (leader_sequence_two_keys(KC_G, KC_P)) {
void matrix_scan_user(void) {
LEADER_DICTIONARY() {
leading = false;
leader_end();
SEQ_TWO_KEYS(KC_G, KC_P) {
SEND_STRING("git push"); SEND_STRING("git push");
} }
SEQ_THREE_KEYS(KC_G, KC_F, KC_P) { if (leader_sequence_three_keys(KC_G, KC_F, KC_P)) {
SEND_STRING("git push --force-with-lease"); SEND_STRING("git push --force-with-lease");
} }
} }
}

View File

@ -50,40 +50,31 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
}; };
//Leader maps //Leader maps
void leader_end_user(void) {
if (leader_sequence_one_key(KC_F)) {
LEADER_EXTERNS();
void matrix_scan_user(void) {
LEADER_DICTIONARY() {
leading = false;
leader_end();
SEQ_ONE_KEY(KC_F) {
// Anything you can do in a macro. // Anything you can do in a macro.
SEND_STRING("QMK is awesome."); SEND_STRING("QMK is awesome.");
} }
//tableflip (LEADER - TF) //tableflip (LEADER - TF)
SEQ_TWO_KEYS(KC_T, KC_F) { if (leader_sequence_two_keys(KC_T, KC_F)) {
set_unicode_input_mode(UNICODE_MODE_MACOS); set_unicode_input_mode(UNICODE_MODE_MACOS);
send_unicode_string("(ノಠ痊ಠ)ノ彡┻━┻"); send_unicode_string("(ノಠ痊ಠ)ノ彡┻━┻");
} }
//screencap (LEADER - SC) //screencap (LEADER - SC)
SEQ_TWO_KEYS(KC_S, KC_C) { if (leader_sequence_two_keys(KC_S, KC_C)) {
SEND_STRING(SS_LGUI(SS_LSFT(SS_TAP(X_4)))); SEND_STRING(SS_LGUI(SS_LSFT(SS_TAP(X_4))));
} }
//screencap (LEADER - TM) //screencap (LEADER - TM)
SEQ_TWO_KEYS(KC_T, KC_M) { if (leader_sequence_two_keys(KC_T, KC_M)) {
set_unicode_input_mode(UNICODE_MODE_MACOS); set_unicode_input_mode(UNICODE_MODE_MACOS);
register_unicode(0x2122); // ™ register_unicode(0x2122); // ™
} }
/* /*
SEQ_THREE_KEYS(KC_D, KC_D, KC_S) { if (leader_sequence_three_keys(KC_D, KC_D, KC_S)) {
SEND_STRING("https://start.duckduckgo.com"SS_TAP(X_ENTER)); SEND_STRING("https://start.duckduckgo.com"SS_TAP(X_ENTER));
} }
*/ */
} }
}
//change colors and rgb modes on layer change //change colors and rgb modes on layer change
layer_state_t layer_state_set_user(layer_state_t state) { layer_state_t layer_state_set_user(layer_state_t state) {

View File

@ -157,47 +157,41 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
return true; return true;
} }
LEADER_EXTERNS(); void leader_end_user(void) {
void matrix_scan_user(void) {
LEADER_DICTIONARY() {
leading = false;
leader_end();
// Screenshot // Screenshot
SEQ_ONE_KEY(KC_S) { if (leader_sequence_one_key(KC_S)) {
tap_code16(G(C(S(KC_4)))); tap_code16(G(C(S(KC_4))));
} }
// Record Screen // Record Screen
SEQ_TWO_KEYS(KC_S, KC_S) { if (leader_sequence_two_keys(KC_S, KC_S)) {
tap_code16(S(G(KC_5))); tap_code16(S(G(KC_5)));
} }
// 1Pass browser // 1Pass browser
SEQ_ONE_KEY(KC_A) { if (leader_sequence_one_key(KC_A)) {
tap_code16(G(A(KC_BSLS))); tap_code16(G(A(KC_BSLS)));
} }
// 1Pass mini // 1Pass mini
SEQ_TWO_KEYS(KC_A, KC_A) { if (leader_sequence_two_keys(KC_A, KC_A)) {
tap_code16(G(KC_BSLS)); tap_code16(G(KC_BSLS));
} }
// Comment out // Comment out
SEQ_ONE_KEY(KC_F) { if (leader_sequence_one_key(KC_F)) {
tap_code16(G(KC_SLSH)); tap_code16(G(KC_SLSH));
} }
// Spotlight // Spotlight
SEQ_ONE_KEY(KC_SPC) { if (leader_sequence_one_key(KC_SPC)) {
tap_code16(G(KC_SPC)); tap_code16(G(KC_SPC));
} }
// Auto format // Auto format
SEQ_ONE_KEY(KC_ENT) { if (leader_sequence_one_key(KC_ENT)) {
tap_code16(S(G(A(KC_F)))); tap_code16(S(G(A(KC_F))));
} }
// Focus file tree // Focus file tree
SEQ_ONE_KEY(KC_TAB) { if (leader_sequence_one_key(KC_TAB)) {
tap_code16(G(KC_1)); tap_code16(G(KC_1));
} }
// Caps-lock // Caps-lock
SEQ_TWO_KEYS(KC_TAB, KC_TAB) { if (leader_sequence_two_keys(KC_TAB, KC_TAB)) {
tap_code16(KC_CAPS); tap_code16(KC_CAPS);
} }
} }
}

View File

@ -372,14 +372,8 @@ void music_scale_user(void)
#endif #endif
LEADER_EXTERNS(); void leader_end_user(void) {
if (leader_sequence_one_key(KC_R)) {
void matrix_scan_user(void) {
LEADER_DICTIONARY() {
leading = false;
leader_end();
SEQ_ONE_KEY (KC_R) {
tap_random_base64(); tap_random_base64();
tap_random_base64(); tap_random_base64();
tap_random_base64(); tap_random_base64();
@ -390,21 +384,20 @@ void matrix_scan_user(void) {
tap_random_base64(); tap_random_base64();
tap_random_base64(); tap_random_base64();
} }
SEQ_ONE_KEY (KC_V) { if (leader_sequence_one_key(KC_V)) {
SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION); SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
} }
SEQ_ONE_KEY(KC_F) { if (leader_sequence_one_key(KC_F)) {
SEND_STRING("if yes\n\tpeanut butter\nelse\n\trice snacks"); SEND_STRING("if yes\n\tpeanut butter\nelse\n\trice snacks");
} }
SEQ_TWO_KEYS(KC_A, KC_S) { if (leader_sequence_two_keys(KC_A, KC_S)) {
register_code(KC_H); register_code(KC_H);
unregister_code(KC_H); unregister_code(KC_H);
} }
SEQ_THREE_KEYS(KC_A, KC_S, KC_D) { if (leader_sequence_three_keys(KC_A, KC_S, KC_D)) {
register_code(KC_LGUI); register_code(KC_LGUI);
register_code(KC_S); register_code(KC_S);
unregister_code(KC_S); unregister_code(KC_S);
unregister_code(KC_LGUI); unregister_code(KC_LGUI);
} }
} }
}

View File

@ -408,7 +408,64 @@ void keyboard_post_init_keymap(void) {
bspc_timer = 0; bspc_timer = 0;
} }
LEADER_EXTERNS(); void leader_end_user(void) {
if (leader_sequence_one_key(KC_K)) {
layer_invert(_KP);
}
if (leader_sequence_one_key(KC_G)) {
layer_invert(_GAME);
}
if (leader_sequence_one_key(KC_KP_5)) {
layer_invert(_KP);
}
if (leader_sequence_one_key(KC_5)) {
layer_invert(_KP);
}
if (leader_sequence_two_keys(KC_SCLN, KC_1)) {
send_secret_string(0);
}
if (leader_sequence_two_keys(KC_SCLN, KC_2)) {
send_secret_string(1);
}
if (leader_sequence_two_keys(KC_SCLN, KC_3)) {
send_secret_string(2);
}
if (leader_sequence_two_keys(KC_SCLN, KC_4)) {
send_secret_string(3);
}
if (leader_sequence_two_keys(KC_SCLN, KC_5)) {
send_secret_string(4);
}
if (leader_sequence_two_keys(KC_SCLN, KC_6)) {
send_secret_string(5);
}
if (leader_sequence_two_keys(KC_SCLN, KC_M)) {
send_secret_string(0);
}
if (leader_sequence_two_keys(KC_SCLN, KC_COMM)) {
send_secret_string(1);
}
if (leader_sequence_two_keys(KC_SCLN, KC_DOT)) {
send_secret_string(2);
}
if (leader_sequence_two_keys(KC_SCLN, KC_J)) {
send_secret_string(3);
}
if (leader_sequence_two_keys(KC_SCLN, KC_K)) {
send_secret_string(4);
}
if (leader_sequence_two_keys(KC_SCLN, KC_L)) {
send_secret_string(5);
}
if (leader_sequence_one_key(KC_C)) {
tap_code16(C(KC_C));
}
// neovim: terminal escape
if (leader_sequence_one_key(KC_QUOT)) {
tap_code16(C(KC_BSLS));
tap_code16(C(KC_N));
}
}
void matrix_scan_keymap(void) { void matrix_scan_keymap(void) {
#ifdef AUDIO_ENABLE #ifdef AUDIO_ENABLE
@ -436,67 +493,6 @@ void matrix_scan_keymap(void) {
bspc_timer = 0; bspc_timer = 0;
register_code(KC_BSPC); register_code(KC_BSPC);
} }
LEADER_DICTIONARY() {
leading = false;
leader_end();
SEQ_ONE_KEY(KC_K) {
layer_invert(_KP);
}
SEQ_ONE_KEY(KC_G) {
layer_invert(_GAME);
}
SEQ_ONE_KEY(KC_KP_5) {
layer_invert(_KP);
}
SEQ_ONE_KEY(KC_5) {
layer_invert(_KP);
}
SEQ_TWO_KEYS(KC_SCLN, KC_1) {
send_secret_string(0);
}
SEQ_TWO_KEYS(KC_SCLN, KC_2) {
send_secret_string(1);
}
SEQ_TWO_KEYS(KC_SCLN, KC_3) {
send_secret_string(2);
}
SEQ_TWO_KEYS(KC_SCLN, KC_4) {
send_secret_string(3);
}
SEQ_TWO_KEYS(KC_SCLN, KC_5) {
send_secret_string(4);
}
SEQ_TWO_KEYS(KC_SCLN, KC_6) {
send_secret_string(5);
}
SEQ_TWO_KEYS(KC_SCLN, KC_M) {
send_secret_string(0);
}
SEQ_TWO_KEYS(KC_SCLN, KC_COMM) {
send_secret_string(1);
}
SEQ_TWO_KEYS(KC_SCLN, KC_DOT) {
send_secret_string(2);
}
SEQ_TWO_KEYS(KC_SCLN, KC_J) {
send_secret_string(3);
}
SEQ_TWO_KEYS(KC_SCLN, KC_K) {
send_secret_string(4);
}
SEQ_TWO_KEYS(KC_SCLN, KC_L) {
send_secret_string(5);
}
SEQ_ONE_KEY(KC_C) {
tap_code16(C(KC_C));
}
// neovim: terminal escape
SEQ_ONE_KEY(KC_QUOT) {
tap_code16(C(KC_BSLS));
tap_code16(C(KC_N));
}
}
} }
bool music_mask_user(uint16_t keycode) { bool music_mask_user(uint16_t keycode) {

View File

@ -984,31 +984,26 @@ bool dip_switch_update_user(uint8_t index, bool active) {
return true; return true;
} }
void leader_end_user(void) {
LEADER_EXTERNS(); if (leader_sequence_one_key(KC_F)) {
void matrix_scan_user(void) {
LEADER_DICTIONARY() {
leading = false;
leader_end();
SEQ_ONE_KEY(KC_F) {
// Anything you can do in a macro. // Anything you can do in a macro.
SEND_STRING("QMK is awesome."); SEND_STRING("QMK is awesome.");
} }
SEQ_TWO_KEYS(KC_D, KC_D) { if (leader_sequence_two_keys(KC_D, KC_D)) {
SEND_STRING(SS_LCTL("a") SS_LCTL("c")); SEND_STRING(SS_LCTL("a") SS_LCTL("c"));
} }
SEQ_THREE_KEYS(KC_D, KC_D, KC_S) { if (leader_sequence_three_keys(KC_D, KC_D, KC_S)) {
SEND_STRING("https://start.duckduckgo.com\n"); SEND_STRING("https://start.duckduckgo.com\n");
} }
SEQ_TWO_KEYS(KC_A, KC_S) { if (leader_sequence_two_keys(KC_A, KC_S)) {
register_code(KC_LGUI); register_code(KC_LGUI);
register_code(KC_S); register_code(KC_S);
unregister_code(KC_S); unregister_code(KC_S);
unregister_code(KC_LGUI); unregister_code(KC_LGUI);
} }
} }
void matrix_scan_user(void) {
#ifdef AUDIO_ENABLE #ifdef AUDIO_ENABLE
if (muse_mode) { if (muse_mode) {
if (muse_counter == 0) { if (muse_counter == 0) {

View File

@ -240,7 +240,6 @@ uint16_t muse_tempo = 50;
// Used by Leader key chords // Used by Leader key chords
bool did_leader_succeed; bool did_leader_succeed;
LEADER_EXTERNS();
// Tap-Dance stuffs, initializing functions that are coded further below // Tap-Dance stuffs, initializing functions that are coded further below
td_state_t cur_dance(tap_dance_state_t* state); td_state_t cur_dance(tap_dance_state_t* state);
@ -1404,6 +1403,81 @@ void leader_start_user(void) {
} }
// Called when either the leader sequence is completed, or the leader timeout is hit // Called when either the leader sequence is completed, or the leader timeout is hit
void leader_end_user(void) { void leader_end_user(void) {
did_leader_succeed = false;
if (leader_sequence_one_key(KC_E)) {
SEND_STRING(SS_LCTL(SS_LSFT("t")));
did_leader_succeed = true;
}
if (leader_sequence_one_key(KC_C)) {
SEND_STRING(SS_LGUI("r") SS_DELAY(250) "calc\n");
did_leader_succeed = true;
}
else if (leader_sequence_one_key(KC_V)) {
SEND_STRING(SS_LCTL("v"));
did_leader_succeed = true;
}
else if (leader_sequence_two_keys(KC_E, KC_D)) {
SEND_STRING(SS_LGUI("r") "cmd\n" SS_LCTL("c"));
did_leader_succeed = true;
}
else if (leader_sequence_two_keys(KC_A, KC_C)) {
SEND_STRING(SS_LCTL("a") SS_LCTL("c"));
did_leader_succeed = true;
}
else if (leader_sequence_three_keys(KC_C, KC_A, KC_T)) {
send_unicode_string("😸");
did_leader_succeed = true;
}
else if (leader_sequence_three_keys(KC_B, KC_A, KC_T)) {
send_unicode_string("🦇");
did_leader_succeed = true;
}
else if (leader_sequence_three_keys(KC_D, KC_O, KC_G)) {
send_unicode_string("🐶");
did_leader_succeed = true;
}
else if (leader_sequence_five_keys(KC_S, KC_M, KC_I, KC_L, KC_E)) {
send_unicode_string("🙂");
did_leader_succeed = true;
}
else if (leader_sequence_four_keys(KC_H, KC_A, KC_P, KC_Y)) {
send_unicode_string("🙂");
did_leader_succeed = true;
}
else if (leader_sequence_five_keys(KC_H, KC_A, KC_P, KC_P, KC_Y)) {
send_unicode_string("🙂");
did_leader_succeed = true;
}
else if (leader_sequence_three_keys(KC_S, KC_A, KC_D)) {
send_unicode_string("🙁");
did_leader_succeed = true;
}
else if (leader_sequence_three_keys(KC_Y, KC_E, KC_S)) {
send_unicode_string("👍");
did_leader_succeed = true;
}
else if (leader_sequence_two_keys(KC_N, KC_O)) {
send_unicode_string("👎");
did_leader_succeed = true;
}
else if (leader_sequence_three_keys(KC_W, KC_O, KC_W)) {
send_unicode_string("🤯");
did_leader_succeed = true;
}
else if (leader_sequence_three_keys(KC_P, KC_O, KC_O)) {
send_unicode_string("💩");
did_leader_succeed = true;
}
else if (leader_sequence_four_keys(KC_P, KC_O, KC_O, KC_P)) {
send_unicode_string("💩");
did_leader_succeed = true;
}
else if (leader_sequence_four_keys(KC_B, KC_O, KC_A, KC_T)) {
send_unicode_string("");
did_leader_succeed = true;
}
if (did_leader_succeed) { if (did_leader_succeed) {
#ifdef AUDIO_ENABLE #ifdef AUDIO_ENABLE
PLAY_SONG(leader_succeed); PLAY_SONG(leader_succeed);
@ -1758,84 +1832,6 @@ void matrix_scan_user(void) {
is_alt_tab_active = false; is_alt_tab_active = false;
} }
} }
// Monitor and perform leader-key chords
LEADER_DICTIONARY() {
did_leader_succeed = leading = false;
SEQ_ONE_KEY(KC_E) {
SEND_STRING(SS_LCTL(SS_LSFT("t")));
did_leader_succeed = true;
}
SEQ_ONE_KEY(KC_C) {
SEND_STRING(SS_LGUI("r") SS_DELAY(250) "calc\n");
did_leader_succeed = true;
}
else SEQ_ONE_KEY(KC_V) {
SEND_STRING(SS_LCTL("v"));
did_leader_succeed = true;
}
else SEQ_TWO_KEYS(KC_E, KC_D) {
SEND_STRING(SS_LGUI("r") "cmd\n" SS_LCTL("c"));
did_leader_succeed = true;
}
else SEQ_TWO_KEYS(KC_A, KC_C) {
SEND_STRING(SS_LCTL("a") SS_LCTL("c"));
did_leader_succeed = true;
}
else SEQ_THREE_KEYS(KC_C, KC_A, KC_T) {
send_unicode_string("😸");
did_leader_succeed = true;
}
else SEQ_THREE_KEYS(KC_B, KC_A, KC_T) {
send_unicode_string("🦇");
did_leader_succeed = true;
}
else SEQ_THREE_KEYS(KC_D, KC_O, KC_G) {
send_unicode_string("🐶");
did_leader_succeed = true;
}
else SEQ_FIVE_KEYS(KC_S, KC_M, KC_I, KC_L, KC_E) {
send_unicode_string("🙂");
did_leader_succeed = true;
}
else SEQ_FOUR_KEYS(KC_H, KC_A, KC_P, KC_Y) {
send_unicode_string("🙂");
did_leader_succeed = true;
}
else SEQ_FIVE_KEYS(KC_H, KC_A, KC_P, KC_P, KC_Y) {
send_unicode_string("🙂");
did_leader_succeed = true;
}
else SEQ_THREE_KEYS(KC_S, KC_A, KC_D) {
send_unicode_string("🙁");
did_leader_succeed = true;
}
else SEQ_THREE_KEYS(KC_Y, KC_E, KC_S) {
send_unicode_string("👍");
did_leader_succeed = true;
}
else SEQ_TWO_KEYS(KC_N, KC_O) {
send_unicode_string("👎");
did_leader_succeed = true;
}
else SEQ_THREE_KEYS(KC_W, KC_O, KC_W) {
send_unicode_string("🤯");
did_leader_succeed = true;
}
else SEQ_THREE_KEYS(KC_P, KC_O, KC_O) {
send_unicode_string("💩");
did_leader_succeed = true;
}
else SEQ_FOUR_KEYS(KC_P, KC_O, KC_O, KC_P) {
send_unicode_string("💩");
did_leader_succeed = true;
}
else SEQ_FOUR_KEYS(KC_B, KC_O, KC_A, KC_T) {
send_unicode_string("");
did_leader_succeed = true;
}
leader_end();
}
// Run the wake-up RGB animation if performing wake-up // Run the wake-up RGB animation if performing wake-up
if (do_wake_animation) { if (do_wake_animation) {
rgb_wakeup_sequence(); rgb_wakeup_sequence();

View File

@ -158,36 +158,24 @@ void keyboard_post_init_user(void) {
} }
bool leader_found; bool leader_found;
LEADER_EXTERNS();
void matrix_scan_user(void) { void leader_end_user(void) {
LEADER_DICTIONARY() {
leading = false;
leader_found = false; leader_found = false;
SEQ_ONE_KEY(L_RESET) {
if (leader_sequence_one_key(L_RESET)) {
leader_found = true; leader_found = true;
reset_keyboard(); reset_keyboard();
} } else if (leader_sequence_one_key(KC_DEL)) {
else
SEQ_ONE_KEY(KC_DEL) {
leader_found = true; leader_found = true;
layer_clear(); layer_clear();
} } else if (leader_sequence_one_key(LOWER)) {
else
SEQ_ONE_KEY(LOWER) {
leader_found = true; leader_found = true;
layer_on(_LOWER); layer_on(_LOWER);
} } else if (leader_sequence_one_key(RAISE)) {
else
SEQ_ONE_KEY(RAISE) {
leader_found = true; leader_found = true;
layer_on(_RAISE); layer_on(_RAISE);
} }
leader_end();
}
}
void leader_end_user(void) {
// Plays sound on if leader sequence found. // Plays sound on if leader sequence found.
if (leader_found) { if (leader_found) {
#ifdef AUDIO_ENABLE #ifdef AUDIO_ENABLE

View File

@ -363,44 +363,35 @@ bool dip_switch_update_user(uint8_t index, bool active) {
return true; return true;
} }
LEADER_EXTERNS();
static inline void register_ctrl_sequence(uint16_t keycode) { static inline void register_ctrl_sequence(uint16_t keycode) {
tap_code16(RCTL(keycode)); tap_code16(RCTL(keycode));
} }
static inline void leader_bindings(void) { void leader_end_user(void) {
LEADER_DICTIONARY() { if (leader_sequence_three_keys(KC_A, KC_C, KC_K)) {
leading = false;
leader_end();
SEQ_THREE_KEYS(KC_A, KC_C, KC_K) {
SEND_STRING("Acked-by: Christian Brauner <brauner@kernel.org>"); SEND_STRING("Acked-by: Christian Brauner <brauner@kernel.org>");
} }
SEQ_THREE_KEYS(KC_R, KC_V, KC_B) { if (leader_sequence_three_keys(KC_R, KC_V, KC_B)) {
SEND_STRING("Reviewed-by: Christian Brauner <brauner@kernel.org>"); SEND_STRING("Reviewed-by: Christian Brauner <brauner@kernel.org>");
} }
SEQ_THREE_KEYS(KC_S, KC_O, KC_B) { if (leader_sequence_three_keys(KC_S, KC_O, KC_B)) {
SEND_STRING("Signed-off-by: Christian Brauner <brauner@kernel.org>"); SEND_STRING("Signed-off-by: Christian Brauner <brauner@kernel.org>");
} }
/* Support vim-style copy. */ /* Support vim-style copy. */
SEQ_ONE_KEY(KC_Y) { if (leader_sequence_one_key(KC_Y)) {
tap_code16(C(S(KC_C))); tap_code16(C(S(KC_C)));
} }
/* Support vim-style paste. */ /* Support vim-style paste. */
SEQ_ONE_KEY(KC_P) { if (leader_sequence_one_key(KC_P)) {
tap_code16(C(S(KC_V))); tap_code16(C(S(KC_V)));
} }
} }
}
void matrix_scan_user(void) { void matrix_scan_user(void) {
leader_bindings();
#ifdef AUDIO_ENABLE #ifdef AUDIO_ENABLE
if (muse_mode) { if (muse_mode) {
if (muse_counter == 0) { if (muse_counter == 0) {

View File

@ -362,112 +362,6 @@ float leader_succeed_song[][2] = SONG(STARTUP_SOUND);
//float leader_fail_song[][2] = SONG(GOODBYE_SOUND); //float leader_fail_song[][2] = SONG(GOODBYE_SOUND);
float leader_fail_song[][2] = SONG(NO_SOUND); float leader_fail_song[][2] = SONG(NO_SOUND);
#endif #endif
LEADER_EXTERNS();
void matrix_scan_user(void) {
LEADER_DICTIONARY() {
did_leader_succeed = leading = false;
// tap dance
// sort by first key
SEQ_ONE_KEY(KC_C) {
SEND_STRING(SS_TAP(X_CAPS));
did_leader_succeed = true;
}
SEQ_ONE_KEY(KC_BSPC) {
SEND_STRING(SS_TAP(X_DEL));
did_leader_succeed = true;
}
SEQ_ONE_KEY(KC_D) {
SEND_STRING("{}"SS_TAP(X_LEFT));
did_leader_succeed = true;
}
SEQ_TWO_KEYS(KC_D, KC_B) {
SEND_STRING("Dear Brother");
did_leader_succeed = true;
}
SEQ_THREE_KEYS(KC_D, KC_B, KC_S) {
SEND_STRING("Dear Brothers and Sister");
did_leader_succeed = true;
}
SEQ_TWO_KEYS(KC_D, KC_D) {
SEND_STRING("{");
did_leader_succeed = true;
}
SEQ_THREE_KEYS(KC_D, KC_D, KC_D) {
SEND_STRING("}");
did_leader_succeed = true;
}
SEQ_TWO_KEYS(KC_D, KC_S) {
SEND_STRING("Dear Sister");
did_leader_succeed = true;
}
// Html Tags
SEQ_TWO_KEYS(KC_H, KC_T) {
SEND_STRING("<></>"SS_TAP(X_LEFT));
did_leader_succeed = true;
}
SEQ_TWO_KEYS(KC_I, KC_C) {
SEND_STRING("In Christ,");
did_leader_succeed = true;
}
SEQ_ONE_KEY(KC_J) {
SEND_STRING("<>"SS_TAP(X_LEFT));
did_leader_succeed = true;
}
SEQ_TWO_KEYS(KC_J, KC_J) {
SEND_STRING("<");
did_leader_succeed = true;
}
SEQ_THREE_KEYS(KC_J, KC_J, KC_J) {
SEND_STRING(">");
did_leader_succeed = true;
}
SEQ_TWO_KEYS(KC_T, KC_S) {
SEND_STRING("Thanks!");
did_leader_succeed = true;
}
SEQ_TWO_KEYS(KC_T, KC_Y) {
SEND_STRING("Thank you!");
did_leader_succeed = true;
}
SEQ_ONE_KEY(KC_X) {
SEND_STRING("()"SS_TAP(X_LEFT));
did_leader_succeed = true;
}
SEQ_TWO_KEYS(KC_X, KC_X) {
SEND_STRING("(");
did_leader_succeed = true;
}
SEQ_THREE_KEYS(KC_X, KC_X, KC_X) {
SEND_STRING(")");
did_leader_succeed = true;
}
SEQ_ONE_KEY(KC_Z) {
SEND_STRING("[]"SS_TAP(X_LEFT));
did_leader_succeed = true;
}
SEQ_TWO_KEYS(KC_Z, KC_Z) {
SEND_STRING("[");
did_leader_succeed = true;
}
SEQ_THREE_KEYS(KC_Z, KC_Z, KC_Z) {
SEND_STRING("]");
did_leader_succeed = true;
}
leader_end();
}
}
void leader_start_user(void) { void leader_start_user(void) {
#ifdef AUDIO_ENABLE #ifdef AUDIO_ENABLE
@ -476,6 +370,105 @@ void leader_start_user(void) {
} }
void leader_end_user(void) { void leader_end_user(void) {
did_leader_succeed = false;
// tap dance
// sort by first key
if (leader_sequence_one_key(KC_C)) {
SEND_STRING(SS_TAP(X_CAPS));
did_leader_succeed = true;
}
if (leader_sequence_one_key(KC_BSPC)) {
SEND_STRING(SS_TAP(X_DEL));
did_leader_succeed = true;
}
if (leader_sequence_one_key(KC_D)) {
SEND_STRING("{}"SS_TAP(X_LEFT));
did_leader_succeed = true;
}
if (leader_sequence_two_keys(KC_D, KC_B)) {
SEND_STRING("Dear Brother");
did_leader_succeed = true;
}
if (leader_sequence_three_keys(KC_D, KC_B, KC_S)) {
SEND_STRING("Dear Brothers and Sister");
did_leader_succeed = true;
}
if (leader_sequence_two_keys(KC_D, KC_D)) {
SEND_STRING("{");
did_leader_succeed = true;
}
if (leader_sequence_three_keys(KC_D, KC_D, KC_D)) {
SEND_STRING("}");
did_leader_succeed = true;
}
if (leader_sequence_two_keys(KC_D, KC_S)) {
SEND_STRING("Dear Sister");
did_leader_succeed = true;
}
// Html Tags
if (leader_sequence_two_keys(KC_H, KC_T)) {
SEND_STRING("<></>"SS_TAP(X_LEFT));
did_leader_succeed = true;
}
if (leader_sequence_two_keys(KC_I, KC_C)) {
SEND_STRING("In Christ,");
did_leader_succeed = true;
}
if (leader_sequence_one_key(KC_J)) {
SEND_STRING("<>"SS_TAP(X_LEFT));
did_leader_succeed = true;
}
if (leader_sequence_two_keys(KC_J, KC_J)) {
SEND_STRING("<");
did_leader_succeed = true;
}
if (leader_sequence_three_keys(KC_J, KC_J, KC_J)) {
SEND_STRING(">");
did_leader_succeed = true;
}
if (leader_sequence_two_keys(KC_T, KC_S)) {
SEND_STRING("Thanks!");
did_leader_succeed = true;
}
if (leader_sequence_two_keys(KC_T, KC_Y)) {
SEND_STRING("Thank you!");
did_leader_succeed = true;
}
if (leader_sequence_one_key(KC_X)) {
SEND_STRING("()"SS_TAP(X_LEFT));
did_leader_succeed = true;
}
if (leader_sequence_two_keys(KC_X, KC_X)) {
SEND_STRING("(");
did_leader_succeed = true;
}
if (leader_sequence_three_keys(KC_X, KC_X, KC_X)) {
SEND_STRING(")");
did_leader_succeed = true;
}
if (leader_sequence_one_key(KC_Z)) {
SEND_STRING("[]"SS_TAP(X_LEFT));
did_leader_succeed = true;
}
if (leader_sequence_two_keys(KC_Z, KC_Z)) {
SEND_STRING("[");
did_leader_succeed = true;
}
if (leader_sequence_three_keys(KC_Z, KC_Z, KC_Z)) {
SEND_STRING("]");
did_leader_succeed = true;
}
if (did_leader_succeed) { if (did_leader_succeed) {
#ifdef AUDIO_ENABLE #ifdef AUDIO_ENABLE
PLAY_SONG(leader_succeed_song); PLAY_SONG(leader_succeed_song);

View File

@ -168,36 +168,24 @@ void keyboard_post_init_user(void) {
} }
bool leader_found; bool leader_found;
LEADER_EXTERNS();
void matrix_scan_user(void) { void leader_end_user(void) {
LEADER_DICTIONARY() {
leading = false;
leader_found = false; leader_found = false;
SEQ_ONE_KEY(L_RESET) {
if (leader_sequence_one_key(L_RESET)) {
leader_found = true; leader_found = true;
reset_keyboard(); reset_keyboard();
} } else if (leader_sequence_one_key(KC_DEL)) {
else
SEQ_ONE_KEY(KC_DEL) {
leader_found = true; leader_found = true;
layer_clear(); layer_clear();
} } else if (leader_sequence_one_key(LOWER)) {
else
SEQ_ONE_KEY(LOWER) {
leader_found = true; leader_found = true;
layer_on(_LOWER); layer_on(_LOWER);
} } else if (leader_sequence_one_key(RAISE)) {
else
SEQ_ONE_KEY(RAISE) {
leader_found = true; leader_found = true;
layer_on(_RAISE); layer_on(_RAISE);
} }
leader_end();
}
}
void leader_end_user(void) {
// Plays sound on if leader sequence found. // Plays sound on if leader sequence found.
if (leader_found) { if (leader_found) {
#ifdef AUDIO_ENABLE #ifdef AUDIO_ENABLE

View File

@ -92,27 +92,33 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
return true; return true;
} }
LEADER_EXTERNS(); void leader_end_user(void) {
void matrix_scan_user(void) {
LEADER_DICTIONARY() {
leading = false;
leader_end();
// Cancel task CTRL+C // Cancel task CTRL+C
SEQ_ONE_KEY(KC_C) { tap_code16(C(KC_C)); } if (leader_sequence_one_key(KC_C)) {
tap_code16(C(KC_C));
}
// copy // copy
SEQ_ONE_KEY(KC_Y) { tap_code16(G(KC_C)); } if (leader_sequence_one_key(KC_Y)) {
tap_code16(G(KC_C));
}
// cut // cut
SEQ_ONE_KEY(KC_X) { tap_code16(G(KC_X)); } if (leader_sequence_one_key(KC_X)) {
tap_code16(G(KC_X));
}
// paste // paste
SEQ_ONE_KEY(KC_P) { tap_code16(G(KC_V)); } if (leader_sequence_one_key(KC_P)) {
tap_code16(G(KC_V));
}
// undo // undo
SEQ_ONE_KEY(KC_U) { tap_code16(G(KC_Z)); } if (leader_sequence_one_key(KC_U)) {
tap_code16(G(KC_Z));
}
// redo // redo
SEQ_ONE_KEY(KC_R) { tap_code16(S(G(KC_Z))); } if (leader_sequence_one_key(KC_R)) {
tap_code16(S(G(KC_Z)));
}
// delete line // delete line
SEQ_TWO_KEYS(KC_D, KC_D) { if (leader_sequence_two_keys(KC_D, KC_D)) {
register_code(KC_LGUI); register_code(KC_LGUI);
tap_code(KC_RIGHT); tap_code(KC_RIGHT);
@ -122,7 +128,11 @@ void matrix_scan_user(void) {
unregister_code(KC_LGUI); unregister_code(KC_LGUI);
} }
// go to the beginning of the string // go to the beginning of the string
SEQ_ONE_KEY(KC_H) { tap_code16(G(KC_LEFT)); } if (leader_sequence_one_key(KC_H)) {
// go to the end of the string tap_code16(G(KC_LEFT));
SEQ_ONE_KEY(KC_L) { tap_code16(G(KC_RIGHT)); } }
// go to the end of the string
if (leader_sequence_one_key(KC_L)) {
tap_code16(G(KC_RIGHT));
}
} }

View File

@ -171,18 +171,11 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
return true; return true;
} }
LEADER_EXTERNS(); void leader_end_user(void) {
if (leader_sequence_one_key(KC_F)) { // Shift + Ctrl + F
void matrix_scan_user(void) {
LEADER_DICTIONARY() {
leading = false;
leader_end();
SEQ_ONE_KEY(KC_F) { // Shift + Ctrl + F
tap_code16(S(C(KC_F))); tap_code16(S(C(KC_F)));
} }
} }
}
#ifdef OLED_ENABLE #ifdef OLED_ENABLE
oled_rotation_t oled_init_user(oled_rotation_t rotation) { oled_rotation_t oled_init_user(oled_rotation_t rotation) {

View File

@ -31,8 +31,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS) KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS)
}; };
LEADER_EXTERNS();
void keyboard_post_init_user(void) { void keyboard_post_init_user(void) {
led_t led_state = host_keyboard_led_state(); led_t led_state = host_keyboard_led_state();
if (!led_state.num_lock) { if (!led_state.num_lock) {
@ -44,27 +42,22 @@ layer_state_t layer_state_set_user(layer_state_t state) {
return update_tri_layer_state(state, _SYMBOLS, _NUMBERS, _SPECIALS); return update_tri_layer_state(state, _SYMBOLS, _NUMBERS, _SPECIALS);
} }
void matrix_scan_user(void) { void leader_end_user(void) {
LEADER_DICTIONARY() {
leading = false;
leader_end();
// Lock screen (macOS) // Lock screen (macOS)
SEQ_ONE_KEY(KC_ESC) { if (leader_sequence_one_key(KC_ESC)) {
tap_code16(LCTL(LGUI(KC_Q))); tap_code16(LCTL(LGUI(KC_Q)));
} }
// Escape-Shift-Z-Z (VIM) // Escape-Shift-Z-Z (VIM)
SEQ_ONE_KEY(KC_Z) { if (leader_sequence_one_key(KC_Z)) {
SEND_STRING(SS_TAP(X_ESC) SS_LSFT("zz")); SEND_STRING(SS_TAP(X_ESC) SS_LSFT("zz"));
} }
// Dead grave accent (macOS) // Dead grave accent (macOS)
SEQ_ONE_KEY(KC_E) { if (leader_sequence_one_key(KC_E)) {
tap_code16(LALT(KC_GRAVE)); tap_code16(LALT(KC_GRAVE));
} }
} }
}
oled_rotation_t oled_init_user(oled_rotation_t rotation) { oled_rotation_t oled_init_user(oled_rotation_t rotation) {
return OLED_ROTATION_180; return OLED_ROTATION_180;

View File

@ -274,27 +274,21 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
return true; return true;
}; };
LEADER_EXTERNS(); void leader_end_user(void) {
void matrix_scan_user(void) {
LEADER_DICTIONARY() {
leading = false;
leader_end();
// Set current OS indicator to macOs // Set current OS indicator to macOs
SEQ_ONE_KEY(KC_M) { if (leader_sequence_one_key(KC_M)) {
user_config.osIsWindows = false; user_config.osIsWindows = false;
eeconfig_update_user(user_config.raw); eeconfig_update_user(user_config.raw);
} }
// Set current OS indicator to Windows // Set current OS indicator to Windows
SEQ_ONE_KEY(KC_W) { if (leader_sequence_one_key(KC_W)) {
user_config.osIsWindows = true; user_config.osIsWindows = true;
eeconfig_update_user(user_config.raw); eeconfig_update_user(user_config.raw);
} }
// Screenshot // Screenshot
SEQ_ONE_KEY(KC_S) { if (leader_sequence_one_key(KC_S)) {
if (user_config.osIsWindows == 1) { if (user_config.osIsWindows == 1) {
tap_code16(S(G(KC_S))); tap_code16(S(G(KC_S)));
} else if (user_config.osIsWindows == 0) { } else if (user_config.osIsWindows == 0) {
@ -303,14 +297,14 @@ void matrix_scan_user(void) {
} }
// Video // Video
SEQ_ONE_KEY(KC_V) { if (leader_sequence_one_key(KC_V)) {
if (user_config.osIsWindows == 0) { if (user_config.osIsWindows == 0) {
tap_code16(S(G(KC_5))); tap_code16(S(G(KC_5)));
} }
} }
// Sleep // Sleep
SEQ_ONE_KEY(KC_P) { if (leader_sequence_one_key(KC_P)) {
if (user_config.osIsWindows == 1) { if (user_config.osIsWindows == 1) {
SEND_STRING(SS_LGUI("x") "u" "h"); SEND_STRING(SS_LGUI("x") "u" "h");
} else if (user_config.osIsWindows == 0) { } else if (user_config.osIsWindows == 0) {
@ -318,4 +312,3 @@ void matrix_scan_user(void) {
} }
} }
} }
}

View File

@ -56,11 +56,18 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
), ),
}; };
void leader_end_user(void) {
if (leader_sequence_one_key(KC_A)) {
tap_code16(SGUI(KC_L));
}
if (leader_sequence_two_keys(KC_S, KC_S)) {
tap_code16(SGUI(KC_5));
}
}
bool is_cmd_tab_active = false; bool is_cmd_tab_active = false;
uint16_t cmd_tab_timer = 0; uint16_t cmd_tab_timer = 0;
LEADER_EXTERNS();
void matrix_scan_user(void) { void matrix_scan_user(void) {
if (is_cmd_tab_active) { if (is_cmd_tab_active) {
if (timer_elapsed(cmd_tab_timer) > 1000) { if (timer_elapsed(cmd_tab_timer) > 1000) {
@ -68,18 +75,6 @@ void matrix_scan_user(void) {
is_cmd_tab_active = false; is_cmd_tab_active = false;
} }
} }
LEADER_DICTIONARY() {
leading = false;
leader_end();
SEQ_ONE_KEY(KC_A) {
tap_code16(SGUI(KC_L));
}
SEQ_TWO_KEYS(KC_S, KC_S) {
tap_code16(SGUI(KC_5));
}
}
} }
#ifdef OLED_ENABLE #ifdef OLED_ENABLE

View File

@ -49,18 +49,11 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
), ),
}; };
LEADER_EXTERNS(); void leader_end_user(void) {
if (leader_sequence_one_key(KC_A)) {
void matrix_scan_user(void) {
LEADER_DICTIONARY() {
leading = false;
leader_end();
SEQ_ONE_KEY(KC_A) {
tap_code16(SGUI(KC_L)); tap_code16(SGUI(KC_L));
} }
SEQ_TWO_KEYS(KC_S, KC_S) { if (leader_sequence_two_keys(KC_S, KC_S)) {
tap_code16(SGUI(KC_5)); tap_code16(SGUI(KC_5));
} }
} }
}

View File

@ -400,82 +400,76 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
} }
#endif #endif
LEADER_EXTERNS(); void leader_end_user(void) {
void matrix_scan_user(void) {
LEADER_DICTIONARY() {
leading = false;
leader_end();
// Sway navigation // Sway navigation
SEQ_ONE_KEY(KC_Q) { // Jump to workspace 1 if (leader_sequence_one_key(KC_Q)) { // Jump to workspace 1
SEND_STRING(SS_LGUI("1")); SEND_STRING(SS_LGUI("1"));
} }
SEQ_ONE_KEY(KC_W) { // Jump to workspace 2 if (leader_sequence_one_key(KC_W)) { // Jump to workspace 2
SEND_STRING(SS_LGUI("2")); SEND_STRING(SS_LGUI("2"));
} }
SEQ_ONE_KEY(KC_E) { // Jump to workspace 3 if (leader_sequence_one_key(KC_E)) { // Jump to workspace 3
SEND_STRING(SS_LGUI("3")); SEND_STRING(SS_LGUI("3"));
} }
SEQ_ONE_KEY(KC_R) { // Jump to workspace 4 if (leader_sequence_one_key(KC_R)) { // Jump to workspace 4
SEND_STRING(SS_LGUI("4")); SEND_STRING(SS_LGUI("4"));
} }
SEQ_ONE_KEY(KC_T) { // Jump to workspace 5 if (leader_sequence_one_key(KC_T)) { // Jump to workspace 5
SEND_STRING(SS_LGUI("5")); SEND_STRING(SS_LGUI("5"));
} }
SEQ_ONE_KEY(KC_Y) { // Jump to workspace 6 if (leader_sequence_one_key(KC_Y)) { // Jump to workspace 6
SEND_STRING(SS_LGUI("6")); SEND_STRING(SS_LGUI("6"));
} }
SEQ_ONE_KEY(KC_U) { // Jump to workspace 7 if (leader_sequence_one_key(KC_U)) { // Jump to workspace 7
SEND_STRING(SS_LGUI("7")); SEND_STRING(SS_LGUI("7"));
} }
SEQ_ONE_KEY(KC_I) { // Jump to workspace 8 if (leader_sequence_one_key(KC_I)) { // Jump to workspace 8
SEND_STRING(SS_LGUI("8")); SEND_STRING(SS_LGUI("8"));
} }
SEQ_ONE_KEY(KC_O) { // Jump to workspace 9 if (leader_sequence_one_key(KC_O)) { // Jump to workspace 9
SEND_STRING(SS_LGUI("9")); SEND_STRING(SS_LGUI("9"));
} }
SEQ_ONE_KEY(KC_P) { // Jump to workspace 0 if (leader_sequence_one_key(KC_P)) { // Jump to workspace 0
SEND_STRING(SS_LGUI("0")); SEND_STRING(SS_LGUI("0"));
} }
SEQ_ONE_KEY(KC_G) { // View scratch pad if (leader_sequence_one_key(KC_G)) { // View scratch pad
SEND_STRING(SS_LGUI("-")); SEND_STRING(SS_LGUI("-"));
} }
// Sway move window // Sway move window
SEQ_TWO_KEYS(KC_M, KC_Q) { // Move to workspace 1 if (leader_sequence_two_keys(KC_M, KC_Q)) { // Move to workspace 1
SEND_STRING(SS_LSFT(SS_LGUI("1"))); SEND_STRING(SS_LSFT(SS_LGUI("1")));
} }
SEQ_TWO_KEYS(KC_M, KC_W) { // Move to workspace 2 if (leader_sequence_two_keys(KC_M, KC_W)) { // Move to workspace 2
SEND_STRING(SS_LSFT(SS_LGUI("2"))); SEND_STRING(SS_LSFT(SS_LGUI("2")));
} }
SEQ_TWO_KEYS(KC_M, KC_E) { // Move to workspace 3 if (leader_sequence_two_keys(KC_M, KC_E)) { // Move to workspace 3
SEND_STRING(SS_LSFT(SS_LGUI("3"))); SEND_STRING(SS_LSFT(SS_LGUI("3")));
} }
SEQ_TWO_KEYS(KC_M, KC_R) { // Move to workspace 4 if (leader_sequence_two_keys(KC_M, KC_R)) { // Move to workspace 4
SEND_STRING(SS_LSFT(SS_LGUI("4"))); SEND_STRING(SS_LSFT(SS_LGUI("4")));
} }
SEQ_TWO_KEYS(KC_M, KC_T) { // Move to workspace 5 if (leader_sequence_two_keys(KC_M, KC_T)) { // Move to workspace 5
SEND_STRING(SS_LSFT(SS_LGUI("5"))); SEND_STRING(SS_LSFT(SS_LGUI("5")));
} }
SEQ_TWO_KEYS(KC_M, KC_Y) { // Move to workspace 6 if (leader_sequence_two_keys(KC_M, KC_Y)) { // Move to workspace 6
SEND_STRING(SS_LSFT(SS_LGUI("6"))); SEND_STRING(SS_LSFT(SS_LGUI("6")));
} }
SEQ_TWO_KEYS(KC_M, KC_U) { // Move to workspace 7 if (leader_sequence_two_keys(KC_M, KC_U)) { // Move to workspace 7
SEND_STRING(SS_LSFT(SS_LGUI("7"))); SEND_STRING(SS_LSFT(SS_LGUI("7")));
} }
SEQ_TWO_KEYS(KC_M, KC_I) { // Move to workspace 8 if (leader_sequence_two_keys(KC_M, KC_I)) { // Move to workspace 8
SEND_STRING(SS_LSFT(SS_LGUI("8"))); SEND_STRING(SS_LSFT(SS_LGUI("8")));
} }
SEQ_TWO_KEYS(KC_M, KC_O) { // Move to workspace 9 if (leader_sequence_two_keys(KC_M, KC_O)) { // Move to workspace 9
SEND_STRING(SS_LSFT(SS_LGUI("9"))); SEND_STRING(SS_LSFT(SS_LGUI("9")));
} }
SEQ_TWO_KEYS(KC_M, KC_P) { // Move to workspace 0 if (leader_sequence_two_keys(KC_M, KC_P)) { // Move to workspace 0
SEND_STRING(SS_LSFT(SS_LGUI("0"))); SEND_STRING(SS_LSFT(SS_LGUI("0")));
} }
SEQ_TWO_KEYS(KC_M, KC_G) { // Move to scratch pad if (leader_sequence_two_keys(KC_M, KC_G)) { // Move to scratch pad
SEND_STRING(SS_LSFT(SS_LGUI("-"))); SEND_STRING(SS_LSFT(SS_LGUI("-")));
} }
} }
}

View File

@ -173,12 +173,54 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
return true; return true;
} }
void leader_end_user(void) {
if (leader_sequence_one_key(KC_C)) { // Inline Code
SEND_STRING("`` " SS_TAP(X_LEFT) SS_TAP(X_LEFT));
}
if (leader_sequence_one_key(KC_P)) { // Invoke Password Manager
SEND_STRING(SS_LCTL(SS_LALT("\\")));
}
if (leader_sequence_one_key(KC_S)) { // Windows screenshot
SEND_STRING(SS_LGUI("\nS"));
}
if (leader_sequence_two_keys(KC_F, KC_P)) { // Fusion Projection prefix
SEND_STRING("[Projection] ");
}
if (leader_sequence_two_keys(KC_B, KC_B)) { // Basecone invoice description
SEND_STRING("[Leveranciersnaam] [Factuurnummer]");
}
if (leader_sequence_two_keys(KC_E, KC_S)) { // Support email splitkb
SEND_STRING("support@splitkb.com");
}
if (leader_sequence_two_keys(KC_E, KC_T)) { // Email splitkb
SEND_STRING("thomas@splitkb.com");
}
if (leader_sequence_two_keys(KC_E, KC_P)) { // Email personal
SEND_STRING("mail@thomasbaart.nl");
}
if (leader_sequence_two_keys(KC_S, KC_D)) { // Splitkb documentation
SEND_STRING("https://docs.splitkb.com/");
}
if (leader_sequence_two_keys(KC_S, KC_V)) { // Splitkb VAT number
SEND_STRING("NL210593349B01");
}
if (leader_sequence_two_keys(KC_B, KC_C)) { // Discord bongocat
SEND_STRING(":bongocat:\n");
}
if (leader_sequence_two_keys(KC_C, KC_B)) { // Discord code block
SEND_STRING("```c" SS_LSFT("\n\n") "``` " SS_TAP(X_UP));
}
if (leader_sequence_two_keys(KC_Y, KC_S)) { // Greeting
SEND_STRING("Yours sincerely,\n\nThomas Baart");
}
if (leader_sequence_three_keys(KC_M, KC_V, KC_G)) { // Greeting
SEND_STRING("Met vriendelijke groet,\n\nThomas Baart");
}
}
bool is_alt_tab_active = false; bool is_alt_tab_active = false;
uint16_t alt_tab_timer = 0; uint16_t alt_tab_timer = 0;
LEADER_EXTERNS();
void matrix_scan_user(void) { void matrix_scan_user(void) {
if (is_alt_tab_active) { if (is_alt_tab_active) {
if (timer_elapsed(alt_tab_timer) > 1000) { if (timer_elapsed(alt_tab_timer) > 1000) {
@ -186,54 +228,6 @@ void matrix_scan_user(void) {
is_alt_tab_active = false; is_alt_tab_active = false;
} }
} }
LEADER_DICTIONARY() {
leading = false;
leader_end();
SEQ_ONE_KEY(KC_C) { // Inline Code
SEND_STRING("`` " SS_TAP(X_LEFT) SS_TAP(X_LEFT));
}
SEQ_ONE_KEY(KC_P) { // Invoke Password Manager
SEND_STRING(SS_LCTL(SS_LALT("\\")));
}
SEQ_ONE_KEY(KC_S) { // Windows screenshot
SEND_STRING(SS_LGUI("\nS"));
}
SEQ_TWO_KEYS(KC_F, KC_P) { // Fusion Projection prefix
SEND_STRING("[Projection] ");
}
SEQ_TWO_KEYS(KC_B, KC_B) { // Basecone invoice description
SEND_STRING("[Leveranciersnaam] [Factuurnummer]");
}
SEQ_TWO_KEYS(KC_E, KC_S) { // Support email splitkb
SEND_STRING("support@splitkb.com");
}
SEQ_TWO_KEYS(KC_E, KC_T) { // Email splitkb
SEND_STRING("thomas@splitkb.com");
}
SEQ_TWO_KEYS(KC_E, KC_P) { // Email personal
SEND_STRING("mail@thomasbaart.nl");
}
SEQ_TWO_KEYS(KC_S, KC_D) { // Splitkb documentation
SEND_STRING("https://docs.splitkb.com/");
}
SEQ_TWO_KEYS(KC_S, KC_V) { // Splitkb VAT number
SEND_STRING("NL210593349B01");
}
SEQ_TWO_KEYS(KC_B, KC_C) { // Discord bongocat
SEND_STRING(":bongocat:\n");
}
SEQ_TWO_KEYS(KC_C, KC_B) { // Discord code block
SEND_STRING("```c" SS_LSFT("\n\n") "``` " SS_TAP(X_UP));
}
SEQ_TWO_KEYS(KC_Y, KC_S) { // Greeting
SEND_STRING("Yours sincerely,\n\nThomas Baart");
}
SEQ_THREE_KEYS(KC_M, KC_V, KC_G) { // Greeting
SEND_STRING("Met vriendelijke groet,\n\nThomas Baart");
}
}
} }
#ifdef OLED_ENABLE #ifdef OLED_ENABLE

View File

@ -7,8 +7,6 @@
#define _BL 0 #define _BL 0
#define _FL 1 #define _FL 1
LEADER_EXTERNS();
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Keymap _BL: (Base Layer) Default Layer /* Keymap _BL: (Base Layer) Default Layer
* ,----------------------------------------------------------------. * ,----------------------------------------------------------------.

View File

@ -105,6 +105,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifdef CAPS_WORD_ENABLE #ifdef CAPS_WORD_ENABLE
# include "caps_word.h" # include "caps_word.h"
#endif #endif
#ifdef LEADER_ENABLE
# include "leader.h"
#endif
static uint32_t last_input_modification_time = 0; static uint32_t last_input_modification_time = 0;
uint32_t last_input_activity_time(void) { uint32_t last_input_activity_time(void) {
@ -546,6 +549,10 @@ void quantum_task(void) {
combo_task(); combo_task();
#endif #endif
#ifdef LEADER_ENABLE
leader_task();
#endif
#ifdef WPM_ENABLE #ifdef WPM_ENABLE
decay_wpm(); decay_wpm();
#endif #endif

101
quantum/leader.c 100644
View File

@ -0,0 +1,101 @@
// Copyright 2023 QMK
// SPDX-License-Identifier: GPL-2.0-or-later
#include "leader.h"
#include "timer.h"
#include "util.h"
#include <string.h>
#ifndef LEADER_TIMEOUT
# define LEADER_TIMEOUT 300
#endif
// Leader key stuff
bool leading = false;
uint16_t leader_time = 0;
uint16_t leader_sequence[5] = {0, 0, 0, 0, 0};
uint8_t leader_sequence_size = 0;
__attribute__((weak)) void leader_start_user(void) {}
__attribute__((weak)) void leader_end_user(void) {}
void leader_start(void) {
if (leading) {
return;
}
leader_start_user();
leading = true;
leader_time = timer_read();
leader_sequence_size = 0;
memset(leader_sequence, 0, sizeof(leader_sequence));
}
void leader_end(void) {
leading = false;
leader_end_user();
}
void leader_task(void) {
if (leader_sequence_active() && leader_sequence_timed_out()) {
leader_end();
}
}
bool leader_sequence_active(void) {
return leading;
}
bool leader_sequence_add(uint16_t keycode) {
if (leader_sequence_size >= ARRAY_SIZE(leader_sequence)) {
return false;
}
#if defined(LEADER_NO_TIMEOUT)
if (leader_sequence_size == 0) {
leader_reset_timer();
}
#endif
leader_sequence[leader_sequence_size] = keycode;
leader_sequence_size++;
return true;
}
bool leader_sequence_timed_out(void) {
#if defined(LEADER_NO_TIMEOUT)
return leader_sequence_size > 0 && timer_elapsed(leader_time) > LEADER_TIMEOUT;
#else
return timer_elapsed(leader_time) > LEADER_TIMEOUT;
#endif
}
void leader_reset_timer(void) {
leader_time = timer_read();
}
bool leader_sequence_is(uint16_t kc1, uint16_t kc2, uint16_t kc3, uint16_t kc4, uint16_t kc5) {
return leader_sequence[0] == kc1 && leader_sequence[1] == kc2 && leader_sequence[2] == kc3 && leader_sequence[3] == kc4 && leader_sequence[4] == kc5;
}
bool leader_sequence_one_key(uint16_t kc) {
return leader_sequence_is(kc, 0, 0, 0, 0);
}
bool leader_sequence_two_keys(uint16_t kc1, uint16_t kc2) {
return leader_sequence_is(kc1, kc2, 0, 0, 0);
}
bool leader_sequence_three_keys(uint16_t kc1, uint16_t kc2, uint16_t kc3) {
return leader_sequence_is(kc1, kc2, kc3, 0, 0);
}
bool leader_sequence_four_keys(uint16_t kc1, uint16_t kc2, uint16_t kc3, uint16_t kc4) {
return leader_sequence_is(kc1, kc2, kc3, kc4, 0);
}
bool leader_sequence_five_keys(uint16_t kc1, uint16_t kc2, uint16_t kc3, uint16_t kc4, uint16_t kc5) {
return leader_sequence_is(kc1, kc2, kc3, kc4, kc5);
}

119
quantum/leader.h 100644
View File

@ -0,0 +1,119 @@
// Copyright 2023 QMK
// SPDX-License-Identifier: GPL-2.0-or-later
#include <stdbool.h>
#include <stdint.h>
/**
* \defgroup leader
*
* Leader Key
* \{
*/
/**
* \brief User callback, invoked when the leader sequence begins.
*/
void leader_start_user(void);
/**
* \brief User callback, invoked when the leader sequence ends.
*/
void leader_end_user(void);
/**
* Begin the leader sequence, resetting the buffer and timer.
*/
void leader_start(void);
/**
* End the leader sequence.
*/
void leader_end(void);
void leader_task(void);
/**
* Whether the leader sequence is active.
*/
bool leader_sequence_active(void);
/**
* Add the given keycode to the sequence buffer.
*
* If `LEADER_NO_TIMEOUT` is defined, the timer is reset if the buffer is empty.
*
* \param keycode The keycode to add.
*
* \return `true` if the keycode was added, `false` if the buffer is full.
*/
bool leader_sequence_add(uint16_t keycode);
/**
* Whether the leader sequence has reached the timeout.
*
* If `LEADER_NO_TIMEOUT` is defined, the buffer must also contain at least one key.
*/
bool leader_sequence_timed_out(void);
/**
* Reset the leader sequence timer.
*/
void leader_reset_timer(void);
/**
* Check the sequence buffer for the given keycode.
*
* \param kc The keycode to check.
*
* \return `true` if the sequence buffer matches.
*/
bool leader_sequence_one_key(uint16_t kc);
/**
* Check the sequence buffer for the given keycodes.
*
* \param kc1 The first keycode to check.
* \param kc2 The second keycode to check.
*
* \return `true` if the sequence buffer matches.
*/
bool leader_sequence_two_keys(uint16_t kc1, uint16_t kc2);
/**
* Check the sequence buffer for the given keycodes.
*
* \param kc1 The first keycode to check.
* \param kc2 The second keycode to check.
* \param kc3 The third keycode to check.
*
* \return `true` if the sequence buffer matches.
*/
bool leader_sequence_three_keys(uint16_t kc1, uint16_t kc2, uint16_t kc3);
/**
* Check the sequence buffer for the given keycodes.
*
* \param kc1 The first keycode to check.
* \param kc2 The second keycode to check.
* \param kc3 The third keycode to check.
* \param kc4 The fourth keycode to check.
*
* \return `true` if the sequence buffer matches.
*/
bool leader_sequence_four_keys(uint16_t kc1, uint16_t kc2, uint16_t kc3, uint16_t kc4);
/**
* Check the sequence buffer for the given keycodes.
*
* \param kc1 The first keycode to check.
* \param kc2 The second keycode to check.
* \param kc3 The third keycode to check.
* \param kc4 The fourth keycode to check.
* \param kc5 The fifth keycode to check.
*
* \return `true` if the sequence buffer matches.
*/
bool leader_sequence_five_keys(uint16_t kc1, uint16_t kc2, uint16_t kc3, uint16_t kc4, uint16_t kc5);
/** \} */

View File

@ -15,71 +15,34 @@
*/ */
#include "process_leader.h" #include "process_leader.h"
#include <string.h> #include "leader.h"
#ifndef LEADER_TIMEOUT
# define LEADER_TIMEOUT 300
#endif
__attribute__((weak)) void leader_start_user(void) {}
__attribute__((weak)) void leader_end_user(void) {}
// Leader key stuff
bool leading = false;
uint16_t leader_time = 0;
uint16_t leader_sequence[5] = {0, 0, 0, 0, 0};
uint8_t leader_sequence_size = 0;
void leader_start(void) {
if (leading) {
return;
}
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) { bool process_leader(uint16_t keycode, keyrecord_t *record) {
// Leader key set-up
if (record->event.pressed) { if (record->event.pressed) {
if (leading) { if (leader_sequence_active() && !leader_sequence_timed_out()) {
#ifndef LEADER_NO_TIMEOUT
if (timer_elapsed(leader_time) < LEADER_TIMEOUT)
#endif // LEADER_NO_TIMEOUT
{
#ifndef LEADER_KEY_STRICT_KEY_PROCESSING #ifndef LEADER_KEY_STRICT_KEY_PROCESSING
if (IS_QK_MOD_TAP(keycode)) { if (IS_QK_MOD_TAP(keycode)) {
keycode = QK_MOD_TAP_GET_TAP_KEYCODE(keycode); keycode = QK_MOD_TAP_GET_TAP_KEYCODE(keycode);
} else if (IS_QK_LAYER_TAP(keycode)) { } else if (IS_QK_LAYER_TAP(keycode)) {
keycode = QK_LAYER_TAP_GET_TAP_KEYCODE(keycode); keycode = QK_LAYER_TAP_GET_TAP_KEYCODE(keycode);
} }
#endif // LEADER_KEY_STRICT_KEY_PROCESSING #endif
if (leader_sequence_size < ARRAY_SIZE(leader_sequence)) {
leader_sequence[leader_sequence_size] = keycode; if (!leader_sequence_add(keycode)) {
leader_sequence_size++; leader_end();
} else {
leading = false;
leader_end_user();
return true; return true;
} }
#ifdef LEADER_PER_KEY_TIMING #ifdef LEADER_PER_KEY_TIMING
leader_time = timer_read(); leader_reset_timer();
#endif #endif
return false; return false;
} } else if (keycode == QK_LEADER) {
} else {
if (keycode == QK_LEADER) {
leader_start(); leader_start();
} }
} }
}
return true; return true;
} }

View File

@ -19,27 +19,3 @@
#include "quantum.h" #include "quantum.h"
bool process_leader(uint16_t keycode, keyrecord_t *record); 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);
#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)
#define SEQ_THREE_KEYS(key1, key2, key3) if (leader_sequence[0] == (key1) && leader_sequence[1] == (key2) && leader_sequence[2] == (key3) && leader_sequence[3] == 0 && leader_sequence[4] == 0)
#define SEQ_FOUR_KEYS(key1, key2, key3, key4) if (leader_sequence[0] == (key1) && leader_sequence[1] == (key2) && leader_sequence[2] == (key3) && leader_sequence[3] == (key4) && leader_sequence[4] == 0)
#define SEQ_FIVE_KEYS(key1, key2, key3, key4, key5) if (leader_sequence[0] == (key1) && leader_sequence[1] == (key2) && leader_sequence[2] == (key3) && leader_sequence[3] == (key4) && leader_sequence[4] == (key5))
#define LEADER_EXTERNS() \
extern bool leading; \
extern uint16_t leader_time; \
extern uint16_t leader_sequence[5]; \
extern uint8_t leader_sequence_size
#ifdef LEADER_NO_TIMEOUT
# define LEADER_DICTIONARY() if (leading && leader_sequence_size > 0 && timer_elapsed(leader_time) > LEADER_TIMEOUT)
#else
# define LEADER_DICTIONARY() if (leading && timer_elapsed(leader_time) > LEADER_TIMEOUT)
#endif

View File

@ -93,6 +93,7 @@ extern layer_state_t layer_state;
#endif #endif
#ifdef LEADER_ENABLE #ifdef LEADER_ENABLE
# include "leader.h"
# include "process_leader.h" # include "process_leader.h"
#endif #endif

View File

@ -0,0 +1,6 @@
// Copyright 2023 QMK
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "test_common.h"

View File

@ -0,0 +1,8 @@
// Copyright 2023 QMK
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "test_common.h"
#define LEADER_NO_TIMEOUT

View File

@ -0,0 +1,7 @@
# --------------------------------------------------------------------------------
# Keep this file, even if it is empty, as a marker that this folder contains tests
# --------------------------------------------------------------------------------
LEADER_ENABLE = yes
SRC += ../leader_sequences.c

View File

@ -0,0 +1,48 @@
// Copyright 2023 QMK
// SPDX-License-Identifier: GPL-2.0-or-later
#include "keyboard_report_util.hpp"
#include "keycode.h"
#include "test_common.hpp"
#include "test_keymap_key.hpp"
using testing::_;
class Leader : public TestFixture {};
TEST_F(Leader, does_not_timeout_until_next_key_pressed) {
TestDriver driver;
auto key_leader = KeymapKey(0, 0, 0, QK_LEADER);
auto key_a = KeymapKey(0, 1, 0, KC_A);
set_keymap({key_leader, key_a});
EXPECT_EQ(leader_sequence_active(), false);
EXPECT_NO_REPORT(driver);
tap_key(key_leader);
EXPECT_EQ(leader_sequence_active(), true);
idle_for(1000);
EXPECT_EQ(leader_sequence_active(), true);
EXPECT_EQ(leader_sequence_timed_out(), false);
EXPECT_REPORT(driver, (KC_1));
EXPECT_EMPTY_REPORT(driver);
tap_key(key_a);
EXPECT_EQ(leader_sequence_active(), true);
EXPECT_EQ(leader_sequence_timed_out(), false);
idle_for(300);
EXPECT_EQ(leader_sequence_active(), false);
EXPECT_EQ(leader_sequence_timed_out(), true);
EXPECT_REPORT(driver, (KC_A));
EXPECT_EMPTY_REPORT(driver);
tap_key(key_a);
}

View File

@ -0,0 +1,5 @@
#pragma once
#include "test_common.h"
#define LEADER_PER_KEY_TIMING

View File

@ -0,0 +1,7 @@
# --------------------------------------------------------------------------------
# Keep this file, even if it is empty, as a marker that this folder contains tests
# --------------------------------------------------------------------------------
LEADER_ENABLE = yes
SRC += ../leader_sequences.c

View File

@ -0,0 +1,40 @@
// Copyright 2023 QMK
// SPDX-License-Identifier: GPL-2.0-or-later
#include "keyboard_report_util.hpp"
#include "keycode.h"
#include "test_common.hpp"
#include "test_keymap_key.hpp"
using testing::_;
class Leader : public TestFixture {};
TEST_F(Leader, does_not_timeout_during_sequence) {
TestDriver driver;
auto key_leader = KeymapKey(0, 0, 0, QK_LEADER);
auto key_a = KeymapKey(0, 1, 0, KC_A);
auto key_b = KeymapKey(0, 2, 0, KC_B);
auto key_c = KeymapKey(0, 3, 0, KC_C);
set_keymap({key_leader, key_a, key_b, key_c});
tap_key(key_leader);
EXPECT_NO_REPORT(driver);
tap_key(key_a);
idle_for(150);
EXPECT_NO_REPORT(driver);
tap_key(key_b);
idle_for(150);
EXPECT_REPORT(driver, (KC_3));
EXPECT_EMPTY_REPORT(driver);
tap_key(key_c);
idle_for(300);
}

View File

@ -0,0 +1,26 @@
// Copyright 2023 QMK
// SPDX-License-Identifier: GPL-2.0-or-later
#include "quantum.h"
void leader_end_user(void) {
if (leader_sequence_one_key(KC_A)) {
tap_code(KC_1);
}
if (leader_sequence_two_keys(KC_A, KC_B)) {
tap_code(KC_2);
}
if (leader_sequence_three_keys(KC_A, KC_B, KC_C)) {
tap_code(KC_3);
}
if (leader_sequence_four_keys(KC_A, KC_B, KC_C, KC_D)) {
tap_code(KC_4);
}
if (leader_sequence_five_keys(KC_A, KC_B, KC_C, KC_D, KC_E)) {
tap_code(KC_5);
}
}

View File

@ -0,0 +1,8 @@
// Copyright 2023 QMK
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "test_common.h"
#define LEADER_KEY_STRICT_KEY_PROCESSING

View File

@ -0,0 +1,7 @@
# --------------------------------------------------------------------------------
# Keep this file, even if it is empty, as a marker that this folder contains tests
# --------------------------------------------------------------------------------
LEADER_ENABLE = yes
SRC += ../leader_sequences.c

View File

@ -0,0 +1,45 @@
// Copyright 2023 QMK
// SPDX-License-Identifier: GPL-2.0-or-later
#include "keyboard_report_util.hpp"
#include "keycode.h"
#include "test_common.hpp"
#include "test_keymap_key.hpp"
using testing::_;
class Leader : public TestFixture {};
TEST_F(Leader, does_not_extract_mod_tap_keycode) {
TestDriver driver;
auto key_leader = KeymapKey(0, 0, 0, QK_LEADER);
auto key_mt = KeymapKey(0, 1, 0, LSFT_T(KC_A));
set_keymap({key_leader, key_mt});
tap_key(key_leader);
EXPECT_NO_REPORT(driver);
tap_key(key_mt);
EXPECT_EQ(leader_sequence_one_key(KC_A), false);
EXPECT_EQ(leader_sequence_one_key(LSFT_T(KC_A)), true);
}
TEST_F(Leader, does_not_extract_layer_tap_keycode) {
TestDriver driver;
auto key_leader = KeymapKey(0, 0, 0, QK_LEADER);
auto key_lt = KeymapKey(0, 1, 0, LT(1, KC_A));
set_keymap({key_leader, key_lt});
tap_key(key_leader);
EXPECT_NO_REPORT(driver);
tap_key(key_lt);
EXPECT_EQ(leader_sequence_one_key(KC_A), false);
EXPECT_EQ(leader_sequence_one_key(LT(1, KC_A)), true);
}

View File

@ -0,0 +1,7 @@
# --------------------------------------------------------------------------------
# Keep this file, even if it is empty, as a marker that this folder contains tests
# --------------------------------------------------------------------------------
LEADER_ENABLE = yes
SRC += leader_sequences.c

View File

@ -0,0 +1,224 @@
// Copyright 2023 QMK
// SPDX-License-Identifier: GPL-2.0-or-later
#include "keyboard_report_util.hpp"
#include "keycode.h"
#include "test_common.hpp"
#include "test_keymap_key.hpp"
using testing::_;
class Leader : public TestFixture {};
TEST_F(Leader, triggers_one_key_sequence) {
TestDriver driver;
auto key_leader = KeymapKey(0, 0, 0, QK_LEADER);
auto key_a = KeymapKey(0, 1, 0, KC_A);
set_keymap({key_leader, key_a});
EXPECT_EQ(leader_sequence_active(), false);
EXPECT_NO_REPORT(driver);
tap_key(key_leader);
EXPECT_EQ(leader_sequence_active(), true);
EXPECT_REPORT(driver, (KC_1));
EXPECT_EMPTY_REPORT(driver);
tap_key(key_a);
EXPECT_EQ(leader_sequence_timed_out(), false);
idle_for(300);
EXPECT_EQ(leader_sequence_active(), false);
EXPECT_EQ(leader_sequence_timed_out(), true);
EXPECT_REPORT(driver, (KC_A));
EXPECT_EMPTY_REPORT(driver);
tap_key(key_a);
}
TEST_F(Leader, triggers_two_key_sequence) {
TestDriver driver;
auto key_leader = KeymapKey(0, 0, 0, QK_LEADER);
auto key_a = KeymapKey(0, 1, 0, KC_A);
auto key_b = KeymapKey(0, 2, 0, KC_B);
set_keymap({key_leader, key_a, key_b});
EXPECT_EQ(leader_sequence_active(), false);
EXPECT_NO_REPORT(driver);
tap_key(key_leader);
EXPECT_EQ(leader_sequence_active(), true);
EXPECT_REPORT(driver, (KC_2));
EXPECT_EMPTY_REPORT(driver);
tap_key(key_a);
tap_key(key_b);
EXPECT_EQ(leader_sequence_timed_out(), false);
idle_for(300);
EXPECT_EQ(leader_sequence_active(), false);
EXPECT_EQ(leader_sequence_timed_out(), true);
EXPECT_REPORT(driver, (KC_A));
EXPECT_EMPTY_REPORT(driver);
tap_key(key_a);
}
TEST_F(Leader, triggers_three_key_sequence) {
TestDriver driver;
auto key_leader = KeymapKey(0, 0, 0, QK_LEADER);
auto key_a = KeymapKey(0, 1, 0, KC_A);
auto key_b = KeymapKey(0, 2, 0, KC_B);
auto key_c = KeymapKey(0, 3, 0, KC_C);
set_keymap({key_leader, key_a, key_b, key_c});
EXPECT_EQ(leader_sequence_active(), false);
EXPECT_NO_REPORT(driver);
tap_key(key_leader);
EXPECT_EQ(leader_sequence_active(), true);
EXPECT_REPORT(driver, (KC_3));
EXPECT_EMPTY_REPORT(driver);
tap_key(key_a);
tap_key(key_b);
tap_key(key_c);
EXPECT_EQ(leader_sequence_timed_out(), false);
idle_for(300);
EXPECT_EQ(leader_sequence_active(), false);
EXPECT_EQ(leader_sequence_timed_out(), true);
EXPECT_REPORT(driver, (KC_A));
EXPECT_EMPTY_REPORT(driver);
tap_key(key_a);
}
TEST_F(Leader, triggers_four_key_sequence) {
TestDriver driver;
auto key_leader = KeymapKey(0, 0, 0, QK_LEADER);
auto key_a = KeymapKey(0, 1, 0, KC_A);
auto key_b = KeymapKey(0, 2, 0, KC_B);
auto key_c = KeymapKey(0, 3, 0, KC_C);
auto key_d = KeymapKey(0, 4, 0, KC_D);
set_keymap({key_leader, key_a, key_b, key_c, key_d});
EXPECT_EQ(leader_sequence_active(), false);
EXPECT_NO_REPORT(driver);
tap_key(key_leader);
EXPECT_EQ(leader_sequence_active(), true);
EXPECT_REPORT(driver, (KC_4));
EXPECT_EMPTY_REPORT(driver);
tap_key(key_a);
tap_key(key_b);
tap_key(key_c);
tap_key(key_d);
EXPECT_EQ(leader_sequence_timed_out(), false);
idle_for(300);
EXPECT_EQ(leader_sequence_active(), false);
EXPECT_EQ(leader_sequence_timed_out(), true);
EXPECT_REPORT(driver, (KC_A));
EXPECT_EMPTY_REPORT(driver);
tap_key(key_a);
}
TEST_F(Leader, triggers_five_key_sequence) {
TestDriver driver;
auto key_leader = KeymapKey(0, 0, 0, QK_LEADER);
auto key_a = KeymapKey(0, 1, 0, KC_A);
auto key_b = KeymapKey(0, 2, 0, KC_B);
auto key_c = KeymapKey(0, 3, 0, KC_C);
auto key_d = KeymapKey(0, 4, 0, KC_D);
auto key_e = KeymapKey(0, 5, 0, KC_E);
set_keymap({key_leader, key_a, key_b, key_c, key_d, key_e});
EXPECT_EQ(leader_sequence_active(), false);
EXPECT_NO_REPORT(driver);
tap_key(key_leader);
EXPECT_EQ(leader_sequence_active(), true);
EXPECT_REPORT(driver, (KC_5));
EXPECT_EMPTY_REPORT(driver);
tap_key(key_a);
tap_key(key_b);
tap_key(key_c);
tap_key(key_d);
tap_key(key_e);
EXPECT_EQ(leader_sequence_timed_out(), false);
idle_for(300);
EXPECT_EQ(leader_sequence_active(), false);
EXPECT_EQ(leader_sequence_timed_out(), true);
EXPECT_REPORT(driver, (KC_A));
EXPECT_EMPTY_REPORT(driver);
tap_key(key_a);
}
TEST_F(Leader, extracts_mod_tap_keycode) {
TestDriver driver;
auto key_leader = KeymapKey(0, 0, 0, QK_LEADER);
auto key_mt = KeymapKey(0, 1, 0, LSFT_T(KC_A));
set_keymap({key_leader, key_mt});
tap_key(key_leader);
EXPECT_REPORT(driver, (KC_1));
EXPECT_EMPTY_REPORT(driver);
tap_key(key_mt);
EXPECT_EQ(leader_sequence_one_key(KC_A), true);
idle_for(300);
}
TEST_F(Leader, extracts_layer_tap_keycode) {
TestDriver driver;
auto key_leader = KeymapKey(0, 0, 0, QK_LEADER);
auto key_lt = KeymapKey(0, 1, 0, LT(1, KC_A));
set_keymap({key_leader, key_lt});
tap_key(key_leader);
EXPECT_REPORT(driver, (KC_1));
EXPECT_EMPTY_REPORT(driver);
tap_key(key_lt);
EXPECT_EQ(leader_sequence_one_key(KC_A), true);
idle_for(300);
}

View File

@ -7,7 +7,12 @@ uint16_t muse_counter = 0;
uint8_t muse_offset = 70; uint8_t muse_offset = 70;
uint16_t muse_tempo = 50; uint16_t muse_tempo = 50;
LEADER_EXTERNS(); void leader_end_user(void) {
// reset keyboard to bootloader
if (leader_sequence_five_keys(KC_R, KC_E, KC_S, KC_E, KC_T)) {
reset_keyboard();
}
}
void matrix_scan_user(void) { void matrix_scan_user(void) {
#ifdef AUDIO_ENABLE #ifdef AUDIO_ENABLE
@ -28,15 +33,6 @@ void matrix_scan_user(void) {
} }
} }
#endif #endif
LEADER_DICTIONARY() {
leading = false;
// reset keyboard to bootloader
SEQ_FIVE_KEYS(KC_R, KC_E, KC_S, KC_E, KC_T) {
reset_keyboard();
}
leader_end();
}
} }
bool syml_pressed = false; bool syml_pressed = false;

View File

@ -303,30 +303,16 @@ void pri_mod_keystroke(uint16_t key) {
pri_mod(false); pri_mod(false);
} }
void matrix_init_user(void) { void leader_end_user(void) {
current_os = eeprom_read_byte(EECONFIG_USERSPACE);
set_os(current_os, false);
}
LEADER_EXTERNS();
void matrix_scan_user(void) {
check_state();
flash_rgb();
fade_rgb();
LEADER_DICTIONARY() {
leading = false;
leader_end();
// begin OS functions // begin OS functions
SEQ_TWO_KEYS(KC_P, KC_B) { if (leader_sequence_two_keys(KC_P, KC_B)) {
if (current_os == OS_WIN) { if (current_os == OS_WIN) {
long_keystroke(2, (uint16_t[]){KC_LGUI, KC_PAUSE}); long_keystroke(2, (uint16_t[]){KC_LGUI, KC_PAUSE});
} else { } else {
return; return;
} }
} }
SEQ_TWO_KEYS(KC_S, KC_S) { if (leader_sequence_two_keys(KC_S, KC_S)) {
if (current_os == OS_MAC) { if (current_os == OS_MAC) {
long_keystroke(3, (uint16_t[]){KC_LGUI, KC_LSFT, KC_4}); long_keystroke(3, (uint16_t[]){KC_LGUI, KC_LSFT, KC_4});
} else if (current_os == OS_WIN) { } else if (current_os == OS_WIN) {
@ -335,13 +321,13 @@ void matrix_scan_user(void) {
return; return;
} }
} }
SEQ_THREE_KEYS(KC_C, KC_A, KC_D) { if (leader_sequence_three_keys(KC_C, KC_A, KC_D)) {
if (current_os == OS_WIN) { if (current_os == OS_WIN) {
long_keystroke(3, (uint16_t[]){KC_LCTL, KC_LALT, KC_DEL}); long_keystroke(3, (uint16_t[]){KC_LCTL, KC_LALT, KC_DEL});
} else { } else {
} }
} }
SEQ_THREE_KEYS(KC_C, KC_A, KC_E) { if (leader_sequence_three_keys(KC_C, KC_A, KC_E)) {
if (current_os == OS_WIN) { if (current_os == OS_WIN) {
long_keystroke(3, (uint16_t[]){KC_LCTL, KC_LALT, KC_END}); long_keystroke(3, (uint16_t[]){KC_LCTL, KC_LALT, KC_END});
} else { } else {
@ -350,59 +336,59 @@ void matrix_scan_user(void) {
// end OS functions // end OS functions
// begin format functions // begin format functions
SEQ_ONE_KEY(KC_B) { if (leader_sequence_one_key(KC_B)) {
surround_type(2, KC_8, true); surround_type(2, KC_8, true);
} }
SEQ_ONE_KEY(KC_I) { if (leader_sequence_one_key(KC_I)) {
surround_type(2, KC_MINS, true); surround_type(2, KC_MINS, true);
} }
SEQ_ONE_KEY(KC_U) { if (leader_sequence_one_key(KC_U)) {
surround_type(4, KC_MINS, true); surround_type(4, KC_MINS, true);
} }
SEQ_ONE_KEY(KC_S) { if (leader_sequence_one_key(KC_S)) {
surround_type(4, KC_GRAVE, true); surround_type(4, KC_GRAVE, true);
} }
SEQ_ONE_KEY(KC_C) { if (leader_sequence_one_key(KC_C)) {
register_unicode(0x00E7); // ç register_unicode(0x00E7); // ç
} }
SEQ_TWO_KEYS(KC_A, KC_V) { if (leader_sequence_two_keys(KC_A, KC_V)) {
surround_type(2, KC_QUOT, true); surround_type(2, KC_QUOT, true);
pair_surround_type(2, KC_LCBR, true); pair_surround_type(2, KC_LCBR, true);
surround_type(2, KC_SPC, false); surround_type(2, KC_SPC, false);
} }
SEQ_TWO_KEYS(KC_M, KC_L) { if (leader_sequence_two_keys(KC_M, KC_L)) {
pair_surround_type(1, KC_LBRC, false); pair_surround_type(1, KC_LBRC, false);
SEND_STRING("LINK_NAME"); SEND_STRING("LINK_NAME");
tap_code(KC_RGHT); tap_code(KC_RGHT);
pair_surround_type(1, KC_LPRN, true); pair_surround_type(1, KC_LPRN, true);
pri_mod_keystroke(KC_V); pri_mod_keystroke(KC_V);
} }
SEQ_TWO_KEYS(KC_C, KC_C) { if (leader_sequence_two_keys(KC_C, KC_C)) {
surround_type(2, KC_GRAVE, false); surround_type(2, KC_GRAVE, false);
} }
SEQ_THREE_KEYS(KC_C, KC_C, KC_C) { if (leader_sequence_three_keys(KC_C, KC_C, KC_C)) {
surround_type(6, KC_GRAVE, false); surround_type(6, KC_GRAVE, false);
} }
SEQ_ONE_KEY(KC_E) { if (leader_sequence_one_key(KC_E)) {
register_unicode(0x00E8); // è register_unicode(0x00E8); // è
} }
SEQ_TWO_KEYS(KC_E, KC_E) { if (leader_sequence_two_keys(KC_E, KC_E)) {
register_unicode(0x00E9); // é register_unicode(0x00E9); // é
} }
// end format functions // end format functions
// start fancy functions // start fancy functions
SEQ_TWO_KEYS(KC_V, KC_P) { if (leader_sequence_two_keys(KC_V, KC_P)) {
SEND_STRING("ggvG}x:set paste\ni"); SEND_STRING("ggvG}x:set paste\ni");
pri_mod_keystroke(KC_V); pri_mod_keystroke(KC_V);
} }
SEQ_THREE_KEYS(KC_C, KC_C, KC_ENT) { if (leader_sequence_three_keys(KC_C, KC_C, KC_ENT)) {
surround_type(6, KC_GRAVE, false); surround_type(6, KC_GRAVE, false);
pri_mod_keystroke(KC_V); pri_mod_keystroke(KC_V);
multi_tap(3, KC_RGHT, false); multi_tap(3, KC_RGHT, false);
tap_code(KC_ENTER); tap_code(KC_ENTER);
} }
SEQ_THREE_KEYS(KC_T, KC_C, KC_ENT) { if (leader_sequence_three_keys(KC_T, KC_C, KC_ENT)) {
multi_tap(3, KC_GRAVE, false); multi_tap(3, KC_GRAVE, false);
pri_mod_keystroke(KC_V); pri_mod_keystroke(KC_V);
multi_tap(2, KC_ENTER, false); multi_tap(2, KC_ENTER, false);
@ -410,39 +396,48 @@ void matrix_scan_user(void) {
// end fancy functions // end fancy functions
// start typing functions // start typing functions
SEQ_TWO_KEYS(KC_T, KC_M) { if (leader_sequence_two_keys(KC_T, KC_M)) {
register_unicode(0x2122); // ™ register_unicode(0x2122); // ™
} }
SEQ_TWO_KEYS(KC_D, KC_D) { if (leader_sequence_two_keys(KC_D, KC_D)) {
SEND_STRING(".\\Administrator"); SEND_STRING(".\\Administrator");
} }
SEQ_THREE_KEYS(KC_D, KC_D, KC_D) { if (leader_sequence_three_keys(KC_D, KC_D, KC_D)) {
SEND_STRING(".\\Administrator"); SEND_STRING(".\\Administrator");
tap_code(KC_TAB); tap_code(KC_TAB);
pri_mod_keystroke(KC_V); pri_mod_keystroke(KC_V);
tap_code(KC_ENTER); tap_code(KC_ENTER);
} }
SEQ_THREE_KEYS(KC_L, KC_O, KC_D) { if (leader_sequence_three_keys(KC_L, KC_O, KC_D)) {
send_unicode_string("ಠ__ಠ"); send_unicode_string("ಠ__ಠ");
} }
SEQ_THREE_KEYS(KC_M, KC_A, KC_P) { if (leader_sequence_three_keys(KC_M, KC_A, KC_P)) {
SEND_STRING("https://github.com/qmk/qmk_firmware/tree/master/users/arkag"); SEND_STRING("https://github.com/qmk/qmk_firmware/tree/master/users/arkag");
} }
SEQ_TWO_KEYS(KC_F, KC_F) { if (leader_sequence_two_keys(KC_F, KC_F)) {
send_unicode_string("(╯‵Д′)╯彡┻━┻"); send_unicode_string("(╯‵Д′)╯彡┻━┻");
} }
SEQ_THREE_KEYS(KC_F, KC_F, KC_F) { if (leader_sequence_three_keys(KC_F, KC_F, KC_F)) {
send_unicode_string("┬─┬ノ( º _ º )"); send_unicode_string("┬─┬ノ( º _ º )");
} }
SEQ_THREE_KEYS(KC_L, KC_O, KC_L) { if (leader_sequence_three_keys(KC_L, KC_O, KC_L)) {
send_unicode_string("( ͡° ͜ʖ ͡°)"); send_unicode_string("( ͡° ͜ʖ ͡°)");
} }
SEQ_THREE_KEYS(KC_S, KC_S, KC_S) { if (leader_sequence_three_keys(KC_S, KC_S, KC_S)) {
send_unicode_string("¯\\_(ツ)_/¯"); send_unicode_string("¯\\_(ツ)_/¯");
} }
// end typing functions // end typing functions
} }
void matrix_init_user(void) {
current_os = eeprom_read_byte(EECONFIG_USERSPACE);
set_os(current_os, false);
}
void matrix_scan_user(void) {
check_state();
flash_rgb();
fade_rgb();
} }
bool process_record_user(uint16_t keycode, keyrecord_t *record) { bool process_record_user(uint16_t keycode, keyrecord_t *record) {

View File

@ -1,24 +0,0 @@
#include "curry.h"
#include "leader.h"
LEADER_EXTERNS();
void matrix_scan_user(void) {
static bool has_ran_yet;
if (!has_ran_yet) {
has_ran_yet = true;
startup_user();
}
#if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
matrix_scan_rgb();
#endif // RGBLIGHT_ENABLE
LEADER_DICTIONARY() {
leading = false;
leader_end();
SEQ_ONE_KEY(KC_F) { SEND_STRING(SS_LCTL("akf")); } // Select all and format
SEQ_ONE_KEY(KC_P) { SEND_STRING(SS_LCTL(SS_LSFT("4"))); } // Screenshot region
SEQ_TWO_KEYS(KC_D, KC_D) { SEND_STRING(SS_LCTL("ac")); } // Copy all
}
matrix_scan_keymap();
}

View File

@ -0,0 +1,31 @@
#include "curry.h"
#include "leader_user.h"
void leader_end_user(void) {
if (leader_sequence_one_key(KC_F)) {
// Select all and format
SEND_STRING(SS_LCTL("akf"));
}
if (leader_sequence_one_key(KC_P)) {
// Screenshot region
SEND_STRING(SS_LCTL(SS_LSFT("4")));
}
if (leader_sequence_two_keys(KC_D, KC_D)) {
// Copy all
SEND_STRING(SS_LCTL("ac"));
}
}
void matrix_scan_user(void) {
static bool has_ran_yet;
if (!has_ran_yet) {
has_ran_yet = true;
startup_user();
}
#if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
matrix_scan_rgb();
#endif // RGBLIGHT_ENABLE
matrix_scan_keymap();
}

View File

@ -29,7 +29,7 @@ ifeq ($(strip $(OLED_ENABLE)), yes)
endif endif
ifeq ($(strip $(LEADER_ENABLE)), yes) ifeq ($(strip $(LEADER_ENABLE)), yes)
SRC += leader.c SRC += leader_user.c
endif endif
ifeq ($(strip $(RGBLIGHT_ENABLE)), yes) ifeq ($(strip $(RGBLIGHT_ENABLE)), yes)

View File

@ -4,32 +4,48 @@ bool onMac = true;
//**************** LEADER *********************// //**************** LEADER *********************//
#ifdef LEADER_ENABLE #ifdef LEADER_ENABLE
LEADER_EXTERNS(); void leader_start_user(vodi) {
# ifdef RGBLIGHT_ENABLE # ifdef RGBLIGHT_ENABLE
rgblight_setrgb_range(5, 100, 199, 10, 15);
void leader_start_user(void) { rgblight_setrgb_range(5, 100, 199, 10, 15); };
void leader_end_user(void) { rgblight_setrgb_range(200, 200, 255, 10, 15); };
# endif # endif
}
void matrix_scan_user(void) { void leader_end_user() {
if (leading && leader_sequence_size > 0 && timer_elapsed(leader_time) > LEADER_TIMEOUT) { if (leader_sequence_one_key(KC_T)) {
leading = false; SEND_STRING("``" SS_TAP(X_LEFT));
SEQ_ONE_KEY(KC_T) { SEND_STRING("``" SS_TAP(X_LEFT)); } }
// Triple ticks // Triple ticks
SEQ_TWO_KEYS(KC_T, KC_T) { SEND_STRING("```" SS_TAP(X_ENTER) SS_TAP(X_ENTER) "```" SS_TAP(X_UP)); } if (leader_sequence_two_keys(KC_T, KC_T)) {
SEND_STRING("```" SS_TAP(X_ENTER) SS_TAP(X_ENTER) "```" SS_TAP(X_UP));
}
// ==== International spanish accent vowels ==== // ==== International spanish accent vowels ====
SEQ_ONE_KEY(KC_A) { SEND_STRING(SS_LALT("e") "a"); } if (leader_sequence_one_key(KC_A)) {
SEQ_ONE_KEY(KC_E) { SEND_STRING(SS_LALT("e") "e"); } SEND_STRING(SS_LALT("e") "a");
SEQ_ONE_KEY(KC_I) { SEND_STRING(SS_LALT("e") "i"); } }
SEQ_ONE_KEY(KC_O) { SEND_STRING(SS_LALT("e") "o"); } if (leader_sequence_one_key(KC_E)) {
SEQ_ONE_KEY(KC_U) { SEND_STRING(SS_LALT("e") "u"); } SEND_STRING(SS_LALT("e") "e");
SEQ_ONE_KEY(KC_N) { SEND_STRING(SS_LALT("n") "n"); } }
if (leader_sequence_one_key(KC_I)) {
SEND_STRING(SS_LALT("e") "i");
}
if (leader_sequence_one_key(KC_O)) {
SEND_STRING(SS_LALT("e") "o");
}
if (leader_sequence_one_key(KC_U)) {
SEND_STRING(SS_LALT("e") "u");
}
if (leader_sequence_one_key(KC_N)) {
SEND_STRING(SS_LALT("n") "n");
}
// ==== MACROS === // ==== MACROS ===
SEQ_ONE_KEY(KC_G) { SEND_STRING(" | grep "); } if (leader_sequence_one_key(KC_G)) {
SEQ_ONE_KEY(KC_K) { onMac ? SEND_STRING(SS_LCTL(" ")) : SEND_STRING(SS_LCTL("f")); } SEND_STRING(" | grep ");
}
if (leader_sequence_one_key(KC_K)) {
onMac ? SEND_STRING(SS_LCTL(" ")) : SEND_STRING(SS_LCTL("f"));
}
// vim delete all // vim delete all
SEQ_TWO_KEYS(KC_D, KC_G) { if (leader_sequence_two_keys(KC_D, KC_G)) {
if (onMac) { if (onMac) {
SEND_STRING(SS_LGUI("a") SS_TAP(X_D)); SEND_STRING(SS_LGUI("a") SS_TAP(X_D));
} else { } else {
@ -37,38 +53,52 @@ void matrix_scan_user(void) {
} }
} }
// tripe delete! // tripe delete!
SEQ_ONE_KEY(KC_BACKSPACE) { SEND_STRING(SS_TAP(X_BACKSPACE) SS_TAP(X_BACKSPACE) SS_TAP(X_BACKSPACE)); } if (leader_sequence_one_key(KC_BACKSPACE)) {
SEQ_TWO_KEYS(KC_P, KC_G) { SEND_STRING("ps -ef | grep "); } SEND_STRING(SS_TAP(X_BACKSPACE) SS_TAP(X_BACKSPACE) SS_TAP(X_BACKSPACE));
SEQ_TWO_KEYS(KC_J, KC_A) { SEND_STRING("() => {}" SS_TAP(X_LEFT) SS_TAP(X_LEFT) SS_TAP(X_LEFT) SS_TAP(X_LEFT) SS_TAP(X_LEFT) SS_TAP(X_LEFT) SS_TAP(X_LEFT)); } }
if (leader_sequence_two_keys(KC_P, KC_G)) {
SEND_STRING("ps -ef | grep ");
}
if (leader_sequence_two_keys(KC_J, KC_A)) {
SEND_STRING("() => {}" SS_TAP(X_LEFT) SS_TAP(X_LEFT) SS_TAP(X_LEFT) SS_TAP(X_LEFT) SS_TAP(X_LEFT) SS_TAP(X_LEFT) SS_TAP(X_LEFT));
}
// this is a pain to type // this is a pain to type
SEQ_TWO_KEYS(KC_S, KC_S) { SEND_STRING("~/.ssh/ "); } if (leader_sequence_two_keys(KC_S, KC_S)) {
SEQ_TWO_KEYS(KC_F, KC_T) { SEND_STRING("feat():" SS_TAP(X_LEFT) SS_TAP(X_LEFT)); } SEND_STRING("~/.ssh/ ");
}
if (leader_sequence_two_keys(KC_F, KC_T)) {
SEND_STRING("feat():" SS_TAP(X_LEFT) SS_TAP(X_LEFT));
}
// ### LAYER CHANGE // ### LAYER CHANGE
SEQ_ONE_KEY(KC_1) { layer_on(1); } if (leader_sequence_one_key(KC_1)) {
layer_on(1);
}
// control enter, because yes // control enter, because yes
SEQ_ONE_KEY(KC_H) { SEND_STRING(SS_DOWN(X_LCTL) SS_TAP(X_ENTER) SS_UP(X_LCTL)); } if (leader_sequence_one_key(KC_H)) {
SEND_STRING(SS_DOWN(X_LCTL) SS_TAP(X_ENTER) SS_UP(X_LCTL));
}
// paste all // paste all
SEQ_ONE_KEY(KC_P) { if (leader_sequence_one_key(KC_P)) {
if (onMac) { if (onMac) {
SEND_STRING(SS_LGUI("a") SS_LGUI("v")); SEND_STRING(SS_LGUI("a") SS_LGUI("v"));
} else { } else {
SEND_STRING(SS_LCTL("a") SS_LCTL("v")); SEND_STRING(SS_LCTL("a") SS_LCTL("v"));
} }
} }
SEQ_THREE_KEYS(KC_M, KC_A, KC_C) { if (leader_sequence_three_keys(KC_M, KC_A, KC_C)) {
onMac = true; onMac = true;
# ifdef RGBLIGHT_ENABLE # ifdef RGBLIGHT_ENABLE
rgblight_setrgb(255, 255, 255); rgblight_setrgb(255, 255, 255);
# endif # endif
} }
SEQ_THREE_KEYS(KC_W, KC_I, KC_N) { if (leader_sequence_three_keys(KC_W, KC_I, KC_N)) {
onMac = false; onMac = false;
# ifdef RGBLIGHT_ENABLE # ifdef RGBLIGHT_ENABLE
rgblight_setrgb(255, 255, 0); rgblight_setrgb(255, 255, 0);
# endif # endif
} }
/* Copy all */ /* Copy all */
SEQ_ONE_KEY(KC_Y) { if (leader_sequence_one_key(KC_Y)) {
if (onMac) { if (onMac) {
SEND_STRING(SS_LGUI("a") SS_LGUI("c")); SEND_STRING(SS_LGUI("a") SS_LGUI("c"));
} else { } else {
@ -76,12 +106,19 @@ void matrix_scan_user(void) {
} }
} }
// emoji bar // emoji bar
SEQ_TWO_KEYS(KC_E, KC_E) { SEND_STRING(SS_DOWN(X_LGUI) SS_LCTL(" ") SS_UP(X_LGUI)); } if (leader_sequence_two_keys(KC_E, KC_E)) {
SEND_STRING(SS_DOWN(X_LGUI) SS_LCTL(" ") SS_UP(X_LGUI));
SEQ_TWO_KEYS(KC_F, KC_F) { SEND_STRING("ps -ef | grep "); }
SEQ_TWO_KEYS(KC_H, KC_T) { SEND_STRING("https://"); }
leader_end();
} }
if (leader_sequence_two_keys(KC_F, KC_F)) {
SEND_STRING("ps -ef | grep ");
}
if (leader_sequence_two_keys(KC_H, KC_T)) {
SEND_STRING("https://");
}
# ifdef RGBLIGHT_ENABLE
rgblight_setrgb_range(200, 200, 255, 10, 15);
# endif
} }
#endif // LEADER #endif // LEADER

View File

@ -23,25 +23,21 @@ __attribute__((weak)) void matrix_scan_keymap(void) {}
__attribute__((weak)) void leader_scan_secrets(void) {} __attribute__((weak)) void leader_scan_secrets(void) {}
#ifdef LEADER_ENABLE #ifdef LEADER_ENABLE
LEADER_EXTERNS(); void leader_end_user(void) {
void matrix_scan_leader(void) {
static uint8_t mods = 0; static uint8_t mods = 0;
mods = get_mods(); mods = get_mods();
LEADER_DICTIONARY() {
leading = false;
leader_end();
clear_mods(); clear_mods();
// Website Refresh / XCode "Run" // Website Refresh / XCode "Run"
SEQ_ONE_KEY(KC_R) { if (leader_sequence_one_key(KC_R)) {
SEND_STRING(SS_LGUI("r")); SEND_STRING(SS_LGUI("r"));
} }
SEQ_TWO_KEYS(KC_B, KC_D) { if (leader_sequence_two_keys(KC_B, KC_D)) {
send_string_with_delay_P(PSTR(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION " Built at: " QMK_BUILDDATE), TAP_CODE_DELAY); send_string_with_delay_P(PSTR(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION " Built at: " QMK_BUILDDATE), TAP_CODE_DELAY);
} }
SEQ_TWO_KEYS(KC_L, KC_C) { if (leader_sequence_two_keys(KC_L, KC_C)) {
send_string_with_delay("/** */", TAP_CODE_DELAY); send_string_with_delay("/** */", TAP_CODE_DELAY);
wait_ms(TAPPING_TERM); wait_ms(TAPPING_TERM);
tap_code(KC_LEFT); tap_code(KC_LEFT);
@ -57,7 +53,6 @@ __attribute__((weak)) void leader_scan_secrets(void) {}
leader_scan_secrets(); leader_scan_secrets();
#endif // !NO_SECRETS #endif // !NO_SECRETS
} }
}
#endif #endif
static bool is_first_run = true; static bool is_first_run = true;
@ -66,9 +61,7 @@ void matrix_scan_user(void) {
is_first_run = false; is_first_run = false;
startup_user(); startup_user();
} }
#ifdef LEADER_ENABLE
matrix_scan_leader();
#endif
matrix_scan_keymap(); matrix_scan_keymap();
} }

View File

@ -53,81 +53,70 @@ void tmux_pane_zoom(void) {
SEND_STRING("z"); SEND_STRING("z");
} }
LEADER_EXTERNS(); void leader_end_user(void) {
void matrix_scan_user(void) {
LEADER_DICTIONARY() {
leading = false;
leader_end();
// Available seqs
// SEQ_ONE_KEY, SEQ_TWO_KEYS, SEQ_THREE_KEYS
// anything you can do in a macro https://docs.qmk.fm/macros.html
// https://docs.qmk.fm/feature_leader_key.html
// Stop music and lock computer via alfred // Stop music and lock computer via alfred
SEQ_ONE_KEY(KC_H) { if (leader_sequence_one_key(KC_H)) {
SEND_STRING(SS_LGUI(" ") SS_TAP(X_LGUI) "afk" SS_TAP(X_ENTER)); SEND_STRING(SS_LGUI(" ") SS_TAP(X_LGUI) "afk" SS_TAP(X_ENTER));
} }
// Stop music and lock computer via alfred // Stop music and lock computer via alfred
SEQ_TWO_KEYS(KC_H, KC_H) { if (leader_sequence_two_keys(KC_H, KC_H)) {
SEND_STRING(SS_LGUI(" ") SS_TAP(X_LGUI) "afk" SS_TAP(X_ENTER) SS_TAP(X_MEDIA_PLAY_PAUSE)); SEND_STRING(SS_LGUI(" ") SS_TAP(X_LGUI) "afk" SS_TAP(X_ENTER) SS_TAP(X_MEDIA_PLAY_PAUSE));
} }
// Whole Screen Shot // Whole Screen Shot
SEQ_ONE_KEY(KC_A) { if (leader_sequence_one_key(KC_A)) {
SEND_STRING(SS_LGUI(SS_LSFT("3"))); SEND_STRING(SS_LGUI(SS_LSFT("3")));
} }
// Selective Screen Shot // Selective Screen Shot
SEQ_ONE_KEY(KC_S) { if (leader_sequence_one_key(KC_S)) {
SEND_STRING(SS_LGUI(SS_LSFT("4"))); SEND_STRING(SS_LGUI(SS_LSFT("4")));
} }
// TMUX - shift to pane 1 and zoom // TMUX - shift to pane 1 and zoom
SEQ_ONE_KEY(KC_J) { if (leader_sequence_one_key(KC_J)) {
tmux_prefix(); tmux_prefix();
SEND_STRING("q1"); SEND_STRING("q1");
tmux_pane_zoom(); tmux_pane_zoom();
} }
// TMUX - shift to first window // TMUX - shift to first window
SEQ_TWO_KEYS(KC_J, KC_J) { if (leader_sequence_two_keys(KC_J, KC_J)) {
tmux_prefix(); tmux_prefix();
SEND_STRING("1"); SEND_STRING("1");
} }
// TMUX - shift to pane 2 and zoom // TMUX - shift to pane 2 and zoom
SEQ_ONE_KEY(KC_K) { if (leader_sequence_one_key(KC_K)) {
tmux_prefix(); tmux_prefix();
SEND_STRING("q2"); SEND_STRING("q2");
tmux_pane_zoom(); tmux_pane_zoom();
} }
// TMUX - shift to second window // TMUX - shift to second window
SEQ_TWO_KEYS(KC_K, KC_K) { if (leader_sequence_two_keys(KC_K, KC_K)) {
tmux_prefix(); tmux_prefix();
SEND_STRING("2"); SEND_STRING("2");
} }
// TMUX - shift to pane 3 and zoom // TMUX - shift to pane 3 and zoom
SEQ_ONE_KEY(KC_L) { if (leader_sequence_one_key(KC_L)) {
tmux_prefix(); tmux_prefix();
SEND_STRING("q3"); SEND_STRING("q3");
tmux_pane_zoom(); tmux_pane_zoom();
} }
// TMUX - shift to third window // TMUX - shift to third window
SEQ_TWO_KEYS(KC_L, KC_L) { if (leader_sequence_two_keys(KC_L, KC_L)) {
tmux_prefix(); tmux_prefix();
SEND_STRING("3"); SEND_STRING("3");
} }
// TMUX - shift to last pane and zoom // TMUX - shift to last pane and zoom
SEQ_ONE_KEY(KC_SEMICOLON) { if (leader_sequence_one_key(KC_SEMICOLON)) {
tmux_prefix(); tmux_prefix();
SEND_STRING(";"); SEND_STRING(";");
tmux_pane_zoom(); tmux_pane_zoom();
} }
} }
}

View File

@ -1,116 +0,0 @@
#include "leader.h"
#ifdef RGBLIGHT_ENABLE
extern rgblight_config_t rgblight_config;
#endif
bool leader_succeed;
LEADER_EXTERNS();
void matrix_scan_user(void) {
static bool has_ran_yet;
if (!has_ran_yet) {
has_ran_yet = true;
startup_user();
}
#ifdef TAP_DANCE_ENABLE // Run Diablo 3 macro checking code.
// run_diablo_macro_check();
#endif
#ifdef RGBLIGHT_ENABLE
matrix_scan_rgb();
#endif
LEADER_DICTIONARY() {
leader_succeed = leading = false;
SEQ_ONE_KEY(KC_W) {
// vim/tmux: Use in command mode in vim: write to file, switch tmux pane in the current session window and repeat the last command
SEND_STRING(":w" SS_TAP(X_ENTER));
tmux_pane_switch_repeat();
leader_succeed = true;
} else
SEQ_ONE_KEY(KC_T) {
// Send the Tmux Prefix
tmux_prefix();
leader_succeed = true;
} else
SEQ_ONE_KEY(KC_A) {
// tmux: Send the prefix and press 'right' arrow
tmux_prefix();
tap_code(KC_RIGHT);
leader_succeed = true;
} else
SEQ_TWO_KEYS(KC_T, KC_T) {
// tmux: Send the prefix to a nested session
tmux_prefix();
tmux_prefix();
leader_succeed = true;
} else
SEQ_TWO_KEYS(KC_T, KC_R) {
// tmux: Switch pane and repeat last action
tmux_pane_switch_repeat();
leader_succeed = true;
} else
SEQ_TWO_KEYS(KC_V, KC_Z){
// vim: Zoom pane
tap_code16(LCTL(KC_W));
tap_code16(LSFT(KC_BSLS));
leader_succeed = true;
} else
SEQ_TWO_KEYS(KC_V, KC_R) {
// vim: Substitute and place cursor
SEND_STRING(":%s///g" SS_TAP(X_LEFT));
tap_code(KC_LEFT);
tap_code(KC_LEFT);
leader_succeed = true;
} else
SEQ_TWO_KEYS(KC_V, KC_T) {
// vim: move current pane to new tab
tap_code16(LCTL(KC_W));
tap_code16(LSFT(KC_T));
leader_succeed = true;
} else
SEQ_ONE_KEY(KC_R){
// Toggle RGB Layer indicator
tap_code16(KC_RGB_T);
leader_succeed = true;
} else
SEQ_ONE_KEY(KC_SPC){
// One Shot Unicode layer
//TODO tap_code16(OS_UNI);
leader_succeed = true;
} else
SEQ_TWO_KEYS(KC_SPC, KC_SPC){
// Toggle _MODS
tap_code16(TG_MODS);
leader_succeed = true;
} else
SEQ_THREE_KEYS(KC_BSPC, KC_BSPC, KC_BSPC){
// Reset the keyboard
reset_keyboard();
leader_succeed = true;
}
leader_end();
}
// matrix_scan_keymap();
}
void leader_start_user(void) {
#ifdef RGBLIGHT_ENABLE
rgblight_savebase();
rgblight_mode_noeeprom(1);
rgblight_sethsv_noeeprom(HSV_GOLDENROD);
#endif
}
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
// fade old color from 0 to 100
#ifdef RGBLIGHT_ENABLE
if (leader_succeed) {
fadeflash_leds(HSV_GREEN);
} else {
fadeflash_leds(HSV_RED);
}
#endif
}

View File

@ -0,0 +1,113 @@
#include "leader_user.h"
#ifdef RGBLIGHT_ENABLE
extern rgblight_config_t rgblight_config;
#endif
bool leader_succeed;
void matrix_scan_user(void) {
static bool has_ran_yet;
if (!has_ran_yet) {
has_ran_yet = true;
startup_user();
}
#ifdef TAP_DANCE_ENABLE // Run Diablo 3 macro checking code.
// run_diablo_macro_check();
#endif
#ifdef RGBLIGHT_ENABLE
matrix_scan_rgb();
#endif
// matrix_scan_keymap();
}
void leader_start_user(void) {
#ifdef RGBLIGHT_ENABLE
rgblight_savebase();
rgblight_mode_noeeprom(1);
rgblight_sethsv_noeeprom(HSV_GOLDENROD);
#endif
}
void leader_end_user(void) {
leader_succeed = false;
if (leader_sequence_one_key(KC_W)) {
// vim/tmux: Use in command mode in vim: write to file, switch tmux pane in the current session window and repeat the last command
SEND_STRING(":w" SS_TAP(X_ENTER));
tmux_pane_switch_repeat();
leader_succeed = true;
} else
if (leader_sequence_one_key(KC_T)) {
// Send the Tmux Prefix
tmux_prefix();
leader_succeed = true;
} else
if (leader_sequence_one_key(KC_A)) {
// tmux: Send the prefix and press 'right' arrow
tmux_prefix();
tap_code(KC_RIGHT);
leader_succeed = true;
} else
if (leader_sequence_two_keys(KC_T, KC_T)) {
// tmux: Send the prefix to a nested session
tmux_prefix();
tmux_prefix();
leader_succeed = true;
} else
if (leader_sequence_two_keys(KC_T, KC_R)) {
// tmux: Switch pane and repeat last action
tmux_pane_switch_repeat();
leader_succeed = true;
} else
if (leader_sequence_two_keys(KC_V, KC_Z)){
// vim: Zoom pane
tap_code16(LCTL(KC_W));
tap_code16(LSFT(KC_BSLS));
leader_succeed = true;
} else
if (leader_sequence_two_keys(KC_V, KC_R)) {
// vim: Substitute and place cursor
SEND_STRING(":%s///g" SS_TAP(X_LEFT));
tap_code(KC_LEFT);
tap_code(KC_LEFT);
leader_succeed = true;
} else
if (leader_sequence_two_keys(KC_V, KC_T)) {
// vim: move current pane to new tab
tap_code16(LCTL(KC_W));
tap_code16(LSFT(KC_T));
leader_succeed = true;
} else
if (leader_sequence_one_key(KC_R)){
// Toggle RGB Layer indicator
tap_code16(KC_RGB_T);
leader_succeed = true;
} else
if (leader_sequence_one_key(KC_SPC)){
// One Shot Unicode layer
//TODO tap_code16(OS_UNI);
leader_succeed = true;
} else
if (leader_sequence_two_keys(KC_SPC, KC_SPC)){
// Toggle _MODS
tap_code16(TG_MODS);
leader_succeed = true;
} else
if (leader_sequence_three_keys(KC_BSPC, KC_BSPC, KC_BSPC)){
// Reset the keyboard
reset_keyboard();
leader_succeed = true;
}
// pick color depending of success /fail
// fade leader_start from 100 to 0
// fade new color from 0 to 100 to 0
// fade old color from 0 to 100
#ifdef RGBLIGHT_ENABLE
if (leader_succeed) {
fadeflash_leds(HSV_GREEN);
} else {
fadeflash_leds(HSV_RED);
}
#endif
}

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "kuchosauronad0.h" #include "kuchosauronad0.h"
#include "leader.h" #include "leader_user.h"
void matrix_scan_user(void); void matrix_scan_user(void);

View File

@ -38,7 +38,7 @@ TODO: Make use of `TD_SPC` and `TD_QT{1..3}`
## [Leader Key](#leader-key) ## [Leader Key](#leader-key)
To enable set `LEADER_ENABLE = yes` in file *rules.mk* To enable set `LEADER_ENABLE = yes` in file *rules.mk*
|LEADER_DICTIONARY()|program| description | |Leader sequence|program| description |
|---|---|---| |---|---|---|
| W |vim/tmux| save file, switch pane and repeat last command | | W |vim/tmux| save file, switch pane and repeat last command |
| T |tmux| send default prefix | | T |tmux| send default prefix |
@ -50,7 +50,7 @@ To enable set `LEADER_ENABLE = yes` in file *rules.mk*
|V + T|vim | move current split to its own tab| |V + T|vim | move current split to its own tab|
|3x Backspace|keyboard| Reset Keyboard | |3x Backspace|keyboard| Reset Keyboard |
`LEADER_DICTIONARY()` is defined in *leader.c* Leader sequences are defined in *leader_user.c*
## [Combo Keys](#combo-keys) ## [Combo Keys](#combo-keys)
To enable set `COMBO_ENABLE = yes` in file *rules.mk*. To enable set `COMBO_ENABLE = yes` in file *rules.mk*.

View File

@ -145,7 +145,7 @@ void rgblight_fade_helper(bool direction){
void fadeflash_leds(uint8_t hue, uint8_t sat, uint8_t val){ void fadeflash_leds(uint8_t hue, uint8_t sat, uint8_t val){
// indicate success / fail of a leader sequence // indicate success / fail of a leader sequence
// fade out, set new hue and saturation, fade in, fade out, set old color, fade in // fade out, set new hue and saturation, fade in, fade out, set old color, fade in
// this is used in leader.c // this is used in leader_user.c
// TODO: come up with a better name maybe // TODO: come up with a better name maybe
rgblight_fade_helper(false); rgblight_fade_helper(false);
rgblight_sethsv_noeeprom(hue, sat, 0); rgblight_sethsv_noeeprom(hue, sat, 0);

View File

@ -21,7 +21,7 @@ ifeq ($(strip $(COMBO_ENABLE)), yes)
endif endif
ifeq ($(strip $(LEADER_ENABLE)), yes) ifeq ($(strip $(LEADER_ENABLE)), yes)
SRC += leader.c SRC += leader_user.c
endif endif
ifneq ("$(wildcard $(USER_PATH)/secrets.c)","") ifneq ("$(wildcard $(USER_PATH)/secrets.c)","")

View File

@ -90,28 +90,21 @@ void store_userspace_config(void) {
eeconfig_update_user(stored_userspace_config.raw); eeconfig_update_user(stored_userspace_config.raw);
} }
LEADER_EXTERNS(); void leader_end_user(void) {
if (leader_sequence_two_keys(KC_F1, KC_L)) {
void matrix_scan_user(void) {
LEADER_DICTIONARY() {
leading = false;
leader_end();
SEQ_TWO_KEYS(KC_F1, KC_L) {
set_os(_OS_LINUX); set_os(_OS_LINUX);
} }
SEQ_TWO_KEYS(KC_F1, KC_M) { if (leader_sequence_two_keys(KC_F1, KC_M)) {
set_os(_OS_MACOS); set_os(_OS_MACOS);
} }
SEQ_TWO_KEYS(KC_F1, KC_W) { if (leader_sequence_two_keys(KC_F1, KC_W)) {
set_os(_OS_WINDOWS); set_os(_OS_WINDOWS);
} }
SEQ_TWO_KEYS(KC_F1, KC_S) { if (leader_sequence_two_keys(KC_F1, KC_S)) {
stored_userspace_config.raw = runtime_userspace_config.raw; stored_userspace_config.raw = runtime_userspace_config.raw;
store_userspace_config(); store_userspace_config();
} }
} }
}
bool process_record_user(uint16_t keycode, keyrecord_t *record) { bool process_record_user(uint16_t keycode, keyrecord_t *record) {
uint8_t os_target = runtime_userspace_config.os_target; uint8_t os_target = runtime_userspace_config.os_target;

View File

@ -534,44 +534,37 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
} }
#ifdef LEADER_ENABLE #ifdef LEADER_ENABLE
LEADER_EXTERNS(); void leader_end_user(void) {
void matrix_scan_user(void) {
LEADER_DICTIONARY() {
leading = false;
leader_end();
#ifdef UCIS_ENABLE #ifdef UCIS_ENABLE
SEQ_ONE_KEY(KC_U) { if (leader_sequence_one_key(KC_U)) {
ucis_start(); ucis_start();
} }
#endif #endif
SEQ_ONE_KEY(KC_H) { if (leader_sequence_one_key(KC_H)) {
send_unicode_string("ᕕ( ᐛ )ᕗ"); // happy send_unicode_string("ᕕ( ᐛ )ᕗ"); // happy
} }
SEQ_ONE_KEY(KC_D) { if (leader_sequence_one_key(KC_D)) {
send_unicode_string("ಠ_ಠ"); // disapproval send_unicode_string("ಠ_ಠ"); // disapproval
} }
SEQ_ONE_KEY(KC_L) { if (leader_sequence_one_key(KC_L)) {
send_unicode_string("( ͡° ͜ʖ ͡°)"); // lenny send_unicode_string("( ͡° ͜ʖ ͡°)"); // lenny
} }
SEQ_ONE_KEY(KC_S) { if (leader_sequence_one_key(KC_S)) {
send_unicode_string("¯\\_(ツ)_/¯"); // shrug send_unicode_string("¯\\_(ツ)_/¯"); // shrug
} }
// tableflip (LEADER - TF) // tableflip (LEADER - TF)
SEQ_TWO_KEYS(KC_T, KC_F) { if (leader_sequence_two_keys(KC_T, KC_F)) {
//set_unicode_input_mode(UNICODE_MODE_LINUX); //set_unicode_input_mode(UNICODE_MODE_LINUX);
//send_unicode_hex_string("0028 30CE 0CA0 75CA 0CA0 0029 30CE 5F61 253B 2501 253B"); //send_unicode_hex_string("0028 30CE 0CA0 75CA 0CA0 0029 30CE 5F61 253B 2501 253B");
send_unicode_string("(╯°□°)╯︵ ┻━┻"); send_unicode_string("(╯°□°)╯︵ ┻━┻");
} }
// untableflip // untableflip
SEQ_THREE_KEYS(KC_U, KC_T, KC_F) { if (leader_sequence_three_keys(KC_U, KC_T, KC_F)) {
//set_unicode_input_mode(UNICODE_MODE_LINUX); //set_unicode_input_mode(UNICODE_MODE_LINUX);
//send_unicode_hex_string("0028 30CE 0CA0 75CA 0CA0 0029 30CE 5F61 253B 2501 253B"); //send_unicode_hex_string("0028 30CE 0CA0 75CA 0CA0 0029 30CE 5F61 253B 2501 253B");
send_unicode_string("┬─┬ノ( º _ ºノ)"); send_unicode_string("┬─┬ノ( º _ ºノ)");
} }
} }
}
#endif #endif
#ifdef UCIS_ENABLE #ifdef UCIS_ENABLE

View File

@ -1,46 +0,0 @@
#include "leader.h"
LEADER_EXTERNS();
// Runs constantly in the background, in a loop.
void matrix_scan_user(void){
#ifdef TAP_DANCE_ENABLE // Run Diablo 3 macro checking code.
// run_diablo_macro_check();
#endif // TAP_DANCE_ENABLE
#ifdef RGBLIGHT_ENABLE
matrix_scan_rgb();
#endif // RGBLIGHT_ENABLE
LEADER_DICTIONARY() {
leading = false;
leader_end();
SEQ_TWO_KEYS(KC_V, KC_Z){
// vim: Zoom pane
tap_code16(LCTL(KC_W));
tap_code16(LSFT(KC_BSLS));
}
SEQ_TWO_KEYS(KC_V, KC_R) {
// vim: Substitute and place cursor
SEND_STRING(":%s///g" SS_TAP(X_LEFT));
tap_code(KC_LEFT);
tap_code(KC_LEFT);
}
SEQ_TWO_KEYS(KC_V, KC_T) {
// vim: move current pane to new tab
tap_code16(LCTL(KC_W));
tap_code16(LSFT(KC_T));
}
SEQ_THREE_KEYS(KC_BSPC, KC_BSPC, KC_BSPC){
// Reset the keyboard
reset_keyboard();
}
}
matrix_scan_keymap();
}

View File

@ -0,0 +1,41 @@
#include "leader_user.h"
void leader_end_user(void) {
if (leader_sequence_two_keys(KC_V, KC_Z)){
// vim: Zoom pane
tap_code16(LCTL(KC_W));
tap_code16(LSFT(KC_BSLS));
}
if (leader_sequence_two_keys(KC_V, KC_R)) {
// vim: Substitute and place cursor
SEND_STRING(":%s///g" SS_TAP(X_LEFT));
tap_code(KC_LEFT);
tap_code(KC_LEFT);
}
if (leader_sequence_two_keys(KC_V, KC_T)) {
// vim: move current pane to new tab
tap_code16(LCTL(KC_W));
tap_code16(LSFT(KC_T));
}
if (leader_sequence_three_keys(KC_BSPC, KC_BSPC, KC_BSPC)){
// Reset the keyboard
reset_keyboard();
}
}
// Runs constantly in the background, in a loop.
void matrix_scan_user(void){
#ifdef TAP_DANCE_ENABLE // Run Diablo 3 macro checking code.
// run_diablo_macro_check();
#endif // TAP_DANCE_ENABLE
#ifdef RGBLIGHT_ENABLE
matrix_scan_rgb();
#endif // RGBLIGHT_ENABLE
matrix_scan_keymap();
}

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "yet-another-developer.h" #include "yet-another-developer.h"
#include "leader.h" #include "leader_user.h"
void matrix_scan_user(void); void matrix_scan_user(void);

View File

@ -14,7 +14,7 @@ endif
ifeq ($(strip $(LEADER_ENABLE)), yes) ifeq ($(strip $(LEADER_ENABLE)), yes)
SRC += leader.c SRC += leader_user.c
endif endif