World of Might and Magic  0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
Структура KeyboardActionMapping

#include <Keyboard.h>

+ Граф связей класса KeyboardActionMapping:

Открытые члены

 KeyboardActionMapping ()
 
void SetKeyMapping (int uAction, int vKey, KeyToggleType type)
 
unsigned int GetActionVKey (enum InputAction eAction)
 
const char * GetVKeyDisplayName (unsigned char a1)
 
const uint8_t TranslateKeyNameToKeyCode (const char *Str)
 
void ReadMappings ()
 
void StoreMappings ()
 
bool ProcessTextInput (unsigned int a2)
 
void SetWindowInputStatus (int a2)
 
void EnterText (int a2, int max_string_len, GUIWindow *pWindow)
 
void ResetKeys ()
 
void SetDefaultMapping ()
 

Открытые атрибуты

unsigned int uLastKeyPressed
 
int field_4
 
int field_8
 
unsigned int pVirtualKeyCodesMapping [30]
 
KeyToggleType pToggleTypes [30]
 
int max_input_string_len
 
char pPressedKeysBuffer [257]
 
uint8_t uNumKeysPressed
 
char field_202
 
char field_203
 
int field_204
 
GUIWindowpWindow
 

Подробное описание

См. определение в файле Keyboard.h строка 45

Конструктор(ы)

◆ KeyboardActionMapping()

KeyboardActionMapping::KeyboardActionMapping ( )

См. определение в файле Keyboard.cpp строка 150

150  {
151  uLastKeyPressed = 0;
152  field_204 = 0;
153  pWindow = nullptr;
154 
156  ReadMappings();
157 
158  ResetKeys();
159 
160  uNumKeysPressed = 0;
161 
163 }

Перекрестные ссылки field_204, pWindow, ReadMappings(), ResetKeys(), SetDefaultMapping(), uGameMenuUI_CurentlySelectedKeyIdx, uLastKeyPressed и uNumKeysPressed.

+ Граф вызовов:

Методы

◆ SetKeyMapping()

void KeyboardActionMapping::SetKeyMapping ( int  uAction,
int  vKey,
KeyToggleType  type 
)

См. определение в файле Keyboard.cpp строка 138

139  {
140  pVirtualKeyCodesMapping[uAction] = vKey;
141  pToggleTypes[uAction] = type;
142 }

Перекрестные ссылки pToggleTypes и pVirtualKeyCodesMapping.

Используется в Application::Menu::EventLoop() и SetDefaultMapping().

+ Граф вызова функции:

◆ GetActionVKey()

unsigned int KeyboardActionMapping::GetActionVKey ( enum InputAction  eAction)

См. определение в файле Keyboard.cpp строка 145

145  {
146  return this->pVirtualKeyCodesMapping[eAction];
147 }

Перекрестные ссылки pVirtualKeyCodesMapping.

Используется в Application::Menu::EventLoop() и UI_Create().

+ Граф вызова функции:

◆ GetVKeyDisplayName()

const char * KeyboardActionMapping::GetVKeyDisplayName ( unsigned char  a1)

См. определение в файле Keyboard.cpp строка 295

295  {
296  static char static_sub_45AE2C_string_69ADE0_keyName[32];
297 
298  if (a1 >= 65 && a1 <= 90) {
299  static_sub_45AE2C_string_69ADE0_keyName[0] = a1;
300  static_sub_45AE2C_string_69ADE0_keyName[1] = '\0';
301  return static_sub_45AE2C_string_69ADE0_keyName;
302  }
303 
304  for (size_t i = 0; i < keyNameToCodeTranslationMap.size(); i++) {
305  if (a1 == std::get<1>(keyNameToCodeTranslationMap[i])) {
306  const char *keyName = std::get<0>(keyNameToCodeTranslationMap[i]);
307  strcpy(static_sub_45AE2C_string_69ADE0_keyName, keyName);
308  return static_sub_45AE2C_string_69ADE0_keyName;
309  }
310  }
311 
312  strcpy(static_sub_45AE2C_string_69ADE0_keyName, "-BAD KEY-");
313  return static_sub_45AE2C_string_69ADE0_keyName;
314 }

Перекрестные ссылки keyNameToCodeTranslationMap.

