Skip to content

Commit

Permalink
added BS_TOGG so BS_SWAP and BS_NORM can be on a single key (qmk#18837)
Browse files Browse the repository at this point in the history
Co-authored-by: Selene ToyKeeper <[email protected]>
  • Loading branch information
ToyKeeper and ToyKeeper authored Oct 25, 2022
1 parent a80b886 commit e863c43
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/keycodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ See also: [Magic Keycodes](keycodes_magic.md)
|`MAGIC_UNSWAP_GRAVE_ESC` |`GE_NORM`|Unswap <code>&#96;</code> and Escape |
|`MAGIC_SWAP_BACKSLASH_BACKSPACE` |`BS_SWAP`|Swap `\` and Backspace |
|`MAGIC_UNSWAP_BACKSLASH_BACKSPACE`|`BS_NORM`|Unswap `\` and Backspace |
|`MAGIC_TOGGLE_BACKSLASH_BACKSPACE`|`BS_TOGG`|Toggle `\` and Backspace swap state |
|`MAGIC_HOST_NKRO` |`NK_ON` |Enable N-key rollover |
|`MAGIC_UNHOST_NKRO` |`NK_OFF` |Disable N-key rollover |
|`MAGIC_TOGGLE_NKRO` |`NK_TOGG`|Toggle N-key rollover |
Expand Down
4 changes: 4 additions & 0 deletions quantum/process_keycode/process_magic.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ 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_TOGGLE_BACKSLASH_BACKSPACE:
case MAGIC_SWAP_ESCAPE_CAPSLOCK ... MAGIC_TOGGLE_ESCAPE_CAPSLOCK:
/* keymap config */
keymap_config.raw = eeconfig_read_keymap();
Expand Down Expand Up @@ -163,6 +164,9 @@ bool process_magic(uint16_t keycode, keyrecord_t *record) {
}
#endif
break;
case MAGIC_TOGGLE_BACKSLASH_BACKSPACE:
keymap_config.swap_backslash_backspace = !keymap_config.swap_backslash_backspace;
break;
case MAGIC_TOGGLE_NKRO:
clear_keyboard(); // clear first buffer to prevent stuck keys
keymap_config.nkro = !keymap_config.nkro;
Expand Down
3 changes: 3 additions & 0 deletions quantum/quantum_keycodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,8 @@ enum quantum_keycodes {
AUTOCORRECT_OFF,
AUTOCORRECT_TOGGLE,

MAGIC_TOGGLE_BACKSLASH_BACKSPACE,

// Start of custom keycode range for keyboards and keymaps - always leave at the end
SAFE_RANGE
};
Expand Down Expand Up @@ -731,6 +733,7 @@ enum quantum_keycodes {

#define BS_SWAP MAGIC_SWAP_BACKSLASH_BACKSPACE
#define BS_NORM MAGIC_UNSWAP_BACKSLASH_BACKSPACE
#define BS_TOGG MAGIC_TOGGLE_BACKSLASH_BACKSPACE

#define NK_ON MAGIC_HOST_NKRO
#define NK_OFF MAGIC_UNHOST_NKRO
Expand Down

0 comments on commit e863c43

Please sign in to comment.