1use crate::event_codes::Key;
2use crate::GenericEvent;
3
4#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
8pub struct ButtonEvent {
9 button: Key,
10 is_synthetic: bool,
11 time: u32,
12 value: i16,
13}
14
15impl ButtonEvent {
16 pub const fn button(&self) -> Key {
18 self.button
19 }
20
21 pub(crate) const fn new(button: Key, is_synthetic: bool, time: u32, value: i16) -> Self {
22 ButtonEvent {
23 button,
24 is_synthetic,
25 time,
26 value,
27 }
28 }
29}
30
31impl GenericEvent for ButtonEvent {
32 fn is_real(&self) -> bool {
33 !self.is_synthetic
34 }
35
36 fn is_synthetic(&self) -> bool {
37 self.is_synthetic
38 }
39
40 fn time(&self) -> u32 {
41 self.time
42 }
43
44 fn value(&self) -> i16 {
45 self.value
46 }
47}