uinput_tokio/event/
mod.rs1use libc::c_int;
2
3pub trait Kind {
5 fn kind(&self) -> c_int;
7}
8
9pub trait Code {
11 fn code(&self) -> c_int;
13}
14
15pub trait Press: Kind + Code {}
17
18pub trait Release: Kind + Code {}
20
21pub trait Position: Kind + Code {}
23
24#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
26pub enum Event {
27 All,
28
29 Keyboard(Keyboard),
31
32 Controller(Controller),
34
35 Relative(Relative),
37
38 Absolute(Absolute),
40}
41
42impl Kind for Event {
43 fn kind(&self) -> c_int {
44 match self {
45 &Event::All => unreachable!(),
46
47 &Event::Keyboard(ref v) => v.kind(),
48 &Event::Controller(ref v) => v.kind(),
49 &Event::Relative(ref v) => v.kind(),
50 &Event::Absolute(ref v) => v.kind(),
51 }
52 }
53}
54
55impl Code for Event {
56 fn code(&self) -> c_int {
57 match self {
58 &Event::All => unreachable!(),
59
60 &Event::Keyboard(ref v) => v.code(),
61 &Event::Controller(ref v) => v.code(),
62 &Event::Relative(ref v) => v.code(),
63 &Event::Absolute(ref v) => v.code(),
64 }
65 }
66}
67
68pub mod keyboard;
69pub use self::keyboard::Keyboard;
70
71pub mod controller;
72pub use self::controller::Controller;
73
74pub mod relative;
75pub use self::relative::Relative;
76
77pub mod absolute;
78pub use self::absolute::Absolute;