Используется в StoreMappings() и GUIWindow_GameKeyBindings::Update().

+ Граф вызова функции:

◆ TranslateKeyNameToKeyCode()

const unsigned __int8 KeyboardActionMapping::TranslateKeyNameToKeyCode ( const char *  Str)

См. определение в файле Keyboard.cpp строка 278

279  {
280  if (strlen(Str) == 1) {
281  if (Str[0] >= 65 && Str[0] <= 90)
282  return *Str;
283  else
284  return 0xFF;
285  }
286 
287  for (size_t i = 0; i < keyNameToCodeTranslationMap.size(); i++) {
288  if (!strcmp(Str, std::get<0>(keyNameToCodeTranslationMap[i])))
289  return std::get<1>(keyNameToCodeTranslationMap[i]);
290  }
291  return 0xFF;
292 }

Перекрестные ссылки keyNameToCodeTranslationMap.

Используется в ReadMappings().

+ Граф вызова функции:

◆ ReadMappings()

void KeyboardActionMapping::ReadMappings ( )

См. определение в файле Keyboard.cpp строка 247

247  {
248  char str[32];
249 
250  for (size_t i = 0; i < keyMappingParams.size(); i++) {
251  const char *keyName = keyMappingParams[i].m_keyName.c_str();
252  short commandDefaultKeyCode = keyMappingParams[i].m_keyDefaultCode;
253  short commandId = keyMappingParams[i].m_cmdId;
254  KeyToggleType toggType = keyMappingParams[i].m_toggType;
255 
256  OS_GetAppString(keyName, str, 32, "DEFAULT");
257  if (strcmp(str, "DEFAULT") && (TranslateKeyNameToKeyCode(str) !=
258  0xff)) // returns 0xff on error not -1
260  else
261  pVirtualKeyCodesMapping[commandId] = commandDefaultKeyCode;
262  pToggleTypes[commandId] = toggType;
263  }
264 }

Перекрестные ссылки keyMappingParams, OS_GetAppString(), pToggleTypes, pVirtualKeyCodesMapping и TranslateKeyNameToKeyCode().

Используется в KeyboardActionMapping().

+ Граф вызовов:
+ Граф вызова функции:

◆ StoreMappings()

void KeyboardActionMapping::StoreMappings ( )

См. определение в файле Keyboard.cpp строка 267

267  {
268  const char *v2; // eax@1
269 
270  for (size_t i = 0; i < keyMappingParams.size(); i++) {
273  OS_SetAppString(keyMappingParams[i].m_keyName.c_str(), v2);
274  }
275 }

Перекрестные ссылки GetVKeyDisplayName(), keyMappingParams, OS_SetAppString() и pVirtualKeyCodesMapping.

Используется в Application::Menu::EventLoop().

+ Граф вызовов:
+ Граф вызова функции:

◆ ProcessTextInput()

bool KeyboardActionMapping::ProcessTextInput ( unsigned int  a2)

См. определение в файле Keyboard.cpp строка 201

201  {
204  if (pKeyActionMap->field_204 != 1 && pKeyActionMap->field_204 != 2)
205  return 0;
206  if (a2 == VK_BACK) {
207  if (pKeyActionMap->uNumKeysPressed > 0) {
211  }
212  } else if (a2 == VK_RETURN) {
213  pKeyActionMap->SetWindowInputStatus(WINDOW_INPUT_CONFIRMED);
214  } else if (a2 == VK_ESCAPE) {
215  pKeyActionMap->SetWindowInputStatus(WINDOW_INPUT_CANCELLED);
216  } else if (this->uNumKeysPressed < this->max_input_string_len) {
217  if (pKeyActionMap->field_204 == 1) {
218  if (a2 != VK_TAB) {
221  a2;
225  0;
226  }
227  } else if (pKeyActionMap->field_204 == 2) {
228  if (isdigit(a2)) {
231  a2;
233  }
234  }
235  }
236  } else {
240  pKeyActionMap->SetWindowInputStatus(WINDOW_INPUT_CONFIRMED);
241  }
242  return 1;
243 }

Перекрестные ссылки field_204, max_input_string_len, pKeyActionMap, pPressedKeysBuffer, SetWindowInputStatus(), uGameMenuUI_CurentlySelectedKeyIdx, uLastKeyPressed и uNumKeysPressed.

