How zmkfirmware/zmk works
ZMK is Zephyr-based mechanical-keyboard firmware. Its principal workflow scans physical key positions, interprets them through keymap behaviors, and sends HID output through USB or Bluetooth; split transports extend that workflow across keyboard halves. The repository also includes sensors, displays, pointing input, and Studio RPC. Several central runtime connections are not shown in the excerpts, so those edges are dashed and unverified; the display composition and output-status relationships have direct source evidence.
Main entry points: endpoints.c Output selection · behavior.c Behaviors · keymap.c Keymap · output_status.c Output status widget
Components 24
Input and mapping
- Matrix scan
app/module/drivers/kscan/kscan_gpio_matrix.c - Keymap
app/src/keymap.c - Combos
app/src/combo.c - Sensor input
app/src/sensors.c
Behavior and HID
- Behaviors
app/src/behavior.c - Hold-tap
app/src/behaviors/behavior_hold_tap.c - HID reports
app/src/hid.c - Output selection
app/src/endpoints.c
Connectivity
- USB HID
app/src/usb_hid.c - Bluetooth
app/src/ble.c - Split service
app/src/split/bluetooth/service.c - Split central
app/src/split/central.c - Split peripheral
app/src/split/peripheral.c
Devices and display
- Battery gauge
app/module/drivers/sensor/max17048/max17048.c - Display runtime
app/src/display/main.c - Corneish Zen screen
app/boards/lowprokb/corneish_zen/custom_status_screen.c - Output status widget
app/boards/lowprokb/corneish_zen/widgets/output_status.c - Nice!View screen
app/boards/shields/nice_view/custom_status_screen.c - Nice!View status widget
app/boards/shields/nice_view/widgets/status.c - IL0323 display driver
app/module/drivers/display/il0323.c
Studio
- Studio RPC
app/src/studio/rpc.c - Studio keymap
app/src/studio/keymap_subsystem.c
Other components
- Keyboard user
- HID host
Connections 21
- Keyboard user → Matrix scan: presses keys
- Matrix scan → Keymap: reports positions
- Keymap → Behaviors: dispatches bindings
- Keymap → Combos: checks combos
- Sensor input → Behaviors: triggers bindings
- Behaviors → HID reports: produces reports
- Hold-tap → Behaviors: implements behavior
- HID reports → Output selection: selects output
- Output selection → USB HID: routes reports
- Output selection → Bluetooth: routes reports
- Split central → Split service: uses service
- Split peripheral → Split service: uses service
- Split service → HID host: notifies state
- Battery gauge → Corneish Zen screen: supplies readings
- Display runtime → Corneish Zen screen: loads screen
- Display runtime → IL0323 display driver: uses display device
- Corneish Zen screen → Output status widget: initializes widget
app/boards/lowprokb/corneish_zen/custom_status_screen.c - Output status widget → Output selection: reads selection
app/boards/lowprokb/corneish_zen/widgets/output_status.c - Output status widget → Bluetooth: reads profile state
app/boards/lowprokb/corneish_zen/widgets/output_status.c - Nice!View screen → Nice!View status widget: initializes widget
app/boards/shields/nice_view/custom_status_screen.c - Studio RPC → Studio keymap: dispatches RPC