diff options
-rw-r--r-- | quantum/quantum.c | 26 | ||||
-rw-r--r-- | quantum/via.c | 30 | ||||
-rw-r--r-- | tmk_core/common.mk | 2 | ||||
-rw-r--r-- | tmk_core/common/bootmagic_lite.c | 51 |
4 files changed, 53 insertions, 56 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c index 52b700bb93..0ada2fa9b0 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -591,32 +591,6 @@ void tap_random_base64(void) { } } -__attribute__((weak)) void bootmagic_lite(void) { - // The lite version of TMK's bootmagic based on Wilba. - // 100% less potential for accidentally making the - // keyboard do stupid things. - - // We need multiple scans because debouncing can't be turned off. - matrix_scan(); -#if defined(DEBOUNCE) && DEBOUNCE > 0 - wait_ms(DEBOUNCE * 2); -#else - wait_ms(30); -#endif - matrix_scan(); - - // If the Esc and space bar are held down on power up, - // reset the EEPROM valid state and jump to bootloader. - // Assumes Esc is at [0,0]. - // This isn't very generalized, but we need something that doesn't - // rely on user's keymaps in firmware or EEPROM. - if (matrix_get_row(BOOTMAGIC_LITE_ROW) & (1 << BOOTMAGIC_LITE_COLUMN)) { - eeconfig_disable(); - // Jump to bootloader. - bootloader_jump(); - } -} - void matrix_init_quantum() { #ifdef BOOTMAGIC_LITE bootmagic_lite(); diff --git a/quantum/via.c b/quantum/via.c index f85af8d9e1..288299ada8 100644 --- a/quantum/via.c +++ b/quantum/via.c @@ -92,36 +92,6 @@ void via_eeprom_reset(void) { eeconfig_disable(); } -// Override bootmagic_lite() so it can flag EEPROM as invalid -// as well as jump to bootloader, thus performing a "factory reset" -// of dynamic keymaps and optionally backlight/other settings. -void bootmagic_lite(void) { - // The lite version of TMK's bootmagic based on Wilba. - // 100% less potential for accidentally making the - // keyboard do stupid things. - - // We need multiple scans because debouncing can't be turned off. - matrix_scan(); -#if defined(DEBOUNCE) && DEBOUNCE > 0 - wait_ms(DEBOUNCE * 2); -#else - wait_ms(30); -#endif - matrix_scan(); - - // If the Esc and space bar are held down on power up, - // reset the EEPROM valid state and jump to bootloader. - // Assumes Esc is at [0,0]. - // This isn't very generalized, but we need something that doesn't - // rely on user's keymaps in firmware or EEPROM. - if (matrix_get_row(BOOTMAGIC_LITE_ROW) & (1 << BOOTMAGIC_LITE_COLUMN)) { - // This is the only difference from the default implementation. - via_eeprom_reset(); - // Jump to bootloader. - bootloader_jump(); - } -} - // Override this at the keyboard code level to check // VIA's EEPROM valid state and reset to defaults as needed. // Used by keyboards that store their own state in EEPROM, diff --git a/tmk_core/common.mk b/tmk_core/common.mk index 835146f65f..52fcf634f3 100644 --- a/tmk_core/common.mk +++ b/tmk_core/common.mk @@ -34,6 +34,8 @@ ifneq ($(strip $(BOOTMAGIC_ENABLE)), no) endif ifeq ($(strip $(BOOTMAGIC_ENABLE)), lite) TMK_COMMON_DEFS += -DBOOTMAGIC_LITE + TMK_COMMON_SRC += $(COMMON_DIR)/bootmagic_lite.c + TMK_COMMON_DEFS += -DMAGIC_ENABLE TMK_COMMON_SRC += $(COMMON_DIR)/magic.c else diff --git a/tmk_core/common/bootmagic_lite.c b/tmk_core/common/bootmagic_lite.c new file mode 100644 index 0000000000..38275cdd30 --- /dev/null +++ b/tmk_core/common/bootmagic_lite.c @@ -0,0 +1,51 @@ +#include "quantum.h" + +bool is_keyboard_left(void); + +/** \brief Reset eeprom + * + * ...just incase someone wants to only change the eeprom behaviour + */ +__attribute__((weak)) void bootmagic_lite_reset_eeprom(void) { +#if defined(VIA_ENABLE) + via_eeprom_reset(); +#else + eeconfig_disable(); +#endif +} + +/** \brief The lite version of TMK's bootmagic based on Wilba. + * + * 100% less potential for accidentally making the keyboard do stupid things. + */ +__attribute__((weak)) void bootmagic_lite(void) { + // We need multiple scans because debouncing can't be turned off. + matrix_scan(); +#if defined(DEBOUNCE) && DEBOUNCE > 0 + wait_ms(DEBOUNCE * 2); +#else + wait_ms(30); +#endif + matrix_scan(); + + // If the configured key (commonly Esc) is held down on power up, + // reset the EEPROM valid state and jump to bootloader. + // This isn't very generalized, but we need something that doesn't + // rely on user's keymaps in firmware or EEPROM. + uint8_t row = BOOTMAGIC_LITE_ROW; + uint8_t col = BOOTMAGIC_LITE_COLUMN; + +#if defined(SPLIT_KEYBOARD) && defined(BOOTMAGIC_LITE_ROW_RIGHT) && defined(BOOTMAGIC_LITE_COLUMN_RIGHT) + if (!is_keyboard_left()) { + row = BOOTMAGIC_LITE_ROW_RIGHT; + col = BOOTMAGIC_LITE_COLUMN_RIGHT; + } +#endif + + if (matrix_get_row(row) & (1 << col)) { + bootmagic_lite_reset_eeprom(); + + // Jump to bootloader. + bootloader_jump(); + } +}
\ No newline at end of file |