Added macros to Dynamic Keymaps, Zeal60 RGB backlight improvements (#4520)
[jackhill/qmk/firmware.git] / docs / feature_bootmagic.md
CommitLineData
f2ebafce 1# Bootmagic
9b879b12 2
f2ebafce 3There are three separate but related features that allow you to change the behavior of your keyboard without reflashing. While each of them have similar functionality, it is accessed in different ways depending on how your keyboard is configured.
9b879b12 4
f2ebafce 5**Bootmagic** is a system for configuring your keyboard while it initializes. To trigger a Bootmagic command, hold down the Bootmagic key and one or more command keys.
9b879b12 6
f2ebafce 7**Bootmagic Keycodes** are prefixed with `MAGIC_`, and allow you to access the Bootmagic functionality *after* your keyboard has initialized. To use the keycodes, assign them to your keymap as you would any other keycode.
9b879b12 8
f2ebafce 9**Command**, formerly known as **Magic**, is another feature that allows you to control different aspects of your keyboard. While it shares some functionality with Bootmagic, it also allows you to do things that Bootmagic does not, such as printing version information to the console. For more information, see [Command](feature_command.md).
a8daf3ff 10
f2ebafce 11On some keyboards Bootmagic is disabled by default. If this is the case, it must be explicitly enabled in your `rules.mk` with:
a8daf3ff 12
f2ebafce 13```make
4ffcacd9
DJ
14BOOTMAGIC_ENABLE = full
15```
16
7373d5b3 17?> You may see `yes` being used in place of `full`, and this is okay. However, `yes` is deprecated, and ideally `full` (or `lite`) should be used instead.
4ffcacd9
DJ
18
19Additionally, you can use [Bootmagic Lite](#bootmagic-lite) (a scaled down, very basic version of Bootmagic) by adding the following to your `rules.mk` file:
20
21```make
22BOOTMAGIC_ENABLE = lite
f2ebafce 23```
a8daf3ff 24
f2ebafce 25## Hotkeys
a8daf3ff 26
f2ebafce 27Hold down the Bootmagic key (Space by default) and the desired hotkey while plugging in your keyboard. For example, holding Space+`B` should cause it to enter the bootloader.
a8daf3ff 28
f2ebafce 29|Hotkey |Description |
30|------------------|---------------------------------------------|
31|Escape |Ignore Bootmagic configuration in EEPROM |
32|`B` |Enter the bootloader |
33|`D` |Toggle debugging over serial |
34|`X` |Toggle key matrix debugging |
35|`K` |Toggle keyboard debugging |
36|`M` |Toggle mouse debugging |
37|Backspace |Clear the EEPROM |
38|Caps Lock |Toggle treating Caps Lock as Left Control |
39|Left Control |Toggle swapping Caps Lock and Left Control |
40|Left Alt |Toggle swapping Left Alt and Left GUI |
41|Right Alt |Toggle swapping Right Alt and Right GUI |
42|Left GUI |Toggle the GUI keys (useful when gaming) |
43|<code>&#96;</code>|Toggle swapping <code>&#96;</code> and Escape|
44|`\` |Toggle swapping `\` and Backspace |
45|`N` |Toggle N-Key Rollover (NKRO) |
46|`0` |Make layer 0 the default layer |
47|`1` |Make layer 1 the default layer |
48|`2` |Make layer 2 the default layer |
49|`3` |Make layer 3 the default layer |
50|`4` |Make layer 4 the default layer |
51|`5` |Make layer 5 the default layer |
52|`6` |Make layer 6 the default layer |
53|`7` |Make layer 7 the default layer |
a8daf3ff 54
f2ebafce 55## Keycodes
a8daf3ff 56
f2ebafce 57|Keycode |Aliases |Description |
58|----------------------------------|---------|------------------------------------------|
59|`MAGIC_CAPSLOCK_TO_CONTROL` | |Treat Caps Lock as Left Control |
60|`MAGIC_UNCAPSLOCK_TO_CONTROL` | |Stop treating Caps Lock as Left Control |
61|`MAGIC_HOST_NKRO` | |Force N-Key Rollover (NKRO) on |
62|`MAGIC_UNHOST_NKRO` | |Force NKRO off |
63|`MAGIC_TOGGLE_NKRO` | |Turn NKRO on or off |
64|`MAGIC_NO_GUI` | |Disable the GUI keys (useful when gaming) |
65|`MAGIC_UNNO_GUI` | |Enable the GUI keys |
66|`MAGIC_SWAP_ALT_GUI` |`AG_SWAP`|Swap Alt and GUI on both sides (for macOS)|
67|`MAGIC_UNSWAP_ALT_GUI` |`AG_NORM`|Unswap Left Alt and Left GUI |
a6d1db2c 68|`MAGIC_TOGGLE_ALT_GUI` |`AG_TOGG`|Toggle Left Alt and GUI swap |
f2ebafce 69|`MAGIC_SWAP_BACKSLASH_BACKSPACE` | |Swap `\` and Backspace |
70|`MAGIC_UNSWAP_BACKSLASH_BACKSPACE`| |Unswap `\` and Backspace |
71|`MAGIC_SWAP_CONTROL_CAPSLOCK` | |Swap Left Control and Caps Lock |
72|`MAGIC_UNSWAP_CONTROL_CAPSLOCK` | |Unswap Left Control and Caps Lock |
73|`MAGIC_SWAP_GRAVE_ESC` | |Swap <code>&#96;</code> and Escape |
74|`MAGIC_UNSWAP_GRAVE_ESC` | |Unswap <code>&#96;</code> and Escape |
75|`MAGIC_SWAP_LALT_LGUI` | |Swap Left Alt and Left GUI |
76|`MAGIC_UNSWAP_LALT_LGUI` | |Unswap Left Alt and Left GUI |
77|`MAGIC_SWAP_RALT_RGUI` | |Swap Right Alt and Right GUI |
78|`MAGIC_UNSWAP_RALT_RGUI` | |Unswap Right Alt and Right GUI |
a8daf3ff 79
f2ebafce 80## Configuration
a8daf3ff 81
f2ebafce 82If you would like to change the hotkey assignments for Bootmagic, `#define` these in your `config.h` at either the keyboard or keymap level.
a8daf3ff 83
f2ebafce 84|Define |Default |Description |
85|----------------------------------------|-------------|---------------------------------------------------|
86|`BOOTMAGIC_KEY_SALT` |`KC_SPACE` |The Bootmagic key |
87|`BOOTMAGIC_KEY_SKIP` |`KC_ESC` |Ignore Bootmagic configuration in EEPROM |
88|`BOOTMAGIC_KEY_EEPROM_CLEAR` |`KC_BSPACE` |Clear the EEPROM configuration |
89|`BOOTMAGIC_KEY_BOOTLOADER` |`KC_B` |Enter the bootloader |
90|`BOOTMAGIC_KEY_DEBUG_ENABLE` |`KC_D` |Toggle debugging over serial |
91|`BOOTMAGIC_KEY_DEBUG_MATRIX` |`KC_X` |Toggle matrix debugging |
92|`BOOTMAGIC_KEY_DEBUG_KEYBOARD` |`KC_K` |Toggle keyboard debugging |
93|`BOOTMAGIC_KEY_DEBUG_MOUSE` |`KC_M` |Toggle mouse debugging |
94|`BOOTMAGIC_KEY_SWAP_CONTROL_CAPSLOCK` |`KC_LCTRL` |Swap Left Control and Caps Lock |
95|`BOOTMAGIC_KEY_CAPSLOCK_TO_CONTROL` |`KC_CAPSLOCK`|Toggle treating Caps Lock as Left Control |
96|`BOOTMAGIC_KEY_SWAP_LALT_LGUI` |`KC_LALT` |Toggle swapping Left Alt and Left GUI (for macOS) |
97|`BOOTMAGIC_KEY_SWAP_RALT_RGUI` |`KC_RALT` |Toggle swapping Right Alt and Right GUI (for macOS)|
98|`BOOTMAGIC_KEY_NO_GUI` |`KC_LGUI` |Toggle the GUI keys (useful when gaming) |
99|`BOOTMAGIC_KEY_SWAP_GRAVE_ESC` |`KC_GRAVE` |Toggle swapping <code>&#96;</code> and Escape |
100|`BOOTMAGIC_KEY_SWAP_BACKSLASH_BACKSPACE`|`KC_BSLASH` |Toggle swapping `\` and Backspace |
101|`BOOTMAGIC_HOST_NKRO` |`KC_N` |Toggle N-Key Rollover (NKRO) |
102|`BOOTMAGIC_KEY_DEFAULT_LAYER_0` |`KC_0` |Make layer 0 the default layer |
103|`BOOTMAGIC_KEY_DEFAULT_LAYER_1` |`KC_1` |Make layer 1 the default layer |
104|`BOOTMAGIC_KEY_DEFAULT_LAYER_2` |`KC_2` |Make layer 2 the default layer |
105|`BOOTMAGIC_KEY_DEFAULT_LAYER_3` |`KC_3` |Make layer 3 the default layer |
106|`BOOTMAGIC_KEY_DEFAULT_LAYER_4` |`KC_4` |Make layer 4 the default layer |
107|`BOOTMAGIC_KEY_DEFAULT_LAYER_5` |`KC_5` |Make layer 5 the default layer |
108|`BOOTMAGIC_KEY_DEFAULT_LAYER_6` |`KC_6` |Make layer 6 the default layer |
109|`BOOTMAGIC_KEY_DEFAULT_LAYER_7` |`KC_7` |Make layer 7 the default layer |
4ffcacd9
DJ
110
111# Bootmagic Lite
112
113In addition to the full blown Bootmagic feature, is the Bootmagic Lite feature that only handles jumping into the bootloader. This is great for boards that don't have a physical reset button but you need a way to jump into the bootloader, and don't want to deal with the headache that Bootmagic can cause.
114
115To enable this version of Bootmagic, you need to enable it in your `rules.mk` with:
116
117```make
118BOOTMAGIC_ENABLE = lite
119```
120
121Additionally, 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:
122
123```c
124#define BOOTMAGIC_LITE_ROW 0
125#define BOOTMAGIC_LITE_COLUMN 1
126```
127
128By default, these are set to 0 and 0, which is usually the "ESC" key on a majority of keyboards.
129
130And to trigger the bootloader, you hold this key down when plugging the keyboard in. Just the single key.
131
132## Advanced Bootmagic Lite
133
134The `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.
135
136To replace the function, all you need to do is add something like this to your code:
137
138```c
139void bootmagic_lite(void) {
140 matrix_scan();
141 wait_ms(DEBOUNCING_DELAY * 2);
142 matrix_scan();
143
144 if (matrix_get_row(BOOTMAGIC_LITE_ROW) & (1 << BOOTMAGIC_LITE_COLUMN)) {
145 // Jump to bootloader.
146 bootloader_jump();
147 }
148}
149```
150
151You can additional feature here. For instance, resetting the eeprom or requiring additional keys to be pressed to trigger bootmagic. Keep in mind that `bootmagic_lite` is called before a majority of features are initialized in the firmware.