Mercurial > mm7
annotate Keyboard.cpp @ 2280:a5926b36a1b4
pMMT_MainMenu_BtnExit coordinates
author | Ritor1 |
---|---|
date | Fri, 14 Mar 2014 22:41:35 +0600 |
parents | aff7a7b072b7 |
children | 9551756f46c4 |
rev | line source |
---|---|
2253
aff7a7b072b7
adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents:
2201
diff
changeset
|
1 #define _CRT_SECURE_NO_WARNINGS |
0 | 2 #include "Keyboard.h" |
3 #include "GUIWindow.h" | |
4 #include "Game.h" | |
5 | |
6 #include "mm7_data.h" | |
2152 | 7 #include "mm7_unsorted_subs.h" |
1297 | 8 #include "Vis.h" |
9 #include "MM7.h" | |
10 #include "Actor.h" | |
11 #include "DecorationList.h" | |
12 #include "Indoor.h" | |
13 #include "viewport.h" | |
14 #include "AudioPlayer.h" | |
1828
35c1e4ff6ba7
party_finds_gold to Party::PartyFindsGold, cleaned up, moved Level/Decoration.h reference out of Indoor.h
Grumpy7
parents:
1459
diff
changeset
|
15 #include "Level/Decoration.h" |
0 | 16 |
2200
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
17 #include <tuple> |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
18 #include <vector> |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
19 #include <string> |
0 | 20 |
21 struct KeyboardActionMapping *pKeyActionMap; | |
22 | |
23 | |
2200
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
24 class CKeyListElement{ |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
25 public: |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
26 std::string m_keyName; |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
27 unsigned char m_keyDefaultCode; |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
28 unsigned short m_cmdId; |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
29 KeyToggleType m_toggType; |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
30 CKeyListElement(std::string keyName, unsigned char keyDefaultCode, unsigned short cmdId, KeyToggleType toggType): |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
31 m_keyName(keyName), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
32 m_keyDefaultCode(keyDefaultCode), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
33 m_cmdId(cmdId), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
34 m_toggType(toggType) |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
35 { |
0 | 36 |
2200
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
37 } |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
38 }; |
0 | 39 |
2200
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
40 std::array<CKeyListElement, 30>keyMappingParams = { |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
41 CKeyListElement("KEY_FORWARD", VK_UP, INPUT_MoveForward, TOGGLE_Continuously), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
42 CKeyListElement("KEY_BACKWARD", VK_DOWN, INPUT_MoveBackwards, TOGGLE_Continuously), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
43 CKeyListElement("KEY_LEFT", VK_LEFT, INPUT_TurnLeft, TOGGLE_Continuously), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
44 CKeyListElement("KEY_RIGHT", VK_RIGHT, INPUT_TurnRight, TOGGLE_Continuously), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
45 CKeyListElement("KEY_ATTACK", 'A', INPUT_Attack, TOGGLE_OneTimePress), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
46 CKeyListElement("KEY_CASTREADY", 'S', INPUT_CastReady, TOGGLE_OneTimePress), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
47 CKeyListElement("KEY_YELL", 'Y', INPUT_Yell, TOGGLE_OneTimePress), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
48 CKeyListElement("KEY_JUMP", 'X', INPUT_Jump, TOGGLE_OneTimePress), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
49 CKeyListElement("KEY_COMBAT", VK_RETURN, INPUT_Combat, TOGGLE_OneTimePress), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
50 CKeyListElement("KEY_EVENTTRIGGER", VK_SPACE, INPUT_EventTrigger, TOGGLE_OneTimePress), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
51 CKeyListElement("KEY_CAST", 'C', INPUT_Cast, TOGGLE_OneTimePress), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
52 CKeyListElement("KEY_PASS", 'B', INPUT_Pass, TOGGLE_OneTimePress), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
53 CKeyListElement("KEY_CHARCYCLE", VK_TAB, INPUT_CharCycle, TOGGLE_OneTimePress), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
54 CKeyListElement("KEY_QUEST", 'Q', INPUT_Quest, TOGGLE_OneTimePress), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
55 CKeyListElement("KEY_QUICKREF", 'Z', INPUT_QuickRef, TOGGLE_OneTimePress), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
56 CKeyListElement("KEY_REST", 'R', INPUT_Rest, TOGGLE_OneTimePress), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
57 CKeyListElement("KEY_TIMECAL", 'T', INPUT_TimeCal, TOGGLE_OneTimePress), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
58 CKeyListElement("KEY_AUTONOTES", 'N', INPUT_Autonotes, TOGGLE_OneTimePress), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
59 CKeyListElement("KEY_MAPBOOK", 'M', INPUT_Mapbook, TOGGLE_OneTimePress), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
60 CKeyListElement("KEY_LOOKUP", VK_NEXT, INPUT_LookUp, TOGGLE_OneTimePress), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
61 CKeyListElement("KEY_LOOKDOWN", VK_DELETE, INPUT_LookDown, TOGGLE_OneTimePress), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
62 CKeyListElement("KEY_CENTERVIEWPT", VK_END, INPUT_CenterView, TOGGLE_OneTimePress), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
63 CKeyListElement("KEY_ZOOMIN", VK_ADD, INPUT_ZoomIn, TOGGLE_OneTimePress), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
64 CKeyListElement("KEY_ZOOMOUT", VK_SUBTRACT, INPUT_ZoomOut, TOGGLE_OneTimePress), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
65 CKeyListElement("KEY_FLYUP", VK_PRIOR, INPUT_FlyUp, TOGGLE_Continuously), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
66 CKeyListElement("KEY_FLYDOWN", VK_INSERT, INPUT_FlyDown, TOGGLE_Continuously), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
67 CKeyListElement("KEY_LAND", VK_HOME, INPUT_Land, TOGGLE_OneTimePress), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
68 CKeyListElement("KEY_ALWAYSRUN", 'U', INPUT_AlwaysRun, TOGGLE_OneTimePress), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
69 CKeyListElement("KEY_STEPLEFT", VK_OEM_4, INPUT_StrafeLeft, TOGGLE_Continuously), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
70 CKeyListElement("KEY_STEPRIGHT", VK_OEM_6, INPUT_StrafeRight, TOGGLE_Continuously) |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
71 }; |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
72 |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
73 std::array<std::tuple<const char*, const unsigned __int8>, 26> keyNameToCodeTranslationMap = |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
74 { |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
75 std::tuple<const char*, const unsigned __int8>("UP", VK_UP), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
76 std::tuple<const char*, const unsigned __int8>("DOWN", VK_DOWN), |
2201 | 77 std::tuple<const char*, const unsigned __int8>("LEFT", VK_LEFT), |
2200
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
78 std::tuple<const char*, const unsigned __int8>("бкебн", VK_LEFT), |
2201 | 79 std::tuple<const char*, const unsigned __int8>("RIGHT", VK_RIGHT), |
2200
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
80 std::tuple<const char*, const unsigned __int8>("бопюбн", VK_RIGHT), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
81 std::tuple<const char*, const unsigned __int8>("RETURN", VK_RETURN), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
82 std::tuple<const char*, const unsigned __int8>("SPACE", VK_SPACE), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
83 std::tuple<const char*, const unsigned __int8>("PAGE_DOWN", VK_NEXT), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
84 std::tuple<const char*, const unsigned __int8>("PAGE_UP", VK_PRIOR), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
85 std::tuple<const char*, const unsigned __int8>("TAB", VK_TAB), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
86 std::tuple<const char*, const unsigned __int8>("SUBTRACT", VK_SUBTRACT), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
87 std::tuple<const char*, const unsigned __int8>("ADD", VK_ADD), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
88 std::tuple<const char*, const unsigned __int8>("END", VK_END), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
89 std::tuple<const char*, const unsigned __int8>("DELETE", VK_DELETE), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
90 std::tuple<const char*, const unsigned __int8>("HOME", VK_HOME), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
91 std::tuple<const char*, const unsigned __int8>("INSERT", VK_INSERT), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
92 std::tuple<const char*, const unsigned __int8>("COMMA", VK_OEM_COMMA), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
93 std::tuple<const char*, const unsigned __int8>("DECIMAL", VK_DECIMAL), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
94 std::tuple<const char*, const unsigned __int8>("SEMICOLON", VK_OEM_1), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
95 std::tuple<const char*, const unsigned __int8>("PERIOD", VK_OEM_PERIOD), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
96 std::tuple<const char*, const unsigned __int8>("SLASH", VK_OEM_2), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
97 std::tuple<const char*, const unsigned __int8>("SQUOTE", VK_OEM_7), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
98 std::tuple<const char*, const unsigned __int8>("BACKSLASH", VK_OEM_5), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
99 std::tuple<const char*, const unsigned __int8>("BACKSPACE", VK_BACK), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
100 std::tuple<const char*, const unsigned __int8>("CONTROL", VK_CONTROL), |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
101 }; |
0 | 102 |
103 //----- (00459C68) -------------------------------------------------------- | |
104 void KeyboardActionMapping::SetKeyMapping(int uAction, int vKey, KeyToggleType type) | |
105 { | |
106 pVirtualKeyCodesMapping[uAction] = vKey; | |
107 pToggleTypes[uAction] = type; | |
108 } | |
109 | |
110 //----- (00459C82) -------------------------------------------------------- | |
111 unsigned int KeyboardActionMapping::GetActionVKey(enum InputAction eAction) | |
112 { | |
113 return this->pVirtualKeyCodesMapping[eAction]; | |
114 } | |
115 | |
116 //----- (00459C8D) -------------------------------------------------------- | |
117 KeyboardActionMapping::KeyboardActionMapping() | |
118 { | |
119 uLastKeyPressed = 0; | |
271 | 120 field_204 = 0; |
323 | 121 pWindow = nullptr; |
0 | 122 |
123 SetDefaultMapping(); | |
124 ReadMappings(); | |
125 | |
126 ResetKeys(); | |
127 | |
1031 | 128 uGameMenuUI_CurentlySelectedKeyIdx = -1; |
0 | 129 } |
1031 | 130 // 506E68: using guessed type int uGameMenuUI_CurentlySelectedKeyIdx; |
0 | 131 |
132 //----- (00459CC4) -------------------------------------------------------- | |
133 void KeyboardActionMapping::SetDefaultMapping() | |
134 { | |
2200
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
135 for ( size_t i = 0; i < keyMappingParams.size(); i++) |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
136 { |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
137 SetKeyMapping(keyMappingParams[i].m_cmdId, keyMappingParams[i].m_keyDefaultCode, keyMappingParams[i].m_toggType); |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
138 } |
0 | 139 } |
140 | |
141 //----- (00459E3F) -------------------------------------------------------- | |
142 void KeyboardActionMapping::ResetKeys() | |
143 { | |
144 for (uint i = 0; i < 30; ++i) | |
145 GetAsyncKeyState(pVirtualKeyCodesMapping[i]); | |
146 } | |
147 | |
148 //----- (00459E5A) -------------------------------------------------------- | |
1038 | 149 void KeyboardActionMapping::EnterText(int a2, int max_string_len, GUIWindow *pWindow) |
0 | 150 { |
151 KeyboardActionMapping *v4; // esi@1 | |
152 | |
153 v4 = this; | |
154 memset(this->pPressedKeysBuffer, 0, 0x101u); | |
155 v4->uNumKeysPressed = 0; | |
156 if ( a2 ) | |
157 v4->field_204 = 2; | |
158 else | |
159 v4->field_204 = 1; | |
1038 | 160 v4->max_input_string_len = max_string_len; |
0 | 161 v4->pWindow = pWindow; |
1038 | 162 pWindow->receives_keyboard_input_2 = WINDOW_INPUT_IN_PROGRESS; |
0 | 163 } |
164 | |
165 //----- (00459ED1) -------------------------------------------------------- | |
1038 | 166 void KeyboardActionMapping::SetWindowInputStatus(int a2) |
0 | 167 { |
1038 | 168 field_204 = 0; |
169 if ( pWindow ) | |
170 pWindow->receives_keyboard_input_2 = a2; | |
0 | 171 } |
172 | |
173 //----- (00459F10) -------------------------------------------------------- | |
2201 | 174 bool KeyboardActionMapping::ProcessTextInput(unsigned int a2) |
0 | 175 { |
176 pKeyActionMap->uLastKeyPressed = a2; | |
1031 | 177 if ( uGameMenuUI_CurentlySelectedKeyIdx == -1 ) |
0 | 178 { |
2201 | 179 if ( pKeyActionMap->field_204 != 1 && pKeyActionMap->field_204 != 2 ) |
180 return 0; | |
181 if ( a2 == VK_BACK) | |
0 | 182 { |
2201 | 183 if (pKeyActionMap->uNumKeysPressed > 0) |
0 | 184 { |
2201 | 185 --pKeyActionMap->uNumKeysPressed; |
0 | 186 pKeyActionMap->pPressedKeysBuffer[pKeyActionMap->uNumKeysPressed] = 0; |
187 } | |
188 } | |
2201 | 189 else if ( a2 == VK_RETURN ) |
190 { | |
191 pKeyActionMap->SetWindowInputStatus(WINDOW_INPUT_CONFIRMED); | |
192 } | |
193 else if ( a2 == VK_ESCAPE ) | |
0 | 194 { |
2201 | 195 pKeyActionMap->SetWindowInputStatus(WINDOW_INPUT_CANCELLED); |
196 } | |
197 else if (this->uNumKeysPressed < this->max_input_string_len) | |
198 { | |
199 if ( pKeyActionMap->field_204 == 1 ) | |
0 | 200 { |
2201 | 201 if ( a2 != VK_TAB ) |
0 | 202 { |
2201 | 203 pKeyActionMap->pPressedKeysBuffer[pKeyActionMap->uNumKeysPressed] = a2; |
204 ++pKeyActionMap->uNumKeysPressed; | |
205 pKeyActionMap->pPressedKeysBuffer[pKeyActionMap->uNumKeysPressed] = 0; | |
0 | 206 } |
2201 | 207 } |
208 else if (pKeyActionMap->field_204 == 2) | |
209 { | |
210 if ( isdigit(a2)) | |
211 { | |
212 pKeyActionMap->pPressedKeysBuffer[pKeyActionMap->uNumKeysPressed] = a2; | |
213 ++pKeyActionMap->uNumKeysPressed; | |
214 } | |
0 | 215 } |
216 } | |
217 } | |
2201 | 218 else |
219 { | |
220 pKeyActionMap->pPressedKeysBuffer[pKeyActionMap->uNumKeysPressed] = a2; | |
221 ++pKeyActionMap->uNumKeysPressed; | |
222 pKeyActionMap->pPressedKeysBuffer[pKeyActionMap->uNumKeysPressed] = 0; | |
223 pKeyActionMap->SetWindowInputStatus(WINDOW_INPUT_CONFIRMED); | |
224 } | |
0 | 225 return 1; |
226 } | |
1031 | 227 // 506E68: using guessed type int uGameMenuUI_CurentlySelectedKeyIdx; |
0 | 228 |
2200
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
229 |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
230 |
0 | 231 //----- (00459FFC) -------------------------------------------------------- |
232 void KeyboardActionMapping::ReadMappings() | |
233 { | |
234 char str[32]; | |
235 | |
2200
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
236 for (size_t i = 0; i < keyMappingParams.size(); i++) |
0 | 237 { |
2200
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
238 const char* keyName = keyMappingParams[i].m_keyName.c_str(); |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
239 short commandDefaultKeyCode = keyMappingParams[i].m_keyDefaultCode; |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
240 short commandId = keyMappingParams[i].m_cmdId; |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
241 KeyToggleType toggType = keyMappingParams[i].m_toggType; |
0 | 242 |
2200
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
243 ReadWindowsRegistryString(keyName, str, 32, "DEFAULT"); |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
244 if ( strcmp(str, "DEFAULT") && ( TranslateKeyNameToKeyCode(str) != -1) ) |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
245 { |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
246 pVirtualKeyCodesMapping[commandId] = TranslateKeyNameToKeyCode(str); |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
247 } |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
248 else |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
249 { |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
250 pVirtualKeyCodesMapping[commandId] = commandDefaultKeyCode; |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
251 } |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
252 pToggleTypes[commandId] = toggType; |
0 | 253 } |
254 | |
255 bAlwaysRun = ReadWindowsRegistryInt("valAlwaysRun", 0) != 0; | |
256 bFlipOnExit = ReadWindowsRegistryInt("FlipOnExit", 0) != 0; | |
257 } | |
258 | |
259 //----- (0045A960) -------------------------------------------------------- | |
260 void KeyboardActionMapping::StoreMappings() | |
261 { | |
2200
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
262 |
0 | 263 const char *v2; // eax@1 |
264 | |
2200
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
265 for ( size_t i = 0; i < keyMappingParams.size(); i++) |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
266 { |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
267 v2 = GetVKeyDisplayName(pVirtualKeyCodesMapping[keyMappingParams[i].m_cmdId]); |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
268 WriteWindowsRegistryString(keyMappingParams[i].m_keyName.c_str(), v2); |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
269 } |
0 | 270 } |
271 | |
272 //----- (0045ABCA) -------------------------------------------------------- | |
2200
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
273 const unsigned __int8 KeyboardActionMapping::TranslateKeyNameToKeyCode(const char *Str) |
0 | 274 { |
2200
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
275 if (strlen(Str) == 1) |
0 | 276 { |
2200
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
277 if( Str[0] >= 65 && Str[0] <= 90 ) |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
278 return *Str; |
0 | 279 else |
2200
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
280 return 0xFF; |
0 | 281 } |
2200
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
282 |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
283 for ( size_t i = 0; i < keyNameToCodeTranslationMap.size(); i++) |
0 | 284 { |
2200
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
285 if (!strcmp(Str, std::get<0>(keyNameToCodeTranslationMap[i]))) |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
286 return std::get<1>(keyNameToCodeTranslationMap[i]); |
0 | 287 } |
2200
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
288 return 0xFF; |
0 | 289 } |
290 | |
291 //----- (0045AE2C) -------------------------------------------------------- | |
2200
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
292 const char * KeyboardActionMapping::GetVKeyDisplayName(unsigned char a1) |
0 | 293 { |
2200
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
294 static char static_sub_45AE2C_string_69ADE0_keyName[32]; |
0 | 295 |
2200
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
296 if ( a1 >= 65 && a1 <= 90 ) |
0 | 297 { |
2200
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
298 static_sub_45AE2C_string_69ADE0_keyName[0] = a1; |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
299 static_sub_45AE2C_string_69ADE0_keyName[1] = '\0'; |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
300 return static_sub_45AE2C_string_69ADE0_keyName; |
0 | 301 } |
2200
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
302 |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
303 for ( size_t i = 0; i < keyNameToCodeTranslationMap.size(); i++) |
0 | 304 { |
2201 | 305 if ( a1 == std::get<1>(keyNameToCodeTranslationMap[i])) |
2200
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
306 { |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
307 const char* keyName = std::get<0>(keyNameToCodeTranslationMap[i]); |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
308 strcpy_s(static_sub_45AE2C_string_69ADE0_keyName, keyName); |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
309 return static_sub_45AE2C_string_69ADE0_keyName; |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
310 } |
0 | 311 } |
2200
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
312 |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
313 strcpy_s(static_sub_45AE2C_string_69ADE0_keyName, "-мер -"); |
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
314 return static_sub_45AE2C_string_69ADE0_keyName; |
0 | 315 } |
316 | |
317 | |
318 //----- (0045B019) -------------------------------------------------------- | |
319 void Keyboard::EnterCriticalSection() | |
320 { | |
321 } | |
322 | |
323 //----- (0045B06E) -------------------------------------------------------- | |
324 bool Keyboard::IsShiftHeld() | |
325 { | |
2200
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
326 return (GetAsyncKeyState(VK_SHIFT) & 0x8001) != 0; |
0 | 327 } |
328 | |
329 //----- (0045B0A9) -------------------------------------------------------- | |
330 bool Keyboard::IsKeyBeingHeld(int vKey) | |
331 { | |
2200
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
332 return (GetAsyncKeyState(vKey) & 0x8001) != 0; |
0 | 333 } |
334 | |
335 //----- (0045B0CE) -------------------------------------------------------- | |
336 bool Keyboard::WasKeyPressed(int vKey) | |
337 { | |
2200
f0477fe92362
Keyboard.cpp removing the huge cases and separating data and code
Grumpy7
parents:
2154
diff
changeset
|
338 return (GetAsyncKeyState(vKey) & 1) != 0; |
0 | 339 } |
1297 | 340 //----- (0046A14B) -------------------------------------------------------- |
341 void OnPressSpace() | |
342 { | |
343 //SHORT v0; // ax@2 | |
2201 | 344 /*int *v1; // eax@2 |
1297 | 345 char *v2; // ebx@5 |
346 unsigned int v3; // esi@5 | |
347 signed int v4; // edi@7 | |
348 unsigned int v5; // edx@7 | |
349 int v6; // ecx@8 | |
350 int v7; // eax@8 | |
351 int v8; // ecx@17 | |
352 int *v9; // esi@22 | |
353 signed int v10; // ebx@22 | |
354 int i; // edi@23 | |
355 int v12; // edx@24 | |
356 int v13; // ecx@24 | |
357 int j; // esi@28 | |
358 int v16; // [sp+4h] [bp-1Ch]@0 | |
359 char *v17; // [sp+8h] [bp-18h]@5 | |
360 unsigned int v18; // [sp+Ch] [bp-14h]@5 | |
361 int v19; // [sp+10h] [bp-10h]@8 | |
362 int *v20; // [sp+14h] [bp-Ch]@5 | |
363 int *v21; // [sp+18h] [bp-8h]@7 | |
2201 | 364 int v22; // [sp+1Ch] [bp-4h]@4*/ |
1297 | 365 |
2154 | 366 //if ( pRenderer->pRenderD3D ) |
1297 | 367 { |
2201 | 368 pGame->PickKeyboard(Keyboard::IsKeyBeingHeld(VK_CONTROL), &vis_sprite_filter_3, &vis_door_filter); |
1980 | 369 int pid = pGame->pVisInstance->get_picked_object_zbuf_val(); |
1297 | 370 if ( pid != -1 ) |
371 DoInteractionWithTopmostZObject(pid & 0xFFFF, PID_ID(pid)); | |
372 return; | |
373 } | |
374 | |
375 | |
376 // software render stuff following | |
2154 | 377 /* |
1297 | 378 static int dword_720660[100]; // 720660 |
379 static int dword_7207F0[100]; // 7207F0 | |
380 | |
381 v22 = 0; | |
382 v1 = (int *)((signed int)(viewparams->uScreen_BttmR_X + viewparams->uScreen_topL_X) >> 1);//wrong pointer | |
383 if ( (signed int)viewparams->uScreen_topL_Y < (signed int)viewparams->uScreen_BttmR_Y ) | |
384 { | |
385 v2 = (char *)v1 - 50; | |
386 v1 = (int *)((char *)v1 + 50); | |
387 v3 = 640 * viewparams->uScreen_topL_Y; | |
388 v17 = v2; | |
389 v20 = v1; | |
390 v18 = ((viewparams->uScreen_BttmR_Y - viewparams->uScreen_topL_Y - 1) >> 1) + 1; | |
391 do | |
392 { | |
393 if ( (signed int)v2 < (signed int)v20 ) | |
394 { | |
395 v1 = &pRenderer->pActiveZBuffer[(int)&v2[v3]]; | |
396 v21 = &pRenderer->pActiveZBuffer[(int)&v2[v3]]; | |
397 v4 = v22; | |
398 v5 = (((char *)v20 - v2 - 1) >> 1) + 1; | |
399 do | |
400 { | |
401 v6 = 0; | |
402 v7 = *v1 & 0xFFFF; | |
403 v19 = 0; | |
404 if ( v4 > 0 ) | |
405 { | |
406 do | |
407 { | |
408 if ( dword_7207F0[v6] == v7 ) | |
409 break; | |
410 ++v6; | |
411 v19 = v6; | |
412 } | |
413 while ( v6 < v22 ); | |
414 } | |
415 if ( PID_TYPE(v7) == OBJECT_Decoration) | |
416 { | |
417 v16 = (unsigned int)PID_ID(v7); | |
418 if ( (signed int)(((unsigned int)*v21 >> 16) | |
419 - pDecorationList->pDecorations[pLevelDecorations[(unsigned int)PID_ID(v7)].uDecorationDescID].uRadius) <= 512 ) | |
420 if ( v19 == v22 && v4 < 100 ) | |
421 { | |
422 ++v22; | |
423 ++v4; | |
424 v8 = *v21; | |
425 dword_7207F0[v4 - 1] = v7; | |
426 dword_720660[v4 - 1] = v8; | |
427 } | |
428 } | |
429 else if ( (unsigned int)*v21 <= 0x2000000 ) | |
430 { | |
431 if ( v19 == v22 && v4 < 100 ) | |
432 { | |
433 ++v22; | |
434 ++v4; | |
435 v8 = *v21; | |
436 dword_7207F0[v4 - 1] = v7; | |
437 dword_720660[v4 - 1] = v8; | |
438 } | |
439 } | |
440 v1 = v21 + 2; | |
441 --v5; | |
442 v21 += 2; | |
443 } | |
444 while ( v5 ); | |
445 v2 = v17; | |
446 } | |
447 v3 += 1280; | |
448 --v18; | |
449 } | |
450 while ( v18 ); | |
451 } | |
452 if ( v22 > 0 ) | |
453 { | |
454 v9 = dword_720660; | |
455 v10 = 1; | |
456 do | |
457 { | |
458 for ( i = v10; i < v22; ++i ) | |
459 { | |
460 v12 = *v9; | |
461 v13 = dword_720660[i]; | |
462 if ( v13 < *v9 ) | |
463 { | |
464 *v9 = v13; | |
465 dword_720660[i] = v12; | |
466 } | |
467 } | |
468 ++v10; | |
469 ++v9; | |
470 LOBYTE(v1) = v10 - 1; | |
471 } | |
472 while ( v10 - 1 < v22 ); | |
473 } | |
474 for ( j = 0; j < v22; ++j ) | |
475 { | |
476 LOBYTE(v1) = DoInteractionWithTopmostZObject(dword_720660[j] & 0xFFFF, v16); | |
477 if ( !(char)v1 ) | |
478 break; | |
2154 | 479 }*/ |
1297 | 480 } |