diff options
| author | Joel Challis <git@zvecr.com> | 2021-02-28 15:50:15 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-28 15:50:15 +0000 |
| commit | a3cbc8a004f6ec5b0e1df326353a2a2fc8221129 (patch) | |
| tree | a124699fd5e949703b24abea49df14c34b89f43a /quantum/bootmagic/bootmagic_lite.c | |
| parent | 02dc3b672217a4bc28b68c944863efd34dc28108 (diff) | |
| download | qmk_firmware-a3cbc8a004f6ec5b0e1df326353a2a2fc8221129.tar.gz qmk_firmware-a3cbc8a004f6ec5b0e1df326353a2a2fc8221129.zip | |
Overhaul bootmagic logic to have single entrypoint (#8532)
* Relocate bootmagic logic to have single entrypoint
* Align init of layer state
Diffstat (limited to 'quantum/bootmagic/bootmagic_lite.c')
| -rw-r--r-- | quantum/bootmagic/bootmagic_lite.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/quantum/bootmagic/bootmagic_lite.c b/quantum/bootmagic/bootmagic_lite.c new file mode 100644 index 000000000..9cbdcb0bb --- /dev/null +++ b/quantum/bootmagic/bootmagic_lite.c | |||
| @@ -0,0 +1,66 @@ | |||
| 1 | /* Copyright 2021 QMK | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 3 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #include "quantum.h" | ||
| 17 | |||
| 18 | /** \brief Reset eeprom | ||
| 19 | * | ||
| 20 | * ...just incase someone wants to only change the eeprom behaviour | ||
| 21 | */ | ||
| 22 | __attribute__((weak)) void bootmagic_lite_reset_eeprom(void) { | ||
| 23 | #if defined(VIA_ENABLE) | ||
| 24 | via_eeprom_reset(); | ||
| 25 | #else | ||
| 26 | eeconfig_disable(); | ||
| 27 | #endif | ||
| 28 | } | ||
| 29 | |||
| 30 | /** \brief The lite version of TMK's bootmagic based on Wilba. | ||
| 31 | * | ||
| 32 | * 100% less potential for accidentally making the keyboard do stupid things. | ||
| 33 | */ | ||
| 34 | __attribute__((weak)) void bootmagic_lite(void) { | ||
| 35 | // We need multiple scans because debouncing can't be turned off. | ||
| 36 | matrix_scan(); | ||
| 37 | #if defined(DEBOUNCE) && DEBOUNCE > 0 | ||
| 38 | wait_ms(DEBOUNCE * 2); | ||
| 39 | #else | ||
| 40 | wait_ms(30); | ||
| 41 | #endif | ||
| 42 | matrix_scan(); | ||
| 43 | |||
| 44 | // If the configured key (commonly Esc) is held down on power up, | ||
| 45 | // reset the EEPROM valid state and jump to bootloader. | ||
| 46 | // This isn't very generalized, but we need something that doesn't | ||
| 47 | // rely on user's keymaps in firmware or EEPROM. | ||
| 48 | uint8_t row = BOOTMAGIC_LITE_ROW; | ||
| 49 | uint8_t col = BOOTMAGIC_LITE_COLUMN; | ||
| 50 | |||
| 51 | #if defined(SPLIT_KEYBOARD) && defined(BOOTMAGIC_LITE_ROW_RIGHT) && defined(BOOTMAGIC_LITE_COLUMN_RIGHT) | ||
| 52 | if (!is_keyboard_left()) { | ||
| 53 | row = BOOTMAGIC_LITE_ROW_RIGHT; | ||
| 54 | col = BOOTMAGIC_LITE_COLUMN_RIGHT; | ||
| 55 | } | ||
| 56 | #endif | ||
| 57 | |||
| 58 | if (matrix_get_row(row) & (1 << col)) { | ||
| 59 | bootmagic_lite_reset_eeprom(); | ||
| 60 | |||
| 61 | // Jump to bootloader. | ||
| 62 | bootloader_jump(); | ||
| 63 | } | ||
| 64 | } | ||
| 65 | |||
| 66 | void bootmagic(void) { bootmagic_lite(); } | ||
