diff options
| author | Joel Challis <git@zvecr.com> | 2024-02-17 12:27:34 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-17 12:27:34 +0000 |
| commit | e2dbe39b9475b0d46702e5a32432cb248d72290c (patch) | |
| tree | 0703d8929f4119bd99a6abe6875736a6d4e1f038 /quantum/bootmagic | |
| parent | 538333571754c3cbeec92bc793b1b8023744cbbd (diff) | |
Removal of bootmagic lite terminology (#22979)
Diffstat (limited to 'quantum/bootmagic')
| -rw-r--r-- | quantum/bootmagic/bootmagic.c | 54 | ||||
| -rw-r--r-- | quantum/bootmagic/bootmagic.h | 23 |
2 files changed, 51 insertions, 26 deletions
diff --git a/quantum/bootmagic/bootmagic.c b/quantum/bootmagic/bootmagic.c index efce6bfd12..419ec5229e 100644 --- a/quantum/bootmagic/bootmagic.c +++ b/quantum/bootmagic/bootmagic.c | |||
| @@ -20,44 +20,54 @@ | |||
| 20 | #include "eeconfig.h" | 20 | #include "eeconfig.h" |
| 21 | #include "bootloader.h" | 21 | #include "bootloader.h" |
| 22 | 22 | ||
| 23 | #ifndef BOOTMAGIC_DEBOUNCE | ||
| 24 | # if defined(DEBOUNCE) && DEBOUNCE > 0 | ||
| 25 | # define BOOTMAGIC_DEBOUNCE (DEBOUNCE * 2) | ||
| 26 | # else | ||
| 27 | # define BOOTMAGIC_DEBOUNCE 30 | ||
| 28 | # endif | ||
| 29 | #endif | ||
| 30 | |||
| 23 | /** \brief Reset eeprom | 31 | /** \brief Reset eeprom |
| 24 | * | 32 | * |
| 25 | * ...just incase someone wants to only change the eeprom behaviour | 33 | * ...just incase someone wants to only change the eeprom behaviour |
| 26 | */ | 34 | */ |
| 27 | __attribute__((weak)) void bootmagic_lite_reset_eeprom(void) { | 35 | __attribute__((weak)) void bootmagic_reset_eeprom(void) { |
| 28 | eeconfig_disable(); | 36 | eeconfig_disable(); |
| 29 | } | 37 | } |
| 30 | 38 | ||
| 31 | /** \brief The lite version of TMK's bootmagic based on Wilba. | 39 | /** \brief Decide reboot based on current matrix state |
| 32 | * | ||
| 33 | * 100% less potential for accidentally making the keyboard do stupid things. | ||
| 34 | */ | 40 | */ |
| 35 | __attribute__((weak)) void bootmagic_lite(void) { | 41 | __attribute__((weak)) bool bootmagic_should_reset(void) { |
| 36 | // We need multiple scans because debouncing can't be turned off. | ||
| 37 | matrix_scan(); | ||
| 38 | #if defined(DEBOUNCE) && DEBOUNCE > 0 | ||
| 39 | wait_ms(DEBOUNCE * 2); | ||
| 40 | #else | ||
| 41 | wait_ms(30); | ||
| 42 | #endif | ||
| 43 | matrix_scan(); | ||
| 44 | |||
| 45 | // If the configured key (commonly Esc) is held down on power up, | 42 | // If the configured key (commonly Esc) is held down on power up, |
| 46 | // reset the EEPROM valid state and jump to bootloader. | 43 | // reset the EEPROM valid state and jump to bootloader. |
| 47 | // This isn't very generalized, but we need something that doesn't | 44 | // This isn't very generalized, but we need something that doesn't |
| 48 | // rely on user's keymaps in firmware or EEPROM. | 45 | // rely on user's keymaps in firmware or EEPROM. |
| 49 | uint8_t row = BOOTMAGIC_LITE_ROW; | 46 | uint8_t row = BOOTMAGIC_ROW; |
| 50 | uint8_t col = BOOTMAGIC_LITE_COLUMN; | 47 | uint8_t col = BOOTMAGIC_COLUMN; |
| 51 | 48 | ||
| 52 | #if defined(SPLIT_KEYBOARD) && defined(BOOTMAGIC_LITE_ROW_RIGHT) && defined(BOOTMAGIC_LITE_COLUMN_RIGHT) | 49 | #if defined(SPLIT_KEYBOARD) && defined(BOOTMAGIC_ROW_RIGHT) && defined(BOOTMAGIC_COLUMN_RIGHT) |
| 53 | if (!is_keyboard_left()) { | 50 | if (!is_keyboard_left()) { |
| 54 | row = BOOTMAGIC_LITE_ROW_RIGHT; | 51 | row = BOOTMAGIC_ROW_RIGHT; |
| 55 | col = BOOTMAGIC_LITE_COLUMN_RIGHT; | 52 | col = BOOTMAGIC_COLUMN_RIGHT; |
| 56 | } | 53 | } |
| 57 | #endif | 54 | #endif |
| 58 | 55 | ||
| 59 | if (matrix_get_row(row) & (1 << col)) { | 56 | return matrix_get_row(row) & (1 << col); |
| 60 | bootmagic_lite_reset_eeprom(); | 57 | } |
| 58 | |||
| 59 | /** \brief The abridged version of TMK's bootmagic based on Wilba. | ||
| 60 | * | ||
| 61 | * 100% less potential for accidentally making the keyboard do stupid things. | ||
| 62 | */ | ||
| 63 | __attribute__((weak)) void bootmagic_scan(void) { | ||
| 64 | // We need multiple scans because debouncing can't be turned off. | ||
| 65 | matrix_scan(); | ||
| 66 | wait_ms(BOOTMAGIC_DEBOUNCE); | ||
| 67 | matrix_scan(); | ||
| 68 | |||
| 69 | if (bootmagic_should_reset()) { | ||
| 70 | bootmagic_reset_eeprom(); | ||
| 61 | 71 | ||
| 62 | // Jump to bootloader. | 72 | // Jump to bootloader. |
| 63 | bootloader_jump(); | 73 | bootloader_jump(); |
| @@ -65,5 +75,5 @@ __attribute__((weak)) void bootmagic_lite(void) { | |||
| 65 | } | 75 | } |
| 66 | 76 | ||
| 67 | void bootmagic(void) { | 77 | void bootmagic(void) { |
| 68 | bootmagic_lite(); | 78 | bootmagic_scan(); |
| 69 | } | 79 | } |
diff --git a/quantum/bootmagic/bootmagic.h b/quantum/bootmagic/bootmagic.h index 4b5f5f7c5e..ee6fb49748 100644 --- a/quantum/bootmagic/bootmagic.h +++ b/quantum/bootmagic/bootmagic.h | |||
| @@ -15,11 +15,26 @@ | |||
| 15 | */ | 15 | */ |
| 16 | #pragma once | 16 | #pragma once |
| 17 | 17 | ||
| 18 | #ifndef BOOTMAGIC_LITE_COLUMN | 18 | // ======== DEPRECATED DEFINES - DO NOT USE ======== |
| 19 | # define BOOTMAGIC_LITE_COLUMN 0 | 19 | #ifdef BOOTMAGIC_LITE_ROW |
| 20 | # define BOOTMAGIC_ROW BOOTMAGIC_LITE_ROW | ||
| 20 | #endif | 21 | #endif |
| 21 | #ifndef BOOTMAGIC_LITE_ROW | 22 | #ifdef BOOTMAGIC_LITE_COLUMN |
| 22 | # define BOOTMAGIC_LITE_ROW 0 | 23 | # define BOOTMAGIC_COLUMN BOOTMAGIC_LITE_COLUMN |
| 24 | #endif | ||
| 25 | #ifdef BOOTMAGIC_LITE_ROW_RIGHT | ||
| 26 | # define BOOTMAGIC_ROW_RIGHT BOOTMAGIC_LITE_ROW_RIGHT | ||
| 27 | #endif | ||
| 28 | #ifdef BOOTMAGIC_LITE_COLUMN_RIGHT | ||
| 29 | # define BOOTMAGIC_COLUMN_RIGHT BOOTMAGIC_LITE_COLUMN_RIGHT | ||
| 30 | #endif | ||
| 31 | // ======== | ||
| 32 | |||
| 33 | #ifndef BOOTMAGIC_COLUMN | ||
| 34 | # define BOOTMAGIC_COLUMN 0 | ||
| 35 | #endif | ||
| 36 | #ifndef BOOTMAGIC_ROW | ||
| 37 | # define BOOTMAGIC_ROW 0 | ||
| 23 | #endif | 38 | #endif |
| 24 | 39 | ||
| 25 | void bootmagic(void); | 40 | void bootmagic(void); |
