1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
use parse_split_peripheral_mod;
use FromMeta;
use NestedMeta;
use TokenStream;
use parse_macro_input;
use crateparse_keyboard_mod;
/// Expand a directory of simulator scenario TOMLs into `#[test]` fns targeting
/// rmk's `tests/integration/simulator` harness. Test-only; see
/// `rmk/tests/scenarios/README.md`.
/// Attribute for `rmk_peripheral` macro
/// Marker attribute for coordinating Runnable generation between macros.
/// Do not use directly.
/// Derive macro for multi-event enums that generates automatic event dispatch.
///
/// This macro generates:
/// - `{EnumName}Publisher` struct implementing `AsyncEventPublisher` and `EventPublisher`
/// - `PublishableEvent` and `AsyncPublishableEvent` trait implementations
/// - `From<VariantType>` impls for each variant
///
/// Each variant is forwarded to its underlying event channel when published.
///
/// **Note**: You cannot subscribe to wrapper enums directly. Subscribe to the individual
/// concrete event types (e.g., `BatteryEvent`, `PointingEvent`) instead.
///
/// # Example
///
/// ```rust,ignore
/// #[derive(Event)]
/// pub enum MultiSensorEvent {
/// Battery(BatteryEvent),
/// Pointing(PointingEvent),
/// }
///
/// // Publishing: events are routed to their concrete type channels
/// publish_event_async(MultiSensorEvent::Battery(event)).await;
/// ```
/// 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
///
/// ```rust,ignore
/// #[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
/// }
/// }
/// ```
/// Unified macro for defining events with static channels.
///
/// Generates `PublishableEvent`, `SubscribableEvent`, and `AsyncPublishableEvent`
/// trait implementations.
///
/// # Parameters
///
/// - `channel_size`: Buffer size of the channel (default: 8 for MPSC, 1 for PubSub)
/// - `subs`: Max subscribers (triggers PubSub mode, default: 4)
/// - `pubs`: Max publishers (triggers PubSub mode, default: 1)
///
/// If `subs` or `pubs` is specified, PubSub channel is used; otherwise MPSC channel.
///
/// # Examples
///
/// ```rust,ignore
/// // MPSC channel (single consumer)
/// #[event(channel_size = 16)]
/// #[derive(Clone, Copy, Debug)]
/// pub struct KeyboardEvent { /* ... */ }
///
/// // PubSub channel (multiple subscribers)
/// #[event(channel_size = 4, subs = 8, pubs = 2)]
/// #[derive(Clone, Copy, Debug)]
/// pub struct LedIndicatorEvent { /* ... */ }
/// ```
/// Unified macro for defining event processors.
///
/// Generates `Processor` and optional `PollingProcessor` implementations.
///
/// # Parameters
///
/// - `subscribe`: Array of event types to subscribe to (required)
/// - `poll_interval`: Optional polling interval in milliseconds
///
/// # Examples
///
/// ```rust,ignore
/// // Event-driven processor
/// #[processor(subscribe = [LedIndicatorEvent])]
/// struct LedController { /* ... */ }
///
/// impl LedController {
/// async fn on_led_indicator_event(&mut self, event: LedIndicatorEvent) {
/// // Handle event
/// }
/// }
///
/// // Polling processor
/// #[processor(subscribe = [BatteryStatusEvent], poll_interval = 1000)]
/// struct BatteryMonitor { /* ... */ }
///
/// impl BatteryMonitor {
/// async fn on_battery_status_event(&mut self, event: BatteryStatusEvent) {
/// // Handle event
/// }
///
/// async fn poll(&mut self) {
/// // Called every 1000ms
/// }
/// }
/// ```