]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
Add keycodes for swap-hands feature.
authorJoe Wasson <jwasson+github@gmail.com>
Sun, 11 Mar 2018 23:53:35 +0000 (16:53 -0700)
committerJack Humbert <jack.humb@gmail.com>
Fri, 16 Mar 2018 20:33:43 +0000 (16:33 -0400)
docs/feature_swap_hands.md
docs/keycodes.md
keyboards/planck/keymaps/experimental/keymap.c
quantum/keymap_common.c
quantum/quantum_keycodes.h

index 61c66a2c10bded32eb3a0262c0d53e6b2677e91d..92e8e3b107224d470f80ae4015363bcf786ff9ae 100644 (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.
 
-## 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.                                 |
index 030b23827a0c2628d0a5deca12ad804270cff329..21a722250e7fec9277a841ebb5e02494cf7b30bb 100644 (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`                       |
 |`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.                                 |
index feeb137fa0b42d98e050c2cc156e4b078fdb8fa3..8ddb3d4650b80efbcf53fe828e1e4bf7e0061f01 100644 (file)
@@ -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);
index a0d4c1ddb0873e9a767218401e434c96fde862ff..8b09f93fced6815f6ca4107535022ed92f2f2665 100644 (file)
@@ -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;
index a4ee4d6bb92ed6b702618cfae4a78145af18082b..9040299a74491bc1b7580a980ad5efa2dd5000d0 100644 (file)
@@ -76,6 +76,10 @@ enum quantum_keycodes {
     QK_STENO_BOLT         = 0x5A30,
     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,
@@ -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