Event Configuration

RMK provides configuration that allows you to tune the controller event system based on your specific needs and hardware constraints.

Overview

All built-in controller events use Embassy's PubSubChannel for efficient inter-task communication. RMK's configuration system allows you to customize three key parameters for each controller event type:

  • channel_size: Buffer size for the event channel - how many events can be queued
  • pubs: Number of publishers - how many concurrent tasks can publish this event type
  • subs: Number of subscribers - how many concurrent tasks can subscribe to this event type

Each controller event in RMK has default values chosen for typical use cases. You only need to configure events when your specific requirements differ from these defaults.

Configuration Method

Add a [controller_event] section to your keyboard.toml file. You can configure any subset of the three parameters for each event - unspecified parameters will use their default values.

Configuration syntax:

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

Examples:

[controller_event]
# Increase key event buffer for fast typing
key.channel_size = 16

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

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

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

Configurable Events

All built-in controller events can be configured. Here's the complete list showing the mapping between configuration names and event types:

BLE Events

Connection Events

Input Events

  • keyKeyEvent - Key press/release events (default: channel_size=8 for fast typing)
  • modifierModifierEvent - Modifier key state changes (Shift, Ctrl, Alt, etc.)

Keyboard State Events

  • layer_changeLayerChangeEvent - Active layer changes (default: subs=4 for multiple displays)
  • wpm_updateWpmUpdateEvent - WPM statistics updates
  • led_indicatorLedIndicatorEvent - LED indicator state changes (Caps Lock, Num Lock, Scroll Lock)
  • sleep_stateSleepStateEvent - Sleep/wake state transitions

Power Events

Split Keyboard Events

For detailed information about these event types and how to use them in custom controllers, see the Controller Support documentation.