butt_head/event.rs
1use crate::TimeDuration;
2
3/// A button event produced by the state machine.
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5#[cfg_attr(feature = "defmt", derive(defmt::Format))]
6pub enum Event<D: TimeDuration> {
7 /// The button was pressed. Fires immediately on press edge.
8 Press,
9
10 /// The button was released. `duration` is the total time it was held.
11 Release { duration: D },
12
13 /// A complete click gesture (press + release, no hold).
14 /// `count` starts at 1. Fires once after `click_timeout` expires with no
15 /// further press. A double-click produces a single `Click { count: 2 }`.
16 Click { count: u8 },
17
18 /// The button is being held. Fires repeatedly at a configured interval.
19 /// `clicks_before` is the number of clicks that preceded this hold
20 /// (0 = plain hold, 1 = click+hold, 2 = double-click+hold, ...).
21 /// `level` increments on each repeat (0 = first hold event, 1 = second, ...).
22 Hold { clicks_before: u8, level: u8 },
23}