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
#[derive(Debug)]
pub enum Event {
Connect(Box<crate::Gamepad>),
Disconnect,
Accept(bool),
Cancel(bool),
Common(bool),
Action(bool),
Up(bool),
Down(bool),
Left(bool),
Right(bool),
Back(bool),
Forward(bool),
L(bool),
R(bool),
Lz(f32),
Rz(f32),
MotionH(f32),
MotionV(f32),
CameraH(f32),
CameraV(f32),
MotionButton(bool),
CameraButton(bool),
Quit,
}
impl std::fmt::Display for Event {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
use Event::*;
let pushed = |pushed| if pushed { "Pushed" } else { "Released" };
match *self {
Connect(_) => write!(f, "Controller Connected"),
Disconnect => write!(f, "Controller Disconnected"),
Accept(p) => write!(f, "Accept {}", pushed(p)),
Cancel(p) => write!(f, "Cancel {}", pushed(p)),
Common(p) => write!(f, "Common {}", pushed(p)),
Action(p) => write!(f, "Action {}", pushed(p)),
Up(p) => write!(f, "Up {}", pushed(p)),
Down(p) => write!(f, "Down {}", pushed(p)),
Left(p) => write!(f, "Left {}", pushed(p)),
Right(p) => write!(f, "Right {}", pushed(p)),
Back(p) => write!(f, "Back {}", pushed(p)),
Forward(p) => write!(f, "Forward {}", pushed(p)),
L(p) => write!(f, "L {}", pushed(p)),
R(p) => write!(f, "R {}", pushed(p)),
Lz(v) => write!(f, "Lz {}", v),
Rz(v) => write!(f, "Rz {}", v),
MotionH(v) => write!(f, "MotionH {}", v),
MotionV(v) => write!(f, "MotionV {}", v),
CameraH(v) => write!(f, "CameraH {}", v),
CameraV(v) => write!(f, "CameraV {}", v),
MotionButton(p) => write!(f, "MotionButton {}", pushed(p)),
CameraButton(p) => write!(f, "CameraButton {}", pushed(p)),
Quit => write!(f, "Quit"),
}
}
}