Используется в Application::GameWindowHandler::OnChar() и Application::GameWindowHandler::OnVkDown().

+ Граф вызовов:
+ Граф вызова функции:

◆ SetWindowInputStatus()

void KeyboardActionMapping::SetWindowInputStatus ( int  a2)

См. определение в файле Keyboard.cpp строка 195

195  {
196  field_204 = 0;
198 }

Перекрестные ссылки field_204, pWindow и GUIWindow::receives_keyboard_input_2.

Используется в EnterHouse(), Application::Menu::EventLoop(), HouseDialogPressCloseBtn(), MainMenuLoad_EventLoop(), ProcessTextInput(), GUIWindow_GenericDialogue::Release() и GUIWindow_GenericDialogue::Update().

+ Граф вызова функции:

◆ EnterText()

void KeyboardActionMapping::EnterText ( int  a2,
int  max_string_len,
GUIWindow pWindow 
)

См. определение в файле Keyboard.cpp строка 181

182  {
183  memset(this->pPressedKeysBuffer, 0, 0x101u);
184  this->uNumKeysPressed = 0;
185  if (a2)
186  this->field_204 = 2;
187  else
188  this->field_204 = 1;
189  this->max_input_string_len = max_string_len;
190  this->pWindow = pWindow;
191  pWindow->receives_keyboard_input_2 = WINDOW_INPUT_IN_PROGRESS;
192 }

Перекрестные ссылки field_204, max_input_string_len, pPressedKeysBuffer, pWindow, GUIWindow::receives_keyboard_input_2 и uNumKeysPressed.

Используется в CreateParty_EventLoop(), Application::Menu::EventLoop(), GUIWindow_GenericDialogue::GUIWindow_GenericDialogue() и MainMenuLoad_EventLoop().

+ Граф вызова функции:

◆ ResetKeys()

void KeyboardActionMapping::ResetKeys ( )

См. определение в файле Keyboard.cpp строка 176

176  {
177  for (uint i = 0; i < 30; ++i) GetAsyncKeyState(pVirtualKeyCodesMapping[i]);
178 }

Перекрестные ссылки GetAsyncKeyState() и pVirtualKeyCodesMapping.

Используется в EnterHouse(), HouseDialogPressCloseBtn(), KeyboardActionMapping() и Timer::Resume().

+ Граф вызовов:
+ Граф вызова функции:

◆ SetDefaultMapping()

void KeyboardActionMapping::SetDefaultMapping ( )

См. определение в файле Keyboard.cpp строка 167

167  {
168  for (size_t i = 0; i < keyMappingParams.size(); i++) {
169  SetKeyMapping(keyMappingParams[i].m_cmdId,
170  keyMappingParams[i].m_keyDefaultCode,
171  keyMappingParams[i].m_toggType);
172  }
173 }

Перекрестные ссылки keyMappingParams и SetKeyMapping().

Используется в Application::Menu::EventLoop() и KeyboardActionMapping().

+ Граф вызовов:
+ Граф вызова функции:

Данные класса

◆ uLastKeyPressed

unsigned int KeyboardActionMapping::uLastKeyPressed

См. определение в файле Keyboard.h строка 60

Используется в KeyboardActionMapping() и ProcessTextInput().

◆ field_4

int KeyboardActionMapping::field_4

См. определение в файле Keyboard.h строка 61

◆ field_8

int KeyboardActionMapping::field_8

См. определение в файле Keyboard.h строка 62

◆ pVirtualKeyCodesMapping

unsigned int KeyboardActionMapping::pVirtualKeyCodesMapping[30]

◆ pToggleTypes

KeyToggleType KeyboardActionMapping::pToggleTypes[30]

См. определение в файле Keyboard.h строка 64

Используется в Keyboard::ProcessInputActions(), ReadMappings() и SetKeyMapping().

◆ max_input_string_len

int KeyboardActionMapping::max_input_string_len

См. определение в файле Keyboard.h строка 65

Используется в EnterText() и ProcessTextInput().

◆ pPressedKeysBuffer

◆ uNumKeysPressed

uint8_t KeyboardActionMapping::uNumKeysPressed

См. определение в файле Keyboard.h строка 67

