diff options
| -rw-r--r-- | docs/feature_swap_hands.md | 21 | ||||
| -rw-r--r-- | docs/keycodes.md | 12 | ||||
| -rw-r--r-- | keyboards/planck/keymaps/experimental/keymap.c | 11 | ||||
| -rw-r--r-- | quantum/keymap_common.c | 6 | ||||
| -rw-r--r-- | quantum/quantum_keycodes.h | 14 |
5 files changed, 46 insertions, 18 deletions
diff --git a/docs/feature_swap_hands.md b/docs/feature_swap_hands.md index 61c66a2c1..92e8e3b10 100644 --- a/docs/feature_swap_hands.md +++ b/docs/feature_swap_hands.md | |||
| @@ -17,15 +17,14 @@ const keypos_t hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = { | |||
| 17 | 17 | ||
| 18 | Note that the array indices are reversed same as the matrix and the values are of type `keypos_t` which is `{col, row}` and all values are zero-based. In the example above, `hand_swap_config[2][4]` (third row, fifth column) would return `{7, 2}` (third row, eighth column). Yes, this is confusing. | 18 | Note that the array indices are reversed same as the matrix and the values are of type `keypos_t` which is `{col, row}` and all values are zero-based. In the example above, `hand_swap_config[2][4]` (third row, fifth column) would return `{7, 2}` (third row, eighth column). Yes, this is confusing. |
| 19 | 19 | ||
| 20 | ## Advanced Swap Commands | 20 | ## Swap Keycodes |
| 21 | 21 | ||
| 22 | |Macro | Description | | 22 | |Key |Description | |
| 23 | |------|-------------| | 23 | |-----------|-------------------------------------------------------------------------| |
| 24 | | `ACTION_SWAP_HANDS()` | Swaps hands when pressed, returns to normal when released (momentary). | | 24 | |`SH_T(key)`|Sends `key` with a tap; momentary swap when held. | |
| 25 | | `ACTION_SWAP_HANDS_TOGGLE()` | Toggles swap on and off with every key press. | | 25 | |`SW_ON` |Turns on swapping and leaves it on. | |
| 26 | | `ACTION_SWAP_HANDS_TAP_TOGGLE()` | Toggles with a tap; momentary when held. | | 26 | |`SW_OFF` |Turn off swapping and leaves it off. Good for returning to a known state.| |
| 27 | | `ACTION_SWAP_HANDS_TAP_KEY(key)`| Sends `key` with a tap; momentary swap when held. | | 27 | |`SW_MON` |Swaps hands when pressed, returns to normal when released (momentary). | |
| 28 | | `ACTION_SWAP_HANDS_ON_OFF()` | Alias for `ACTION_SWAP_HANDS()` | | 28 | |`SW_MOFF` |Momentarily turns off swap. | |
| 29 | | `ACTION_SWAP_HANDS_OFF_ON()` | Momentarily turns off swap. | | 29 | |`SH_TG` |Toggles swap on and off with every key press. | |
| 30 | | `ACTION_SWAP_HANDS_ON()` | Turns on swapping and leaves it on. | | 30 | |`SH_TT` |Toggles with a tap; momentary when held. | |
| 31 | | `ACTION_SWAP_HANDS_OFF()` | Turn off swapping and leaves it off. Good for returning to a known state. | \ No newline at end of file | ||
diff --git a/docs/keycodes.md b/docs/keycodes.md index 030b23827..21a722250 100644 --- a/docs/keycodes.md +++ b/docs/keycodes.md | |||
| @@ -390,3 +390,15 @@ This is a reference only. Each group of keys links to the page documenting their | |||
| 390 | |------------|-------|-------------------------------------------------| | 390 | |------------|-------|-------------------------------------------------| |
| 391 | |`UNICODE(n)`|`UC(n)`|Send Unicode character `n` | | 391 | |`UNICODE(n)`|`UC(n)`|Send Unicode character `n` | |
| 392 | |`X(n)` | |Send Unicode character `n` via a different method| | 392 | |`X(n)` | |Send Unicode character `n` via a different method| |
| 393 | |||
| 394 | ## [Swap Hands](feature_swap_hands.md) | ||
| 395 | |||
| 396 | |Key |Description | | ||
| 397 | |-----------|-------------------------------------------------------------------------| | ||
| 398 | |`SH_T(key)`|Sends `key` with a tap; momentary swap when held. | | ||
| 399 | |`SW_ON` |Turns on swapping and leaves it on. | | ||
| 400 | |`SW_OFF` |Turn off swapping and leaves it off. Good for returning to a known state.| | ||
| 401 | |`SH_MON` |Swaps hands when pressed, returns to normal when released (momentary). | | ||
| 402 | |`SH_MOFF` |Momentarily turns off swap. | | ||
| 403 | |`SH_TG` |Toggles swap on and off with every key press. | | ||
| 404 | |`SH_TT` |Toggles with a tap; momentary when held. | | ||
diff --git a/keyboards/planck/keymaps/experimental/keymap.c b/keyboards/planck/keymaps/experimental/keymap.c index feeb137fa..8ddb3d465 100644 --- a/keyboards/planck/keymaps/experimental/keymap.c +++ b/keyboards/planck/keymaps/experimental/keymap.c | |||
| @@ -45,6 +45,7 @@ enum planck_keycodes { | |||
| 45 | // Fillers to make layering more clear | 45 | // Fillers to make layering more clear |
| 46 | #define _______ KC_TRNS | 46 | #define _______ KC_TRNS |
| 47 | #define XXXXXXX KC_NO | 47 | #define XXXXXXX KC_NO |
| 48 | #define SW_SPC SH_T(KC_SPC) | ||
| 48 | 49 | ||
| 49 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | 50 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { |
| 50 | [0] = { | 51 | [0] = { |
| @@ -69,7 +70,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
| 69 | {KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC}, | 70 | {KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC}, |
| 70 | {KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT}, | 71 | {KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT}, |
| 71 | {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT }, | 72 | {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT }, |
| 72 | {KC_LEAD, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_FN0, KC_FN0, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} | 73 | {KC_LEAD, KC_LCTL, KC_LALT, KC_LGUI, LOWER, SW_SPC, SW_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} |
| 73 | }, | 74 | }, |
| 74 | 75 | ||
| 75 | /* Colemak | 76 | /* Colemak |
| @@ -87,7 +88,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
| 87 | {KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC}, | 88 | {KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC}, |
| 88 | {KC_ESC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT}, | 89 | {KC_ESC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT}, |
| 89 | {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT }, | 90 | {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT }, |
| 90 | {KC_LEAD, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_FN0, KC_FN0, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} | 91 | {KC_LEAD, KC_LCTL, KC_LALT, KC_LGUI, LOWER, SW_SPC, SW_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} |
| 91 | }, | 92 | }, |
| 92 | 93 | ||
| 93 | /* Dvorak | 94 | /* Dvorak |
| @@ -105,7 +106,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
| 105 | {KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC}, | 106 | {KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC}, |
| 106 | {KC_ESC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH}, | 107 | {KC_ESC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH}, |
| 107 | {KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT }, | 108 | {KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT }, |
| 108 | {KC_LEAD, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_FN0, KC_FN0, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} | 109 | {KC_LEAD, KC_LCTL, KC_LALT, KC_LGUI, LOWER, SW_SPC, SW_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} |
| 109 | }, | 110 | }, |
| 110 | 111 | ||
| 111 | /* Lower | 112 | /* Lower |
| @@ -184,10 +185,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
| 184 | 185 | ||
| 185 | }; | 186 | }; |
| 186 | 187 | ||
| 187 | const uint16_t PROGMEM fn_actions[] = { | ||
| 188 | ACTION_SWAP_HANDS_TAP_KEY(KC_SPC), | ||
| 189 | }; | ||
| 190 | |||
| 191 | #ifdef AUDIO_ENABLE | 188 | #ifdef AUDIO_ENABLE |
| 192 | 189 | ||
| 193 | float tone_startup[][2] = SONG(STARTUP_SOUND); | 190 | float tone_startup[][2] = SONG(STARTUP_SOUND); |
diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index a0d4c1ddb..8b09f93fc 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c | |||
| @@ -146,6 +146,12 @@ action_t action_for_key(uint8_t layer, keypos_t key) | |||
| 146 | action.code = ACTION_BACKLIGHT_STEP(); | 146 | action.code = ACTION_BACKLIGHT_STEP(); |
| 147 | break; | 147 | break; |
| 148 | #endif | 148 | #endif |
| 149 | #ifdef SWAP_HANDS_ENABLE | ||
| 150 | case QK_SWAP_HANDS ... QK_SWAP_HANDS_MAX: | ||
| 151 | action.code = ACTION(ACT_SWAP_HANDS, keycode & 0xff); | ||
| 152 | break; | ||
| 153 | #endif | ||
| 154 | |||
| 149 | default: | 155 | default: |
| 150 | action.code = ACTION_NO; | 156 | action.code = ACTION_NO; |
| 151 | break; | 157 | break; |
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index a4ee4d6bb..9040299a7 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h | |||
| @@ -77,6 +77,10 @@ enum quantum_keycodes { | |||
| 77 | QK_STENO_GEMINI = 0x5A31, | 77 | QK_STENO_GEMINI = 0x5A31, |
| 78 | QK_STENO_MAX = 0x5A3F, | 78 | QK_STENO_MAX = 0x5A3F, |
| 79 | #endif | 79 | #endif |
| 80 | #ifdef SWAP_HANDS_ENABLE | ||
| 81 | QK_SWAP_HANDS = 0x5B00, | ||
| 82 | QK_SWAP_HANDS_MAX = 0x5BFF, | ||
| 83 | #endif | ||
| 80 | QK_MOD_TAP = 0x6000, | 84 | QK_MOD_TAP = 0x6000, |
| 81 | QK_MOD_TAP_MAX = 0x7FFF, | 85 | QK_MOD_TAP_MAX = 0x7FFF, |
| 82 | #if defined(UNICODEMAP_ENABLE) && defined(UNICODE_ENABLE) | 86 | #if defined(UNICODEMAP_ENABLE) && defined(UNICODE_ENABLE) |
| @@ -641,4 +645,14 @@ enum quantum_keycodes { | |||
| 641 | #define X(n) (n | QK_UNICODE_MAP) | 645 | #define X(n) (n | QK_UNICODE_MAP) |
| 642 | #endif | 646 | #endif |
| 643 | 647 | ||
| 648 | #ifdef SWAP_HANDS_ENABLE | ||
| 649 | #define SH_T(key) (QK_SWAP_HANDS | key) | ||
| 650 | #define SH_TG (QK_SWAP_HANDS | OP_SH_TOGGLE) | ||
| 651 | #define SH_TT (QK_SWAP_HANDS | OP_SH_TAP_TOGGLE) | ||
| 652 | #define SH_MON (QK_SWAP_HANDS | OP_SH_ON_OFF) | ||
| 653 | #define SH_MOFF (QK_SWAP_HANDS | OP_SH_OFF_ON) | ||
| 654 | #define SH_ON (QK_SWAP_HANDS | OP_SH_ON) | ||
| 655 | #define SH_OFF (QK_SWAP_HANDS | OP_SH_OFF) | ||
| 656 | #endif | ||
| 657 | |||
| 644 | #endif // QUANTUM_KEYCODES_H | 658 | #endif // QUANTUM_KEYCODES_H |
