forked from martinohanlon/mayhem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mapping_key.cpp
executable file
·239 lines (229 loc) · 5.64 KB
/
mapping_key.cpp
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
#include "mapping_key.h"
#include <cstdio>
int mapping_key::key_sets[4][5] = {
{ALLEGRO_KEY_Z, ALLEGRO_KEY_X, ALLEGRO_KEY_V, ALLEGRO_KEY_C, ALLEGRO_KEY_G},
{ALLEGRO_KEY_LEFT, ALLEGRO_KEY_RIGHT, ALLEGRO_KEY_PAD_DELETE,
ALLEGRO_KEY_PAD_0, ALLEGRO_KEY_PAD_ENTER},
{ALLEGRO_KEY_B, ALLEGRO_KEY_N, ALLEGRO_KEY_COMMA, ALLEGRO_KEY_M,
ALLEGRO_KEY_L},
{ALLEGRO_KEY_Y, ALLEGRO_KEY_U, ALLEGRO_KEY_O, ALLEGRO_KEY_I,
ALLEGRO_KEY_0}};
void init_mapping_key(struct mapping_key *keymap, int keysetno) {
keymap->left = mapping_key::key_sets[keysetno][0];
keymap->right = mapping_key::key_sets[keysetno][1];
keymap->thrust = mapping_key::key_sets[keysetno][2];
keymap->shield = mapping_key::key_sets[keysetno][3];
keymap->fire = mapping_key::key_sets[keysetno][4];
}
const char *key_to_str(int key) {
switch (key) {
case ALLEGRO_KEY_A:
return ("A");
case ALLEGRO_KEY_B:
return ("B");
case ALLEGRO_KEY_C:
return ("C");
case ALLEGRO_KEY_D:
return ("D");
case ALLEGRO_KEY_E:
return ("E");
case ALLEGRO_KEY_F:
return ("F");
case ALLEGRO_KEY_G:
return ("G");
case ALLEGRO_KEY_H:
return ("H");
case ALLEGRO_KEY_I:
return ("I");
case ALLEGRO_KEY_J:
return ("J");
case ALLEGRO_KEY_K:
return ("K");
case ALLEGRO_KEY_L:
return ("L");
case ALLEGRO_KEY_M:
return ("M");
case ALLEGRO_KEY_N:
return ("N");
case ALLEGRO_KEY_O:
return ("O");
case ALLEGRO_KEY_P:
return ("P");
case ALLEGRO_KEY_Q:
return ("Q");
case ALLEGRO_KEY_R:
return ("R");
case ALLEGRO_KEY_S:
return ("S");
case ALLEGRO_KEY_T:
return ("T");
case ALLEGRO_KEY_U:
return ("U");
case ALLEGRO_KEY_V:
return ("V");
case ALLEGRO_KEY_W:
return ("W");
case ALLEGRO_KEY_X:
return ("X");
case ALLEGRO_KEY_Y:
return ("Y");
case ALLEGRO_KEY_Z:
return ("Z");
case ALLEGRO_KEY_0:
return ("0");
case ALLEGRO_KEY_1:
return ("1");
case ALLEGRO_KEY_2:
return ("2");
case ALLEGRO_KEY_3:
return ("3");
case ALLEGRO_KEY_4:
return ("4");
case ALLEGRO_KEY_5:
return ("5");
case ALLEGRO_KEY_6:
return ("6");
case ALLEGRO_KEY_7:
return ("7");
case ALLEGRO_KEY_8:
return ("8");
case ALLEGRO_KEY_9:
return ("9");
case ALLEGRO_KEY_PAD_0:
return ("Keypad 0");
case ALLEGRO_KEY_PAD_1:
return ("Keypad 1");
case ALLEGRO_KEY_PAD_2:
return ("Keypad 2");
case ALLEGRO_KEY_PAD_3:
return ("Keypad 3");
case ALLEGRO_KEY_PAD_4:
return ("Keypad 4");
case ALLEGRO_KEY_PAD_5:
return ("Keypad 5");
case ALLEGRO_KEY_PAD_6:
return ("Keypad 6");
case ALLEGRO_KEY_PAD_7:
return ("Keypad 7");
case ALLEGRO_KEY_PAD_8:
return ("Keypad 8");
case ALLEGRO_KEY_PAD_9:
return ("Keypad 9");
case ALLEGRO_KEY_F1:
return ("F1");
case ALLEGRO_KEY_F2:
return ("F2");
case ALLEGRO_KEY_F3:
return ("F3");
case ALLEGRO_KEY_F4:
return ("F4");
case ALLEGRO_KEY_F5:
return ("F5");
case ALLEGRO_KEY_F6:
return ("F6");
case ALLEGRO_KEY_F7:
return ("F7");
case ALLEGRO_KEY_F8:
return ("F8");
case ALLEGRO_KEY_F9:
return ("F9");
case ALLEGRO_KEY_F10:
return ("F10");
case ALLEGRO_KEY_F11:
return ("F11");
case ALLEGRO_KEY_F12:
return ("F12");
case ALLEGRO_KEY_LSHIFT:
return ("LShift");
case ALLEGRO_KEY_RSHIFT:
return ("RShift");
case ALLEGRO_KEY_LCTRL:
return ("LCtrl");
case ALLEGRO_KEY_RCTRL:
return ("RCtrl");
case ALLEGRO_KEY_ALT:
return ("Alt");
case ALLEGRO_KEY_ALTGR:
return ("AltGr");
case ALLEGRO_KEY_LWIN:
return ("LWin");
case ALLEGRO_KEY_RWIN:
return ("RWin");
case ALLEGRO_KEY_MENU:
return ("Menu");
case ALLEGRO_KEY_SCROLLLOCK:
return ("Scrollock");
case ALLEGRO_KEY_NUMLOCK:
return ("Numlock");
case ALLEGRO_KEY_CAPSLOCK:
return ("Capslock");
case ALLEGRO_KEY_ESCAPE:
return ("");
case ALLEGRO_KEY_TILDE:
return ("~");
case ALLEGRO_KEY_MINUS:
return ("-");
case ALLEGRO_KEY_EQUALS:
return ("=");
case ALLEGRO_KEY_BACKSPACE:
return ("Backspace");
case ALLEGRO_KEY_TAB:
return ("Tab");
case ALLEGRO_KEY_OPENBRACE:
return ("[");
case ALLEGRO_KEY_CLOSEBRACE:
return ("]");
case ALLEGRO_KEY_ENTER:
return ("Enter");
case ALLEGRO_KEY_SEMICOLON:
return (";");
case ALLEGRO_KEY_QUOTE:
return ("\"");
case ALLEGRO_KEY_BACKSLASH:
return ("\\");
case ALLEGRO_KEY_BACKSLASH2:
return ("\\");
case ALLEGRO_KEY_COMMA:
return (",");
case ALLEGRO_KEY_FULLSTOP:
return (".");
case ALLEGRO_KEY_SLASH:
return ("/");
case ALLEGRO_KEY_SPACE:
return ("Space");
case ALLEGRO_KEY_INSERT:
return ("Insert");
case ALLEGRO_KEY_DELETE:
return ("Delete");
case ALLEGRO_KEY_HOME:
return ("Home");
case ALLEGRO_KEY_END:
return ("End");
case ALLEGRO_KEY_PGUP:
return ("PgUp");
case ALLEGRO_KEY_PGDN:
return ("PgDn");
case ALLEGRO_KEY_LEFT:
return ("Left");
case ALLEGRO_KEY_RIGHT:
return ("Right");
case ALLEGRO_KEY_UP:
return ("Up");
case ALLEGRO_KEY_DOWN:
return ("Down");
case ALLEGRO_KEY_PAD_SLASH:
return ("Keypad /");
case ALLEGRO_KEY_PAD_ASTERISK:
return ("Keypad *");
case ALLEGRO_KEY_PAD_MINUS:
return ("Keypad -");
case ALLEGRO_KEY_PAD_PLUS:
return ("Keypad +");
case ALLEGRO_KEY_PAD_DELETE:
return ("Keypad Del");
case ALLEGRO_KEY_PAD_ENTER:
return ("Keypad Enter");
default:
return ("???");
}
}