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