diff options
author | Joe Wasson <jwasson+github@gmail.com> | 2018-03-11 16:53:35 -0700 |
---|---|---|
committer | Jack Humbert <jack.humb@gmail.com> | 2018-03-16 16:33:43 -0400 |
commit | 23ac2a02ef870dce91318a4d98e3c8ec5749bced (patch) | |
tree | 302f61696ce319d635c17e919ec6d8acf264d2ab | |
parent | 7230923b051bdb32bea19c3d732fa1fbc4883a68 (diff) | |
download | qmk_firmware-23ac2a02ef870dce91318a4d98e3c8ec5749bced.tar.gz qmk_firmware-23ac2a02ef870dce91318a4d98e3c8ec5749bced.zip |
Add keycodes for swap-hands feature.
-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 61c66a2c10..92e8e3b107 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] = { 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 | -|------|-------------| -| `ACTION_SWAP_HANDS()` | Swaps hands when pressed, returns to normal when released (momentary). | -| `ACTION_SWAP_HANDS_TOGGLE()` | Toggles swap on and off with every key press. | -| `ACTION_SWAP_HANDS_TAP_TOGGLE()` | Toggles with a tap; momentary when held. | -| `ACTION_SWAP_HANDS_TAP_KEY(key)`| Sends `key` with a tap; momentary swap when held. | -| `ACTION_SWAP_HANDS_ON_OFF()` | Alias for `ACTION_SWAP_HANDS()` | -| `ACTION_SWAP_HANDS_OFF_ON()` | Momentarily turns off swap. | -| `ACTION_SWAP_HANDS_ON()` | Turns on swapping and leaves it on. | -| `ACTION_SWAP_HANDS_OFF()` | Turn off swapping and leaves it off. Good for returning to a known state. |
\ No newline at end of file +|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.| +|`SW_MON` |Swaps hands when pressed, returns to normal when released (momentary). | +|`SW_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. | diff --git a/docs/keycodes.md b/docs/keycodes.md index 030b23827a..21a722250e 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 |------------|-------|-------------------------------------------------| |`UNICODE(n)`|`UC(n)`|Send Unicode character `n` | |`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. | diff --git a/keyboards/planck/keymaps/experimental/keymap.c b/keyboards/planck/keymaps/experimental/keymap.c index feeb137fa0..8ddb3d4650 100644 --- a/keyboards/planck/keymaps/experimental/keymap.c +++ b/keyboards/planck/keymaps/experimental/keymap.c @@ -45,6 +45,7 @@ enum planck_keycodes { // Fillers to make layering more clear #define _______ KC_TRNS #define XXXXXXX KC_NO +#define SW_SPC SH_T(KC_SPC) const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [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_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_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 @@ -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_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_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 @@ -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_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_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 @@ -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 float tone_startup[][2] = SONG(STARTUP_SOUND); diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index a0d4c1ddb0..8b09f93fce 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) action.code = ACTION_BACKLIGHT_STEP(); break; #endif + #ifdef SWAP_HANDS_ENABLE + case QK_SWAP_HANDS ... QK_SWAP_HANDS_MAX: + action.code = ACTION(ACT_SWAP_HANDS, keycode & 0xff); + break; + #endif + default: action.code = ACTION_NO; break; diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index a4ee4d6bb9..9040299a74 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -77,6 +77,10 @@ enum quantum_keycodes { QK_STENO_GEMINI = 0x5A31, QK_STENO_MAX = 0x5A3F, #endif +#ifdef SWAP_HANDS_ENABLE + QK_SWAP_HANDS = 0x5B00, + QK_SWAP_HANDS_MAX = 0x5BFF, +#endif QK_MOD_TAP = 0x6000, QK_MOD_TAP_MAX = 0x7FFF, #if defined(UNICODEMAP_ENABLE) && defined(UNICODE_ENABLE) @@ -641,4 +645,14 @@ enum quantum_keycodes { #define X(n) (n | QK_UNICODE_MAP) #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 |