mirror of
https://github.com/Keychron/qmk_firmware.git
synced 2024-11-25 09:56:54 +06:00
Add support for Bootmagic lite when using SPLIT_HAND_PIN (#8347)
* Add support for Bootmagic lite when using SPLIT_HAND_PIN * Deduplicate bootmagic_lite logic from within via * Revert location of defaults so that user overrides still work for now * Tidy up code slightly
This commit is contained in:
parent
a747c1c3de
commit
789e199450
|
@ -144,6 +144,17 @@ And to trigger the bootloader, you hold this key down when plugging the keyboard
|
||||||
|
|
||||||
!> Using bootmagic lite will **always reset** the EEPROM, so you will lose any settings that have been saved.
|
!> Using bootmagic lite will **always reset** the EEPROM, so you will lose any settings that have been saved.
|
||||||
|
|
||||||
|
## Split Keyboards
|
||||||
|
|
||||||
|
When handedness is predetermined via an option like `SPLIT_HAND_PIN`, you might need to configure a different key between halves. This To do so, add these entries to your `config.h` file:
|
||||||
|
|
||||||
|
```c
|
||||||
|
#define BOOTMAGIC_LITE_ROW_RIGHT 4
|
||||||
|
#define BOOTMAGIC_LITE_COLUMN_RIGHT 1
|
||||||
|
```
|
||||||
|
|
||||||
|
By default, these values are not set.
|
||||||
|
|
||||||
## Advanced Bootmagic Lite
|
## Advanced Bootmagic Lite
|
||||||
|
|
||||||
The `bootmagic_lite` function is defined weakly, so that you can replace this in your code, if you need. A great example of this is the Zeal60 boards that have some additional handling needed.
|
The `bootmagic_lite` function is defined weakly, so that you can replace this in your code, if you need. A great example of this is the Zeal60 boards that have some additional handling needed.
|
||||||
|
|
|
@ -581,32 +581,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() {
|
void matrix_init_quantum() {
|
||||||
#ifdef BOOTMAGIC_LITE
|
#ifdef BOOTMAGIC_LITE
|
||||||
bootmagic_lite();
|
bootmagic_lite();
|
||||||
|
|
|
@ -92,36 +92,6 @@ void via_eeprom_reset(void) {
|
||||||
eeconfig_disable();
|
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
|
// Override this at the keyboard code level to check
|
||||||
// VIA's EEPROM valid state and reset to defaults as needed.
|
// VIA's EEPROM valid state and reset to defaults as needed.
|
||||||
// Used by keyboards that store their own state in EEPROM,
|
// Used by keyboards that store their own state in EEPROM,
|
||||||
|
|
|
@ -34,6 +34,8 @@ ifneq ($(strip $(BOOTMAGIC_ENABLE)), no)
|
||||||
endif
|
endif
|
||||||
ifeq ($(strip $(BOOTMAGIC_ENABLE)), lite)
|
ifeq ($(strip $(BOOTMAGIC_ENABLE)), lite)
|
||||||
TMK_COMMON_DEFS += -DBOOTMAGIC_LITE
|
TMK_COMMON_DEFS += -DBOOTMAGIC_LITE
|
||||||
|
TMK_COMMON_SRC += $(COMMON_DIR)/bootmagic_lite.c
|
||||||
|
|
||||||
TMK_COMMON_DEFS += -DMAGIC_ENABLE
|
TMK_COMMON_DEFS += -DMAGIC_ENABLE
|
||||||
TMK_COMMON_SRC += $(COMMON_DIR)/magic.c
|
TMK_COMMON_SRC += $(COMMON_DIR)/magic.c
|
||||||
else
|
else
|
||||||
|
|
51
tmk_core/common/bootmagic_lite.c
Normal file
51
tmk_core/common/bootmagic_lite.c
Normal file
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user