summaryrefslogtreecommitdiff
path: root/docs/keymap.md
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2024-05-30 10:00:28 +0100
committerGitHub <noreply@github.com>2024-05-30 10:00:28 +0100
commitb39285807e1d21300e8a5dbbf6f2c43a8aab3494 (patch)
tree311895a73c967f5d322885c1a9f1073a7b9f1b91 /docs/keymap.md
parent6ef97172889ccd5db376b2a9f8825489e24fdac4 (diff)
[docs] Fix code blocks overflowing page width (#23829)
Fix code blocks overflowing page width
Diffstat (limited to 'docs/keymap.md')
-rw-r--r--docs/keymap.md155
1 files changed, 82 insertions, 73 deletions
diff --git a/docs/keymap.md b/docs/keymap.md
index e371fd9ba5..864d3e14f4 100644
--- a/docs/keymap.md
+++ b/docs/keymap.md
@@ -10,20 +10,21 @@ For trivial key definitions, the higher 8 bits of the **action code** are all 0
10 10
11Respective layers can be validated simultaneously. Layers are indexed with 0 to 31 and higher layer has precedence. 11Respective layers can be validated simultaneously. Layers are indexed with 0 to 31 and higher layer has precedence.
12 12
13 Keymap: 32 Layers Layer: action code matrix 13```
14 ----------------- --------------------- 14Keymap: 32 Layers Layer: action code matrix
15 stack of layers array_of_action_code[row][column] 15----------------- ---------------------
16 ____________ precedence _______________________ 16stack of layers array_of_action_code[row][column]
17 / / | high / ESC / F1 / F2 / F3 .... 17 ____________ precedence _______________________
18 31 /___________// | /-----/-----/-----/----- 18 / / | high / ESC / F1 / F2 / F3 ....
19 30 /___________// | / TAB / Q / W / E .... 19 31 /___________// | /-----/-----/-----/-----
20 29 /___________/ | /-----/-----/-----/----- 20 30 /___________// | / TAB / Q / W / E ....
21 : _:_:_:_:_:__ | : /LCtrl/ A / S / D .... 21 29 /___________/ | /-----/-----/-----/-----
22 : / : : : : : / | : / : : : : 22 : _:_:_:_:_:__ | : /LCtrl/ A / S / D ....
23 2 /___________// | 2 `-------------------------- 23 : / : : : : : / | : / : : : :
24 1 /___________// | 1 `-------------------------- 24 2 /___________// | 2 `--------------------------
25 0 /___________/ V low 0 `-------------------------- 25 1 /___________// | 1 `--------------------------
26 26 0 /___________/ V low 0 `--------------------------
27```
27 28
28Sometimes, the action code stored in keymap may be referred as keycode in some documents due to the TMK history. 29Sometimes, the action code stored in keymap may be referred as keycode in some documents due to the TMK history.
29 30
@@ -36,50 +37,54 @@ The state of the Keymap layer is determined by two 32 bit parameters:
36 37
37Keymap layer '0' is usually the `default_layer`, with other layers initially off after booting up the firmware, although this can configured differently in `config.h`. It is useful to change `default_layer` when you completely switch a key layout, for example, if you want to switch to Colemak instead of Qwerty. 38Keymap layer '0' is usually the `default_layer`, with other layers initially off after booting up the firmware, although this can configured differently in `config.h`. It is useful to change `default_layer` when you completely switch a key layout, for example, if you want to switch to Colemak instead of Qwerty.
38 39
39 Initial state of Keymap Change base layout 40```
40 ----------------------- ------------------ 41Initial state of Keymap Change base layout
41 42----------------------- ------------------
42 31 31 43
43 30 30 44 31 31
44 29 29 45 30 30
45 : : 46 29 29
46 : : ____________ 47 : :
47 2 ____________ 2 / / 48 : : ____________
48 1 / / ,->1 /___________/ 49 2 ____________ 2 / /
49 ,->0 /___________/ | 0 50 1 / / ,->1 /___________/
50 | | 51,->0 /___________/ | 0
51 `--- default_layer = 0 `--- default_layer = 1 52| |
52 layer_state = 0x00000001 layer_state = 0x00000002 53`--- default_layer = 0 `--- default_layer = 1
54 layer_state = 0x00000001 layer_state = 0x00000002
55```
53 56
54On the other hand, you can change `layer_state` to overlay the base layer with other layers for features such as navigation keys, function keys (F1-F12), media keys, and/or special actions. 57On the other hand, you can change `layer_state` to overlay the base layer with other layers for features such as navigation keys, function keys (F1-F12), media keys, and/or special actions.
55 58
56 Overlay feature layer 59```
57 --------------------- bit|status 60Overlay feature layer
58 ____________ ---+------ 61--------------------- bit|status
59 31 / / 31 | 0 62 ____________ ---+------
60 30 /___________// -----> 30 | 1 63 31 / / 31 | 0
61 29 /___________/ -----> 29 | 1 64 30 /___________// -----> 30 | 1
62 : : | : 65 29 /___________/ -----> 29 | 1
63 : ____________ : | : 66 : : | :
64 2 / / 2 | 0 67 : ____________ : | :
65 ,->1 /___________/ -----> 1 | 1 68 2 / / 2 | 0
66 | 0 0 | 0 69,->1 /___________/ -----> 1 | 1
67 | + 70| 0 0 | 0
68 `--- default_layer = 1 | 71| +
69 layer_state = 0x60000002 <-' 72`--- default_layer = 1 |
70 73 layer_state = 0x60000002 <-'
71 74```
72 75
73### Layer Precedence and Transparency 76### Layer Precedence and Transparency
74Note that ***higher layers have higher priority within the stack of layers***. The firmware works its way down from the highest active layers to look up keycodes. Once the firmware locates a keycode other than `KC_TRNS` (transparent) on an active layer, it stops searching, and lower layers aren't referenced. 77Note that ***higher layers have higher priority within the stack of layers***. The firmware works its way down from the highest active layers to look up keycodes. Once the firmware locates a keycode other than `KC_TRNS` (transparent) on an active layer, it stops searching, and lower layers aren't referenced.
75 78
76 ____________ 79```
77 / / <--- Higher layer 80 ____________
78 / KC_TRNS // 81 / / <--- Higher layer
79 /___________// <--- Lower layer (KC_A) 82 / KC_TRNS //
80 /___________/ 83/___________// <--- Lower layer (KC_A)
81 84/___________/
82 In the above scenario, the non-transparent keys on the higher layer would be usable, but whenever `KC_TRNS` (or equivalent) is defined, the keycode (`KC_A`) on the lower level would be used. 85```
86
87In the above scenario, the non-transparent keys on the higher layer would be usable, but whenever `KC_TRNS` (or equivalent) is defined, the keycode (`KC_A`) on the lower level would be used.
83 88
84**Note:** Valid ways to denote transparency on a given layer: 89**Note:** Valid ways to denote transparency on a given layer:
85* `KC_TRANSPARENT` 90* `KC_TRANSPARENT`
@@ -101,27 +106,29 @@ There are 2 main sections of a `keymap.c` file you'll want to concern yourself w
101 106
102At the top of the file you'll find this: 107At the top of the file you'll find this:
103 108
104 #include QMK_KEYBOARD_H 109```c
105 110#include QMK_KEYBOARD_H
106 // Helpful defines 111
107 #define GRAVE_MODS (MOD_BIT(KC_LSFT)|MOD_BIT(KC_RSFT)|MOD_BIT(KC_LGUI)|MOD_BIT(KC_RGUI)|MOD_BIT(KC_LALT)|MOD_BIT(KC_RALT)) 112// Helpful defines
108 113#define GRAVE_MODS (MOD_BIT(KC_LSFT)|MOD_BIT(KC_RSFT)|MOD_BIT(KC_LGUI)|MOD_BIT(KC_RGUI)|MOD_BIT(KC_LALT)|MOD_BIT(KC_RALT))
109 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 114
110 * You can use _______ in place for KC_TRNS (transparent) * 115/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
111 * Or you can use XXXXXXX for KC_NO (NOOP) * 116 * You can use _______ in place for KC_TRNS (transparent) *
112 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 117 * Or you can use XXXXXXX for KC_NO (NOOP) *
113 118 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
114 // Each layer gets a name for readability. 119
115 // The underscores don't mean anything - you can 120// Each layer gets a name for readability.
116 // have a layer called STUFF or any other name. 121// The underscores don't mean anything - you can
117 // Layer names don't all need to be of the same 122// have a layer called STUFF or any other name.
118 // length, and you can also skip them entirely 123// Layer names don't all need to be of the same
119 // and just use numbers. 124// length, and you can also skip them entirely
120 enum layer_names { 125// and just use numbers.
121 _BL, 126enum layer_names {
122 _FL, 127 _BL,
123 _CL, 128 _FL,
124 }; 129 _CL,
130};
131```
125 132
126These are some handy definitions we can use when building our keymap and our custom function. The `GRAVE_MODS` definition will be used later in our custom function, and the following `_BL`, `_FL`, and `_CL` defines make it easier to refer to each of our layers. 133These are some handy definitions we can use when building our keymap and our custom function. The `GRAVE_MODS` definition will be used later in our custom function, and the following `_BL`, `_FL`, and `_CL` defines make it easier to refer to each of our layers.
127 134
@@ -131,7 +138,9 @@ Note: You may also find some older keymap files may also have a define(s) for `_
131 138
132The main part of this file is the `keymaps[]` definition. This is where you list your layers and the contents of those layers. This part of the file begins with this definition: 139The main part of this file is the `keymaps[]` definition. This is where you list your layers and the contents of those layers. This part of the file begins with this definition:
133 140
134 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 141```c
142const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
143```
135 144
136After this you'll find the layer definitions. Typically you'll have one or more "base layers" (such as QWERTY, Dvorak, or Colemak) and then you'll layer on top of that one or more "function" layers. Due to the way layers are processed you can't overlay a "lower" layer on top of a "higher" layer. 145After this you'll find the layer definitions. Typically you'll have one or more "base layers" (such as QWERTY, Dvorak, or Colemak) and then you'll layer on top of that one or more "function" layers. Due to the way layers are processed you can't overlay a "lower" layer on top of a "higher" layer.
137 146