Skip to main content

input_device

Attribute Macro input_device 

Source
#[input_device]
Expand description

Macro for defining input devices that publish events.

This macro generates InputDevice and Runnable implementations for single-event devices. For multi-event devices, use #[derive(Event)] on a user-defined enum instead.

§Parameters

  • publish: The event type to publish (single event type only)

§Example

#[input_device(publish = BatteryEvent)]
pub struct BatteryReader { ... }

impl BatteryReader {
    // User implements this inherent method
    async fn read_battery_event(&mut self) -> BatteryEvent {
        // Wait and return single event
    }
}