Skip to content

Commit

Permalink
ARM split - Add bootmagic/magic keycodes for setting handedness (qmk#…
Browse files Browse the repository at this point in the history
…6545)

* Add docs on bootmagic/magic keycodes for setting handedness

* Clang format fixes

* Maintain backwards compatibility

* Maintain backwards compatibility
  • Loading branch information
zvecr authored and fdidron committed Jan 8, 2020
1 parent 1f66fd1 commit a15119d
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 5 deletions.
8 changes: 7 additions & 1 deletion quantum/quantum.c
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,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()) {
Expand Down Expand Up @@ -655,6 +655,12 @@ bool process_record_quantum(keyrecord_t *record) {
clear_keyboard(); // clear first buffer to prevent stuck keys
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
2 changes: 2 additions & 0 deletions quantum/quantum_keycodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,

WEBUSB_PAIR,

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
19 changes: 17 additions & 2 deletions tmk_core/common/eeconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,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
Expand All @@ -176,9 +176,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); }
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 a15119d

Please sign in to comment.