Improve naming, use virtual key constants (#979)

This commit is contained in:
Christian Semmler 2024-05-31 22:46:05 -04:00 committed by GitHub
parent 77af1a5483
commit b67af71f33
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 36 additions and 36 deletions

View File

@ -153,7 +153,7 @@ void IsleApp::Close()
if (Lego()) { if (Lego()) {
GameState()->Save(0); GameState()->Save(0);
if (InputManager()) { 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); VideoManager()->Get3DManager()->GetLego3DView()->GetViewManager()->RemoveAll(NULL);

View File

@ -125,8 +125,8 @@ public:
void ProcessEvents(); void ProcessEvents();
MxBool ProcessOneEvent(LegoEventNotificationParam& p_param); MxBool ProcessOneEvent(LegoEventNotificationParam& p_param);
MxBool FUN_1005cdf0(LegoEventNotificationParam& p_param); MxBool FUN_1005cdf0(LegoEventNotificationParam& p_param);
void FUN_1005c0f0(); void GetKeyboardState();
MxResult FUN_1005c160(MxU32& p_keyFlags); MxResult GetNavigationKeyStates(MxU32& p_keyFlags);
// SYNTHETIC: LEGO1 0x1005b8d0 // SYNTHETIC: LEGO1 0x1005b8d0
// LegoInputManager::`scalar deleting destructor' // LegoInputManager::`scalar deleting destructor'
@ -148,8 +148,8 @@ private:
MxBool m_unk0x88; // 0x88 MxBool m_unk0x88; // 0x88
IDirectInput* m_directInput; // 0x8c IDirectInput* m_directInput; // 0x8c
IDirectInputDevice* m_directInputDevice; // 0x90 IDirectInputDevice* m_directInputDevice; // 0x90
MxBool m_unk0x94; // 0x94 MxBool m_kbStateSuccess; // 0x94
MxU8 m_unk0x95[256]; // 0x95 MxU8 m_keyboardState[256]; // 0x95
MxBool m_unk0x195; // 0x195 MxBool m_unk0x195; // 0x195
MxS32 m_joyid; // 0x198 MxS32 m_joyid; // 0x198
MxS32 m_joystickIndex; // 0x19c MxS32 m_joystickIndex; // 0x19c

View File

@ -537,7 +537,7 @@ MxResult LegoNavController::ProcessKeyboardInput()
LegoInputManager* inputManager = LegoOmni::GetInstance()->GetInputManager(); LegoInputManager* inputManager = LegoOmni::GetInstance()->GetInputManager();
MxU32 keyFlags; MxU32 keyFlags;
if (inputManager == NULL || inputManager->FUN_1005c160(keyFlags) == FAILURE) { if (inputManager == NULL || inputManager->GetNavigationKeyStates(keyFlags) == FAILURE) {
return FAILURE; return FAILURE;
} }

View File

@ -40,7 +40,7 @@ LegoInputManager::LegoInputManager()
m_unk0x88 = FALSE; m_unk0x88 = FALSE;
m_directInput = NULL; m_directInput = NULL;
m_directInputDevice = NULL; m_directInputDevice = NULL;
m_unk0x94 = FALSE; m_kbStateSuccess = FALSE;
m_unk0x195 = 0; m_unk0x195 = 0;
m_joyid = -1; m_joyid = -1;
m_joystickIndex = -1; m_joystickIndex = -1;
@ -142,63 +142,63 @@ void LegoInputManager::ReleaseDX()
} }
// FUNCTION: LEGO1 0x1005c0f0 // FUNCTION: LEGO1 0x1005c0f0
void LegoInputManager::FUN_1005c0f0() void LegoInputManager::GetKeyboardState()
{ {
m_unk0x94 = FALSE; m_kbStateSuccess = FALSE;
if (m_directInputDevice) { 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 (hr == DIERR_INPUTLOST || hr == DIERR_NOTACQUIRED) {
if (m_directInputDevice->Acquire() == S_OK) { 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) { if (hr == S_OK) {
m_unk0x94 = TRUE; m_kbStateSuccess = TRUE;
} }
} }
} }
// FUNCTION: LEGO1 0x1005c160 // 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; return FAILURE;
} }
if (g_unk0x100f67b8) { if (g_unk0x100f67b8) {
if (m_unk0x95[DIK_LEFT] & 0x80 && GetAsyncKeyState(VK_LEFT) == 0) { if (m_keyboardState[DIK_LEFT] & 0x80 && GetAsyncKeyState(VK_LEFT) == 0) {
m_unk0x95[DIK_LEFT] = 0; m_keyboardState[DIK_LEFT] = 0;
} }
if (m_unk0x95[DIK_RIGHT] & 0x80 && GetAsyncKeyState(VK_RIGHT) == 0) { if (m_keyboardState[DIK_RIGHT] & 0x80 && GetAsyncKeyState(VK_RIGHT) == 0) {
m_unk0x95[DIK_RIGHT] = 0; m_keyboardState[DIK_RIGHT] = 0;
} }
} }
MxU32 keyFlags = 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; 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; 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; 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; 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; keyFlags |= c_bit5;
} }
@ -290,6 +290,7 @@ MxResult LegoInputManager::GetJoystickState(
} }
} }
} }
return FAILURE; 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); LegoEventNotificationParam param = LegoEventNotificationParam(p_id, NULL, p_modifier, p_x, p_y, p_key);
if (((!m_unk0x88) || ((m_unk0x335 && (param.GetType() == c_notificationButtonDown)))) || if (((!m_unk0x88) || ((m_unk0x335 && (param.GetType() == c_notificationButtonDown)))) ||
((m_unk0x336 && (p_key == ' ')))) { ((m_unk0x336 && (p_key == VK_SPACE)))) {
ProcessOneEvent(param); ProcessOneEvent(param);
} }
} }
@ -369,8 +370,8 @@ MxBool LegoInputManager::ProcessOneEvent(LegoEventNotificationParam& p_param)
MxBool processRoi; MxBool processRoi;
if (p_param.GetType() == c_notificationKeyPress) { if (p_param.GetType() == c_notificationKeyPress) {
if (!Lego()->IsTimerRunning() || p_param.GetKey() == 0x13) { if (!Lego()->IsTimerRunning() || p_param.GetKey() == VK_PAUSE) {
if (p_param.GetKey() == 0x10) { if (p_param.GetKey() == VK_SHIFT) {
if (m_unk0x195) { if (m_unk0x195) {
m_unk0x80 = FALSE; m_unk0x80 = FALSE;
p_param.SetType(c_notificationDrag); p_param.SetType(c_notificationDrag);

View File

@ -297,7 +297,7 @@ MxLong GasStation::HandleEndAction(MxEndActionNotificationParam& p_param)
// FUNCTION: LEGO1 0x10005920 // FUNCTION: LEGO1 0x10005920
MxLong GasStation::HandleKeyPress(MxS8 p_key) 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(); m_state->FUN_10006490();
return 1; return 1;
} }

View File

@ -226,7 +226,7 @@ MxLong Hospital::HandleKeyPress(MxS8 p_key)
{ {
MxLong result = 0; 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); DeleteObjects(&m_atom, HospitalScript::c_hho002cl_RunAnim, HospitalScript::c_hho006cl_RunAnim);
result = 1; result = 1;
} }

View File

@ -612,7 +612,6 @@ MxU8 Infocenter::HandleMouseMove(MxS32 p_x, MxS32 p_y)
VideoManager()->SortPresenterList(); VideoManager()->SortPresenterList();
m_unk0x11c->Enable(TRUE); m_unk0x11c->Enable(TRUE);
m_unk0x11c->SetPosition(p_x, p_y); m_unk0x11c->SetPosition(p_x, p_y);
m_unk0x11c->SetDisplayZ(oldDisplayZ); m_unk0x11c->SetDisplayZ(oldDisplayZ);
} }
else { else {
@ -631,7 +630,7 @@ MxLong Infocenter::HandleKeyPress(MxS8 p_key)
{ {
MxLong result = 0; MxLong result = 0;
if (p_key == ' ' && m_worldStarted) { if (p_key == VK_SPACE && m_worldStarted) {
switch (m_infocenterState->GetUnknown0x74()) { switch (m_infocenterState->GetUnknown0x74()) {
case 0: case 0:
StopCutscene(); StopCutscene();

View File

@ -164,7 +164,7 @@ MxLong Police::HandleKeyPress(LegoEventNotificationParam& p_param)
{ {
MxLong result = 0; 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); DeleteObjects(&m_atom, PoliceScript::c_nps001ni_RunAnim, PoliceScript::c_nps002la_RunAnim);
m_policeState->SetUnknown0x0c(0); m_policeState->SetUnknown0x0c(0);
return 1; return 1;

View File

@ -166,13 +166,13 @@ MxLong RegistrationBook::HandleKeyPress(MxU8 p_key)
key = p_key; key = p_key;
} }
if ((key < 'A' || key > 'Z') && key != '\b') { if ((key < 'A' || key > 'Z') && key != VK_BACK) {
if (key == ' ') { if (key == VK_SPACE) {
DeleteObjects(&m_atom, RegbookScript::c_iic006in_RunAnim, RegbookScript::c_iic008in_PlayWav); DeleteObjects(&m_atom, RegbookScript::c_iic006in_RunAnim, RegbookScript::c_iic008in_PlayWav);
BackgroundAudioManager()->RaiseVolume(); 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(); m_name[0][m_unk0x280.m_cursorPos] = m_alphabet[key - 'A']->Clone();
if (m_name[0][m_unk0x280.m_cursorPos] != NULL) { if (m_name[0][m_unk0x280.m_cursorPos] != NULL) {
@ -190,7 +190,7 @@ MxLong RegistrationBook::HandleKeyPress(MxU8 p_key)
} }
} }
else { else {
if (key == '\b' && m_unk0x280.m_cursorPos > 0) { if (key == VK_BACK && m_unk0x280.m_cursorPos > 0) {
m_unk0x280.m_cursorPos--; m_unk0x280.m_cursorPos--;
m_name[0][m_unk0x280.m_cursorPos]->Enable(FALSE); m_name[0][m_unk0x280.m_cursorPos]->Enable(FALSE);