Clean-room ZMK steno engine with trie/DAWG dictionary
Format v4 (docs/FORMAT_V4.md): one union CHD MPHF over 226,791 stroke keys from Plover (147,424) + Lapwing (114,885), sections distributed across halves. Left blob 387KB (displacements log-class Huffman 59KB, membership 57KB, fingerprints 113KB, conflicts 9.6KB, value-index slice 157KB); right blob 515KB (strings front-coded+deflate 193KB, value-index remainder 324KB, conflicts dup). Shared string table: 73,464 unique translations, Lapwing 93% subset of Plover. - tools/compile_v4.py: encoder + full verification (all 262,309 entries byte-exact through cold decode path; hard error if either blob exceeds budget — never trims) - src/dict_v4.c/.h: decoder — canonical Huffman displacement decode, conflict binary search, FC block walk, 2-block LRU cache - src/behavior_steno.c: Plover-style sliding longest-match with retrace replaces multi-stroke timeout + prefix checks - src/split_dict.c/.h: protocol v4 — GET_STRING(string_id) / RESOLVE(slot, dict); decisions are 100% left-local, BLE only for translation text - CMake/Kconfig: STENO_DICT_BOTH default, one compiler run emits both half blobs; legacy MPHF path kept behind STENO_DICT_V4=n - Host round-trip test: 42,000 vectors left→right split path, 0 mismatches (tests/test_dict_v4.c) |
||
|---|---|---|
| dicts | ||
| dts | ||
| include/dt-bindings/zmk | ||
| src | ||
| tests | ||
| tools | ||
| zephyr | ||
| .gitignore | ||
| CMakeLists.txt | ||
| Kconfig | ||
| LICENSE | ||
| README.md | ||
zmk-steno-engine
Clean-room stenography engine for ZMK Firmware. Dictionary-based lookup with multi-stroke support, optimized for nRF52840 flash constraints.
Status: Early development — basic single/multi-stroke lookup works, formatter not yet implemented.
Features
- Standard 23-key steno layout
- Sorted-array dictionary with binary search lookup
- Multi-stroke support with configurable timeout
- All-up chord detection
- HID keyboard output (ASCII)
- Build-time dictionary compilation from Plover JSON
- Test dictionary included for development
Building
Add as a ZMK module in your west.yml:
manifest:
remotes:
- name: zmk-steno-engine
url-base: https://github.com/afiqzudinhadi
projects:
- name: zmk-steno-engine
remote: zmk-steno-engine
revision: optimize-dict
Enable in your .conf:
CONFIG_STENO_ENGINE=y
Use in your keymap:
#include <dt-bindings/zmk/steno_keys.h>
/ {
keymap {
steno_layer {
bindings = <
&steno STENO_SL &steno STENO_TL &steno STENO_PL ...
>;
};
};
};
Dictionary Compiler
# Compile test dictionary
python3 tools/compile_simple.py dicts/test.json -o steno_dict.bin --stats
# Compile Plover dictionary (trimmed)
python3 tools/compile_simple.py plover-main.json -o steno_dict.bin --max-entries 120000 --stats