diff options
-rw-r--r-- | docs/keycodes.md | 3 | ||||
-rw-r--r-- | docs/keycodes_magic.md | 3 | ||||
-rw-r--r-- | quantum/command.c | 2 | ||||
-rw-r--r-- | quantum/keycode_config.c | 4 | ||||
-rw-r--r-- | quantum/keycode_config.h | 1 | ||||
-rw-r--r-- | quantum/process_keycode/process_magic.c | 10 | ||||
-rw-r--r-- | quantum/quantum_keycodes.h | 8 |
7 files changed, 31 insertions, 0 deletions
diff --git a/docs/keycodes.md b/docs/keycodes.md index bd5af32dd3..37e9d00392 100644 --- a/docs/keycodes.md +++ b/docs/keycodes.md @@ -337,6 +337,9 @@ See also: [Magic Keycodes](keycodes_magic.md) |`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_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_UNCAPSLOCK_TO_CONTROL` |`CL_CAPS`|Stop treating Caps Lock as Control | |`MAGIC_SWAP_LCTL_LGUI` |`LCG_SWP`|Swap Left Control and GUI | diff --git a/docs/keycodes_magic.md b/docs/keycodes_magic.md index 01eb69168e..982a301630 100644 --- a/docs/keycodes_magic.md +++ b/docs/keycodes_magic.md @@ -7,6 +7,9 @@ |`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_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_UNCAPSLOCK_TO_CONTROL` |`CL_CAPS`|Stop treating Caps Lock as Control | |`MAGIC_SWAP_LCTL_LGUI` |`LCG_SWP`|Swap Left Control and GUI | diff --git a/quantum/command.c b/quantum/command.c index f90d73207c..2e94cb44b8 100644 --- a/quantum/command.c +++ b/quantum/command.c @@ -282,6 +282,7 @@ static void print_eeconfig(void) { ".swap_grave_esc: %u\n" ".swap_backslash_backspace: %u\n" ".nkro: %u\n" + ".swap_escape_capslock: %u\n" , kc.raw , kc.swap_control_capslock @@ -294,6 +295,7 @@ static void print_eeconfig(void) { , kc.swap_grave_esc , kc.swap_backslash_backspace , kc.nkro + , kc.swap_escape_capslock ); /* clang-format on */ # ifdef BACKLIGHT_ENABLE diff --git a/quantum/keycode_config.c b/quantum/keycode_config.c index dd2a17e242..5b5cc5d28e 100644 --- a/quantum/keycode_config.c +++ b/quantum/keycode_config.c @@ -29,6 +29,8 @@ uint16_t keycode_config(uint16_t keycode) { case KC_LOCKING_CAPS_LOCK: if (keymap_config.swap_control_capslock || keymap_config.capslock_to_control) { return KC_LEFT_CTRL; + } else if (keymap_config.swap_escape_capslock) { + return KC_ESCAPE; } return keycode; case KC_LEFT_CTRL: @@ -96,6 +98,8 @@ uint16_t keycode_config(uint16_t keycode) { case KC_ESCAPE: if (keymap_config.swap_grave_esc) { return KC_GRAVE; + } else if (keymap_config.swap_escape_capslock) { + return KC_CAPS_LOCK; } return KC_ESCAPE; case KC_BACKSLASH: diff --git a/quantum/keycode_config.h b/quantum/keycode_config.h index a2cb025ed2..81a8e61471 100644 --- a/quantum/keycode_config.h +++ b/quantum/keycode_config.h @@ -38,6 +38,7 @@ typedef union { bool swap_lctl_lgui : 1; bool swap_rctl_rgui : 1; bool oneshot_enable : 1; + bool swap_escape_capslock : 1; }; } keymap_config_t; diff --git a/quantum/process_keycode/process_magic.c b/quantum/process_keycode/process_magic.c index 10161adda3..ae60f29bf5 100644 --- a/quantum/process_keycode/process_magic.c +++ b/quantum/process_keycode/process_magic.c @@ -45,12 +45,16 @@ bool process_magic(uint16_t keycode, keyrecord_t *record) { case MAGIC_SWAP_LCTL_LGUI ... MAGIC_EE_HANDS_RIGHT: case MAGIC_TOGGLE_GUI: case MAGIC_TOGGLE_CONTROL_CAPSLOCK: + case MAGIC_SWAP_ESCAPE_CAPSLOCK ... MAGIC_TOGGLE_ESCAPE_CAPSLOCK: /* keymap config */ keymap_config.raw = eeconfig_read_keymap(); switch (keycode) { case MAGIC_SWAP_CONTROL_CAPSLOCK: keymap_config.swap_control_capslock = true; break; + case MAGIC_SWAP_ESCAPE_CAPSLOCK: + keymap_config.swap_escape_capslock = true; + break; case MAGIC_CAPSLOCK_TO_CONTROL: keymap_config.capslock_to_control = true; break; @@ -94,6 +98,9 @@ bool process_magic(uint16_t keycode, keyrecord_t *record) { case MAGIC_UNSWAP_CONTROL_CAPSLOCK: keymap_config.swap_control_capslock = false; break; + case MAGIC_UNSWAP_ESCAPE_CAPSLOCK: + keymap_config.swap_escape_capslock = false; + break; case MAGIC_UNCAPSLOCK_TO_CONTROL: keymap_config.capslock_to_control = false; break; @@ -172,6 +179,9 @@ bool process_magic(uint16_t keycode, keyrecord_t *record) { case MAGIC_TOGGLE_CONTROL_CAPSLOCK: keymap_config.swap_control_capslock = !keymap_config.swap_control_capslock; break; + case MAGIC_TOGGLE_ESCAPE_CAPSLOCK: + keymap_config.swap_escape_capslock = !keymap_config.swap_escape_capslock; + break; } eeconfig_update_keymap(keymap_config.raw); diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 869826ce19..456fad6f1b 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -605,6 +605,10 @@ enum quantum_keycodes { 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 SAFE_RANGE }; @@ -756,6 +760,10 @@ enum quantum_keycodes { #define CL_CAPS MAGIC_UNCAPSLOCK_TO_CONTROL #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_NRM MAGIC_UNSWAP_LCTL_LGUI #define RCG_SWP MAGIC_SWAP_RCTL_RGUI |