Skip to content

Commit

Permalink
Add docs on bootmagic/magic keycodes for setting handedness
Browse files Browse the repository at this point in the history
  • Loading branch information
zvecr committed Aug 30, 2019
1 parent d217307 commit 6303b6b
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 40 deletions.
6 changes: 6 additions & 0 deletions docs/feature_bootmagic.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ Hold down the Bootmagic key (Space by default) and the desired hotkey while plug
|`X` |Toggle key matrix debugging |
|`K` |Toggle keyboard debugging |
|`M` |Toggle mouse debugging |
|`L` |Set "Left Hand" for EE_HANDS handedness |
|`R` |Set "Right Hand" for EE_HANDS handedness |
|Backspace |Clear the EEPROM |
|Caps Lock |Toggle treating Caps Lock as Left Control |
|Left Control |Toggle swapping Caps Lock and Left Control |
Expand Down Expand Up @@ -83,6 +85,8 @@ Hold down the Bootmagic key (Space by default) and the desired hotkey while plug
|`MAGIC_UNSWAP_LCTL_LGUI` | |Unswap Left Control and Left GUI |
|`MAGIC_SWAP_RCTL_RGUI` | |Swap Right Control and Right GUI |
|`MAGIC_UNSWAP_RCTL_RGUI` | |Unswap Right Control and Right GUI |
|`MAGIC_EE_HANDS_LEFT` | |Set "Left Hand" for EE_HANDS handedness |
|`MAGIC_EE_HANDS_RIGHT` | |Set "Right Hand" for EE_HANDS handedness |

## Configuration

Expand All @@ -98,6 +102,8 @@ If you would like to change the hotkey assignments for Bootmagic, `#define` thes
|`BOOTMAGIC_KEY_DEBUG_MATRIX` |`KC_X` |Toggle matrix debugging |
|`BOOTMAGIC_KEY_DEBUG_KEYBOARD` |`KC_K` |Toggle keyboard debugging |
|`BOOTMAGIC_KEY_DEBUG_MOUSE` |`KC_M` |Toggle mouse debugging |
|`BOOTMAGIC_KEY_EE_HANDS_LEFT` |`KC_L` |Set "Left Hand" for EE_HANDS handedness |
|`BOOTMAGIC_KEY_EE_HANDS_RIGHT` |`KC_R` |Set "Right Hand" for EE_HANDS handedness |
|`BOOTMAGIC_KEY_SWAP_CONTROL_CAPSLOCK` |`KC_LCTRL` |Swap Left Control and Caps Lock |
|`BOOTMAGIC_KEY_CAPSLOCK_TO_CONTROL` |`KC_CAPSLOCK`|Toggle treating Caps Lock as Left Control |
|`BOOTMAGIC_KEY_SWAP_LALT_LGUI` |`KC_LALT` |Toggle swapping Left Alt and Left GUI (for macOS) |
Expand Down
58 changes: 30 additions & 28 deletions docs/keycodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,35 +257,37 @@ This is a reference only. Each group of keys links to the page documenting their

## [Bootmagic](feature_bootmagic.md)

