Add keycodes for swap-hands feature.

This commit is contained in:
Joe Wasson 2018-03-11 16:53:35 -07:00 committed by Jack Humbert
parent 7230923b05
commit 23ac2a02ef
5 changed files with 46 additions and 18 deletions

View File

@ -17,15 +17,14 @@ const keypos_t hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = {
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. 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.
## Advanced Swap Commands ## Swap Keycodes
|Macro | Description | |Key |Description |
|------|-------------| |-----------|-------------------------------------------------------------------------|
| `ACTION_SWAP_HANDS()` | Swaps hands when pressed, returns to normal when released (momentary). | |`SH_T(key)`|Sends `key` with a tap; momentary swap when held. |
| `ACTION_SWAP_HANDS_TOGGLE()` | Toggles swap on and off with every key press. | |`SW_ON` |Turns on swapping and leaves it on. |
| `ACTION_SWAP_HANDS_TAP_TOGGLE()` | Toggles with a tap; momentary when held. | |`SW_OFF` |Turn off swapping and leaves it off. Good for returning to a known state.|
| `ACTION_SWAP_HANDS_TAP_KEY(key)`| Sends `key` with a tap; momentary swap when held. | |`SW_MON` |Swaps hands when pressed, returns to normal when released (momentary). |
| `ACTION_SWAP_HANDS_ON_OFF()` | Alias for `ACTION_SWAP_HANDS()` | |`SW_MOFF` |Momentarily turns off swap. |
| `ACTION_SWAP_HANDS_OFF_ON()` | Momentarily turns off swap. | |`SH_TG` |Toggles swap on and off with every key press. |
| `ACTION_SWAP_HANDS_ON()` | Turns on swapping and leaves it on. | |`SH_TT` |Toggles with a tap; momentary when held. |
| `ACTION_SWAP_HANDS_OFF()` | Turn off swapping and leaves it off. Good for returning to a known state. |

View File

@ -390,3 +390,15 @@ This is a reference only. Each group of keys links to the page documenting their
|------------|-------|-------------------------------------------------| |------------|-------|-------------------------------------------------|
|`UNICODE(n)`|`UC(n)`|Send Unicode character `n` | |`UNICODE(n)`|`UC(n)`|Send Unicode character `n` |
|`X(n)` | |Send Unicode character `n` via a different method| |`X(n)` | |Send Unicode character `n` via a different method|
## [Swap Hands](feature_swap_hands.md)
|Key |Description |
|-----------|-------------------------------------------------------------------------|
|`SH_T(key)`|Sends `key` with a tap; momentary swap when held. |
|`SW_ON` |Turns on swapping and leaves it on. |
|`SW_OFF` |Turn off swapping and leaves it off. Good for returning to a known state.|
|`SH_MON` |Swaps hands when pressed, returns to normal when released (momentary). |
|`SH_MOFF` |Momentarily turns off swap. |
|`SH_TG` |Toggles swap on and off with every key press. |
|`SH_TT` |Toggles with a tap; momentary when held. |

View File

@ -45,6 +45,7 @@ enum planck_keycodes {
// Fillers to make layering more clear // Fillers to make layering more clear
#define _______ KC_TRNS #define _______ KC_TRNS
#define XXXXXXX KC_NO #define XXXXXXX KC_NO
#define SW_SPC SH_T(KC_SPC)
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = { [0] = {
@ -69,7 +70,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
{KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC}, {KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC},
{KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT}, {KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT},
{KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT }, {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT },
{KC_LEAD, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_FN0, KC_FN0, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} {KC_LEAD, KC_LCTL, KC_LALT, KC_LGUI, LOWER, SW_SPC, SW_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
}, },
/* Colemak /* Colemak
@ -87,7 +88,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
{KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC}, {KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC},
{KC_ESC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT}, {KC_ESC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT},
{KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT }, {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT },
{KC_LEAD, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_FN0, KC_FN0, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} {KC_LEAD, KC_LCTL, KC_LALT, KC_LGUI, LOWER, SW_SPC, SW_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
}, },
/* Dvorak /* Dvorak
@ -105,7 +106,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
{KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC}, {KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC},
{KC_ESC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH}, {KC_ESC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH},
{KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT }, {KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT },
{KC_LEAD, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_FN0, KC_FN0, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} {KC_LEAD, KC_LCTL, KC_LALT, KC_LGUI, LOWER, SW_SPC, SW_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
}, },
/* Lower /* Lower
@ -184,10 +185,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
}; };
const uint16_t PROGMEM fn_actions[] = {
ACTION_SWAP_HANDS_TAP_KEY(KC_SPC),
};
#ifdef AUDIO_ENABLE #ifdef AUDIO_ENABLE
float tone_startup[][2] = SONG(STARTUP_SOUND); float tone_startup[][2] = SONG(STARTUP_SOUND);

View File

@ -146,6 +146,12 @@ action_t action_for_key(uint8_t layer, keypos_t key)
action.code = ACTION_BACKLIGHT_STEP(); action.code = ACTION_BACKLIGHT_STEP();
break; break;
#endif #endif
#ifdef SWAP_HANDS_ENABLE
case QK_SWAP_HANDS ... QK_SWAP_HANDS_MAX:
action.code = ACTION(ACT_SWAP_HANDS, keycode & 0xff);
break;
#endif
default: default:
action.code = ACTION_NO; action.code = ACTION_NO;
break; break;

View File

@ -76,6 +76,10 @@ enum quantum_keycodes {
QK_STENO_BOLT = 0x5A30, QK_STENO_BOLT = 0x5A30,
QK_STENO_GEMINI = 0x5A31, QK_STENO_GEMINI = 0x5A31,
QK_STENO_MAX = 0x5A3F, QK_STENO_MAX = 0x5A3F,
#endif
#ifdef SWAP_HANDS_ENABLE
QK_SWAP_HANDS = 0x5B00,
QK_SWAP_HANDS_MAX = 0x5BFF,
#endif #endif
QK_MOD_TAP = 0x6000, QK_MOD_TAP = 0x6000,
QK_MOD_TAP_MAX = 0x7FFF, QK_MOD_TAP_MAX = 0x7FFF,
@ -641,4 +645,14 @@ enum quantum_keycodes {
#define X(n) (n | QK_UNICODE_MAP) #define X(n) (n | QK_UNICODE_MAP)
#endif #endif
#ifdef SWAP_HANDS_ENABLE
#define SH_T(key) (QK_SWAP_HANDS | key)
#define SH_TG (QK_SWAP_HANDS | OP_SH_TOGGLE)
#define SH_TT (QK_SWAP_HANDS | OP_SH_TAP_TOGGLE)
#define SH_MON (QK_SWAP_HANDS | OP_SH_ON_OFF)
#define SH_MOFF (QK_SWAP_HANDS | OP_SH_OFF_ON)
#define SH_ON (QK_SWAP_HANDS | OP_SH_ON)
#define SH_OFF (QK_SWAP_HANDS | OP_SH_OFF)
#endif
#endif // QUANTUM_KEYCODES_H #endif // QUANTUM_KEYCODES_H