Mercurial > mm7
annotate Keyboard.cpp @ 1206:ab6560001f5b
arrays to std::arrays phase 2 - some more arrays converted
author | Grumpy7 |
---|---|
date | Sun, 09 Jun 2013 01:10:49 +0200 |
parents | 29a8defbad9e |
children | 0aeac0b9ca30 |
rev | line source |
---|---|
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1038
diff
changeset
|
1 #ifdef _MSC_VER |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1038
diff
changeset
|
2 #define _CRT_SECURE_NO_WARNINGS |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1038
diff
changeset
|
3 #endif |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1038
diff
changeset
|
4 |
0 | 5 #include "OSAPI.h" |
6 | |
7 #include "Keyboard.h" | |
8 #include "GUIWindow.h" | |
9 #include "Game.h" | |
10 #include "OSInfo.h" | |
11 | |
12 #include "mm7_data.h" | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 struct KeyboardActionMapping *pKeyActionMap; | |
20 struct AsyncKeyboard *pAsyncKeyboard; | |
21 | |
22 | |
23 | |
24 | |
25 | |
26 //----- (00459C68) -------------------------------------------------------- | |
27 void KeyboardActionMapping::SetKeyMapping(int uAction, int vKey, KeyToggleType type) | |
28 { | |
29 pVirtualKeyCodesMapping[uAction] = vKey; | |
30 pToggleTypes[uAction] = type; | |
31 } | |
32 | |
33 //----- (00459C82) -------------------------------------------------------- | |
34 unsigned int KeyboardActionMapping::GetActionVKey(enum InputAction eAction) | |
35 { | |
36 return this->pVirtualKeyCodesMapping[eAction]; | |
37 } | |
38 | |
39 //----- (00459C8D) -------------------------------------------------------- | |
40 KeyboardActionMapping::KeyboardActionMapping() | |
41 { | |
42 uLastKeyPressed = 0; | |
271 | 43 field_204 = 0; |
323 | 44 pWindow = nullptr; |
0 | 45 |
46 SetDefaultMapping(); | |
47 ReadMappings(); | |
48 | |
49 ResetKeys(); | |
50 | |
1031 | 51 uGameMenuUI_CurentlySelectedKeyIdx = -1; |
0 | 52 } |
1031 | 53 // 506E68: using guessed type int uGameMenuUI_CurentlySelectedKeyIdx; |
0 | 54 |
55 //----- (00459CC4) -------------------------------------------------------- | |
56 void KeyboardActionMapping::SetDefaultMapping() | |
57 { | |
58 pVirtualKeyCodesMapping[0] = VK_UP; | |
59 pToggleTypes[0] = TOGGLE_Continuously; | |
60 pVirtualKeyCodesMapping[1] = VK_DOWN; | |
61 pToggleTypes[1] = TOGGLE_Continuously; | |
62 pVirtualKeyCodesMapping[2] = VK_LEFT; | |
63 pToggleTypes[2] = TOGGLE_Continuously; | |
64 pVirtualKeyCodesMapping[3] = VK_RIGHT; | |
65 pToggleTypes[3] = TOGGLE_Continuously; | |
66 pVirtualKeyCodesMapping[8] = 'A'; | |
67 pToggleTypes[8] = TOGGLE_OneTimePress; | |
68 pVirtualKeyCodesMapping[7] = 'S'; | |
69 pToggleTypes[7] = TOGGLE_OneTimePress; | |
70 pVirtualKeyCodesMapping[4] = 'Y'; | |
71 pToggleTypes[4] = TOGGLE_OneTimePress; | |
72 pVirtualKeyCodesMapping[5] = 'X'; | |
73 pToggleTypes[5] = TOGGLE_OneTimePress; | |
74 pVirtualKeyCodesMapping[6] = VK_RETURN; | |
75 pToggleTypes[6] = TOGGLE_OneTimePress; | |
76 pVirtualKeyCodesMapping[9] = VK_SPACE; | |
77 pToggleTypes[9] = TOGGLE_OneTimePress; | |
78 pVirtualKeyCodesMapping[10] = 'C'; | |
79 pToggleTypes[10] = TOGGLE_OneTimePress; | |
80 pVirtualKeyCodesMapping[11] = 'B'; | |
81 pToggleTypes[11] = TOGGLE_OneTimePress; | |
82 pVirtualKeyCodesMapping[12] = VK_TAB; | |
83 pToggleTypes[12] = TOGGLE_OneTimePress; | |
84 pVirtualKeyCodesMapping[13] = 'Q'; | |
85 pToggleTypes[13] = TOGGLE_OneTimePress; | |
86 pVirtualKeyCodesMapping[14] = 'Z'; | |
87 pToggleTypes[14] = TOGGLE_OneTimePress; | |
88 pVirtualKeyCodesMapping[15] = 'R'; | |
89 pToggleTypes[15] = TOGGLE_OneTimePress; | |
90 pVirtualKeyCodesMapping[16] = 'T'; | |
91 pToggleTypes[16] = TOGGLE_OneTimePress; | |
92 pVirtualKeyCodesMapping[17] = 'N'; | |
93 pToggleTypes[17] = TOGGLE_OneTimePress; | |
94 pVirtualKeyCodesMapping[18] = 'M'; | |
95 pToggleTypes[18] = TOGGLE_OneTimePress; | |
96 pVirtualKeyCodesMapping[20] = VK_NEXT; | |
97 pToggleTypes[20] = TOGGLE_Continuously; | |
98 pVirtualKeyCodesMapping[21] = VK_DELETE; | |
99 pToggleTypes[21] = TOGGLE_Continuously; | |
100 | |
101 SetKeyMapping(INPUT_CenterView, VK_END, TOGGLE_Continuously); | |
102 SetKeyMapping(INPUT_ZoomIn, VK_ADD, TOGGLE_OneTimePress); | |
103 SetKeyMapping(INPUT_ZoomOut, VK_SUBTRACT, TOGGLE_OneTimePress); | |
104 SetKeyMapping(INPUT_FlyUp, VK_PRIOR, TOGGLE_Continuously); | |
105 SetKeyMapping(INPUT_FlyDown, VK_INSERT, TOGGLE_Continuously); | |
106 SetKeyMapping(INPUT_Land, VK_HOME, TOGGLE_OneTimePress); | |
107 SetKeyMapping(INPUT_AlwaysRun, 'U', TOGGLE_OneTimePress); | |
108 SetKeyMapping(INPUT_StrafeLeft, VK_OEM_4, TOGGLE_Continuously); | |
109 SetKeyMapping(INPUT_StrafeRight, VK_OEM_6, TOGGLE_Continuously); | |
110 } | |
111 | |
112 //----- (00459E3F) -------------------------------------------------------- | |
113 void KeyboardActionMapping::ResetKeys() | |
114 { | |
115 for (uint i = 0; i < 30; ++i) | |
116 GetAsyncKeyState(pVirtualKeyCodesMapping[i]); | |
117 } | |
118 | |
119 //----- (00459E5A) -------------------------------------------------------- | |
1038 | 120 void KeyboardActionMapping::EnterText(int a2, int max_string_len, GUIWindow *pWindow) |
0 | 121 { |
122 KeyboardActionMapping *v4; // esi@1 | |
123 | |
124 v4 = this; | |
125 memset(this->pPressedKeysBuffer, 0, 0x101u); | |
126 v4->uNumKeysPressed = 0; | |
127 if ( a2 ) | |
128 v4->field_204 = 2; | |
129 else | |
130 v4->field_204 = 1; | |
1038 | 131 v4->max_input_string_len = max_string_len; |
0 | 132 v4->pWindow = pWindow; |
1038 | 133 pWindow->receives_keyboard_input_2 = WINDOW_INPUT_IN_PROGRESS; |
0 | 134 } |
135 | |
136 //----- (00459ED1) -------------------------------------------------------- | |
1038 | 137 void KeyboardActionMapping::SetWindowInputStatus(int a2) |
0 | 138 { |
1038 | 139 field_204 = 0; |
140 if ( pWindow ) | |
141 pWindow->receives_keyboard_input_2 = a2; | |
0 | 142 } |
143 | |
144 //----- (00459F10) -------------------------------------------------------- | |
145 bool KeyboardActionMapping::_459F10(unsigned int a2) | |
146 { | |
147 int v3; // [sp-4h] [bp-4h]@3 | |
148 | |
149 pKeyActionMap->uLastKeyPressed = a2; | |
1031 | 150 if ( uGameMenuUI_CurentlySelectedKeyIdx == -1 ) |
0 | 151 { |
152 if ( pKeyActionMap->field_204 == 1 ) | |
153 { | |
154 if ( a2 != 8 ) | |
155 { | |
156 if ( a2 == 9 ) | |
157 return 1; | |
158 if ( a2 == 13 ) | |
159 goto LABEL_3; | |
160 if ( a2 == 27 ) | |
161 goto LABEL_15; | |
1038 | 162 if ( this->uNumKeysPressed >= this->max_input_string_len ) |
0 | 163 return 1; |
164 pKeyActionMap->pPressedKeysBuffer[pKeyActionMap->uNumKeysPressed] = a2; | |
165 ++pKeyActionMap->uNumKeysPressed; | |
166 LABEL_24: | |
167 pKeyActionMap->pPressedKeysBuffer[pKeyActionMap->uNumKeysPressed] = 0; | |
168 return 1; | |
169 } | |
170 } | |
171 else | |
172 { | |
173 if ( pKeyActionMap->field_204 != 2 ) | |
174 return 0; | |
175 if ( a2 != 8 ) | |
176 { | |
177 if ( a2 == 13 ) | |
178 goto LABEL_3; | |
179 if ( a2 != 27 ) | |
180 { | |
181 if ( (signed int)a2 >= 48 && (signed int)a2 <= 57 ) | |
182 { | |
1038 | 183 if ( pKeyActionMap->uNumKeysPressed < this->max_input_string_len ) |
0 | 184 { |
185 pKeyActionMap->pPressedKeysBuffer[pKeyActionMap->uNumKeysPressed] = a2; | |
186 ++pKeyActionMap->uNumKeysPressed; | |
187 } | |
188 } | |
189 return 1; | |
190 } | |
191 LABEL_15: | |
192 v3 = 3; | |
193 goto LABEL_4; | |
194 } | |
195 } | |
196 if ( !pKeyActionMap->uNumKeysPressed ) | |
197 return 1; | |
198 --pKeyActionMap->uNumKeysPressed; | |
199 goto LABEL_24; | |
200 } | |
201 pKeyActionMap->pPressedKeysBuffer[pKeyActionMap->uNumKeysPressed] = a2; | |
202 ++pKeyActionMap->uNumKeysPressed; | |
203 pKeyActionMap->pPressedKeysBuffer[pKeyActionMap->uNumKeysPressed] = 0; | |
204 LABEL_3: | |
205 v3 = 2; | |
206 LABEL_4: | |
1038 | 207 pKeyActionMap->SetWindowInputStatus(v3); |
0 | 208 return 1; |
209 } | |
1031 | 210 // 506E68: using guessed type int uGameMenuUI_CurentlySelectedKeyIdx; |
0 | 211 |
212 //----- (00459FFC) -------------------------------------------------------- | |
213 void KeyboardActionMapping::ReadMappings() | |
214 { | |
215 //KeyboardActionMapping *v1; // esi@1 | |
216 int v2; // eax@2 | |
217 unsigned int v3; // eax@3 | |
218 int v4; // eax@6 | |
219 unsigned int v5; // eax@7 | |
220 int v6; // eax@10 | |
221 unsigned int v7; // eax@11 | |
222 int v8; // eax@14 | |
223 unsigned int v9; // eax@15 | |
224 int v10; // eax@18 | |
225 unsigned int v11; // eax@19 | |
226 int v12; // eax@22 | |
227 //unsigned int v13; // eax@23 | |
228 int v14; // eax@26 | |
229 //unsigned int v15; // eax@27 | |
230 int v16; // eax@30 | |
231 //unsigned int v17; // eax@31 | |
232 int v18; // eax@34 | |
233 //unsigned int v19; // eax@35 | |
234 int v20; // eax@38 | |
235 //unsigned int v21; // eax@39 | |
236 int v22; // eax@42 | |
237 //unsigned int v23; // eax@43 | |
238 int v24; // eax@46 | |
239 //unsigned int v25; // eax@47 | |
240 int v26; // eax@50 | |
241 //unsigned int v27; // eax@51 | |
242 int v28; // eax@54 | |
243 //unsigned int v29; // eax@55 | |
244 int v30; // eax@58 | |
245 //unsigned int v31; // eax@59 | |
246 int v32; // eax@62 | |
247 //unsigned int v33; // eax@63 | |
248 int v34; // eax@66 | |
249 //unsigned int v35; // eax@67 | |
250 int v36; // eax@70 | |
251 //unsigned int v37; // eax@71 | |
252 int v38; // eax@74 | |
253 //unsigned int v39; // eax@75 | |
254 int v40; // eax@78 | |
255 //unsigned int v41; // eax@79 | |
256 int v42; // eax@82 | |
257 //unsigned int v43; // eax@83 | |
258 int v44; // eax@86 | |
259 //unsigned int v45; // eax@87 | |
260 int v46; // eax@90 | |
261 //unsigned int v47; // eax@91 | |
262 int v48; // eax@94 | |
263 //unsigned int v49; // eax@95 | |
264 int v50; // eax@98 | |
265 //unsigned int v51; // eax@99 | |
266 int v52; // eax@102 | |
267 //unsigned int v53; // eax@103 | |
268 int v54; // eax@106 | |
269 //unsigned int v55; // eax@107 | |
270 int v56; // eax@110 | |
271 unsigned int v57; // eax@111 | |
272 int v58; // eax@114 | |
273 unsigned int v59; // eax@115 | |
274 int v60; // eax@118 | |
275 unsigned int v61; // eax@119 | |
276 //char str[32]; // [sp+Ch] [bp-20h]@1 | |
277 | |
278 char str[32]; | |
279 | |
280 ReadWindowsRegistryString("KEY_FORWARD", str, 32, "DEFAULT"); | |
281 if ( strcmp(str, "DEFAULT") && (LOBYTE(v2) = GetActionDefaultVKey(str), v2 != -1) ) | |
282 { | |
283 pVirtualKeyCodesMapping[0] = GetActionDefaultVKey(str); | |
284 } | |
285 else | |
286 { | |
287 pVirtualKeyCodesMapping[0] = VK_UP; | |
288 } | |
289 pToggleTypes[0] = TOGGLE_Continuously; | |
290 ReadWindowsRegistryString("KEY_BACKWARD", str, 0x20u, "DEFAULT"); | |
291 if ( strcmp(str, "DEFAULT") && (LOBYTE(v4) = GetActionDefaultVKey(str), v4 != -1) ) | |
292 { | |
293 pVirtualKeyCodesMapping[1] = GetActionDefaultVKey(str); | |
294 } | |
295 else | |
296 { | |
297 pVirtualKeyCodesMapping[1] = VK_DOWN; | |
298 } | |
299 pToggleTypes[1] = TOGGLE_Continuously; | |
300 | |
301 ReadWindowsRegistryString("KEY_LEFT", str, 0x20u, "DEFAULT"); | |
302 if ( strcmp(str, "DEFAULT") && (LOBYTE(v6) = GetActionDefaultVKey(str), v6 != -1) ) | |
303 { | |
304 pVirtualKeyCodesMapping[2] = GetActionDefaultVKey(str); | |
305 } | |
306 else | |
307 { | |
308 pVirtualKeyCodesMapping[2] = VK_LEFT; | |
309 } | |
310 pToggleTypes[2] = TOGGLE_Continuously; | |
311 | |
312 ReadWindowsRegistryString("KEY_RIGHT", str, 0x20u, "DEFAULT"); | |
313 if ( strcmp(str, "DEFAULT") && (LOBYTE(v8) = GetActionDefaultVKey(str), v8 != -1) ) | |
314 { | |
315 pVirtualKeyCodesMapping[3] = GetActionDefaultVKey(str); | |
316 } | |
317 else | |
318 { | |
319 pVirtualKeyCodesMapping[3] = VK_RIGHT; | |
320 } | |
321 pToggleTypes[3] = TOGGLE_Continuously; | |
322 | |
323 ReadWindowsRegistryString("KEY_ATTACK", str, 0x20u, "DEFAULT"); | |
324 if ( strcmp(str, "DEFAULT") && (LOBYTE(v10) = GetActionDefaultVKey(str), v10 != -1) ) | |
325 { | |
326 pVirtualKeyCodesMapping[8] = GetActionDefaultVKey(str); | |
327 } | |
328 else | |
329 { | |
330 pVirtualKeyCodesMapping[8] = 'A'; | |
331 } | |
332 pToggleTypes[8] = TOGGLE_OneTimePress; | |
333 | |
334 ReadWindowsRegistryString("KEY_CASTREADY", str, 0x20u, "DEFAULT"); | |
335 if ( strcmp(str, "DEFAULT") && (LOBYTE(v12) = GetActionDefaultVKey(str), v12 != -1) ) | |
336 { | |
337 pVirtualKeyCodesMapping[7] = GetActionDefaultVKey(str); | |
338 } | |
339 else | |
340 { | |
341 pVirtualKeyCodesMapping[7] = 'S'; | |
342 } | |
343 pToggleTypes[7] = TOGGLE_OneTimePress; | |
344 | |
345 ReadWindowsRegistryString("KEY_YELL", str, 0x20u, "DEFAULT"); | |
346 if ( strcmp(str, "DEFAULT") && (LOBYTE(v14) = GetActionDefaultVKey(str), v14 != -1) ) | |
347 { | |
348 pVirtualKeyCodesMapping[4] = GetActionDefaultVKey(str); | |
349 } | |
350 else | |
351 { | |
352 pVirtualKeyCodesMapping[4] = 'Y'; | |
353 } | |
354 pToggleTypes[4] = TOGGLE_OneTimePress; | |
355 | |
356 ReadWindowsRegistryString("KEY_JUMP", str, 0x20u, "DEFAULT"); | |
357 if ( strcmp(str, "DEFAULT") && (LOBYTE(v16) = GetActionDefaultVKey(str), v16 != -1) ) | |
358 { | |
359 pVirtualKeyCodesMapping[5] = GetActionDefaultVKey(str); | |
360 } | |
361 else | |
362 { | |
363 pVirtualKeyCodesMapping[5] = 'X'; | |
364 } | |
365 pToggleTypes[5] = TOGGLE_OneTimePress; | |
366 | |
367 ReadWindowsRegistryString("KEY_COMBAT", str, 0x20u, "DEFAULT"); | |
368 if ( strcmp(str, "DEFAULT") && (LOBYTE(v18) = GetActionDefaultVKey(str), v18 != -1) ) | |
369 { | |
370 pVirtualKeyCodesMapping[6] = GetActionDefaultVKey(str); | |
371 } | |
372 else | |
373 { | |
374 pVirtualKeyCodesMapping[6] = VK_RETURN; | |
375 } | |
376 pToggleTypes[6] = TOGGLE_OneTimePress; | |
377 | |
378 ReadWindowsRegistryString("KEY_EVENTTRIGGER", str, 0x20u, "DEFAULT"); | |
379 if ( strcmp(str, "DEFAULT") && (LOBYTE(v20) = GetActionDefaultVKey(str), v20 != -1) ) | |
380 { | |
381 pVirtualKeyCodesMapping[9] = GetActionDefaultVKey(str); | |
382 } | |
383 else | |
384 { | |
385 pVirtualKeyCodesMapping[9] = VK_SPACE; | |
386 } | |
387 pToggleTypes[9] = TOGGLE_OneTimePress; | |
388 | |
389 ReadWindowsRegistryString("KEY_CAST", str, 0x20u, "DEFAULT"); | |
390 if ( strcmp(str, "DEFAULT") && (LOBYTE(v22) = GetActionDefaultVKey(str), v22 != -1) ) | |
391 { | |
392 pVirtualKeyCodesMapping[10] = GetActionDefaultVKey(str); | |
393 } | |
394 else | |
395 { | |
396 pVirtualKeyCodesMapping[10] = 'C'; | |
397 } | |
398 pToggleTypes[10] = TOGGLE_OneTimePress; | |
399 | |
400 ReadWindowsRegistryString("KEY_PASS", str, 0x20u, "DEFAULT"); | |
401 if ( strcmp(str, "DEFAULT") && (LOBYTE(v24) = GetActionDefaultVKey(str), v24 != -1) ) | |
402 { | |
403 pVirtualKeyCodesMapping[11] = GetActionDefaultVKey(str); | |
404 } | |
405 else | |
406 { | |
407 pVirtualKeyCodesMapping[11] = 'B'; | |
408 } | |
409 pToggleTypes[11] = TOGGLE_OneTimePress; | |
410 | |
411 ReadWindowsRegistryString("KEY_CHARCYCLE", str, 0x20u, "DEFAULT"); | |
412 if ( strcmp(str, "DEFAULT") && (LOBYTE(v26) = GetActionDefaultVKey(str), v26 != -1) ) | |
413 { | |
414 pVirtualKeyCodesMapping[12] = GetActionDefaultVKey(str); | |
415 } | |
416 else | |
417 { | |
418 pVirtualKeyCodesMapping[12] = VK_TAB; | |
419 } | |
420 pToggleTypes[12] = TOGGLE_OneTimePress; | |
421 | |
422 ReadWindowsRegistryString("KEY_QUEST", str, 0x20u, "DEFAULT"); | |
423 if ( strcmp(str, "DEFAULT") && (LOBYTE(v28) = GetActionDefaultVKey(str), v28 != -1) ) | |
424 { | |
425 pVirtualKeyCodesMapping[13] = GetActionDefaultVKey(str); | |
426 } | |
427 else | |
428 { | |
429 pVirtualKeyCodesMapping[13] = 'Q'; | |
430 } | |
431 pToggleTypes[13] = TOGGLE_OneTimePress; | |
432 | |
433 ReadWindowsRegistryString("KEY_QUICKREF", str, 0x20u, "DEFAULT"); | |
434 if ( strcmp(str, "DEFAULT") && (LOBYTE(v30) = GetActionDefaultVKey(str), v30 != -1) ) | |
435 { | |
436 pVirtualKeyCodesMapping[14] = GetActionDefaultVKey(str); | |
437 } | |
438 else | |
439 { | |
440 pVirtualKeyCodesMapping[14] = 'Z'; | |
441 } | |
442 pToggleTypes[14] = TOGGLE_OneTimePress; | |
443 | |
444 ReadWindowsRegistryString("KEY_REST", str, 0x20u, "DEFAULT"); | |
445 if ( strcmp(str, "DEFAULT") && (LOBYTE(v32) = GetActionDefaultVKey(str), v32 != -1) ) | |
446 { | |
447 pVirtualKeyCodesMapping[15] = GetActionDefaultVKey(str); | |
448 } | |
449 else | |
450 { | |
451 pVirtualKeyCodesMapping[15] = 'R'; | |
452 } | |
453 pToggleTypes[15] = TOGGLE_OneTimePress; | |
454 | |
455 ReadWindowsRegistryString("KEY_TIMECAL", str, 0x20u, "DEFAULT"); | |
456 if ( strcmp(str, "DEFAULT") && (LOBYTE(v34) = GetActionDefaultVKey(str), v34 != -1) ) | |
457 { | |
458 pVirtualKeyCodesMapping[16] = GetActionDefaultVKey(str); | |
459 } | |
460 else | |
461 { | |
462 pVirtualKeyCodesMapping[16] = 'T'; | |
463 } | |
464 pToggleTypes[16] = TOGGLE_OneTimePress; | |
465 | |
466 ReadWindowsRegistryString("KEY_AUTONOTES", str, 0x20u, "DEFAULT"); | |
467 if ( strcmp(str, "DEFAULT") && (LOBYTE(v36) = GetActionDefaultVKey(str), v36 != -1) ) | |
468 { | |
469 pVirtualKeyCodesMapping[17] = GetActionDefaultVKey(str); | |
470 } | |
471 else | |
472 { | |
473 pVirtualKeyCodesMapping[17] = 'N'; | |
474 } | |
475 pToggleTypes[17] = TOGGLE_OneTimePress; | |
476 | |
477 ReadWindowsRegistryString("KEY_MAPBOOK", str, 0x20u, "DEFAULT"); | |
478 if ( strcmp(str, "DEFAULT") && (LOBYTE(v38) = GetActionDefaultVKey(str), v38 != -1) ) | |
479 { | |
480 pVirtualKeyCodesMapping[18] = GetActionDefaultVKey(str); | |
481 } | |
482 else | |
483 { | |
484 pVirtualKeyCodesMapping[18] = 'M'; | |
485 } | |
486 pToggleTypes[18] = TOGGLE_OneTimePress; | |
487 | |
488 ReadWindowsRegistryString("KEY_LOOKUP", str, 0x20u, "DEFAULT"); | |
489 if ( strcmp(str, "DEFAULT") && (LOBYTE(v40) = GetActionDefaultVKey(str), v40 != -1) ) | |
490 { | |
491 pVirtualKeyCodesMapping[20] = GetActionDefaultVKey(str); | |
492 } | |
493 else | |
494 { | |
495 pVirtualKeyCodesMapping[20] = VK_NEXT; | |
496 } | |
497 pToggleTypes[20] = TOGGLE_OneTimePress; | |
498 | |
499 ReadWindowsRegistryString("KEY_LOOKDOWN", str, 0x20u, "DEFAULT"); | |
500 if ( strcmp(str, "DEFAULT") && (LOBYTE(v42) = GetActionDefaultVKey(str), v42 != -1) ) | |
501 { | |
502 pVirtualKeyCodesMapping[21] = GetActionDefaultVKey(str); | |
503 } | |
504 else | |
505 { | |
506 pVirtualKeyCodesMapping[21] = VK_DELETE; | |
507 } | |
508 pToggleTypes[21] = TOGGLE_OneTimePress; | |
509 | |
510 ReadWindowsRegistryString("KEY_CENTERVIEWPT", str, 0x20u, "DEFAULT"); | |
511 if ( strcmp(str, "DEFAULT") && (LOBYTE(v44) = GetActionDefaultVKey(str), v44 != -1) ) | |
512 { | |
513 pVirtualKeyCodesMapping[22] = GetActionDefaultVKey(str); | |
514 } | |
515 else | |
516 { | |
517 pVirtualKeyCodesMapping[22] = VK_END; | |
518 } | |
519 pToggleTypes[22] = TOGGLE_OneTimePress; | |
520 | |
521 ReadWindowsRegistryString("KEY_ZOOMIN", str, 0x20u, "DEFAULT"); | |
522 if ( strcmp(str, "DEFAULT") && (LOBYTE(v46) = GetActionDefaultVKey(str), v46 != -1) ) | |
523 { | |
524 pVirtualKeyCodesMapping[23] = GetActionDefaultVKey(str); | |
525 } | |
526 else | |
527 { | |
528 pVirtualKeyCodesMapping[23] = VK_ADD; | |
529 } | |
530 pToggleTypes[23] = TOGGLE_OneTimePress; | |
531 | |
532 ReadWindowsRegistryString("KEY_ZOOMOUT", str, 0x20u, "DEFAULT"); | |
533 if ( strcmp(str, "DEFAULT") && (LOBYTE(v48) = GetActionDefaultVKey(str), v48 != -1) ) | |
534 { | |
535 pVirtualKeyCodesMapping[24] = GetActionDefaultVKey(str); | |
536 } | |
537 else | |
538 { | |
539 pVirtualKeyCodesMapping[24] = VK_SUBTRACT; | |
540 } | |
541 pToggleTypes[24] = TOGGLE_OneTimePress; | |
542 | |
543 ReadWindowsRegistryString("KEY_FLYUP", str, 0x20u, "DEFAULT"); | |
544 if ( strcmp(str, "DEFAULT") && (LOBYTE(v50) = GetActionDefaultVKey(str), v50 != -1) ) | |
545 { | |
546 pVirtualKeyCodesMapping[25] = GetActionDefaultVKey(str); | |
547 } | |
548 else | |
549 { | |
550 pVirtualKeyCodesMapping[25] = VK_PRIOR; | |
551 } | |
552 pToggleTypes[25] = TOGGLE_Continuously; | |
553 | |
554 ReadWindowsRegistryString("KEY_FLYDOWN", str, 0x20u, "DEFAULT"); | |
555 if ( strcmp(str, "DEFAULT") && (LOBYTE(v52) = GetActionDefaultVKey(str), v52 != -1) ) | |
556 { | |
557 pVirtualKeyCodesMapping[26] = GetActionDefaultVKey(str); | |
558 } | |
559 else | |
560 { | |
561 pVirtualKeyCodesMapping[26] = VK_INSERT; | |
562 } | |
563 pToggleTypes[26] = TOGGLE_Continuously; | |
564 | |
565 ReadWindowsRegistryString("KEY_LAND", str, 0x20u, "DEFAULT"); | |
566 if ( strcmp(str, "DEFAULT") && (LOBYTE(v54) = GetActionDefaultVKey(str), v54 != -1) ) | |
567 { | |
568 pVirtualKeyCodesMapping[27] = GetActionDefaultVKey(str); | |
569 } | |
570 else | |
571 { | |
572 pVirtualKeyCodesMapping[27] = VK_HOME; | |
573 } | |
574 pToggleTypes[27] = TOGGLE_OneTimePress; | |
575 | |
576 ReadWindowsRegistryString("KEY_ALWAYSRUN", str, 0x20u, "DEFAULT"); | |
577 if ( strcmp(str, "DEFAULT") && (LOBYTE(v56) = GetActionDefaultVKey(str), v56 != -1) ) | |
578 { | |
579 pVirtualKeyCodesMapping[19] = GetActionDefaultVKey(str); | |
580 } | |
581 else | |
582 { | |
583 pVirtualKeyCodesMapping[19] = 'U'; | |
584 } | |
585 pToggleTypes[19] = TOGGLE_OneTimePress; | |
586 | |
587 bAlwaysRun = ReadWindowsRegistryInt("valAlwaysRun", 0) != 0; | |
588 bFlipOnExit = ReadWindowsRegistryInt("FlipOnExit", 0) != 0; | |
589 ReadWindowsRegistryString("KEY_STEPLEFT", str, 0x20u, "DEFAULT"); | |
590 if ( strcmp(str, "DEFAULT") && (LOBYTE(v58) = GetActionDefaultVKey(str), v58 != -1) ) | |
591 { | |
592 pVirtualKeyCodesMapping[28] = GetActionDefaultVKey(str); | |
593 pToggleTypes[28] = TOGGLE_OneTimePress; | |
594 } | |
595 else | |
596 { | |
597 pToggleTypes[28] = TOGGLE_Continuously; | |
598 pVirtualKeyCodesMapping[28] = VK_OEM_4; | |
599 } | |
600 | |
601 ReadWindowsRegistryString("KEY_STEPRIGHT", str, 0x20u, "DEFAULT"); | |
602 if ( strcmp(str, "DEFAULT") && (LOBYTE(v60) = GetActionDefaultVKey(str), v60 != -1) ) | |
603 { | |
604 pVirtualKeyCodesMapping[29] = GetActionDefaultVKey(str); | |
605 pToggleTypes[29] = TOGGLE_OneTimePress; | |
606 } | |
607 else | |
608 { | |
609 pToggleTypes[29] = TOGGLE_Continuously; | |
610 pVirtualKeyCodesMapping[29] = VK_OEM_6; | |
611 } | |
612 } | |
613 | |
614 //----- (0045A960) -------------------------------------------------------- | |
615 void KeyboardActionMapping::StoreMappings() | |
616 { | |
617 const char *v2; // eax@1 | |
618 const char *v3; // eax@1 | |
619 const char *v4; // eax@1 | |
620 const char *v5; // eax@1 | |
621 const char *v6; // eax@1 | |
622 const char *v7; // eax@1 | |
623 const char *v8; // eax@1 | |
624 const char *v9; // eax@1 | |
625 const char *v10; // eax@1 | |
626 const char *v11; // eax@1 | |
627 const char *v12; // eax@1 | |
628 const char *v13; // eax@1 | |
629 const char *v14; // eax@1 | |
630 const char *v15; // eax@1 | |
631 const char *v16; // eax@1 | |
632 const char *v17; // eax@1 | |
633 const char *v18; // eax@1 | |
634 const char *v19; // eax@1 | |
635 const char *v20; // eax@1 | |
636 const char *v21; // eax@1 | |
637 const char *v22; // eax@1 | |
638 const char *v23; // eax@1 | |
639 const char *v24; // eax@1 | |
640 const char *v25; // eax@1 | |
641 const char *v26; // eax@1 | |
642 const char *v27; // eax@1 | |
643 const char *v28; // eax@1 | |
644 const char *v29; // eax@1 | |
645 | |
1038 | 646 v2 = GetVKeyDisplayName(pVirtualKeyCodesMapping[0]); |
0 | 647 WriteWindowsRegistryString("KEY_FORWARD", v2); |
648 v3 = GetVKeyDisplayName(pVirtualKeyCodesMapping[1]); | |
649 WriteWindowsRegistryString("KEY_BACKWARD", v3); | |
650 v4 = GetVKeyDisplayName(pVirtualKeyCodesMapping[2]); | |
651 WriteWindowsRegistryString("KEY_LEFT", v4); | |
652 v5 = GetVKeyDisplayName(pVirtualKeyCodesMapping[3]); | |
653 WriteWindowsRegistryString("KEY_RIGHT", v5); | |
654 v6 = GetVKeyDisplayName(pVirtualKeyCodesMapping[8]); | |
655 WriteWindowsRegistryString("KEY_ATTACK", v6); | |
656 v7 = GetVKeyDisplayName(pVirtualKeyCodesMapping[7]); | |
657 WriteWindowsRegistryString("KEY_CASTREADY", v7); | |
658 v8 = GetVKeyDisplayName(pVirtualKeyCodesMapping[4]); | |
659 WriteWindowsRegistryString("KEY_YELL", v8); | |
660 v9 = GetVKeyDisplayName(pVirtualKeyCodesMapping[5]); | |
661 WriteWindowsRegistryString("KEY_JUMP", v9); | |
662 v10 = GetVKeyDisplayName(pVirtualKeyCodesMapping[6]); | |
663 WriteWindowsRegistryString("KEY_COMBAT", v10); | |
664 v11 = GetVKeyDisplayName(pVirtualKeyCodesMapping[9]); | |
665 WriteWindowsRegistryString("KEY_EVENTTRIGGER", v11); | |
666 v12 = GetVKeyDisplayName(pVirtualKeyCodesMapping[10]); | |
667 WriteWindowsRegistryString("KEY_CAST", v12); | |
668 v13 = GetVKeyDisplayName(pVirtualKeyCodesMapping[11]); | |
669 WriteWindowsRegistryString("KEY_PASS", v13); | |
670 v14 = GetVKeyDisplayName(pVirtualKeyCodesMapping[12]); | |
671 WriteWindowsRegistryString("KEY_CHARCYCLE", v14); | |
672 v15 = GetVKeyDisplayName(pVirtualKeyCodesMapping[13]); | |
673 WriteWindowsRegistryString("KEY_QUEST", v15); | |
674 v16 = GetVKeyDisplayName(pVirtualKeyCodesMapping[14]); | |
675 WriteWindowsRegistryString("KEY_QUICKREF", v16); | |
676 v17 = GetVKeyDisplayName(pVirtualKeyCodesMapping[15]); | |
677 WriteWindowsRegistryString("KEY_REST", v17); | |
678 v18 = GetVKeyDisplayName(pVirtualKeyCodesMapping[16]); | |
679 WriteWindowsRegistryString("KEY_TIMECAL", v18); | |
680 v19 = GetVKeyDisplayName(pVirtualKeyCodesMapping[17]); | |
681 WriteWindowsRegistryString("KEY_AUTONOTES", v19); | |
682 v20 = GetVKeyDisplayName(pVirtualKeyCodesMapping[18]); | |
683 WriteWindowsRegistryString("KEY_MAPBOOK", v20); | |
684 v21 = GetVKeyDisplayName(pVirtualKeyCodesMapping[20]); | |
685 WriteWindowsRegistryString("KEY_LOOKUP", v21); | |
686 v22 = GetVKeyDisplayName(pVirtualKeyCodesMapping[21]); | |
687 WriteWindowsRegistryString("KEY_LOOKDOWN", v22); | |
688 v23 = GetVKeyDisplayName(pVirtualKeyCodesMapping[22]); | |
689 WriteWindowsRegistryString("KEY_CENTERVIEWPT", v23); | |
690 v24 = GetVKeyDisplayName(pVirtualKeyCodesMapping[23]); | |
691 WriteWindowsRegistryString("KEY_ZOOMIN", v24); | |
692 v25 = GetVKeyDisplayName(pVirtualKeyCodesMapping[24]); | |
693 WriteWindowsRegistryString("KEY_ZOOMOUT", v25); | |
694 v26 = GetVKeyDisplayName(pVirtualKeyCodesMapping[25]); | |
695 WriteWindowsRegistryString("KEY_FLYUP", v26); | |
696 v27 = GetVKeyDisplayName(pVirtualKeyCodesMapping[26]); | |
697 WriteWindowsRegistryString("KEY_FLYDOWN", v27); | |
698 v28 = GetVKeyDisplayName(pVirtualKeyCodesMapping[27]); | |
699 WriteWindowsRegistryString("KEY_LAND", v28); | |
700 v29 = GetVKeyDisplayName(pVirtualKeyCodesMapping[19]); | |
701 WriteWindowsRegistryString("KEY_ALWAYSRUN", v29); | |
702 } | |
703 | |
704 //----- (0045ABCA) -------------------------------------------------------- | |
705 const unsigned __int8 KeyboardActionMapping::GetActionDefaultVKey(const char *Str) | |
706 { | |
707 unsigned __int8 result; // al@3 | |
708 | |
709 if ( !strcmp(Str, "UP") ) | |
710 return VK_UP; | |
711 if ( !strcmp(Str, "DOWN") ) | |
712 return VK_DOWN; | |
713 if (!strcmp(Str, "ยหลยฮ") || !strcmp(Str, "LEFT")) | |
714 return VK_LEFT; | |
715 if (!strcmp(Str, "ยฯะภยฮ") || !strcmp(Str, "RIGHT")) | |
716 return VK_RIGHT; | |
717 if ( !strcmp(Str, "RETURN") ) | |
718 return VK_RETURN; | |
719 if ( !strcmp(Str, "SPACE") ) | |
720 return VK_SPACE; | |
721 if ( !strcmp(Str, "PAGE_DOWN") ) | |
722 return VK_NEXT; | |
723 if ( !strcmp(Str, "PAGE_UP") ) | |
724 return VK_PRIOR; | |
725 if ( !strcmp(Str, "TAB") ) | |
726 return VK_TAB; | |
727 if ( !strcmp(Str, "SUBTRACT") ) | |
728 return VK_SUBTRACT; | |
729 if ( !strcmp(Str, "ADD") ) | |
730 return VK_ADD; | |
731 if ( !strcmp(Str, "END") ) | |
732 return VK_END; | |
733 if ( !strcmp(Str, "DELETE") ) | |
734 return VK_DELETE; | |
735 if ( !strcmp(Str, "HOME") ) | |
736 return VK_HOME; | |
737 if ( !strcmp(Str, "INSERT") ) | |
738 return VK_INSERT; | |
739 if ( strcmp(Str, "COMMA") ) | |
740 { | |
741 if ( !strcmp(Str, "DECIMAL") ) | |
742 return VK_DECIMAL; | |
743 if ( strcmp(Str, "SEMICOLON") ) | |
744 { | |
745 if ( strcmp(Str, "PERIOD") ) | |
746 { | |
747 if ( strcmp(Str, "SLASH") ) | |
748 { | |
749 if ( strcmp(Str, "SQUOTE") ) | |
750 { | |
751 if ( strcmp(Str, "BACKSLASH") ) | |
752 { | |
753 if ( !strcmp(Str, "BACKSPACE") ) | |
754 return VK_BACK; | |
755 if ( !strcmp(Str, "CONTROL") ) | |
756 return VK_CONTROL; | |
757 if ( strlen(Str) != 1 || (result = *Str, (unsigned __int8)*Str < 0x41u) || result > 0x5Au ) | |
758 result = -1; | |
759 } | |
760 else | |
761 { | |
762 result = -36; | |
763 } | |
764 } | |
765 else | |
766 { | |
767 result = -34; | |
768 } | |
769 } | |
770 else | |
771 { | |
772 result = -65; | |
773 } | |
774 } | |
775 else | |
776 { | |
777 result = -66; | |
778 } | |
779 } | |
780 else | |
781 { | |
782 result = -70; | |
783 } | |
784 } | |
785 else | |
786 { | |
787 result = -68; | |
788 } | |
789 return result; | |
790 } | |
791 | |
792 //----- (0045AE2C) -------------------------------------------------------- | |
793 const char *KeyboardActionMapping::GetVKeyDisplayName(signed int a1) | |
794 { | |
795 char *v3; // [sp-4h] [bp-8h]@2 | |
796 | |
797 static char static_sub_45AE2C_string_69ADE0[32]; | |
798 | |
799 if ( a1 == VK_UP ) | |
800 { | |
801 v3 = "UP"; | |
802 LABEL_53: | |
803 strcpy(static_sub_45AE2C_string_69ADE0, v3); | |
804 return static_sub_45AE2C_string_69ADE0; | |
805 } | |
806 if ( a1 == VK_DOWN ) | |
807 { | |
808 v3 = "DOWN"; | |
809 goto LABEL_53; | |
810 } | |
811 if ( a1 == VK_LEFT ) | |
812 { | |
159 | 813 v3 = "LEFT"; |
0 | 814 goto LABEL_53; |
815 } | |
816 if ( a1 == VK_RIGHT ) | |
817 { | |
159 | 818 v3 = "RIGHT"; |
0 | 819 goto LABEL_53; |
820 } | |
821 if ( a1 == VK_RETURN ) | |
822 { | |
823 v3 = "RETURN"; | |
824 goto LABEL_53; | |
825 } | |
826 if ( a1 == VK_SPACE ) | |
827 { | |
828 v3 = "SPACE"; | |
829 goto LABEL_53; | |
830 } | |
831 if ( a1 == VK_NEXT ) | |
832 { | |
833 v3 = "PAGE_DOWN"; | |
834 goto LABEL_53; | |
835 } | |
836 if ( a1 == VK_PRIOR ) | |
837 { | |
838 v3 = "PAGE_UP"; | |
839 goto LABEL_53; | |
840 } | |
841 if ( a1 == VK_TAB ) | |
842 { | |
843 v3 = "TAB"; | |
844 goto LABEL_53; | |
845 } | |
846 if ( a1 == 'm' ) | |
847 { | |
848 v3 = "SUBTRACT"; | |
849 goto LABEL_53; | |
850 } | |
851 if ( a1 == 'k' ) | |
852 { | |
853 v3 = "ADD"; | |
854 goto LABEL_53; | |
855 } | |
856 if ( a1 == VK_END ) | |
857 { | |
858 v3 = "END"; | |
859 goto LABEL_53; | |
860 } | |
861 if ( a1 == VK_DELETE ) | |
862 { | |
863 v3 = "DELETE"; | |
864 goto LABEL_53; | |
865 } | |
866 if ( a1 == VK_HOME ) | |
867 { | |
868 v3 = "HOME"; | |
869 goto LABEL_53; | |
870 } | |
871 if ( a1 == VK_INSERT ) | |
872 { | |
873 v3 = "INSERT"; | |
874 goto LABEL_53; | |
875 } | |
876 if ( a1 == VK_DECIMAL ) | |
877 { | |
878 v3 = "DECIMAL"; | |
879 goto LABEL_53; | |
880 } | |
881 if ( a1 == VK_OEM_COMMA ) | |
882 { | |
883 v3 = "COMMA"; | |
884 goto LABEL_53; | |
885 } | |
886 if ( a1 == VK_OEM_1 ) | |
887 { | |
888 v3 = "SEMICOLON"; | |
889 goto LABEL_53; | |
890 } | |
891 if ( a1 == VK_OEM_PERIOD ) | |
892 { | |
893 v3 = "PERIOD"; | |
894 goto LABEL_53; | |
895 } | |
896 if ( a1 == VK_OEM_2 ) | |
897 { | |
898 v3 = "SLASH"; | |
899 goto LABEL_53; | |
900 } | |
901 if ( a1 == VK_OEM_7 ) | |
902 { | |
903 v3 = "SQUOTE"; | |
904 goto LABEL_53; | |
905 } | |
906 if ( a1 == VK_OEM_5 ) | |
907 { | |
908 v3 = "BACKSLASH"; | |
909 goto LABEL_53; | |
910 } | |
911 if ( a1 == VK_CONTROL ) | |
912 { | |
913 v3 = "CONTROL"; | |
914 goto LABEL_53; | |
915 } | |
916 if ( a1 == VK_BACK ) | |
917 { | |
918 v3 = "BACKSPACE"; | |
919 goto LABEL_53; | |
920 } | |
921 if ( a1 < 65 || a1 > 90 ) | |
922 { | |
923 v3 = "-อลา -"; | |
924 goto LABEL_53; | |
925 } | |
926 *(unsigned short *)static_sub_45AE2C_string_69ADE0 = (unsigned __int8)a1; | |
927 return static_sub_45AE2C_string_69ADE0; | |
928 } | |
929 | |
930 //----- (0045AFD9) -------------------------------------------------------- | |
931 Keyboard::Keyboard() | |
932 { | |
933 bUsingAsynKeyboard = false; | |
934 | |
935 if (pVersion->pVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT && | |
936 pVersion->pVersionInfo.dwMajorVersion == 4) | |
937 bUsingAsynKeyboard = false; | |
938 } | |
939 | |
940 //----- (0045B019) -------------------------------------------------------- | |
941 void Keyboard::EnterCriticalSection() | |
942 { | |
943 } | |
944 | |
945 //----- (0045B06E) -------------------------------------------------------- | |
946 bool Keyboard::IsShiftHeld() | |
947 { | |
1038 | 948 return GetAsyncKeyState(VK_SHIFT); |
0 | 949 } |
950 | |
951 //----- (0045B0A9) -------------------------------------------------------- | |
952 bool Keyboard::IsKeyBeingHeld(int vKey) | |
953 { | |
1038 | 954 return GetAsyncKeyState(vKey) & 0x8001; |
0 | 955 } |
956 | |
957 //----- (0045B0CE) -------------------------------------------------------- | |
958 bool Keyboard::WasKeyPressed(int vKey) | |
959 { | |
1038 | 960 return GetAsyncKeyState(vKey) & 1; |
0 | 961 } |