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