|
| 1 | +--- |
| 2 | +name: zmk-add-layer |
| 3 | +description: Guided walkthrough for adding a new layer to the ZMK config |
| 4 | +disable-model-invocation: true |
| 5 | +allowed-tools: Read, Grep, Glob |
| 6 | +--- |
| 7 | + |
| 8 | +Guide the user through adding a new layer. Read current state first, then walk through every required change. |
| 9 | + |
| 10 | +## Step 1: Gather Requirements |
| 11 | + |
| 12 | +Ask the user: |
| 13 | +1. **Layer name** — what to call it (e.g. MEDIA, NUMPAD, ARROWS) |
| 14 | +2. **Purpose** — what keys go on it |
| 15 | +3. **Which keyboards** — Sofle, Cradio, Bullet Train, or all three? |
| 16 | +4. **Home row mods?** — Gaming-adjacent layers should NOT have HRM |
| 17 | +5. **Switching method** — How to enter/exit: |
| 18 | + - `&mo` (momentary, release to exit) |
| 19 | + - `<` (layer-tap: hold=layer, tap=keycode) |
| 20 | + - `&to` (permanent switch, need combo or key to exit) |
| 21 | + - `&tog` (toggle on/off) |
| 22 | + - Conditional/tri-layer (activated by holding two layers) |
| 23 | + - Combo (3-finger switch) |
| 24 | + |
| 25 | +## Step 2: Determine Layer Index |
| 26 | + |
| 27 | +Read `config/wrappers.dtsi` and find the current highest layer index. |
| 28 | +New layer = highest + 1 (currently MOUSE=10, so next would be 11). |
| 29 | + |
| 30 | +**IMPORTANT**: Layer order in keymaps must match define order. The new layer goes AFTER all existing layers. |
| 31 | + |
| 32 | +## Step 3: Walk Through All Required Changes |
| 33 | + |
| 34 | +### 3a. Layer Index Define — `config/wrappers.dtsi` |
| 35 | + |
| 36 | +Add after the last `#define` in the layer index block: |
| 37 | +```c |
| 38 | +#define NEWLAYER 11 |
| 39 | +``` |
| 40 | +
|
| 41 | +### 3b. Core 5-Column Macros — `config/wrappers.dtsi` |
| 42 | +
|
| 43 | +Add a comment block following the existing format, then 6 macros: |
| 44 | +```c |
| 45 | +/* -------------------------------------------------------------------------- |
| 46 | + * NEWLAYER LAYER - Description |
| 47 | + * -------------------------------------------------------------------------- |
| 48 | + * _ _ _ _ _ _ _ _ _ _ |
| 49 | + * _ _ _ _ _ _ _ _ _ _ |
| 50 | + * _ _ _ _ _ _ _ _ _ _ |
| 51 | + */ |
| 52 | +#define ___NEWLAYER_L1___ ...5 keys... |
| 53 | +#define ___NEWLAYER_L2___ ...5 keys... |
| 54 | +#define ___NEWLAYER_L3___ ...5 keys... |
| 55 | +#define ___NEWLAYER_R1___ ...5 keys... |
| 56 | +#define ___NEWLAYER_R2___ ...5 keys... |
| 57 | +#define ___NEWLAYER_R3___ ...5 keys... |
| 58 | +``` |
| 59 | + |
| 60 | +### 3c. Number Row Macros (if Sofle or BT needs it) — `config/wrappers.dtsi` |
| 61 | + |
| 62 | +5-col base + 6-col expansion: |
| 63 | +```c |
| 64 | +#define ___NUM_NEWLAYER_L___ _______ _______ _______ _______ _______ |
| 65 | +#define ___NUM_NEWLAYER_R___ _______ _______ _______ _______ _______ |
| 66 | +#define ___NUM_NEWLAYER_L_6___ _______ ___NUM_NEWLAYER_L___ |
| 67 | +#define ___NUM_NEWLAYER_R_6___ ___NUM_NEWLAYER_R___ _______ |
| 68 | +``` |
| 69 | +
|
| 70 | +### 3d. 6-Column Expansion Macros (Sofle + BT) — `config/wrappers.dtsi` |
| 71 | +
|
| 72 | +```c |
| 73 | +#define ___NEWLAYER_L1_6___ OUTER_L ___NEWLAYER_L1___ |
| 74 | +#define ___NEWLAYER_L2_6___ OUTER_L ___NEWLAYER_L2___ |
| 75 | +#define ___NEWLAYER_L3_6___ OUTER_L ___NEWLAYER_L3___ |
| 76 | +#define ___NEWLAYER_R1_6___ ___NEWLAYER_R1___ OUTER_R |
| 77 | +#define ___NEWLAYER_R2_6___ ___NEWLAYER_R2___ OUTER_R |
| 78 | +#define ___NEWLAYER_R3_6___ ___NEWLAYER_R3___ OUTER_R |
| 79 | +``` |
| 80 | + |
| 81 | +Outer column keys depend on layer purpose. Check existing layers for patterns: |
| 82 | +- BASE: ESC/TAB/LGUI on left, BSPC/SQT/RGUI on right |
| 83 | +- Gaming: TAB/LCTRL/LSHFT on left |
| 84 | +- Most others: `_______` for transparent |
| 85 | + |
| 86 | +### 3e. Sofle Thumb Clusters — `config/wrappers.dtsi` |
| 87 | + |
| 88 | +```c |
| 89 | +#define ___SOFLE_THUMBS_L_NEWLAYER___ (5 keys) |
| 90 | +#define ___SOFLE_THUMBS_R_NEWLAYER___ (5 keys) |
| 91 | +``` |
| 92 | +
|
| 93 | +**CRITICAL**: If this is a gaming-adjacent layer accessed via `&to`, use explicit `&kp` keys. Never `&trans`. |
| 94 | +
|
| 95 | +### 3f. Sweep Thumb Cluster — `config/wrappers.dtsi` |
| 96 | +
|
| 97 | +```c |
| 98 | +#define ___SWEEP_THUMBS_NEWLAYER___ (4 keys total: 2 left + 2 right) |
| 99 | +``` |
| 100 | + |
| 101 | +Same `&trans` rule applies for gaming layers. |
| 102 | + |
| 103 | +### 3g. Encoder Bindings (Sofle only) — `config/wrappers.dtsi` |
| 104 | + |
| 105 | +```c |
| 106 | +#define ___ENC_NEWLAYER___ &inc_dec_kp C_VOL_UP C_VOL_DN &inc_dec_kp PG_UP PG_DN |
| 107 | +#define ___ENC_KEY_NEWLAYER___ _______ _______ |
| 108 | +``` |
| 109 | + |
| 110 | +### 3h. Bullet Train Wrappers (if BT needs it) — `config/wrappers.dtsi` |
| 111 | + |
| 112 | +BT has custom wrappers for several rows. All of these need a NEWLAYER variant: |
| 113 | +```c |
| 114 | +#define ___BT_NUMROW_NEWLAYER___ _______ _______ _______ _______ _______ _______ |
| 115 | +#define ___BT_NEWLAYER_R2_6___ ___NEWLAYER_R2___ _______ |
| 116 | +#define ___BT_NEWLAYER_L3_6___ &kp LSHFT ___NEWLAYER_L3___ |
| 117 | +#define ___BT_NEWLAYER_R3_6___ (6 keys — manually expand, UP at position 10) |
| 118 | +#define ___BT_THUMBS_NEWLAYER___ (9 keys total) |
| 119 | +``` |
| 120 | +
|
| 121 | +Check existing BT wrappers for the exact pattern — Row 3 right side embeds UP before SLASH. |
| 122 | +
|
| 123 | +### 3i. Layer Block in Each Keymap |
| 124 | +
|
| 125 | +Add as the LAST layer block (position must match the `#define` index). |
| 126 | +
|
| 127 | +**Sofle** (`config/sofle.keymap`): |
| 128 | +``` |
| 129 | +newlayer { |
| 130 | + display-name = "NEWLAYER"; |
| 131 | + bindings = < |
| 132 | + ___NUM_NEWLAYER_L_6___ ___NUM_NEWLAYER_R_6___ |
| 133 | + ___NEWLAYER_L1_6___ ___NEWLAYER_R1_6___ |
| 134 | + ___NEWLAYER_L2_6___ ___NEWLAYER_R2_6___ |
| 135 | + ___NEWLAYER_L3_6___ ___ENC_KEY_NEWLAYER___ ___NEWLAYER_R3_6___ |
| 136 | + ___SOFLE_THUMBS_L_NEWLAYER___ ___SOFLE_THUMBS_R_NEWLAYER___ |
| 137 | + >; |
| 138 | + sensor-bindings = <___ENC_NEWLAYER___>; |
| 139 | +}; |
| 140 | +``` |
| 141 | + |
| 142 | +**Cradio** (`config/cradio.keymap`): |
| 143 | +``` |
| 144 | +newlayer_layer { |
| 145 | + bindings = < |
| 146 | + ___NEWLAYER_L1___ ___NEWLAYER_R1___ |
| 147 | + ___NEWLAYER_L2___ ___NEWLAYER_R2___ |
| 148 | + ___NEWLAYER_L3___ ___NEWLAYER_R3___ |
| 149 | + ___SWEEP_THUMBS_NEWLAYER___ |
| 150 | + >; |
| 151 | +}; |
| 152 | +``` |
| 153 | + |
| 154 | +**Bullet Train** (`config/bullet_train.keymap`): |
| 155 | +``` |
| 156 | +NEWLAYER_layer { |
| 157 | + display-name = "NewLayer"; |
| 158 | + bindings = < |
| 159 | + ___BT_NUMROW_NEWLAYER___ |
| 160 | + ___NEWLAYER_L1_6___ ___NEWLAYER_R1_6___ |
| 161 | + ___NEWLAYER_L2_6___ ___BT_NEWLAYER_R2_6___ |
| 162 | + ___BT_NEWLAYER_L3_6___ ___BT_NEWLAYER_R3_6___ |
| 163 | + ___BT_THUMBS_NEWLAYER___ |
| 164 | + >; |
| 165 | +}; |
| 166 | +``` |
| 167 | + |
| 168 | +### 3j. Layer Switching |
| 169 | + |
| 170 | +Depending on the chosen method: |
| 171 | +- **Combo**: Add to `combos.dtsi` + position overrides in all 3 keymaps (use `/zmk-add-combo` skill) |
| 172 | +- **Key binding**: Modify an existing thumb cluster or key in `wrappers.dtsi` |
| 173 | +- **Conditional layer**: Add to `conditional_layers` block in `behaviors.dtsi` |
| 174 | + |
| 175 | +### 3k. Update Existing Combos (if needed) |
| 176 | + |
| 177 | +If any existing combos should also be active on this new layer, update their `layers` list in `combos.dtsi`. |
| 178 | + |
| 179 | +## Step 4: Verification Checklist |
| 180 | + |
| 181 | +Present the full checklist grouped by file: |
| 182 | + |
| 183 | +**config/wrappers.dtsi:** |
| 184 | +- [ ] `#define NEWLAYER N` added to layer index block |
| 185 | +- [ ] 6 core 5-col macros (`___NEWLAYER_[LR][123]___`) |
| 186 | +- [ ] 4 number row macros (5-col + 6-col) |
| 187 | +- [ ] 6 expansion macros (`___NEWLAYER_[LR][123]_6___`) |
| 188 | +- [ ] Sofle thumb macros (L + R, 5 keys each) |
| 189 | +- [ ] Sweep thumb macro (4 keys total) |
| 190 | +- [ ] Encoder rotation macro (2 bindings) |
| 191 | +- [ ] Encoder key macro (2 keys) |
| 192 | +- [ ] BT numrow macro (6 keys) — if BT needs it |
| 193 | +- [ ] BT row 2 right, row 3 left/right macros — if BT needs it |
| 194 | +- [ ] BT thumb macro (9 keys) — if BT needs it |
| 195 | + |
| 196 | +**config/sofle.keymap:** |
| 197 | +- [ ] Layer block added at correct position (index N) |
| 198 | +- [ ] Uses `_6___` macros + encoder bindings |
| 199 | + |
| 200 | +**config/cradio.keymap:** |
| 201 | +- [ ] Layer block added at correct position (index N) |
| 202 | +- [ ] Uses 5-col macros + sweep thumbs |
| 203 | + |
| 204 | +**config/bullet_train.keymap:** |
| 205 | +- [ ] Layer block added at correct position (index N) |
| 206 | +- [ ] Uses `___BT_*___` macros |
| 207 | + |
| 208 | +**config/combos.dtsi or behaviors.dtsi:** |
| 209 | +- [ ] Layer switching mechanism added (if needed) |
| 210 | +- [ ] Existing combo layer lists updated (if needed) |
| 211 | +- [ ] Conditional layer added (if tri-layer) |
0 commit comments