diff --git a/data/mappings/info_config.hjson b/data/mappings/info_config.hjson index 2c4a75df895..e2e9569372e 100644 --- a/data/mappings/info_config.hjson +++ b/data/mappings/info_config.hjson @@ -36,10 +36,10 @@ "BACKLIGHT_DEFAULT_LEVEL": {"info_key": "backlight.default.brightness", "value_type": "int"}, // Bootmagic - "BOOTMAGIC_LITE_COLUMN": {"info_key": "bootmagic.matrix.1", "value_type": "int"}, - "BOOTMAGIC_LITE_COLUMN_RIGHT": {"info_key": "split.bootmagic.matrix.1", "value_type": "int"}, - "BOOTMAGIC_LITE_ROW": {"info_key": "bootmagic.matrix.0", "value_type": "int"}, - "BOOTMAGIC_LITE_ROW_RIGHT": {"info_key": "split.bootmagic.matrix.0", "value_type": "int"}, + "BOOTMAGIC_COLUMN": {"info_key": "bootmagic.matrix.1", "value_type": "int"}, + "BOOTMAGIC_COLUMN_RIGHT": {"info_key": "split.bootmagic.matrix.1", "value_type": "int"}, + "BOOTMAGIC_ROW": {"info_key": "bootmagic.matrix.0", "value_type": "int"}, + "BOOTMAGIC_ROW_RIGHT": {"info_key": "split.bootmagic.matrix.0", "value_type": "int"}, // Caps Word "BOTH_SHIFTS_TURNS_ON_CAPS_WORD": {"info_key": "caps_word.both_shifts_turns_on", "value_type": "flag"}, diff --git a/docs/feature_bootmagic.md b/docs/feature_bootmagic.md index 4239cdfd2a2..564760be925 100644 --- a/docs/feature_bootmagic.md +++ b/docs/feature_bootmagic.md @@ -1,8 +1,8 @@ -# Bootmagic Lite :id=bootmagic-lite +# Bootmagic :id=bootmagic -The Bootmagic Lite feature that only handles jumping into the bootloader. This is great for boards that don't have a physical reset button, giving you a way to jump into the bootloader +The Bootmagic feature that only handles jumping into the bootloader. This is great for boards that don't have a physical reset button, giving you a way to jump into the bootloader -On some keyboards Bootmagic Lite is disabled by default. If this is the case, it must be explicitly enabled in your `rules.mk` with: +On some keyboards Bootmagic is disabled by default. If this is the case, it must be explicitly enabled in your `rules.mk` with: ```make BOOTMAGIC_ENABLE = yes @@ -11,15 +11,15 @@ BOOTMAGIC_ENABLE = yes Additionally, you may want to specify which key to use. This is especially useful for keyboards that have unusual matrices. To do so, you need to specify the row and column of the key that you want to use. Add these entries to your `config.h` file: ```c -#define BOOTMAGIC_LITE_ROW 0 -#define BOOTMAGIC_LITE_COLUMN 1 +#define BOOTMAGIC_ROW 0 +#define BOOTMAGIC_COLUMN 1 ``` By default, these are set to 0 and 0, which is usually the "ESC" key on a majority of keyboards. And to trigger the bootloader, you hold this key down when plugging the keyboard in. Just the single key. -!> Using Bootmagic Lite will **always reset** the EEPROM, so you will lose any settings that have been saved. +!> Using Bootmagic will **always reset** the EEPROM, so you will lose any settings that have been saved. ## Split Keyboards @@ -44,35 +44,35 @@ When [handedness](feature_split_keyboard.md#setting-handedness) is predetermined } ``` -If you pick the top right key for the right half, it is `R05` on the top layout. Within the key matrix below, `R05` is located on row 4 columnn 4. To use that key as the right half's Bootmagic Lite trigger, add these entries to your `config.h` file: +If you pick the top right key for the right half, it is `R05` on the top layout. Within the key matrix below, `R05` is located on row 4 columnn 4. To use that key as the right half's Bootmagic trigger, add these entries to your `config.h` file: ```c -#define BOOTMAGIC_LITE_ROW_RIGHT 4 -#define BOOTMAGIC_LITE_COLUMN_RIGHT 4 +#define BOOTMAGIC_ROW_RIGHT 4 +#define BOOTMAGIC_COLUMN_RIGHT 4 ``` ?> These values are not set by default. -## Advanced Bootmagic Lite +## Advanced Bootmagic -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_scan` 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. To replace the function, all you need to do is add something like this to your code: ```c -void bootmagic_lite(void) { +void bootmagic_scan(void) { matrix_scan(); wait_ms(DEBOUNCE * 2); matrix_scan(); - if (matrix_get_row(BOOTMAGIC_LITE_ROW) & (1 << BOOTMAGIC_LITE_COLUMN)) { + if (matrix_get_row(BOOTMAGIC_ROW) & (1 << BOOTMAGIC_COLUMN)) { // Jump to bootloader. bootloader_jump(); } } ``` -You can define additional logic here. For instance, resetting the EEPROM or requiring additional keys to be pressed to trigger Bootmagic Lite. Keep in mind that `bootmagic_lite` is called before a majority of features are initialized in the firmware. +You can define additional logic here. For instance, resetting the EEPROM or requiring additional keys to be pressed to trigger Bootmagic. Keep in mind that `bootmagic_scan` is called before a majority of features are initialized in the firmware. ## Addenda diff --git a/docs/ja/feature_bootmagic.md b/docs/ja/feature_bootmagic.md index 2ad6fc85313..c146176a7ee 100644 --- a/docs/ja/feature_bootmagic.md +++ b/docs/ja/feature_bootmagic.md @@ -139,8 +139,8 @@ BOOTMAGIC_ENABLE = lite さらに、どのキーを使うかを指定したほうが良いかもしれません。これは普通ではないマトリックスを持つキーボードで特に便利です。そのためには、使いたいキーの行と列を指定する必要があります。`config.h` ファイルにこれらのエントリを追加します: ```c -#define BOOTMAGIC_LITE_ROW 0 -#define BOOTMAGIC_LITE_COLUMN 1 +#define BOOTMAGIC_ROW 0 +#define BOOTMAGIC_COLUMN 1 ``` デフォルトでは、これらは 0 と 0 に設定されます。これは通常はほとんどのキーボードで "ESC" キーです。 @@ -154,8 +154,8 @@ BOOTMAGIC_ENABLE = lite `SPLIT_HAND_PIN` のようなオプションで、左右の設定があらかじめ決められている場合は、キーボードの左右で別のキーを設定する必要があるかもしれません。これを行うには、`config.h` ファイルに以下のエントリを追加します。 ```c -#define BOOTMAGIC_LITE_ROW_RIGHT 4 -#define BOOTMAGIC_LITE_COLUMN_RIGHT 1 +#define BOOTMAGIC_ROW_RIGHT 4 +#define BOOTMAGIC_COLUMN_RIGHT 1 ``` デフォルトでは、これらの値は設定されていません。 @@ -172,7 +172,7 @@ void bootmagic_lite(void) { wait_ms(DEBOUNCE * 2); matrix_scan(); - if (matrix_get_row(BOOTMAGIC_LITE_ROW) & (1 << BOOTMAGIC_LITE_COLUMN)) { + if (matrix_get_row(BOOTMAGIC_ROW) & (1 << BOOTMAGIC_COLUMN)) { // ブートローダにジャンプする。 bootloader_jump(); } diff --git a/keyboards/crkbd/post_config.h b/keyboards/crkbd/post_config.h index 133014b02ad..aaf405a5bf9 100644 --- a/keyboards/crkbd/post_config.h +++ b/keyboards/crkbd/post_config.h @@ -16,18 +16,18 @@ #pragma once -#ifndef BOOTMAGIC_LITE_ROW -# define BOOTMAGIC_LITE_ROW 0 +#ifndef BOOTMAGIC_ROW +# define BOOTMAGIC_ROW 0 #endif -#ifndef BOOTMAGIC_LITE_COLUMN -# define BOOTMAGIC_LITE_COLUMN 1 +#ifndef BOOTMAGIC_COLUMN +# define BOOTMAGIC_COLUMN 1 #endif -#ifndef BOOTMAGIC_LITE_ROW_RIGHT -# define BOOTMAGIC_LITE_ROW_RIGHT 4 +#ifndef BOOTMAGIC_ROW_RIGHT +# define BOOTMAGIC_ROW_RIGHT 4 #endif -#ifndef BOOTMAGIC_LITE_COLUMN_RIGHT -# define BOOTMAGIC_LITE_COLUMN_RIGHT 1 +#ifndef BOOTMAGIC_COLUMN_RIGHT +# define BOOTMAGIC_COLUMN_RIGHT 1 #endif #ifdef RGBLIGHT_ENABLE diff --git a/keyboards/handwired/tractyl_manuform/5x6_right/f411/f411.c b/keyboards/handwired/tractyl_manuform/5x6_right/f411/f411.c index 10986fd25ff..a0c3ee0f4e4 100644 --- a/keyboards/handwired/tractyl_manuform/5x6_right/f411/f411.c +++ b/keyboards/handwired/tractyl_manuform/5x6_right/f411/f411.c @@ -24,7 +24,7 @@ void matrix_scan_sub_kb(void) { } } -__attribute__((weak)) void bootmagic_lite(void) { +__attribute__((weak)) void bootmagic_scan(void) { // We need multiple scans because debouncing can't be turned off. matrix_scan(); #if defined(DEBOUNCE) && DEBOUNCE > 0 @@ -34,13 +34,13 @@ __attribute__((weak)) void bootmagic_lite(void) { #endif matrix_scan(); - uint8_t row = BOOTMAGIC_LITE_ROW; - uint8_t col = BOOTMAGIC_LITE_COLUMN; + uint8_t row = BOOTMAGIC_ROW; + uint8_t col = BOOTMAGIC_COLUMN; -#if defined(SPLIT_KEYBOARD) && defined(BOOTMAGIC_LITE_ROW_RIGHT) && defined(BOOTMAGIC_LITE_COLUMN_RIGHT) +#if defined(SPLIT_KEYBOARD) && defined(BOOTMAGIC_ROW_RIGHT) && defined(BOOTMAGIC_COLUMN_RIGHT) if (!is_keyboard_left()) { - row = BOOTMAGIC_LITE_ROW_RIGHT; - col = BOOTMAGIC_LITE_COLUMN_RIGHT; + row = BOOTMAGIC_ROW_RIGHT; + col = BOOTMAGIC_COLUMN_RIGHT; } #endif diff --git a/keyboards/jorne/post_config.h b/keyboards/jorne/post_config.h index 4a4c71517a7..7d159c0de20 100644 --- a/keyboards/jorne/post_config.h +++ b/keyboards/jorne/post_config.h @@ -2,18 +2,18 @@ // SPDX-License-Identifier: GPL-2.0-or-later #pragma once -#ifndef BOOTMAGIC_LITE_ROW -# define BOOTMAGIC_LITE_ROW 0 +#ifndef BOOTMAGIC_ROW +# define BOOTMAGIC_ROW 0 #endif -#ifndef BOOTMAGIC_LITE_COLUMN -# define BOOTMAGIC_LITE_COLUMN 1 +#ifndef BOOTMAGIC_COLUMN +# define BOOTMAGIC_COLUMN 1 #endif -#ifndef BOOTMAGIC_LITE_ROW_RIGHT -# define BOOTMAGIC_LITE_ROW_RIGHT 4 +#ifndef BOOTMAGIC_ROW_RIGHT +# define BOOTMAGIC_ROW_RIGHT 4 #endif -#ifndef BOOTMAGIC_LITE_COLUMN_RIGHT -# define BOOTMAGIC_LITE_COLUMN_RIGHT 1 +#ifndef BOOTMAGIC_COLUMN_RIGHT +# define BOOTMAGIC_COLUMN_RIGHT 1 #endif #ifdef RGBLIGHT_ENABLE diff --git a/keyboards/junco/rev1/post_config.h b/keyboards/junco/rev1/post_config.h index bcc15a941a0..d9fa5e4c603 100644 --- a/keyboards/junco/rev1/post_config.h +++ b/keyboards/junco/rev1/post_config.h @@ -7,9 +7,9 @@ // Top left for left side is default in core // Top right for right side -#ifndef BOOTMAGIC_LITE_ROW_RIGHT -# define BOOTMAGIC_LITE_ROW_RIGHT 5 +#ifndef BOOTMAGIC_ROW_RIGHT +# define BOOTMAGIC_ROW_RIGHT 5 #endif -#ifndef BOOTMAGIC_LITE_COLUMN_RIGHT -# define BOOTMAGIC_LITE_COLUMN_RIGHT 0 +#ifndef BOOTMAGIC_COLUMN_RIGHT +# define BOOTMAGIC_COLUMN_RIGHT 0 #endif diff --git a/keyboards/nullbitsco/scramble/keymaps/oled/config.h b/keyboards/nullbitsco/scramble/keymaps/oled/config.h index cd980b09366..67a896c8af0 100644 --- a/keyboards/nullbitsco/scramble/keymaps/oled/config.h +++ b/keyboards/nullbitsco/scramble/keymaps/oled/config.h @@ -18,5 +18,5 @@ along with this program. If not, see . #pragma once // Alternate boot pins for accessing the bootloader, // since the boot switch is blocked by the OLED. -#define BOOTMAGIC_LITE_ROW 1 -#define BOOTMAGIC_LITE_COLUMN 2 +#define BOOTMAGIC_ROW 1 +#define BOOTMAGIC_COLUMN 2 diff --git a/keyboards/phoenix/phoenix.c b/keyboards/phoenix/phoenix.c index 706a65b4dee..e870f987f4c 100644 --- a/keyboards/phoenix/phoenix.c +++ b/keyboards/phoenix/phoenix.c @@ -2,7 +2,7 @@ #include "usb_main.h" #include "phoenix.h" -void bootmagic_lite(void) { +void bootmagic_scan(void) { matrix_scan(); wait_ms(5); matrix_scan(); diff --git a/quantum/bootmagic/bootmagic.c b/quantum/bootmagic/bootmagic.c index efce6bfd121..419ec5229e4 100644 --- a/quantum/bootmagic/bootmagic.c +++ b/quantum/bootmagic/bootmagic.c @@ -20,44 +20,54 @@ #include "eeconfig.h" #include "bootloader.h" +#ifndef BOOTMAGIC_DEBOUNCE +# if defined(DEBOUNCE) && DEBOUNCE > 0 +# define BOOTMAGIC_DEBOUNCE (DEBOUNCE * 2) +# else +# define BOOTMAGIC_DEBOUNCE 30 +# endif +#endif + /** \brief Reset eeprom * * ...just incase someone wants to only change the eeprom behaviour */ -__attribute__((weak)) void bootmagic_lite_reset_eeprom(void) { +__attribute__((weak)) void bootmagic_reset_eeprom(void) { eeconfig_disable(); } -/** \brief The lite version of TMK's bootmagic based on Wilba. - * - * 100% less potential for accidentally making the keyboard do stupid things. +/** \brief Decide reboot based on current matrix state */ -__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(); - +__attribute__((weak)) bool bootmagic_should_reset(void) { // 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; + uint8_t row = BOOTMAGIC_ROW; + uint8_t col = BOOTMAGIC_COLUMN; -#if defined(SPLIT_KEYBOARD) && defined(BOOTMAGIC_LITE_ROW_RIGHT) && defined(BOOTMAGIC_LITE_COLUMN_RIGHT) +#if defined(SPLIT_KEYBOARD) && defined(BOOTMAGIC_ROW_RIGHT) && defined(BOOTMAGIC_COLUMN_RIGHT) if (!is_keyboard_left()) { - row = BOOTMAGIC_LITE_ROW_RIGHT; - col = BOOTMAGIC_LITE_COLUMN_RIGHT; + row = BOOTMAGIC_ROW_RIGHT; + col = BOOTMAGIC_COLUMN_RIGHT; } #endif - if (matrix_get_row(row) & (1 << col)) { - bootmagic_lite_reset_eeprom(); + return matrix_get_row(row) & (1 << col); +} + +/** \brief The abridged version of TMK's bootmagic based on Wilba. + * + * 100% less potential for accidentally making the keyboard do stupid things. + */ +__attribute__((weak)) void bootmagic_scan(void) { + // We need multiple scans because debouncing can't be turned off. + matrix_scan(); + wait_ms(BOOTMAGIC_DEBOUNCE); + matrix_scan(); + + if (bootmagic_should_reset()) { + bootmagic_reset_eeprom(); // Jump to bootloader. bootloader_jump(); @@ -65,5 +75,5 @@ __attribute__((weak)) void bootmagic_lite(void) { } void bootmagic(void) { - bootmagic_lite(); + bootmagic_scan(); } diff --git a/quantum/bootmagic/bootmagic.h b/quantum/bootmagic/bootmagic.h index 4b5f5f7c5e8..ee6fb49748e 100644 --- a/quantum/bootmagic/bootmagic.h +++ b/quantum/bootmagic/bootmagic.h @@ -15,11 +15,26 @@ */ #pragma once -#ifndef BOOTMAGIC_LITE_COLUMN -# define BOOTMAGIC_LITE_COLUMN 0 +// ======== DEPRECATED DEFINES - DO NOT USE ======== +#ifdef BOOTMAGIC_LITE_ROW +# define BOOTMAGIC_ROW BOOTMAGIC_LITE_ROW #endif -#ifndef BOOTMAGIC_LITE_ROW -# define BOOTMAGIC_LITE_ROW 0 +#ifdef BOOTMAGIC_LITE_COLUMN +# define BOOTMAGIC_COLUMN BOOTMAGIC_LITE_COLUMN +#endif +#ifdef BOOTMAGIC_LITE_ROW_RIGHT +# define BOOTMAGIC_ROW_RIGHT BOOTMAGIC_LITE_ROW_RIGHT +#endif +#ifdef BOOTMAGIC_LITE_COLUMN_RIGHT +# define BOOTMAGIC_COLUMN_RIGHT BOOTMAGIC_LITE_COLUMN_RIGHT +#endif +// ======== + +#ifndef BOOTMAGIC_COLUMN +# define BOOTMAGIC_COLUMN 0 +#endif +#ifndef BOOTMAGIC_ROW +# define BOOTMAGIC_ROW 0 #endif void bootmagic(void);