# What Bazecor taught us

Mined from [Dygmalab/Bazecor](https://github.com/Dygmalab/Bazecor) 1.10.0 (GPL-3.0-only, commit `0decf36`, 2026-08-11). The JSON files in `reference/bazecor/` are derived from it and carry that license; the app code is ours.

## Keycode encoding (`keymap.custom`)

One 16-bit number per key, 80 per layer, layers back to back. Bazecor's parser is a flat lookup table (`src/api/keymap/db.ts`); anything it doesn't know renders as `#<code>`.

| Range | Meaning | Notes |
|---|---|---|
| 0 | disabled | `NO KEY` |
| 65535 | transparent | falls through to the layer below |
| 4..231 | HID usage | letters 4..29, digits 30..39, F1..F12 58..69, F13..F24 104..115, numpad 83..99, `<>` ISO key 100, Menu 101, modifiers 224..231 |
| + 256 | Control held | modifier flags add to the HID code |
| + 512 | Alt held | 768 = Control+Alt |
| + 1024 | AltGr held | 3072 = AltGr+Shift |
| + 2048 | Shift held | shifted glyphs in the language tables live here |
| + 4096 | OS (Cmd/Win) held | Meh 2530 = Ctrl+Shift+Alt on 226, Hyper 3043 = Ctrl+Shift+Alt+OS on 227 |
| 17152..17154 | LED next / previous / toggle | |
| 17408..17417 | Lock layer 1..10 | `LockLayerTable` |
| 17450..17459 | Shift to layer 1..10 (hold) | |
| 17492..17501 | Move to layer 1..10 | `MoveToLayerTable` |
| 18552 | media: Camera | consumer keys are listed individually, not a formula |
| 18834 | media: Calculator | |
| 19682 | media: Mute | |
| 20481 / 20482 / 20484 / 20488 | mouse up / down / left / right | |
| 20497 / 20498 / 20500 / 20504 | wheel up / down / left / right | |
| 20545 / 20546 / 20548 / 20552 / 20560 | mouse button left / right / middle / back / forward | |
| 20517 / 20518 / 20521 / 20522 / 20576 | mouse warp NW / SW / NE / SE / end | |
| 20865 / 20866 | Shut down / Sleep | listed under "miscellaneous" |
| 22709 / 22710 / 22711 / 22712 / 22713 | Next / Prev / Stop / Eject / Shuffle | |
| 22733 | Play / pause | |
| 23663 / 23664 | Brightness + / − | |
| 23785 / 23786 | Volume + / − | |
| 49153..49160 | One-shot modifier (Ctrl, Shift, Alt, OS, RCtrl, RShift, RAlt, ROS) | |
| 49161..49168 | One-shot layer 1..8 | |
| 49169 + key | Dual-use: Control when held, `key` when tapped | |
| 49425 + key | Dual-use Shift | |
| 49681 + key | Dual-use Alt | |
| 49937 + key | Dual-use OS | |
| 50705 + key | Dual-use AltGr | note the gap, not 256-spaced |
| 51218 + 256·(n−1) + key | Dual-use: layer *n* when held, `key` when tapped | n = 1..8, Bazecor numbering |
| 53267 + i | Tap dance i | |
| 53283..53290 | Leader #0..#7 | |
| 53291 / 53292 | Cycle / Syster | |
| 53549..53590 | Steno | |
| 53591 / 53592 | Space Cadet enable / disable | |
| 53852 + i | Macro i (Bazecor shows i+1) | |
| 53980 + i | Superkey i (Bazecor shows i+1) | |
| 54108 | Battery level | wireless boards |
| 54109 | Bluetooth pairing | |
| 54111 | Energy status | |
| 54112 | LayerLens overlay key (also RF status) | |
| 54113 / 54114 | LayerLens tap / hold | |

**Layer numbering.** Bazecor shows layers 1-based everywhere: code 17451 is "Shift to layer 2" and holds firmware layer index 1, which is the second block of 80 in `keymap.custom`. The export names them `L1`..`L10` in that same order. So "L2" in this app, "layer 2" in Bazecor, and index 1 in the file are the same thing.

## Superkeys (`superkeys.map`)

Space-separated numbers. Each superkey is five actions in order: tap, hold, tap-then-hold, double tap, double tap-then-hold. `0` ends a superkey, `" 0 0"` ends the list, `1` is an empty action slot. Actions use the keycode encoding above.

## Macros (`macros.map`)

Space-separated bytes. Each action starts with a type byte, `0` ends a macro, `255` pads the rest of the store.

| Type | Meaning | Payload |
|---|---|---|
| 1 | interval | two 16-bit values (4 bytes) |
| 2 | wait | 16-bit ms |
| 3 / 4 / 5 | key down / key up / tap, 16-bit keycode | 2 bytes |
| 6 / 7 / 8 | key down / key up / tap, 8-bit HID code | 1 byte |

## Matrix and which keys exist

All Dygma boards report `rows: 5, columns: 16`, index = row·16 + column. Which indexes are wired differs per model. Bazecor's SVG components only draw the real ones (`reference/bazecor/geometry.json`):

| Model | Thumb indexes (left / right) | Absent bottom-row index |
|---|---|---|
| Raise 2 ISO / ANSI | top 67 (big), 68; bottom 69 (outer), 70 (inner) / top 75 (big), 74; bottom 73 (outer), 72 (inner) | 71 |
| Raise 1 ISO / ANSI | top 67, 68; bottom 70 (outer), 71 (inner) / same right side as Raise 2 | 69 |
| Defy | 64..71 left (t1..t8), 72..79 right (tR1..tR8), 8 per side, curved | none |
| Sonsei | 64..67 left, 72..75 right | 68..71, 76..79 |

The stock Raise 2 layout still assigns 71 (a Raise 1 leftover); it is not a physical key.

Row 4 columns 22, 38, 57 are never physical on a Raise; 49 exists only on ISO (`<>`), 48 is the wide ANSI Shift.

## Geometry

`geometry.json` is Bazecor's drawing (SVG px, 1u ≈ 77.5 px pitch, rows 67 px apart, keys 57 px tall). It is a stylised picture, not to physical scale: modifiers are drawn 1u wide although they are 1.25u. For the Raise 2 the app uses geometry measured from Dygma's printable PDF instead; Bazecor's numbers are what we have for Defy, Sonsei and Raise 1.

`shapes.json` holds the SVG path for each non-rectangular cap (`t5`, `t8`, `enterKey`, `defy-t1..t8`, `defy-tR1..tR8`, `sonsei-t1..t4`, `sonsei-tR1`), in the local coordinates Bazecor draws them at.

## Language legends

`languages.json`: per language, HID code → glyph as printed on that country's caps. Codes below 256 are the plain cap, 2048+ the shifted glyph, 1024+ the AltGr glyph, 512+ the Alt glyph. Languages: da-DK, de-CH, de-DE, en-GB, en-XX-eurkey, es-ES, es-MX, fr-FR, fr-XX-bepo, fr-XX-ergol, fr-XX-optimot, is-IS, it-IT, ja-JP, ko-KR, nb-NO, pl-PL, ru-RU, sv-SE. Anything not listed falls back to the US legend.
