summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2019-09-24 15:24:12 +0100
committerGitHub <noreply@github.com>2019-09-24 15:24:12 +0100
commitad8dbd5ca5390ad9e441943b705684fce521bc15 (patch)
tree5426b36cba3db2fafe4eb4dc59ee05c3b3788b77
parent237147ca236b0e942fc14e73010479a2785bf764 (diff)
downloadqmk_firmware-ad8dbd5ca5390ad9e441943b705684fce521bc15.tar.gz
qmk_firmware-ad8dbd5ca5390ad9e441943b705684fce521bc15.zip
ARM split - Add bootmagic/magic keycodes for setting handedness (#6545)
* Add docs on bootmagic/magic keycodes for setting handedness * Clang format fixes * Maintain backwards compatibility * Maintain backwards compatibility
-rw-r--r--docs/feature_bootmagic.md6
-rw-r--r--docs/keycodes.md58
-rw-r--r--quantum/quantum.c8
-rw-r--r--quantum/quantum_keycodes.h2
-rw-r--r--quantum/split_common/split_util.c3
-rw-r--r--tmk_core/common/bootmagic.c8
-rw-r--r--tmk_core/common/bootmagic.h6
-rw-r--r--tmk_core/common/eeconfig.c19
-rw-r--r--tmk_core/common/eeconfig.h3
9 files changed, 80 insertions, 33 deletions
diff --git a/docs/feature_bootmagic.md b/docs/feature_bootmagic.md
index fc37a3302b..ed00d51295 100644
--- a/docs/feature_bootmagic.md
+++ b/docs/feature_bootmagic.md
@@ -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 |
@@ -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
@@ -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) |
diff --git a/docs/keycodes.md b/docs/keycodes.md
index e17fef6fd2..dfbab148b8 100644
--- a/docs/keycodes.md
+++ b/docs/keycodes.md
@@ -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)
diff --git a/quantum/quantum.c b/quantum/quantum.c
index ec80fa557f..16922dd011 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -544,7 +544,7 @@ bool process_record_quantum(keyrecord_t *record) {
# endif
#endif
case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_ALT_GUI:
- case MAGIC_SWAP_LCTL_LGUI ... MAGIC_TOGGLE_CTL_GUI:
+ case MAGIC_SWAP_LCTL_LGUI ... MAGIC_EE_HANDS_RIGHT:
if (record->event.pressed) {
// MAGIC actions (BOOTMAGIC without the boot)
if (!eeconfig_is_enabled()) {
@@ -662,6 +662,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;
}
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h
index af984a7cd7..5fac6a5cae 100644
--- a/quantum/quantum_keycodes.h
+++ b/quantum/quantum_keycodes.h
@@ -502,6 +502,8 @@ enum quantum_keycodes {
MAGIC_SWAP_CTL_GUI,
MAGIC_UNSWAP_CTL_GUI,
MAGIC_TOGGLE_CTL_GUI,
+ MAGIC_EE_HANDS_LEFT,
+ MAGIC_EE_HANDS_RIGHT,
// always leave at the end
SAFE_RANGE
diff --git a/quantum/split_common/split_util.c b/quantum/split_common/split_util.c
index 5114b188ec..d16a989770 100644
--- a/quantum/split_common/split_util.c
+++ b/quantum/split_common/split_util.c
@@ -7,7 +7,6 @@
#include "quantum.h"
#ifdef EE_HANDS
-# include "tmk_core/common/eeprom.h"
# include "eeconfig.h"
#endif
@@ -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
diff --git a/tmk_core/common/bootmagic.c b/tmk_core/common/bootmagic.c
index 09b1664c90..bb2aa0db8c 100644
--- a/tmk_core/common/bootmagic.c
+++ b/tmk_core/common/bootmagic.c
@@ -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
diff --git a/tmk_core/common/bootmagic.h b/tmk_core/common/bootmagic.h
index fb76472579..c64dc17858 100644
--- a/tmk_core/common/bootmagic.h
+++ b/tmk_core/common/bootmagic.h
@@ -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
diff --git a/tmk_core/common/eeconfig.c b/tmk_core/common/eeconfig.c
index 61aaec2054..933ac42bd2 100644
--- a/tmk_core/common/eeconfig.c
+++ b/tmk_core/common/eeconfig.c
@@ -153,8 +153,8 @@ uint32_t eeconfig_read_kb(void) { return eeprom_read_dword(EECONFIG_KEYBOARD); }
*
* FIXME: needs doc
*/
-
void eeconfig_update_kb(uint32_t val) { eeprom_update_dword(EECONFIG_KEYBOARD, val); }
+
/** \brief eeconfig read user
*
* FIXME: needs doc
@@ -166,9 +166,24 @@ uint32_t eeconfig_read_user(void) { return eeprom_read_dword(EECONFIG_USER); }
*/
void eeconfig_update_user(uint32_t val) { eeprom_update_dword(EECONFIG_USER, val); }
+/** \brief eeconfig read haptic
+ *
+ * FIXME: needs doc
+ */
uint32_t eeconfig_read_haptic(void) { return eeprom_read_dword(EECONFIG_HAPTIC); }
-/** \brief eeconfig update user
+/** \brief eeconfig update haptic
*
* FIXME: needs doc
*/
void eeconfig_update_haptic(uint32_t val) { eeprom_update_dword(EECONFIG_HAPTIC, val); }
+
+/** \brief eeconfig read split handedness
+ *
+ * FIXME: needs doc
+ */
+bool eeconfig_read_handedness(void) { return !!eeprom_read_byte(EECONFIG_HANDEDNESS); }
+/** \brief eeconfig update split handedness
+ *
+ * FIXME: needs doc
+ */
+void eeconfig_update_handedness(bool val) { eeprom_update_byte(EECONFIG_HANDEDNESS, !!val); }
diff --git a/tmk_core/common/eeconfig.h b/tmk_core/common/eeconfig.h
index aea4eff9f6..308f865e19 100644
--- a/tmk_core/common/eeconfig.h
+++ b/tmk_core/common/eeconfig.h
@@ -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