|Key |Aliases |Description |
|----------------------------------|---------|------------------------------------|
|`MAGIC_SWAP_CONTROL_CAPSLOCK` | |Swap Caps Lock and Left Control |
|`MAGIC_CAPSLOCK_TO_CONTROL` | |Treat Caps Lock as Control |
|`MAGIC_SWAP_LCTL_LGUI` | |Swap Left Control and GUI |
|`MAGIC_SWAP_RCTL_RGUI` | |Swap Right Control and GUI |
|`MAGIC_SWAP_LALT_LGUI` | |Swap Left Alt and GUI |
|`MAGIC_SWAP_RALT_RGUI` | |Swap Right Alt and GUI |
|`MAGIC_NO_GUI` | |Disable the GUI key |
|`MAGIC_SWAP_GRAVE_ESC` | |Swap <code>&#96;</code> and Escape |
|`MAGIC_SWAP_BACKSLASH_BACKSPACE` | |Swap `\` and Backspace |
|`MAGIC_HOST_NKRO` | |Force NKRO on |
|`MAGIC_SWAP_ALT_GUI` |`AG_SWAP`|Swap Alt and GUI on both sides |
|Key |Aliases |Description |
|----------------------------------|---------|-------------------------------------------|
|`MAGIC_SWAP_CONTROL_CAPSLOCK` | |Swap Caps Lock and Left Control |
|`MAGIC_CAPSLOCK_TO_CONTROL` | |Treat Caps Lock as Control |
|`MAGIC_SWAP_LCTL_LGUI` | |Swap Left Control and GUI |
|`MAGIC_SWAP_RCTL_RGUI` | |Swap Right Control and GUI |
|`MAGIC_SWAP_LALT_LGUI` | |Swap Left Alt and GUI |
|`MAGIC_SWAP_RALT_RGUI` | |Swap Right Alt and GUI |
|`MAGIC_NO_GUI` | |Disable the GUI key |
|`MAGIC_SWAP_GRAVE_ESC` | |Swap <code>&#96;</code> and Escape |
|`MAGIC_SWAP_BACKSLASH_BACKSPACE` | |Swap `\` and Backspace |
|`MAGIC_HOST_NKRO` | |Force NKRO on |
|`MAGIC_SWAP_ALT_GUI` |`AG_SWAP`|Swap Alt and GUI on both sides |
|`MAGIC_SWAP_CTL_GUI` |`CG_SWAP`|Swap Ctrl and GUI on both sides (for macOS)|
|`MAGIC_UNSWAP_CONTROL_CAPSLOCK` | |Unswap Caps Lock and Left Control |
|`MAGIC_UNCAPSLOCK_TO_CONTROL` | |Stop treating Caps Lock as Control |
|`MAGIC_UNSWAP_LCTL_LGUI` | |Unswap Left Control and GUI |
|`MAGIC_UNSWAP_RCTL_RGUI` | |Unswap Right Control and GUI |
|`MAGIC_UNSWAP_LALT_LGUI` | |Unswap Left Alt and GUI |
|`MAGIC_UNSWAP_RALT_RGUI` | |Unswap Right Alt and GUI |
|`MAGIC_UNNO_GUI` | |Enable the GUI key |
|`MAGIC_UNSWAP_GRAVE_ESC` | |Unswap <code>&#96;</code> and Escape|
|`MAGIC_UNSWAP_BACKSLASH_BACKSPACE`| |Unswap `\` and Backspace |
|`MAGIC_UNHOST_NKRO` | |Force NKRO off |
|`MAGIC_UNSWAP_ALT_GUI` |`AG_NORM`|Unswap Alt and GUI on both sides |
|`MAGIC_UNSWAP_CTL_GUI` |`CG_NORM`|Unswap Ctrl and GUI on both sides |
|`MAGIC_TOGGLE_ALT_GUI` |`AG_TOGG`|Toggle Alt and GUI swap on both sides |
|`MAGIC_TOGGLE_CTL_GUI` |`CG_TOGG`|Toggle Ctrl and GUI swap on both sides |
|`MAGIC_TOGGLE_NKRO` | |Turn NKRO on or off |
|`MAGIC_UNSWAP_CONTROL_CAPSLOCK` | |Unswap Caps Lock and Left Control |
|`MAGIC_UNCAPSLOCK_TO_CONTROL` | |Stop treating Caps Lock as Control |
|`MAGIC_UNSWAP_LCTL_LGUI` | |Unswap Left Control and GUI |
|`MAGIC_UNSWAP_RCTL_RGUI` | |Unswap Right Control and GUI |
|`MAGIC_UNSWAP_LALT_LGUI` | |Unswap Left Alt and GUI |
|`MAGIC_UNSWAP_RALT_RGUI` | |Unswap Right Alt and GUI |
|`MAGIC_UNNO_GUI` | |Enable the GUI key |
|`MAGIC_UNSWAP_GRAVE_ESC` | |Unswap <code>&#96;</code> and Escape |
|`MAGIC_UNSWAP_BACKSLASH_BACKSPACE`| |Unswap `\` and Backspace |
|`MAGIC_UNHOST_NKRO` | |Force NKRO off |
|`MAGIC_UNSWAP_ALT_GUI` |`AG_NORM`|Unswap Alt and GUI on both sides |
|`MAGIC_UNSWAP_CTL_GUI` |`CG_NORM`|Unswap Ctrl and GUI on both sides |
|`MAGIC_TOGGLE_ALT_GUI` |`AG_TOGG`|Toggle Alt and GUI swap on both sides |
|`MAGIC_TOGGLE_CTL_GUI` |`CG_TOGG`|Toggle Ctrl and GUI swap on both sides |
|`MAGIC_TOGGLE_NKRO` | |Turn NKRO on or off |
|`MAGIC_EE_HANDS_LEFT` | |Set "Left Hand" for EE_HANDS handedness |
|`MAGIC_EE_HANDS_RIGHT` | |Set "Right Hand" for EE_HANDS handedness |

## [Bluetooth](feature_bluetooth.md)

Expand Down
9 changes: 7 additions & 2 deletions quantum/quantum.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,8 +543,7 @@ bool process_record_quantum(keyrecord_t *record) {
return false;
# endif
#endif
case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_ALT_GUI:
case MAGIC_SWAP_LCTL_LGUI ... MAGIC_TOGGLE_CTL_GUI:
case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_EE_HANDS_RIGHT:
if (record->event.pressed) {
// MAGIC actions (BOOTMAGIC without the boot)
if (!eeconfig_is_enabled()) {
Expand Down Expand Up @@ -662,6 +661,12 @@ bool process_record_quantum(keyrecord_t *record) {
case MAGIC_TOGGLE_NKRO:
keymap_config.nkro = !keymap_config.nkro;
break;
case MAGIC_EE_HANDS_LEFT:
eeconfig_update_handedness(true);
break;
case MAGIC_EE_HANDS_RIGHT:
eeconfig_update_handedness(false);
break;
default:
break;
}
Expand Down
17 changes: 9 additions & 8 deletions quantum/quantum_keycodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,15 @@ enum quantum_keycodes {
MAGIC_UNSWAP_ALT_GUI,
MAGIC_TOGGLE_NKRO,
MAGIC_TOGGLE_ALT_GUI,
MAGIC_SWAP_LCTL_LGUI,
MAGIC_SWAP_RCTL_RGUI,
MAGIC_UNSWAP_LCTL_LGUI,
MAGIC_UNSWAP_RCTL_RGUI,
MAGIC_SWAP_CTL_GUI,
MAGIC_UNSWAP_CTL_GUI,
MAGIC_TOGGLE_CTL_GUI,
MAGIC_EE_HANDS_LEFT,
MAGIC_EE_HANDS_RIGHT,
GRAVE_ESC,

// Leader key
Expand Down Expand Up @@ -492,14 +501,6 @@ enum quantum_keycodes {
CMB_OFF,
CMB_TOG,

MAGIC_SWAP_LCTL_LGUI,
MAGIC_SWAP_RCTL_RGUI,
MAGIC_UNSWAP_LCTL_LGUI,
MAGIC_UNSWAP_RCTL_RGUI,
MAGIC_SWAP_CTL_GUI,
MAGIC_UNSWAP_CTL_GUI,
MAGIC_TOGGLE_CTL_GUI,

// always leave at the end
SAFE_RANGE
};
Expand Down
3 changes: 1 addition & 2 deletions quantum/split_common/split_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "quantum.h"

#ifdef EE_HANDS
# include "tmk_core/common/eeprom.h"
# include "eeconfig.h"
#endif

Expand All @@ -23,7 +22,7 @@ __attribute__((weak)) bool is_keyboard_left(void) {
setPinInput(SPLIT_HAND_PIN);
return readPin(SPLIT_HAND_PIN);
#elif defined(EE_HANDS)
return eeprom_read_byte(EECONFIG_HANDEDNESS);
return eeconfig_read_handedness();
#elif defined(MASTER_RIGHT)
return !is_keyboard_master();
#endif
Expand Down
8 changes: 8 additions & 0 deletions tmk_core/common/bootmagic.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@ void bootmagic(void) {
default_layer = eeconfig_read_default_layer();
default_layer_set((layer_state_t)default_layer);
}

/* EE_HANDS handedness */
if (bootmagic_scan_keycode(BOOTMAGIC_KEY_EE_HANDS_LEFT)) {
eeconfig_update_handedness(true);
}
if (bootmagic_scan_keycode(BOOTMAGIC_KEY_EE_HANDS_RIGHT)) {
eeconfig_update_handedness(false);
}
}

/** \brief Scan Keycode
Expand Down
6 changes: 6 additions & 0 deletions tmk_core/common/bootmagic.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
#ifndef BOOTMAGIC_KEY_DEBUG_MOUSE
# define BOOTMAGIC_KEY_DEBUG_MOUSE KC_M
#endif
#ifndef BOOTMAGIC_KEY_EE_HANDS_LEFT
#define BOOTMAGIC_KEY_EE_HANDS_LEFT KC_L
#endif
#ifndef BOOTMAGIC_KEY_EE_HANDS_RIGHT
#define BOOTMAGIC_KEY_EE_HANDS_RIGHT KC_R
#endif

/*
* keymap config
Expand Down
4 changes: 4 additions & 0 deletions tmk_core/common/eeconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,7 @@ uint32_t eeconfig_read_haptic(void) { return eeprom_read_dword(EECONFIG_HAPTIC);
* FIXME: needs doc
*/
void eeconfig_update_haptic(uint32_t val) { eeprom_update_dword(EECONFIG_HAPTIC, val); }

bool eeconfig_read_handedness(void) { return !!eeprom_read_byte(EECONFIG_HANDEDNESS); }

void eeconfig_update_handedness(bool val) { eeprom_update_byte(EECONFIG_HANDEDNESS, !!val); }
3 changes: 3 additions & 0 deletions tmk_core/common/eeconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,7 @@ uint32_t eeconfig_read_haptic(void);
void eeconfig_update_haptic(uint32_t val);
#endif

bool eeconfig_read_handedness(void);
void eeconfig_update_handedness(bool val);

#endif

0 comments on commit 6303b6b

Please sign in to comment.