Event Configuration

RMK allows you to tune event channel parameters in keyboard.toml based on your specific needs and hardware constraints.

For an overview of events and how to define custom events, see the Event documentation.

Configuration Parameters

Each event channel has three configurable parameters:

  • channel_size: Buffer size - how many events can be queued
  • pubs: Number of publishers - how many concurrent tasks can publish
  • subs: Number of subscribers - how many concurrent tasks can subscribe

Each event has default values for typical use cases. You can view all defaults in rmk-config/src/default_config/event_default.toml.

The subs values are base counts. When a Cargo feature is enabled, RMK adds the subscribers its own tasks need on top of subs, whether the value comes from the defaults or from your [event.<name>] entry. For example, the internal _ble feature (enabled by every BLE chip feature) adds 1 to keyboard and pointing, split adds 2 to led_indicator, and display adds 1 to wpm_update, modifier, sleep_state, layer_change, battery_status and led_indicator. The full list of bumps is in rmk-config/src/default_config/subscriber_default.toml. If you add your own subscribers, raise subs from its default by that number; you don't need to count the feature-gated built-in subscribers.

Configuration Syntax

Add an [event] section to your keyboard.toml:

[event]
# Configure specific parameters for individual events
event_name.channel_size = <value>
event_name.pubs = <value>
event_name.subs = <value>

Examples:

[event]
# Increase key event buffer for fast typing
keyboard.channel_size = 32

# Add more subscribers for multiple displays monitoring layer changes
layer_change.subs = 8

# Reduce subscribers to save memory on constrained devices
keyboard.subs = 2
led_indicator.subs = 2

# Configure multiple parameters for one event
peripheral_battery.channel_size = 4
peripheral_battery.subs = 4

Configurable Event Names

Config NameEvent TypeDefault Notes
Input Events
keyboardKeyboardEventchannel_size=16, pubs=4, subs=3
modifierModifierEventchannel_size=8, subs=2
pointingPointingEventchannel_size=8, pubs=4, subs=2
State Events
layer_changeLayerChangeEventpubs=2
wpm_updateWpmUpdateEvent
led_indicatorLedIndicatorEventchannel_size=2, pubs=2, subs=3
sleep_stateSleepStateEvent
Battery Events
battery_adcBatteryAdcEventchannel_size=2
charging_stateChargingStateEventchannel_size=2
battery_statusBatteryStatusEventsubs=0
Connection Events
connection_status_changeConnectionStatusChangeEventchannel_size=2, pubs=2
Split Events
peripheral_connectedPeripheralConnectedEvent
central_connectedCentralConnectedEvent
peripheral_batteryPeripheralBatteryEventchannel_size=2, subs=2
clear_peerClearPeerEventsubs=0
DFU Events
dfu_statusDfuStatusEventchannel_size=2
Action Events
actionActionEventchannel_size=16, subs=0

Unlisted parameters default to 1. The subs values are base counts before the feature bumps described above.

  • Event - Event concepts, built-in events, and custom event definition
  • Input Device - How to create input devices that publish events
  • Processor - How to create processors that subscribe to events