Add explicit id tags to externally linked headers
[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 |
ad8dbd5c
JC
37|`L` |Set "Left Hand" for EE_HANDS handedness |
38|`R` |Set "Right Hand" for EE_HANDS handedness |
f2ebafce 39|Backspace |Clear the EEPROM |
40|Caps Lock |Toggle treating Caps Lock as Left Control |
41|Left Control |Toggle swapping Caps Lock and Left Control |
42|Left Alt |Toggle swapping Left Alt and Left GUI |
43|Right Alt |Toggle swapping Right Alt and Right GUI |
44|Left GUI |Toggle the GUI keys (useful when gaming) |
45|<code>&#96;</code>|Toggle swapping <code>&#96;</code> and Escape|
46|`\` |Toggle swapping `\` and Backspace |
47|`N` |Toggle N-Key Rollover (NKRO) |
48|`0` |Make layer 0 the default layer |
49|`1` |Make layer 1 the default layer |
50|`2` |Make layer 2 the default layer |
51|`3` |Make layer 3 the default layer |
52|`4` |Make layer 4 the default layer |
53|`5` |Make layer 5 the default layer |
54|`6` |Make layer 6 the default layer |
55|`7` |Make layer 7 the default layer |
a8daf3ff 56
54c58ea6 57## Keycodes :id=keycodes
a8daf3ff 58
3ad389de 59|Key |Aliases |Description |
60|----------------------------------|---------|--------------------------------------------------------------------------|
61|`MAGIC_SWAP_CONTROL_CAPSLOCK` |`CL_SWAP`|Swap Caps Lock and Left Control |
62|`MAGIC_UNSWAP_CONTROL_CAPSLOCK` |`CL_NORM`|Unswap Caps Lock and Left Control |
63|`MAGIC_CAPSLOCK_TO_CONTROL` |`CL_CTRL`|Treat Caps Lock as Control |
64|`MAGIC_UNCAPSLOCK_TO_CONTROL` |`CL_CAPS`|Stop treating Caps Lock as Control |
65|`MAGIC_SWAP_LCTL_LGUI` |`LCG_SWP`|Swap Left Control and GUI |
66|`MAGIC_UNSWAP_LCTL_LGUI` |`LCG_NRM`|Unswap Left Control and GUI |
67|`MAGIC_SWAP_RCTL_RGUI` |`RCG_SWP`|Swap Right Control and GUI |
68|`MAGIC_UNSWAP_RCTL_RGUI` |`RCG_NRM`|Unswap Right Control and GUI |
69|`MAGIC_SWAP_CTL_GUI` |`CG_SWAP`|Swap Control and GUI on both sides |
70|`MAGIC_UNSWAP_CTL_GUI` |`CG_NORM`|Unswap Control and GUI on both sides |
71|`MAGIC_TOGGLE_CTL_GUI` |`CG_TOGG`|Toggle Control and GUI swap on both sides |
72|`MAGIC_SWAP_LALT_LGUI` |`LAG_SWP`|Swap Left Alt and GUI |
73|`MAGIC_UNSWAP_LALT_LGUI` |`LAG_NRM`|Unswap Left Alt and GUI |
74|`MAGIC_SWAP_RALT_RGUI` |`RAG_SWP`|Swap Right Alt and GUI |
75|`MAGIC_UNSWAP_RALT_RGUI` |`RAG_NRM`|Unswap Right Alt and GUI |
76|`MAGIC_SWAP_ALT_GUI` |`AG_SWAP`|Swap Alt and GUI on both sides |
77|`MAGIC_UNSWAP_ALT_GUI` |`AG_NORM`|Unswap Alt and GUI on both sides |
78|`MAGIC_TOGGLE_ALT_GUI` |`AG_TOGG`|Toggle Alt and GUI swap on both sides |
79|`MAGIC_NO_GUI` |`GUI_OFF`|Disable the GUI keys |
80|`MAGIC_UNNO_GUI` |`GUI_ON` |Enable the GUI keys |
81|`MAGIC_SWAP_GRAVE_ESC` |`GE_SWAP`|Swap <code>&#96;</code> and Escape |
82|`MAGIC_UNSWAP_GRAVE_ESC` |`GE_NORM`|Unswap <code>&#96;</code> and Escape |
83|`MAGIC_SWAP_BACKSLASH_BACKSPACE` |`BS_SWAP`|Swap `\` and Backspace |
84|`MAGIC_UNSWAP_BACKSLASH_BACKSPACE`|`BS_NORM`|Unswap `\` and Backspace |
85|`MAGIC_HOST_NKRO` |`NK_ON` |Enable N-key rollover |
86|`MAGIC_UNHOST_NKRO` |`NK_OFF` |Disable N-key rollover |
87|`MAGIC_TOGGLE_NKRO` |`NK_TOGG`|Toggle N-key rollover |
88|`MAGIC_EE_HANDS_LEFT` |`EH_LEFT`|Set the master half of a split keyboard as the left hand (for `EE_HANDS`) |
89|`MAGIC_EE_HANDS_RIGHT` |`EH_RGHT`|Set the master half of a split keyboard as the right hand (for `EE_HANDS`)|
a8daf3ff 90
f2ebafce 91## Configuration
a8daf3ff 92
f2ebafce 93If you would like to change the hotkey assignments for Bootmagic, `#define` these in your `config.h` at either the keyboard or keymap level.
a8daf3ff 94
f2ebafce 95|Define |Default |Description |
96|----------------------------------------|-------------|---------------------------------------------------|
97|`BOOTMAGIC_KEY_SALT` |`KC_SPACE` |The Bootmagic key |
98|`BOOTMAGIC_KEY_SKIP` |`KC_ESC` |Ignore Bootmagic configuration in EEPROM |
99|`BOOTMAGIC_KEY_EEPROM_CLEAR` |`KC_BSPACE` |Clear the EEPROM configuration |
100|`BOOTMAGIC_KEY_BOOTLOADER` |`KC_B` |Enter the bootloader |
101|`BOOTMAGIC_KEY_DEBUG_ENABLE` |`KC_D` |Toggle debugging over serial |
102|`BOOTMAGIC_KEY_DEBUG_MATRIX` |`KC_X` |Toggle matrix debugging |
103|`BOOTMAGIC_KEY_DEBUG_KEYBOARD` |`KC_K` |Toggle keyboard debugging |
104|`BOOTMAGIC_KEY_DEBUG_MOUSE` |`KC_M` |Toggle mouse debugging |
ad8dbd5c
JC
105|`BOOTMAGIC_KEY_EE_HANDS_LEFT` |`KC_L` |Set "Left Hand" for EE_HANDS handedness |
106|`BOOTMAGIC_KEY_EE_HANDS_RIGHT` |`KC_R` |Set "Right Hand" for EE_HANDS handedness |
f2ebafce 107|`BOOTMAGIC_KEY_SWAP_CONTROL_CAPSLOCK` |`KC_LCTRL` |Swap Left Control and Caps Lock |
108|`BOOTMAGIC_KEY_CAPSLOCK_TO_CONTROL` |`KC_CAPSLOCK`|Toggle treating Caps Lock as Left Control |
109|`BOOTMAGIC_KEY_SWAP_LALT_LGUI` |`KC_LALT` |Toggle swapping Left Alt and Left GUI (for macOS) |
110|`BOOTMAGIC_KEY_SWAP_RALT_RGUI` |`KC_RALT` |Toggle swapping Right Alt and Right GUI (for macOS)|
111|`BOOTMAGIC_KEY_NO_GUI` |`KC_LGUI` |Toggle the GUI keys (useful when gaming) |
112|`BOOTMAGIC_KEY_SWAP_GRAVE_ESC` |`KC_GRAVE` |Toggle swapping <code>&#96;</code> and Escape |
113|`BOOTMAGIC_KEY_SWAP_BACKSLASH_BACKSPACE`|`KC_BSLASH` |Toggle swapping `\` and Backspace |
114|`BOOTMAGIC_HOST_NKRO` |`KC_N` |Toggle N-Key Rollover (NKRO) |
115|`BOOTMAGIC_KEY_DEFAULT_LAYER_0` |`KC_0` |Make layer 0 the default layer |
116|`BOOTMAGIC_KEY_DEFAULT_LAYER_1` |`KC_1` |Make layer 1 the default layer |
117|`BOOTMAGIC_KEY_DEFAULT_LAYER_2` |`KC_2` |Make layer 2 the default layer |
118|`BOOTMAGIC_KEY_DEFAULT_LAYER_3` |`KC_3` |Make layer 3 the default layer |
119|`BOOTMAGIC_KEY_DEFAULT_LAYER_4` |`KC_4` |Make layer 4 the default layer |
120|`BOOTMAGIC_KEY_DEFAULT_LAYER_5` |`KC_5` |Make layer 5 the default layer |
121|`BOOTMAGIC_KEY_DEFAULT_LAYER_6` |`KC_6` |Make layer 6 the default layer |
122|`BOOTMAGIC_KEY_DEFAULT_LAYER_7` |`KC_7` |Make layer 7 the default layer |
4ffcacd9 123
54c58ea6 124# Bootmagic Lite :id=bootmagic-lite
4ffcacd9
DJ
125
126In 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.
127
128To enable this version of Bootmagic, you need to enable it in your `rules.mk` with:
129
130```make
131BOOTMAGIC_ENABLE = lite
132```
133
134Additionally, 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:
135
136```c
137#define BOOTMAGIC_LITE_ROW 0
138#define BOOTMAGIC_LITE_COLUMN 1
139```
140
141By default, these are set to 0 and 0, which is usually the "ESC" key on a majority of keyboards.
142
3a513fc3
YFL
143And to trigger the bootloader, you hold this key down when plugging the keyboard in. Just the single key.
144
145!> Using bootmagic lite will **always reset** the EEPROM, so you will lose any settings that have been saved.
4ffcacd9
DJ
146
147## Advanced Bootmagic Lite
148
149The `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.
150
151To replace the function, all you need to do is add something like this to your code:
152
153```c
154void bootmagic_lite(void) {
155 matrix_scan();
faaaa134 156 wait_ms(DEBOUNCE * 2);
4ffcacd9
DJ
157 matrix_scan();
158
159 if (matrix_get_row(BOOTMAGIC_LITE_ROW) & (1 << BOOTMAGIC_LITE_COLUMN)) {
160 // Jump to bootloader.
161 bootloader_jump();
162 }
163}
164```
165
166You 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.