1
0
Fork 0
forked from forks/qmk_firmware

Normalise Swap Hands keycodes (#19720)

This commit is contained in:
Ryan 2023-01-31 05:37:19 +11:00 committed by GitHub
parent cc9520b7a0
commit 2d843088a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 108 additions and 46 deletions

View file

@ -0,0 +1 @@
{}

View file

@ -0,0 +1,53 @@
{
"keycodes": {
"0x56F0": {
"group": "swap_hands",
"key": "QK_SWAP_HANDS_TOGGLE",
"aliases": [
"SH_TOGG"
]
},
"0x56F1": {
"group": "swap_hands",
"key": "QK_SWAP_HANDS_TAP_TOGGLE",
"aliases": [
"SH_TT"
]
},
"0x56F2": {
"group": "swap_hands",
"key": "QK_SWAP_HANDS_MOMENTARY_ON",
"aliases": [
"SH_MON"
]
},
"0x56F3": {
"group": "swap_hands",
"key": "QK_SWAP_HANDS_MOMENTARY_OFF",
"aliases": [
"SH_MOFF"
]
},
"0x56F4": {
"group": "swap_hands",
"key": "QK_SWAP_HANDS_OFF",
"aliases": [
"SH_OFF"
]
},
"0x56F5": {
"group": "swap_hands",
"key": "QK_SWAP_HANDS_ON",
"aliases": [
"SH_ON"
]
},
"0x56F6": {
"group": "swap_hands",
"key": "QK_SWAP_HANDS_ONE_SHOT",
"aliases": [
"SH_OS"
]
}
}
}

View file

@ -19,18 +19,18 @@ Note that the array indices are reversed same as the matrix and the values are o
## Swap Keycodes
|Key |Description |
|-----------|-------------------------------------------------------------------------|
|`SH_T(key)`|Sends `key` with a tap; momentary swap when held. |
|`SH_ON` |Turns on swapping and leaves it on. |
|`SH_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` |Momentary swap when held, toggles with repeated taps (see below). |
|`SH_OS` |One shot swap hands: toggles while pressed or until next key press. |
|Key |Aliases |Description |
|-----------------------------|---------|----------------------------------------------------|
|`SH_T(kc)` | |Momentary swap when held, `kc` when tapped |
|`QK_SWAP_HANDS_ON` |`SH_ON` |Turn on hand swap |
|`QK_SWAP_HANDS_OFF` |`SH_OFF` |Turn off hand swap |
|`QK_SWAP_HANDS_MOMENTARY_ON` |`SH_MON` |Turn on hand swap while held |
|`QK_SWAP_HANDS_MOMENTARY_OFF`|`SH_MOFF`|Turn off hand swap while held |
|`QK_SWAP_HANDS_TOGGLE` |`SH_TOGG`|Toggle hand swap |
|`QK_SWAP_HANDS_TAP_TOGGLE` |`SH_TT` |Momentary swap when held, toggle when tapped |
|`QK_SWAP_HANDS_ONE_SHOT` |`SH_OS` |Turn on hand swap while held or until next key press|
`SH_TT` swap-hands tap-toggle key is similar to [layer tap-toggle](feature_layers.md?id=switching-and-toggling-layers). Tapping repeatedly (5 taps by default) will toggle swap-hands on or off, like `SH_TG`. Tap-toggle count can be changed by defining a value for `TAPPING_TOGGLE`.
`SH_TT` swap-hands tap-toggle key is similar to [layer tap-toggle](feature_layers.md?id=switching-and-toggling-layers). Tapping repeatedly (5 taps by default) will toggle swap-hands on or off, like `SH_TOGG`. Tap-toggle count can be changed by defining a value for `TAPPING_TOGGLE`.
## Encoder Mapping

View file

@ -819,16 +819,16 @@ See also: [Space Cadet](feature_space_cadet.md)
See also: [Swap Hands](feature_swap_hands.md)
|Key |Description |
|-----------|-------------------------------------------------------------------------|
|`SH_T(key)`|Sends `key` with a tap; momentary swap when held. |
|`SH_ON` |Turns on swapping and leaves it on. |
|`SH_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. |
|`SH_OS` |One shot swap hands: toggle while pressed or until next key press. |
|Key |Aliases |Description |
|-----------------------------|---------|----------------------------------------------------|
|`SH_T(kc)` | |Momentary swap when held, `kc` when tapped |
|`QK_SWAP_HANDS_ON` |`SH_ON` |Turn on hand swap |
|`QK_SWAP_HANDS_OFF` |`SH_OFF` |Turn off hand swap |
|`QK_SWAP_HANDS_MOMENTARY_ON` |`SH_MON` |Turn on hand swap while held |
|`QK_SWAP_HANDS_MOMENTARY_OFF`|`SH_MOFF`|Turn off hand swap while held |
|`QK_SWAP_HANDS_TOGGLE` |`SH_TOGG`|Toggle hand swap |
|`QK_SWAP_HANDS_TAP_TOGGLE` |`SH_TT` |Momentary swap when held, toggle when tapped |
|`QK_SWAP_HANDS_ONE_SHOT` |`SH_OS` |Turn on hand swap while held or until next key press|
## Unicode Support :id=unicode-support

View file

@ -181,7 +181,7 @@ static uint8_t layout_conversion_dip_state = 0;
#define LAYOUT_base_wrapper(...) LAYOUT_base(__VA_ARGS__)
#ifdef SWAP_HANDS_ENABLE
#define SW_TG SH_TG
#define SW_TG SH_TOGG
#else
#define SW_TG _______
#endif

View file

@ -22,7 +22,7 @@ enum jian_keycodes {
#define LOWER_T(kc) LT(_LOWER, kc)
#ifdef SWAP_HANDS_ENABLE
#define SW_TG SH_TG
#define SW_TG SH_TOGG
#else
#define SW_TG _______
#endif

View file

@ -23,6 +23,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
QK_BOOT, DB_TOGG, XXXXXXX, BL_UP, RGB_VAI, RGB_HUD, RGB_HUI,
XXXXXXX, XXXXXXX, BL_DOWN, RGB_VAD, RGB_SAD, RGB_SAI,
XXXXXXX, BL_BRTG, BL_TOGG, RGB_TOG, RGB_RMOD,RGB_MOD,
_______, SH_TG, _______
_______, SH_TOGG, _______
)
};

View file

@ -59,7 +59,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
QK_BOOT, RGBRST, AS_UP, AS_TOGG, AS_DOWN, _______, _______, _______, _______, AS_DOWN, AS_TOGG, AS_UP, RGBRST, QK_BOOT,
RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, _______, _______, _______, _______, RGB_VAI, RGB_SAI, RGB_HUI, RGB_TOG,
RGB_MOD, RGB_HUD, RGB_SAD, RGB_VAD, _______, _______, _______, _______, RGB_VAD, RGB_SAD, RGB_HUD, RGB_MOD,
_______, SH_TG, _______, _______, SH_TG, _______
_______, SH_TOGG, _______, _______, SH_TOGG, _______
),
};

View file

@ -59,7 +59,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
QK_BOOT, RGBRST, AS_UP, AS_TOGG, AS_DOWN, _______, _______, _______, _______, AS_DOWN, AS_TOGG, AS_UP, RGBRST, QK_BOOT,
RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, _______, _______, _______, _______, RGB_VAI, RGB_SAI, RGB_HUI, RGB_TOG,
RGB_MOD, RGB_HUD, RGB_SAD, RGB_VAD, _______, _______, _______, _______, RGB_VAD, RGB_SAD, RGB_HUD, RGB_MOD,
_______, SH_TG, _______, _______, SH_TG, _______
_______, SH_TOGG, _______, _______, SH_TOGG, _______
),
};

View file

@ -414,7 +414,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
*/
[_TABULA] = LAYOUT_planck_mit( //
KC_ESC, KC_ALTF4, VK_TOGG, PRINT_WPM_KEY, WAKE_ANI_TOG, WAKE_AUD_TOG, KC_REDO, UC_NEXT, UC_WINC, CG_TOGG, AG_TOGG, KC_DLINE, //
KC_NXTAB, KC_SLCTALL, KC_SAVE, KC_TRNS, KC_FIND, SH_TG, SH_TG, IRONY, KC_LCUT, KC_LCOPY, KC_TRNS, KC_KILL, //
KC_NXTAB, KC_SLCTALL, KC_SAVE, KC_TRNS, KC_FIND, SH_TOGG, SH_TOGG, IRONY, KC_LCUT, KC_LCOPY, KC_TRNS, KC_KILL, //
KC_LSFT, KC_UNDO, KC_CUT, KC_COPY, KC_PASTE, KC_PRVWD, KC_NXTWD, TG(_MOUSY), KC_TRNS, KC_HOME, KC_END, SC_SENT, //
TO(_BASE), KC_LCTL, KC_LGUI, KC_LALT, SC_LSPO, ALT_TAB, SC_RSPC, KC_PRVWD, KC_BRID, KC_BRIU, KC_NXTWD),
/* Tabular Layer [8]

View file

@ -388,7 +388,7 @@ qmk_dict = {
"acc2": "KC_ACL2",
# Modifiers missinng, add entry for each specific application
# Mod-Tap Keys missing, add entry for each specific application
"_Sh_swp": "LSFT_T(SH_TG)",
"_Sh_swp": "LSFT_T(SH_TOGG)",
# RGB Lighting missing
# RGB Matrix Lighting missing
# Thermal Printer missing

View file

@ -304,13 +304,13 @@ enum qk_keycode_defines {
KC_RIGHT_SHIFT = 0x00E5,
KC_RIGHT_ALT = 0x00E6,
KC_RIGHT_GUI = 0x00E7,
SH_TG = 0x56F0,
SH_TT = 0x56F1,
SH_MON = 0x56F2,
SH_MOFF = 0x56F3,
SH_OFF = 0x56F4,
SH_ON = 0x56F5,
SH_OS = 0x56F6,
QK_SWAP_HANDS_TOGGLE = 0x56F0,
QK_SWAP_HANDS_TAP_TOGGLE = 0x56F1,
QK_SWAP_HANDS_MOMENTARY_ON = 0x56F2,
QK_SWAP_HANDS_MOMENTARY_OFF = 0x56F3,
QK_SWAP_HANDS_OFF = 0x56F4,
QK_SWAP_HANDS_ON = 0x56F5,
QK_SWAP_HANDS_ONE_SHOT = 0x56F6,
MAGIC_SWAP_CONTROL_CAPSLOCK = 0x7000,
MAGIC_UNSWAP_CONTROL_CAPSLOCK = 0x7001,
MAGIC_TOGGLE_CONTROL_CAPSLOCK = 0x7002,
@ -863,6 +863,13 @@ enum qk_keycode_defines {
KC_RGUI = KC_RIGHT_GUI,
KC_RCMD = KC_RIGHT_GUI,
KC_RWIN = KC_RIGHT_GUI,
SH_TOGG = QK_SWAP_HANDS_TOGGLE,
SH_TT = QK_SWAP_HANDS_TAP_TOGGLE,
SH_MON = QK_SWAP_HANDS_MOMENTARY_ON,
SH_MOFF = QK_SWAP_HANDS_MOMENTARY_OFF,
SH_OFF = QK_SWAP_HANDS_OFF,
SH_ON = QK_SWAP_HANDS_ON,
SH_OS = QK_SWAP_HANDS_ONE_SHOT,
CL_SWAP = MAGIC_SWAP_CONTROL_CAPSLOCK,
CL_NORM = MAGIC_UNSWAP_CONTROL_CAPSLOCK,
CL_TOGG = MAGIC_TOGGLE_CONTROL_CAPSLOCK,
@ -1309,7 +1316,7 @@ enum qk_keycode_defines {
#define IS_MEDIA_KEYCODE(code) ((code) >= KC_AUDIO_MUTE && (code) <= KC_ASSISTANT)
#define IS_MOUSE_KEYCODE(code) ((code) >= KC_MS_UP && (code) <= KC_MS_ACCEL2)
#define IS_MODIFIERS_KEYCODE(code) ((code) >= KC_LEFT_CTRL && (code) <= KC_RIGHT_GUI)
#define IS_SWAP_HANDS_KEYCODE(code) ((code) >= SH_TG && (code) <= SH_OS)
#define IS_SWAP_HANDS_KEYCODE(code) ((code) >= QK_SWAP_HANDS_TOGGLE && (code) <= QK_SWAP_HANDS_ONE_SHOT)
#define IS_MAGIC_KEYCODE(code) ((code) >= MAGIC_SWAP_CONTROL_CAPSLOCK && (code) <= MAGIC_TOGGLE_ESCAPE_CAPSLOCK)
#define IS_MIDI_KEYCODE(code) ((code) >= QK_MIDI_ON && (code) <= QK_MIDI_PITCH_BEND_UP)
#define IS_SEQUENCER_KEYCODE(code) ((code) >= SQ_ON && (code) <= SQ_SCLR)

View file

@ -126,7 +126,7 @@ __attribute__((weak)) bool process_autocorrect_user(uint16_t *keycode, keyrecord
// and mask for base keycode when they are tapped.
case QK_SWAP_HANDS ... QK_SWAP_HANDS_MAX:
#ifdef SWAP_HANDS_ENABLE
// Note: IS_SWAP_HANDS_KEYCODE() actually tests for the special action keycodes like SH_TG, SH_TT, ...,
// Note: IS_SWAP_HANDS_KEYCODE() actually tests for the special action keycodes like SH_TOGG, SH_TT, ...,
// which currently overlap the SH_T(kc) range.
if (IS_SWAP_HANDS_KEYCODE(*keycode) || !record->tap.count) {
return false;

View file

@ -143,7 +143,7 @@ bool process_caps_word(uint16_t keycode, keyrecord_t* record) {
#ifdef SWAP_HANDS_ENABLE
case QK_SWAP_HANDS ... QK_SWAP_HANDS_MAX:
// Note: IS_SWAP_HANDS_KEYCODE() actually tests for the special action keycodes like SH_TG, SH_TT, ...,
// Note: IS_SWAP_HANDS_KEYCODE() actually tests for the special action keycodes like SH_TOGG, SH_TT, ...,
// which currently overlap the SH_T(kc) range.
if (IS_SWAP_HANDS_KEYCODE(keycode) || record->tap.count == 0) {
return true;

View file

@ -3,3 +3,4 @@
// clang-format off
// Deprecated Quantum keycodes
#define SH_TG QK_SWAP_HANDS_TOGGLE

View file

@ -1,4 +1,4 @@
// Copyright 2022 QMK
// Copyright 2023 QMK
// SPDX-License-Identifier: GPL-2.0-or-later
/*******************************************************************************
@ -250,13 +250,13 @@ std::map<uint16_t, std::string> KEYCODE_ID_TABLE = {
{KC_RIGHT_SHIFT, "KC_RIGHT_SHIFT"},
{KC_RIGHT_ALT, "KC_RIGHT_ALT"},
{KC_RIGHT_GUI, "KC_RIGHT_GUI"},
{SH_TG, "SH_TG"},
{SH_TT, "SH_TT"},
{SH_MON, "SH_MON"},
{SH_MOFF, "SH_MOFF"},
{SH_OFF, "SH_OFF"},
{SH_ON, "SH_ON"},
{SH_OS, "SH_OS"},
{QK_SWAP_HANDS_TOGGLE, "QK_SWAP_HANDS_TOGGLE"},
{QK_SWAP_HANDS_TAP_TOGGLE, "QK_SWAP_HANDS_TAP_TOGGLE"},
{QK_SWAP_HANDS_MOMENTARY_ON, "QK_SWAP_HANDS_MOMENTARY_ON"},
{QK_SWAP_HANDS_MOMENTARY_OFF, "QK_SWAP_HANDS_MOMENTARY_OFF"},
{QK_SWAP_HANDS_OFF, "QK_SWAP_HANDS_OFF"},
{QK_SWAP_HANDS_ON, "QK_SWAP_HANDS_ON"},
{QK_SWAP_HANDS_ONE_SHOT, "QK_SWAP_HANDS_ONE_SHOT"},
{MAGIC_SWAP_CONTROL_CAPSLOCK, "MAGIC_SWAP_CONTROL_CAPSLOCK"},
{MAGIC_UNSWAP_CONTROL_CAPSLOCK, "MAGIC_UNSWAP_CONTROL_CAPSLOCK"},
{MAGIC_TOGGLE_CONTROL_CAPSLOCK, "MAGIC_TOGGLE_CONTROL_CAPSLOCK"},