diff options
author | Joel Challis <git@zvecr.com> | 2020-03-21 23:10:39 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-21 23:10:39 +0000 |
commit | 789e19945038c3b98d6e80bc29166d493a8b1056 (patch) | |
tree | d3d5159d9390365a2374d72cf61bd9c7ecd37ae0 /tmk_core | |
parent | a747c1c3dee728f5124a8effb8f52819f643de5f (diff) | |
download | qmk_firmware-789e19945038c3b98d6e80bc29166d493a8b1056.tar.gz qmk_firmware-789e19945038c3b98d6e80bc29166d493a8b1056.zip |
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
Diffstat (limited to 'tmk_core')
-rw-r--r-- | tmk_core/common.mk | 2 | ||||
-rw-r--r-- | tmk_core/common/bootmagic_lite.c | 51 |
2 files changed, 53 insertions, 0 deletions
diff --git a/tmk_core/common.mk b/tmk_core/common.mk index b766ebe97..3cc72a845 100644 --- a/tmk_core/common.mk +++ b/tmk_core/common.mk | |||
@@ -34,6 +34,8 @@ ifneq ($(strip $(BOOTMAGIC_ENABLE)), no) | |||
34 | endif | 34 | endif |
35 | ifeq ($(strip $(BOOTMAGIC_ENABLE)), lite) | 35 | ifeq ($(strip $(BOOTMAGIC_ENABLE)), lite) |
36 | TMK_COMMON_DEFS += -DBOOTMAGIC_LITE | 36 | TMK_COMMON_DEFS += -DBOOTMAGIC_LITE |
37 | TMK_COMMON_SRC += $(COMMON_DIR)/bootmagic_lite.c | ||
38 | |||
37 | TMK_COMMON_DEFS += -DMAGIC_ENABLE | 39 | TMK_COMMON_DEFS += -DMAGIC_ENABLE |
38 | TMK_COMMON_SRC += $(COMMON_DIR)/magic.c | 40 | TMK_COMMON_SRC += $(COMMON_DIR)/magic.c |
39 | else | 41 | else |
diff --git a/tmk_core/common/bootmagic_lite.c b/tmk_core/common/bootmagic_lite.c new file mode 100644 index 000000000..53bd7b1c7 --- /dev/null +++ b/tmk_core/common/bootmagic_lite.c | |||
@@ -0,0 +1,51 @@ | |||
1 | #include "quantum.h" | ||
2 | |||
3 | bool is_keyboard_left(void); | ||
4 | |||
5 | /** \brief Reset eeprom | ||
6 | * | ||
7 | * ...just incase someone wants to only change the eeprom behaviour | ||
8 | */ | ||
9 | __attribute__((weak)) void bootmagic_lite_reset_eeprom(void) { | ||
10 | #if defined(VIA_ENABLE) | ||
11 | via_eeprom_reset(); | ||
12 | #else | ||
13 | eeconfig_disable(); | ||
14 | #endif | ||
15 | } | ||
16 | |||
17 | /** \brief The lite version of TMK's bootmagic based on Wilba. | ||
18 | * | ||
19 | * 100% less potential for accidentally making the keyboard do stupid things. | ||
20 | */ | ||
21 | __attribute__((weak)) void bootmagic_lite(void) { | ||
22 | // We need multiple scans because debouncing can't be turned off. | ||
23 | matrix_scan(); | ||
24 | #if defined(DEBOUNCE) && DEBOUNCE > 0 | ||
25 | wait_ms(DEBOUNCE * 2); | ||
26 | #else | ||
27 | wait_ms(30); | ||
28 | #endif | ||
29 | matrix_scan(); | ||
30 | |||
31 | // If the configured key (commonly Esc) is held down on power up, | ||
32 | // reset the EEPROM valid state and jump to bootloader. | ||
33 | // This isn't very generalized, but we need something that doesn't | ||
34 | // rely on user's keymaps in firmware or EEPROM. | ||
35 | uint8_t row = BOOTMAGIC_LITE_ROW; | ||
36 | uint8_t col = BOOTMAGIC_LITE_COLUMN; | ||
37 | |||
38 | #if defined(SPLIT_KEYBOARD) && defined(BOOTMAGIC_LITE_ROW_RIGHT) && defined(BOOTMAGIC_LITE_COLUMN_RIGHT) | ||
39 | if (!is_keyboard_left()) { | ||
40 | row = BOOTMAGIC_LITE_ROW_RIGHT; | ||
41 | col = BOOTMAGIC_LITE_COLUMN_RIGHT; | ||
42 | } | ||
43 | #endif | ||
44 | |||
45 | if (matrix_get_row(row) & (1 << col)) { | ||
46 | bootmagic_lite_reset_eeprom(); | ||
47 | |||
48 | // Jump to bootloader. | ||
49 | bootloader_jump(); | ||
50 | } | ||
51 | } \ No newline at end of file | ||