PoC: Swap Escape and Caps (#16336)
This commit is contained in:
parent
c7d8adfeaa
commit
871eeae4ea
7 changed files with 31 additions and 0 deletions
|
@ -337,6 +337,9 @@ See also: [Magic Keycodes](keycodes_magic.md)
|
||||||
|`MAGIC_SWAP_CONTROL_CAPSLOCK` |`CL_SWAP`|Swap Caps Lock and Left Control |
|
|`MAGIC_SWAP_CONTROL_CAPSLOCK` |`CL_SWAP`|Swap Caps Lock and Left Control |
|
||||||
|`MAGIC_UNSWAP_CONTROL_CAPSLOCK` |`CL_NORM`|Unswap Caps Lock and Left Control |
|
|`MAGIC_UNSWAP_CONTROL_CAPSLOCK` |`CL_NORM`|Unswap Caps Lock and Left Control |
|
||||||
|`MAGIC_TOGGLE_CONTROL_CAPSLOCK` |`CL_TOGG`|Toggle Caps Lock and Left Control swap |
|
|`MAGIC_TOGGLE_CONTROL_CAPSLOCK` |`CL_TOGG`|Toggle Caps Lock and Left Control swap |
|
||||||
|
|`MAGIC_SWAP_ESCAPE_CAPSLOCK` |`EC_SWAP`|Swap Caps Lock and Escape |
|
||||||
|
|`MAGIC_UNSWAP_ESCAPE_CAPSLOCK` |`EC_NORM`|Unswap Caps Lock and Escape |
|
||||||
|
|`MAGIC_TOGGLE_ESCAPE_CAPSLOCK` |`EC_TOGG`|Toggle Caps Lock and Escape swap |
|
||||||
|`MAGIC_CAPSLOCK_TO_CONTROL` |`CL_CTRL`|Treat Caps Lock as Control |
|
|`MAGIC_CAPSLOCK_TO_CONTROL` |`CL_CTRL`|Treat Caps Lock as Control |
|
||||||
|`MAGIC_UNCAPSLOCK_TO_CONTROL` |`CL_CAPS`|Stop treating Caps Lock as Control |
|
|`MAGIC_UNCAPSLOCK_TO_CONTROL` |`CL_CAPS`|Stop treating Caps Lock as Control |
|
||||||
|`MAGIC_SWAP_LCTL_LGUI` |`LCG_SWP`|Swap Left Control and GUI |
|
|`MAGIC_SWAP_LCTL_LGUI` |`LCG_SWP`|Swap Left Control and GUI |
|
||||||
|
|
|
@ -7,6 +7,9 @@
|
||||||
|`MAGIC_SWAP_CONTROL_CAPSLOCK` |`CL_SWAP`|Swap Caps Lock and Left Control |
|
|`MAGIC_SWAP_CONTROL_CAPSLOCK` |`CL_SWAP`|Swap Caps Lock and Left Control |
|
||||||
|`MAGIC_UNSWAP_CONTROL_CAPSLOCK` |`CL_NORM`|Unswap Caps Lock and Left Control |
|
|`MAGIC_UNSWAP_CONTROL_CAPSLOCK` |`CL_NORM`|Unswap Caps Lock and Left Control |
|
||||||
|`MAGIC_TOGGLE_CONTROL_CAPSLOCK` |`CL_TOGG`|Toggle Caps Lock and Left Control swap |
|
|`MAGIC_TOGGLE_CONTROL_CAPSLOCK` |`CL_TOGG`|Toggle Caps Lock and Left Control swap |
|
||||||
|
|`MAGIC_SWAP_ESCAPE_CAPSLOCK` |`EC_SWAP`|Swap Caps Lock and Escape |
|
||||||
|
|`MAGIC_UNSWAP_ESCAPE_CAPSLOCK` |`EC_NORM`|Unswap Caps Lock and Escape |
|
||||||
|
|`MAGIC_TOGGLE_ESCAPE_CAPSLOCK` |`EC_TOGG`|Toggle Caps Lock and Escape swap |
|
||||||
|`MAGIC_CAPSLOCK_TO_CONTROL` |`CL_CTRL`|Treat Caps Lock as Control |
|
|`MAGIC_CAPSLOCK_TO_CONTROL` |`CL_CTRL`|Treat Caps Lock as Control |
|
||||||
|`MAGIC_UNCAPSLOCK_TO_CONTROL` |`CL_CAPS`|Stop treating Caps Lock as Control |
|
|`MAGIC_UNCAPSLOCK_TO_CONTROL` |`CL_CAPS`|Stop treating Caps Lock as Control |
|
||||||
|`MAGIC_SWAP_LCTL_LGUI` |`LCG_SWP`|Swap Left Control and GUI |
|
|`MAGIC_SWAP_LCTL_LGUI` |`LCG_SWP`|Swap Left Control and GUI |
|
||||||
|
|
|
@ -282,6 +282,7 @@ static void print_eeconfig(void) {
|
||||||
".swap_grave_esc: %u\n"
|
".swap_grave_esc: %u\n"
|
||||||
".swap_backslash_backspace: %u\n"
|
".swap_backslash_backspace: %u\n"
|
||||||
".nkro: %u\n"
|
".nkro: %u\n"
|
||||||
|
".swap_escape_capslock: %u\n"
|
||||||
|
|
||||||
, kc.raw
|
, kc.raw
|
||||||
, kc.swap_control_capslock
|
, kc.swap_control_capslock
|
||||||
|
@ -294,6 +295,7 @@ static void print_eeconfig(void) {
|
||||||
, kc.swap_grave_esc
|
, kc.swap_grave_esc
|
||||||
, kc.swap_backslash_backspace
|
, kc.swap_backslash_backspace
|
||||||
, kc.nkro
|
, kc.nkro
|
||||||
|
, kc.swap_escape_capslock
|
||||||
); /* clang-format on */
|
); /* clang-format on */
|
||||||
|
|
||||||
# ifdef BACKLIGHT_ENABLE
|
# ifdef BACKLIGHT_ENABLE
|
||||||
|
|
|
@ -29,6 +29,8 @@ uint16_t keycode_config(uint16_t keycode) {
|
||||||
case KC_LOCKING_CAPS_LOCK:
|
case KC_LOCKING_CAPS_LOCK:
|
||||||
if (keymap_config.swap_control_capslock || keymap_config.capslock_to_control) {
|
if (keymap_config.swap_control_capslock || keymap_config.capslock_to_control) {
|
||||||
return KC_LEFT_CTRL;
|
return KC_LEFT_CTRL;
|
||||||
|
} else if (keymap_config.swap_escape_capslock) {
|
||||||
|
return KC_ESCAPE;
|
||||||
}
|
}
|
||||||
return keycode;
|
return keycode;
|
||||||
case KC_LEFT_CTRL:
|
case KC_LEFT_CTRL:
|
||||||
|
@ -96,6 +98,8 @@ uint16_t keycode_config(uint16_t keycode) {
|
||||||
case KC_ESCAPE:
|
case KC_ESCAPE:
|
||||||
if (keymap_config.swap_grave_esc) {
|
if (keymap_config.swap_grave_esc) {
|
||||||
return KC_GRAVE;
|
return KC_GRAVE;
|
||||||
|
} else if (keymap_config.swap_escape_capslock) {
|
||||||
|
return KC_CAPS_LOCK;
|
||||||
}
|
}
|
||||||
return KC_ESCAPE;
|
return KC_ESCAPE;
|
||||||
case KC_BACKSLASH:
|
case KC_BACKSLASH:
|
||||||
|
|
|
@ -38,6 +38,7 @@ typedef union {
|
||||||
bool swap_lctl_lgui : 1;
|
bool swap_lctl_lgui : 1;
|
||||||
bool swap_rctl_rgui : 1;
|
bool swap_rctl_rgui : 1;
|
||||||
bool oneshot_enable : 1;
|
bool oneshot_enable : 1;
|
||||||
|
bool swap_escape_capslock : 1;
|
||||||
};
|
};
|
||||||
} keymap_config_t;
|
} keymap_config_t;
|
||||||
|
|
||||||
|
|
|
@ -45,12 +45,16 @@ bool process_magic(uint16_t keycode, keyrecord_t *record) {
|
||||||
case MAGIC_SWAP_LCTL_LGUI ... MAGIC_EE_HANDS_RIGHT:
|
case MAGIC_SWAP_LCTL_LGUI ... MAGIC_EE_HANDS_RIGHT:
|
||||||
case MAGIC_TOGGLE_GUI:
|
case MAGIC_TOGGLE_GUI:
|
||||||
case MAGIC_TOGGLE_CONTROL_CAPSLOCK:
|
case MAGIC_TOGGLE_CONTROL_CAPSLOCK:
|
||||||
|
case MAGIC_SWAP_ESCAPE_CAPSLOCK ... MAGIC_TOGGLE_ESCAPE_CAPSLOCK:
|
||||||
/* keymap config */
|
/* keymap config */
|
||||||
keymap_config.raw = eeconfig_read_keymap();
|
keymap_config.raw = eeconfig_read_keymap();
|
||||||
switch (keycode) {
|
switch (keycode) {
|
||||||
case MAGIC_SWAP_CONTROL_CAPSLOCK:
|
case MAGIC_SWAP_CONTROL_CAPSLOCK:
|
||||||
keymap_config.swap_control_capslock = true;
|
keymap_config.swap_control_capslock = true;
|
||||||
break;
|
break;
|
||||||
|
case MAGIC_SWAP_ESCAPE_CAPSLOCK:
|
||||||
|
keymap_config.swap_escape_capslock = true;
|
||||||
|
break;
|
||||||
case MAGIC_CAPSLOCK_TO_CONTROL:
|
case MAGIC_CAPSLOCK_TO_CONTROL:
|
||||||
keymap_config.capslock_to_control = true;
|
keymap_config.capslock_to_control = true;
|
||||||
break;
|
break;
|
||||||
|
@ -94,6 +98,9 @@ bool process_magic(uint16_t keycode, keyrecord_t *record) {
|
||||||
case MAGIC_UNSWAP_CONTROL_CAPSLOCK:
|
case MAGIC_UNSWAP_CONTROL_CAPSLOCK:
|
||||||
keymap_config.swap_control_capslock = false;
|
keymap_config.swap_control_capslock = false;
|
||||||
break;
|
break;
|
||||||
|
case MAGIC_UNSWAP_ESCAPE_CAPSLOCK:
|
||||||
|
keymap_config.swap_escape_capslock = false;
|
||||||
|
break;
|
||||||
case MAGIC_UNCAPSLOCK_TO_CONTROL:
|
case MAGIC_UNCAPSLOCK_TO_CONTROL:
|
||||||
keymap_config.capslock_to_control = false;
|
keymap_config.capslock_to_control = false;
|
||||||
break;
|
break;
|
||||||
|
@ -172,6 +179,9 @@ bool process_magic(uint16_t keycode, keyrecord_t *record) {
|
||||||
case MAGIC_TOGGLE_CONTROL_CAPSLOCK:
|
case MAGIC_TOGGLE_CONTROL_CAPSLOCK:
|
||||||
keymap_config.swap_control_capslock = !keymap_config.swap_control_capslock;
|
keymap_config.swap_control_capslock = !keymap_config.swap_control_capslock;
|
||||||
break;
|
break;
|
||||||
|
case MAGIC_TOGGLE_ESCAPE_CAPSLOCK:
|
||||||
|
keymap_config.swap_escape_capslock = !keymap_config.swap_escape_capslock;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
eeconfig_update_keymap(keymap_config.raw);
|
eeconfig_update_keymap(keymap_config.raw);
|
||||||
|
|
|
@ -605,6 +605,10 @@ enum quantum_keycodes {
|
||||||
|
|
||||||
CAPS_WORD,
|
CAPS_WORD,
|
||||||
|
|
||||||
|
MAGIC_SWAP_ESCAPE_CAPSLOCK,
|
||||||
|
MAGIC_UNSWAP_ESCAPE_CAPSLOCK,
|
||||||
|
MAGIC_TOGGLE_ESCAPE_CAPSLOCK,
|
||||||
|
|
||||||
// Start of custom keycode range for keyboards and keymaps - always leave at the end
|
// Start of custom keycode range for keyboards and keymaps - always leave at the end
|
||||||
SAFE_RANGE
|
SAFE_RANGE
|
||||||
};
|
};
|
||||||
|
@ -756,6 +760,10 @@ enum quantum_keycodes {
|
||||||
#define CL_CAPS MAGIC_UNCAPSLOCK_TO_CONTROL
|
#define CL_CAPS MAGIC_UNCAPSLOCK_TO_CONTROL
|
||||||
#define CL_TOGG MAGIC_TOGGLE_CONTROL_CAPSLOCK
|
#define CL_TOGG MAGIC_TOGGLE_CONTROL_CAPSLOCK
|
||||||
|
|
||||||
|
#define EC_SWAP MAGIC_SWAP_ESCAPE_CAPSLOCK
|
||||||
|
#define EC_NORM MAGIC_UNSWAP_ESCAPE_CAPSLOCK
|
||||||
|
#define EC_TOGG MAGIC_TOGGLE_ESCAPE_CAPSLOCK
|
||||||
|
|
||||||
#define LCG_SWP MAGIC_SWAP_LCTL_LGUI
|
#define LCG_SWP MAGIC_SWAP_LCTL_LGUI
|
||||||
#define LCG_NRM MAGIC_UNSWAP_LCTL_LGUI
|
#define LCG_NRM MAGIC_UNSWAP_LCTL_LGUI
|
||||||
#define RCG_SWP MAGIC_SWAP_RCTL_RGUI
|
#define RCG_SWP MAGIC_SWAP_RCTL_RGUI
|
||||||
|
|
Loading…
Reference in a new issue