Используется в EnterText(), Application::Menu::EventLoop(), KeyboardActionMapping(), MainMenuLoad_EventLoop() и ProcessTextInput().

◆ field_202

char KeyboardActionMapping::field_202

См. определение в файле Keyboard.h строка 68

◆ field_203

char KeyboardActionMapping::field_203

См. определение в файле Keyboard.h строка 69

◆ field_204

int KeyboardActionMapping::field_204

См. определение в файле Keyboard.h строка 70

Используется в EnterText(), KeyboardActionMapping(), ProcessTextInput(), SetWindowInputStatus() и GUIWindow_Inventory::Update().

◆ pWindow

GUIWindow* KeyboardActionMapping::pWindow

См. определение в файле Keyboard.h строка 71

Используется в EnterText(), KeyboardActionMapping() и SetWindowInputStatus().


Объявления и описания членов структур находятся в файлах:
KeyboardActionMapping::TranslateKeyNameToKeyCode
const uint8_t TranslateKeyNameToKeyCode(const char *Str)
Definition: Keyboard.cpp:278
keyMappingParams
std::array< CKeyListElement, 30 > keyMappingParams
Definition: Keyboard.cpp:62
GUIWindow::receives_keyboard_input_2
int receives_keyboard_input_2
Definition: GUIWindow.h:486
GetAsyncKeyState
int GetAsyncKeyState(int vKey)
Definition: Keyboard.cpp:8
keyNameToCodeTranslationMap
std::array< std::tuple< const char *, const unsigned __int8 >, 26 > keyNameToCodeTranslationMap
Definition: Keyboard.cpp:106
KeyboardActionMapping::SetKeyMapping
void SetKeyMapping(int uAction, int vKey, KeyToggleType type)
Definition: Keyboard.cpp:138
KeyboardActionMapping::pPressedKeysBuffer
char pPressedKeysBuffer[257]
Definition: Keyboard.h:66
KeyboardActionMapping::ReadMappings
void ReadMappings()
Definition: Keyboard.cpp:247
type
EGLenum type
Definition: SDL_egl.h:850
KeyToggleType
KeyToggleType
Definition: Keyboard.h:37
KeyboardActionMapping::ResetKeys
void ResetKeys()
Definition: Keyboard.cpp:176
KeyboardActionMapping::pVirtualKeyCodesMapping
unsigned int pVirtualKeyCodesMapping[30]
Definition: Keyboard.h:63
KeyboardActionMapping::SetWindowInputStatus
void SetWindowInputStatus(int a2)
Definition: Keyboard.cpp:195
KeyboardActionMapping::field_204
int field_204
Definition: Keyboard.h:70
KeyboardActionMapping::GetVKeyDisplayName
const char * GetVKeyDisplayName(unsigned char a1)
Definition: Keyboard.cpp:295
KeyboardActionMapping::uLastKeyPressed
unsigned int uLastKeyPressed
Definition: Keyboard.h:60
KeyboardActionMapping::SetDefaultMapping
void SetDefaultMapping()
Definition: Keyboard.cpp:167
pKeyActionMap
struct KeyboardActionMapping * pKeyActionMap
Definition: Keyboard.cpp:35
v2
GLfloat GLfloat GLfloat v2
Definition: SDL_opengl_glext.h:695
uint
unsigned int uint
Definition: MM7.h:4
KeyboardActionMapping::pWindow
GUIWindow * pWindow
Definition: Keyboard.h:71
OS_SetAppString
void OS_SetAppString(const char *pKey, const char *pString)
Definition: Lin.cpp:93
KeyboardActionMapping::uNumKeysPressed
uint8_t uNumKeysPressed
Definition: Keyboard.h:67
KeyboardActionMapping::max_input_string_len
int max_input_string_len
Definition: Keyboard.h:65
KeyboardActionMapping::pToggleTypes
KeyToggleType pToggleTypes[30]
Definition: Keyboard.h:64
OS_GetAppString
bool OS_GetAppString(const char *path, char *out_string, int out_string_size)
Definition: Launcher.cpp:62
uGameMenuUI_CurentlySelectedKeyIdx
int uGameMenuUI_CurentlySelectedKeyIdx
Definition: mm7_data.cpp:540