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
use bytemuck::{Pod, Zeroable};
use winapi::um::xinput::*;
/// \[[docs.microsoft.com](https://docs.microsoft.com/en-us/windows/win32/api/xinput/ns-xinput-xinput_keystroke#remarks)\]
/// VK_* values specific to Xbox 360 controllers
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Default, Pod, Zeroable)]
#[repr(transparent)] pub struct VK(u16);
enumish! {
VK => u16;
None, PadA, PadB, PadX, PadY, PadRShoulder, PadLShoulder, PadRTrigger, PadLTrigger,
PadDPadUp, PadDPadDown, PadDPadLeft, PadDPadRight, PadStart, PadBack, PadLThumbPress, PadRThumbPress,
PadLThumbUp, PadLThumbDown, PadLThumbRight, PadLThumbLeft, PadLThumbUpLeft, PadLThumbUpRight, PadLThumbDownRight, PadLThumbDownLeft,
PadRThumbUp, PadRThumbDown, PadRThumbRight, PadRThumbLeft, PadRThumbUpLeft, PadRThumbUpRight, PadRThumbDownRight, PadRThumbDownLeft,
}
#[allow(non_upper_case_globals)] impl VK {
/// No virtual key corresponding to this keystroke event (input method editor input?)
pub const None : VK = VK(0);
/// Typically synonymous select/accept in menus on Xbox 360 style controllers/games/console.
///
/// | Controller | Legend | Where |
/// | ------------- | --------- | ----- |
/// | Xbox 360 | Green A | Bottom button of the right face cluster
/// | Xbox One | A | Bottom button of the right face cluster
pub const PadA : VK = VK(VK_PAD_A);
/// Typically synonymous back/cancel in menus on Xbox 360 style controllers/games/console.
///
/// | Controller | Legend | Where |
/// | ------------- | --------- | ----- |
/// | Xbox 360 | Red B | Right button of the right face cluster
/// | Xbox One | B | Right button of the right face cluster
pub const PadB : VK = VK(VK_PAD_B);
/// | Controller | Legend | Where |
/// | ------------- | --------- | ----- |
/// | Xbox 360 | Blue X | Left button of the right face cluster
/// | Xbox One | X | Left button of the right face cluster
pub const PadX : VK = VK(VK_PAD_X);
/// | Controller | Legend | Where |
/// | ------------- | --------- | ----- |
/// | Xbox 360 | Yellow Y | Top button of the right face cluster
/// | Xbox One | Y | Top button of the right face cluster
pub const PadY : VK = VK(VK_PAD_Y);
/// | Controller | Where |
/// | ------------- | ----- |
/// | Xbox 360 | Top right on the controller
/// | Xbox One | Top right on the controller
pub const PadRShoulder : VK = VK(VK_PAD_RSHOULDER);
/// | Controller | Where |
/// | ------------- | ----- |
/// | Xbox 360 | Top left on the controller
/// | Xbox One | Top left on the controller
pub const PadLShoulder : VK = VK(VK_PAD_LSHOULDER);
/// Analog trigger behind the right side of the gamepad.
pub const PadRTrigger : VK = VK(VK_PAD_RTRIGGER);
/// Analog trigger behind the left side of the gamepad.
pub const PadLTrigger : VK = VK(VK_PAD_LTRIGGER);
/// | Controller | Where |
/// | ------------- | ----- |
/// | Xbox 360 | Directional pad on the bottom left of the face
/// | Xbox One | Directional pad on the bottom left of the face
pub const PadDPadUp : VK = VK(VK_PAD_DPAD_UP);
/// | Controller | Where |
/// | ------------- | ------ |
/// | Xbox 360 | Directional pad on the bottom left of the face
/// | Xbox One | Directional pad on the bottom left of the face
pub const PadDPadDown : VK = VK(VK_PAD_DPAD_DOWN);
/// | Controller | Where |
/// | ------------- | ----- |
/// | Xbox 360 | Directional pad on the bottom left of the face
/// | Xbox One | Directional pad on the bottom left of the face
pub const PadDPadLeft : VK = VK(VK_PAD_DPAD_LEFT);
/// | Controller | Where |
/// | ------------- | ----- |
/// | Xbox 360 | Directional pad on the bottom left of the face
/// | Xbox One | Directional pad on the bottom left of the face
pub const PadDPadRight : VK = VK(VK_PAD_DPAD_RIGHT);
/// | Controller | Legend | Where |
/// | ------------- | --------- | ----- |
/// | Xbox 360 | Start `ᐅ` | Right button of the middle face cluster
/// | Xbox One | Menu `≡` | Right button of the middle face cluster
pub const PadStart : VK = VK(VK_PAD_START);
/// | Controller | Legend | Where |
/// | ------------- | --------- | ----- |
/// | Xbox 360 | Back `ᐊ` | Left button of the middle face cluster
/// | Xbox One | View `⧉` | Left button of the middle face cluster
pub const PadBack : VK = VK(VK_PAD_BACK);
/// | Controller | When |
/// | ------------- | ----- |
/// | Xbox 360 | Pressing the left thumbstick into the controller
/// | Xbox One | Pressing the left thumbstick into the controller
pub const PadLThumbPress : VK = VK(VK_PAD_LTHUMB_PRESS);
/// | Controller | When |
/// | ------------- | ----- |
/// | Xbox 360 | Pressing the right thumbstick into the controller
/// | Xbox One | Pressing the right thumbstick into the controller
pub const PadRThumbPress : VK = VK(VK_PAD_RTHUMB_PRESS);
/// Moved the upper left thumbstick up.
pub const PadLThumbUp : VK = VK(VK_PAD_LTHUMB_UP);
/// Moved the upper left thumbstick down.
pub const PadLThumbDown : VK = VK(VK_PAD_LTHUMB_DOWN);
/// Moved the upper left thumbstick right.
pub const PadLThumbRight : VK = VK(VK_PAD_LTHUMB_RIGHT);
/// Moved the upper left thumbstick left.
pub const PadLThumbLeft : VK = VK(VK_PAD_LTHUMB_LEFT);
/// Moved the upper left thumbstick up and left.
pub const PadLThumbUpLeft : VK = VK(VK_PAD_LTHUMB_UPLEFT);
/// Moved the upper left thumbstick up and right.
pub const PadLThumbUpRight : VK = VK(VK_PAD_LTHUMB_UPRIGHT);
/// Moved the upper left thumbstick down and right.
pub const PadLThumbDownRight : VK = VK(VK_PAD_LTHUMB_DOWNRIGHT);
/// Moved the upper left thumbstick and left.
pub const PadLThumbDownLeft : VK = VK(VK_PAD_LTHUMB_DOWNLEFT);
/// Moved the right thumbstick up.
pub const PadRThumbUp : VK = VK(VK_PAD_RTHUMB_UP);
/// Moved the right thumbstick down.
pub const PadRThumbDown : VK = VK(VK_PAD_RTHUMB_DOWN);
/// Moved the right thumbstick right.
pub const PadRThumbRight : VK = VK(VK_PAD_RTHUMB_RIGHT);
/// Moved the right thumbstick left.
pub const PadRThumbLeft : VK = VK(VK_PAD_RTHUMB_LEFT);
/// Moved the right thumbstick up and left.
pub const PadRThumbUpLeft : VK = VK(VK_PAD_RTHUMB_UPLEFT);
/// Moved the right thumbstick up and right.
pub const PadRThumbUpRight : VK = VK(VK_PAD_RTHUMB_UPRIGHT);
/// Moved the right thumbstick down and right.
pub const PadRThumbDownRight : VK = VK(VK_PAD_RTHUMB_DOWNRIGHT);
/// Moved the right thumbstick down and left.
pub const PadRThumbDownLeft : VK = VK(VK_PAD_RTHUMB_DOWNLEFT);
}