RMK provides configuration that allows you to tune the controller event system based on your specific needs and hardware constraints.
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 queuedpubs: Number of publishers - how many concurrent tasks can publish this event typesubs: Number of subscribers - how many concurrent tasks can subscribe to this event typeEach 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.
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:
Examples:
All built-in controller events can be configured. Here's the complete list showing the mapping between configuration names and event types:
ble_state_change → BleStateChangeEvent - BLE connection state changes (advertising, connected, disconnected)ble_profile_change → BleProfileChangeEvent - BLE profile switchingconnection_change → ConnectionChangeEvent - USB/BLE connection type changeskey → KeyEvent - Key press/release events (default: channel_size=8 for fast typing)modifier → ModifierEvent - Modifier key state changes (Shift, Ctrl, Alt, etc.)layer_change → LayerChangeEvent - Active layer changes (default: subs=4 for multiple displays)wpm_update → WpmUpdateEvent - WPM statistics updatesled_indicator → LedIndicatorEvent - LED indicator state changes (Caps Lock, Num Lock, Scroll Lock)sleep_state → SleepStateEvent - Sleep/wake state transitionsbattery_level → BatteryLevelEvent - Battery level changes (default: subs=4 for multiple displays)charging_state → ChargingStateEvent - Charging status changesperipheral_connected → PeripheralConnectedEvent - Peripheral connection statuscentral_connected → CentralConnectedEvent - Central connection statusperipheral_battery → PeripheralBatteryEvent - Peripheral battery updates (default: channel_size=2, subs=2)clear_peer → ClearPeerEvent - BLE peer clearing eventsFor detailed information about these event types and how to use them in custom controllers, see the Controller Support documentation.