From b67af71f338924b12e5514eed82d292bc92781e4 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Fri, 31 May 2024 22:46:05 -0400 Subject: [PATCH] Improve naming, use virtual key constants (#979) --- ISLE/isleapp.cpp | 2 +- .../lego/legoomni/include/legoinputmanager.h | 8 ++-- .../legoomni/src/entity/legonavcontroller.cpp | 2 +- .../legoomni/src/input/legoinputmanager.cpp | 43 ++++++++++--------- LEGO1/lego/legoomni/src/worlds/gasstation.cpp | 2 +- LEGO1/lego/legoomni/src/worlds/hospital.cpp | 2 +- LEGO1/lego/legoomni/src/worlds/infocenter.cpp | 3 +- LEGO1/lego/legoomni/src/worlds/police.cpp | 2 +- .../legoomni/src/worlds/registrationbook.cpp | 8 ++-- 9 files changed, 36 insertions(+), 36 deletions(-) diff --git a/ISLE/isleapp.cpp b/ISLE/isleapp.cpp index 6f6296aa..3f0892ed 100644 --- a/ISLE/isleapp.cpp +++ b/ISLE/isleapp.cpp @@ -153,7 +153,7 @@ void IsleApp::Close() if (Lego()) { GameState()->Save(0); if (InputManager()) { - InputManager()->QueueEvent(c_notificationKeyPress, 0, 0, 0, 0x20); + InputManager()->QueueEvent(c_notificationKeyPress, 0, 0, 0, VK_SPACE); } VideoManager()->Get3DManager()->GetLego3DView()->GetViewManager()->RemoveAll(NULL); diff --git a/LEGO1/lego/legoomni/include/legoinputmanager.h b/LEGO1/lego/legoomni/include/legoinputmanager.h index 2bd7e26b..c4a0dc1a 100644 --- a/LEGO1/lego/legoomni/include/legoinputmanager.h +++ b/LEGO1/lego/legoomni/include/legoinputmanager.h @@ -125,8 +125,8 @@ public: void ProcessEvents(); MxBool ProcessOneEvent(LegoEventNotificationParam& p_param); MxBool FUN_1005cdf0(LegoEventNotificationParam& p_param); - void FUN_1005c0f0(); - MxResult FUN_1005c160(MxU32& p_keyFlags); + void GetKeyboardState(); + MxResult GetNavigationKeyStates(MxU32& p_keyFlags); // SYNTHETIC: LEGO1 0x1005b8d0 // LegoInputManager::`scalar deleting destructor' @@ -148,8 +148,8 @@ private: MxBool m_unk0x88; // 0x88 IDirectInput* m_directInput; // 0x8c IDirectInputDevice* m_directInputDevice; // 0x90 - MxBool m_unk0x94; // 0x94 - MxU8 m_unk0x95[256]; // 0x95 + MxBool m_kbStateSuccess; // 0x94 + MxU8 m_keyboardState[256]; // 0x95 MxBool m_unk0x195; // 0x195 MxS32 m_joyid; // 0x198 MxS32 m_joystickIndex; // 0x19c diff --git a/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp b/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp index 63377d72..7f5fef34 100644 --- a/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp +++ b/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp @@ -537,7 +537,7 @@ MxResult LegoNavController::ProcessKeyboardInput() LegoInputManager* inputManager = LegoOmni::GetInstance()->GetInputManager(); MxU32 keyFlags; - if (inputManager == NULL || inputManager->FUN_1005c160(keyFlags) == FAILURE) { + if (inputManager == NULL || inputManager->GetNavigationKeyStates(keyFlags) == FAILURE) { return FAILURE; } diff --git a/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp b/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp index 200652b1..de3ae8b2 100644 --- a/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp +++ b/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp @@ -40,7 +40,7 @@ LegoInputManager::LegoInputManager() m_unk0x88 = FALSE; m_directInput = NULL; m_directInputDevice = NULL; - m_unk0x94 = FALSE; + m_kbStateSuccess = FALSE; m_unk0x195 = 0; m_joyid = -1; m_joystickIndex = -1; @@ -142,63 +142,63 @@ void LegoInputManager::ReleaseDX() } // FUNCTION: LEGO1 0x1005c0f0 -void LegoInputManager::FUN_1005c0f0() +void LegoInputManager::GetKeyboardState() { - m_unk0x94 = FALSE; + m_kbStateSuccess = FALSE; if (m_directInputDevice) { - HRESULT hr = m_directInputDevice->GetDeviceState(sizeOfArray(m_unk0x95), &m_unk0x95); + HRESULT hr = m_directInputDevice->GetDeviceState(sizeOfArray(m_keyboardState), &m_keyboardState); if (hr == DIERR_INPUTLOST || hr == DIERR_NOTACQUIRED) { if (m_directInputDevice->Acquire() == S_OK) { - hr = m_directInputDevice->GetDeviceState(sizeOfArray(m_unk0x95), &m_unk0x95); + hr = m_directInputDevice->GetDeviceState(sizeOfArray(m_keyboardState), &m_keyboardState); } } if (hr == S_OK) { - m_unk0x94 = TRUE; + m_kbStateSuccess = TRUE; } } } // FUNCTION: LEGO1 0x1005c160 -MxResult LegoInputManager::FUN_1005c160(MxU32& p_keyFlags) +MxResult LegoInputManager::GetNavigationKeyStates(MxU32& p_keyFlags) { - FUN_1005c0f0(); + GetKeyboardState(); - if (!m_unk0x94) { + if (!m_kbStateSuccess) { return FAILURE; } if (g_unk0x100f67b8) { - if (m_unk0x95[DIK_LEFT] & 0x80 && GetAsyncKeyState(VK_LEFT) == 0) { - m_unk0x95[DIK_LEFT] = 0; + if (m_keyboardState[DIK_LEFT] & 0x80 && GetAsyncKeyState(VK_LEFT) == 0) { + m_keyboardState[DIK_LEFT] = 0; } - if (m_unk0x95[DIK_RIGHT] & 0x80 && GetAsyncKeyState(VK_RIGHT) == 0) { - m_unk0x95[DIK_RIGHT] = 0; + if (m_keyboardState[DIK_RIGHT] & 0x80 && GetAsyncKeyState(VK_RIGHT) == 0) { + m_keyboardState[DIK_RIGHT] = 0; } } MxU32 keyFlags = 0; - if ((m_unk0x95[DIK_NUMPAD8] | m_unk0x95[DIK_UP]) & 0x80) { + if ((m_keyboardState[DIK_NUMPAD8] | m_keyboardState[DIK_UP]) & 0x80) { keyFlags |= c_up; } - if ((m_unk0x95[DIK_NUMPAD2] | m_unk0x95[DIK_DOWN]) & 0x80) { + if ((m_keyboardState[DIK_NUMPAD2] | m_keyboardState[DIK_DOWN]) & 0x80) { keyFlags |= c_down; } - if ((m_unk0x95[DIK_NUMPAD4] | m_unk0x95[DIK_LEFT]) & 0x80) { + if ((m_keyboardState[DIK_NUMPAD4] | m_keyboardState[DIK_LEFT]) & 0x80) { keyFlags |= c_left; } - if ((m_unk0x95[DIK_NUMPAD6] | m_unk0x95[DIK_RIGHT]) & 0x80) { + if ((m_keyboardState[DIK_NUMPAD6] | m_keyboardState[DIK_RIGHT]) & 0x80) { keyFlags |= c_right; } - if ((m_unk0x95[DIK_LCONTROL] | m_unk0x95[DIK_RCONTROL]) & 0x80) { + if ((m_keyboardState[DIK_LCONTROL] | m_keyboardState[DIK_RCONTROL]) & 0x80) { keyFlags |= c_bit5; } @@ -290,6 +290,7 @@ MxResult LegoInputManager::GetJoystickState( } } } + return FAILURE; } @@ -345,7 +346,7 @@ void LegoInputManager::QueueEvent(NotificationId p_id, MxU8 p_modifier, MxLong p LegoEventNotificationParam param = LegoEventNotificationParam(p_id, NULL, p_modifier, p_x, p_y, p_key); if (((!m_unk0x88) || ((m_unk0x335 && (param.GetType() == c_notificationButtonDown)))) || - ((m_unk0x336 && (p_key == ' ')))) { + ((m_unk0x336 && (p_key == VK_SPACE)))) { ProcessOneEvent(param); } } @@ -369,8 +370,8 @@ MxBool LegoInputManager::ProcessOneEvent(LegoEventNotificationParam& p_param) MxBool processRoi; if (p_param.GetType() == c_notificationKeyPress) { - if (!Lego()->IsTimerRunning() || p_param.GetKey() == 0x13) { - if (p_param.GetKey() == 0x10) { + if (!Lego()->IsTimerRunning() || p_param.GetKey() == VK_PAUSE) { + if (p_param.GetKey() == VK_SHIFT) { if (m_unk0x195) { m_unk0x80 = FALSE; p_param.SetType(c_notificationDrag); diff --git a/LEGO1/lego/legoomni/src/worlds/gasstation.cpp b/LEGO1/lego/legoomni/src/worlds/gasstation.cpp index 4042eb8d..5f48e5f0 100644 --- a/LEGO1/lego/legoomni/src/worlds/gasstation.cpp +++ b/LEGO1/lego/legoomni/src/worlds/gasstation.cpp @@ -297,7 +297,7 @@ MxLong GasStation::HandleEndAction(MxEndActionNotificationParam& p_param) // FUNCTION: LEGO1 0x10005920 MxLong GasStation::HandleKeyPress(MxS8 p_key) { - if (p_key == ' ' && g_unk0x100f0160 == 0 && this->m_unk0x106 != 0) { + if (p_key == VK_SPACE && g_unk0x100f0160 == 0 && m_unk0x106 != 0) { m_state->FUN_10006490(); return 1; } diff --git a/LEGO1/lego/legoomni/src/worlds/hospital.cpp b/LEGO1/lego/legoomni/src/worlds/hospital.cpp index 59d265f7..5848b4ad 100644 --- a/LEGO1/lego/legoomni/src/worlds/hospital.cpp +++ b/LEGO1/lego/legoomni/src/worlds/hospital.cpp @@ -226,7 +226,7 @@ MxLong Hospital::HandleKeyPress(MxS8 p_key) { MxLong result = 0; - if (p_key == ' ' && g_unk0x100f7918 == 0) { + if (p_key == VK_SPACE && g_unk0x100f7918 == 0) { DeleteObjects(&m_atom, HospitalScript::c_hho002cl_RunAnim, HospitalScript::c_hho006cl_RunAnim); result = 1; } diff --git a/LEGO1/lego/legoomni/src/worlds/infocenter.cpp b/LEGO1/lego/legoomni/src/worlds/infocenter.cpp index 2277300a..942551bd 100644 --- a/LEGO1/lego/legoomni/src/worlds/infocenter.cpp +++ b/LEGO1/lego/legoomni/src/worlds/infocenter.cpp @@ -612,7 +612,6 @@ MxU8 Infocenter::HandleMouseMove(MxS32 p_x, MxS32 p_y) VideoManager()->SortPresenterList(); m_unk0x11c->Enable(TRUE); m_unk0x11c->SetPosition(p_x, p_y); - m_unk0x11c->SetDisplayZ(oldDisplayZ); } else { @@ -631,7 +630,7 @@ MxLong Infocenter::HandleKeyPress(MxS8 p_key) { MxLong result = 0; - if (p_key == ' ' && m_worldStarted) { + if (p_key == VK_SPACE && m_worldStarted) { switch (m_infocenterState->GetUnknown0x74()) { case 0: StopCutscene(); diff --git a/LEGO1/lego/legoomni/src/worlds/police.cpp b/LEGO1/lego/legoomni/src/worlds/police.cpp index b80e1a33..897fa52c 100644 --- a/LEGO1/lego/legoomni/src/worlds/police.cpp +++ b/LEGO1/lego/legoomni/src/worlds/police.cpp @@ -164,7 +164,7 @@ MxLong Police::HandleKeyPress(LegoEventNotificationParam& p_param) { MxLong result = 0; - if (p_param.GetKey() == ' ' && m_policeState->GetUnknown0x0c() == 1) { + if (p_param.GetKey() == VK_SPACE && m_policeState->GetUnknown0x0c() == 1) { DeleteObjects(&m_atom, PoliceScript::c_nps001ni_RunAnim, PoliceScript::c_nps002la_RunAnim); m_policeState->SetUnknown0x0c(0); return 1; diff --git a/LEGO1/lego/legoomni/src/worlds/registrationbook.cpp b/LEGO1/lego/legoomni/src/worlds/registrationbook.cpp index 28cd8c27..803074d8 100644 --- a/LEGO1/lego/legoomni/src/worlds/registrationbook.cpp +++ b/LEGO1/lego/legoomni/src/worlds/registrationbook.cpp @@ -166,13 +166,13 @@ MxLong RegistrationBook::HandleKeyPress(MxU8 p_key) key = p_key; } - if ((key < 'A' || key > 'Z') && key != '\b') { - if (key == ' ') { + if ((key < 'A' || key > 'Z') && key != VK_BACK) { + if (key == VK_SPACE) { DeleteObjects(&m_atom, RegbookScript::c_iic006in_RunAnim, RegbookScript::c_iic008in_PlayWav); BackgroundAudioManager()->RaiseVolume(); } } - else if (key != '\b' && m_unk0x280.m_cursorPos < 7) { + else if (key != VK_BACK && m_unk0x280.m_cursorPos < 7) { m_name[0][m_unk0x280.m_cursorPos] = m_alphabet[key - 'A']->Clone(); if (m_name[0][m_unk0x280.m_cursorPos] != NULL) { @@ -190,7 +190,7 @@ MxLong RegistrationBook::HandleKeyPress(MxU8 p_key) } } else { - if (key == '\b' && m_unk0x280.m_cursorPos > 0) { + if (key == VK_BACK && m_unk0x280.m_cursorPos > 0) { m_unk0x280.m_cursorPos--; m_name[0][m_unk0x280.m_cursorPos]->Enable(FALSE);