From f5c577a2e2d95b033eec231087a26e8b22ae832a Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sun, 24 Mar 2024 10:19:43 -0400 Subject: [PATCH] Style --- .../lego/legoomni/include/legoinputmanager.h | 17 ++++++---- .../legoomni/src/entity/legonavcontroller.cpp | 18 +++++----- .../legoomni/src/input/legoinputmanager.cpp | 34 +++++++++++-------- 3 files changed, 38 insertions(+), 31 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legoinputmanager.h b/LEGO1/lego/legoomni/include/legoinputmanager.h index bc4a7d0c..17867a2a 100644 --- a/LEGO1/lego/legoomni/include/legoinputmanager.h +++ b/LEGO1/lego/legoomni/include/legoinputmanager.h @@ -69,11 +69,14 @@ class LegoNotifyListCursor : public MxPtrListCursor { class LegoInputManager : public MxPresenter { public: enum Keys { - c_bit1 = 0x01, - c_bit2 = 0x02, - c_bit3 = 0x04, - c_bit4 = 0x08, - c_bit5 = 0x16 + c_left = 0x01, + c_right = 0x02, + c_up = 0x04, + c_down = 0x08, + c_bit5 = 0x10, + + c_leftOrRight = c_left | c_right, + c_upOrDown = c_up | c_down }; LegoInputManager(); @@ -122,7 +125,7 @@ class LegoInputManager : public MxPresenter { MxBool ProcessOneEvent(LegoEventNotificationParam& p_param); MxBool FUN_1005cdf0(LegoEventNotificationParam& p_param); void FUN_1005c0f0(); - MxResult FUN_1005c160(MxU32& p_keys); + MxResult FUN_1005c160(MxU32& p_keyFlags); // SYNTHETIC: LEGO1 0x1005b8d0 // LegoInputManager::`scalar deleting destructor' @@ -144,7 +147,7 @@ class LegoInputManager : public MxPresenter { MxBool m_unk0x88; // 0x88 IDirectInput* m_directInput; // 0x8c IDirectInputDevice* m_directInputDevice; // 0x90 - undefined m_unk0x94; // 0x94 + MxBool m_unk0x94; // 0x94 MxU8 m_unk0x95[256]; // 0x95 MxBool m_unk0x195; // 0x195 MxS32 m_joyid; // 0x198 diff --git a/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp b/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp index 9f1a6005..7538217b 100644 --- a/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp +++ b/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp @@ -524,13 +524,13 @@ MxResult LegoNavController::ProcessKeyboardInput() MxBool bool1 = FALSE; MxBool bool2 = FALSE; LegoInputManager* inputManager = LegoOmni::GetInstance()->GetInputManager(); - MxU32 keys; + MxU32 p_keyFlags; - if (inputManager == NULL || inputManager->FUN_1005c160(keys) == FAILURE) { + if (inputManager == NULL || inputManager->FUN_1005c160(p_keyFlags) == FAILURE) { return FAILURE; } - if (keys == 0) { + if (p_keyFlags == 0) { if (m_unk0x6c) { m_targetRotationalVel = 0.0; m_targetLinearVel = 0.0; @@ -545,10 +545,10 @@ MxResult LegoNavController::ProcessKeyboardInput() m_unk0x6c = TRUE; MxS32 hMax; - if ((keys & 3) == 1) { + if ((p_keyFlags & LegoInputManager::c_leftOrRight) == LegoInputManager::c_left) { hMax = 0; } - else if ((keys & 3) == 2) { + else if ((p_keyFlags & LegoInputManager::c_leftOrRight) == LegoInputManager::c_right) { hMax = m_hMax; } else { @@ -558,10 +558,10 @@ MxResult LegoNavController::ProcessKeyboardInput() } MxS32 vMax; - if ((keys & 12) == 4) { + if ((p_keyFlags & LegoInputManager::c_upOrDown) == LegoInputManager::c_up) { vMax = 0; } - else if ((keys & 12) == 8) { + else if ((p_keyFlags & LegoInputManager::c_upOrDown) == LegoInputManager::c_down) { vMax = m_vMax; } else { @@ -570,8 +570,8 @@ MxResult LegoNavController::ProcessKeyboardInput() bool2 = TRUE; } - MxFloat val = keys & 0x10 ? 1.0f : 4.0f; - MxFloat val2 = keys & 0x10 ? 1.0f : 2.0f; + MxFloat val = p_keyFlags & 0x10 ? 1.0f : 4.0f; + MxFloat val2 = p_keyFlags & 0x10 ? 1.0f : 2.0f; if (!bool1) { m_targetRotationalVel = CalculateNewTargetVel(hMax, m_hMax / 2, m_maxRotationalVel); diff --git a/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp b/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp index c16cfda2..3e6a39dd 100644 --- a/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp +++ b/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp @@ -37,7 +37,7 @@ LegoInputManager::LegoInputManager() m_unk0x88 = FALSE; m_directInput = NULL; m_directInputDevice = NULL; - m_unk0x94 = 0; + m_unk0x94 = FALSE; m_unk0x195 = 0; m_joyid = -1; m_joystickIndex = -1; @@ -141,28 +141,32 @@ void LegoInputManager::ReleaseDX() // FUNCTION: LEGO1 0x1005c0f0 void LegoInputManager::FUN_1005c0f0() { - m_unk0x94 = 0; + m_unk0x94 = FALSE; + if (m_directInputDevice) { - HRESULT hr = m_directInputDevice->GetDeviceState(256, &m_unk0x95); - if (hr == 0x8007001E || hr == 0x8007000c) { + HRESULT hr = m_directInputDevice->GetDeviceState(_countof(m_unk0x95), &m_unk0x95); + + if (hr == DIERR_INPUTLOST || hr == DIERR_NOTACQUIRED) { if (m_directInputDevice->Acquire() == S_OK) { - hr = m_directInputDevice->GetDeviceState(256, &m_unk0x95); + hr = m_directInputDevice->GetDeviceState(_countof(m_unk0x95), &m_unk0x95); } } if (hr == S_OK) { - m_unk0x94 = 1; + m_unk0x94 = TRUE; } } } // FUNCTION: LEGO1 0x1005c160 -MxResult LegoInputManager::FUN_1005c160(MxU32& p_keys) +MxResult LegoInputManager::FUN_1005c160(MxU32& p_keyFlags) { FUN_1005c0f0(); + if (!m_unk0x94) { return FAILURE; } + if (g_unk0x100f67b8) { if (m_unk0x95[DIK_LEFT] & 0x80 && GetAsyncKeyState(VK_LEFT) == 0) { m_unk0x95[DIK_LEFT] = 0; @@ -173,29 +177,29 @@ MxResult LegoInputManager::FUN_1005c160(MxU32& p_keys) } } - MxU32 value = 0; + MxU32 keyFlags = 0; - if ((m_unk0x95[DIK_UP] | m_unk0x95[DIK_NUMPAD8]) & 0x80) { - value = 4; + if ((m_unk0x95[DIK_NUMPAD8] | m_unk0x95[DIK_UP]) & 0x80) { + keyFlags |= c_up; } if ((m_unk0x95[DIK_NUMPAD2] | m_unk0x95[DIK_DOWN]) & 0x80) { - value |= 8; + keyFlags |= c_down; } if ((m_unk0x95[DIK_NUMPAD4] | m_unk0x95[DIK_LEFT]) & 0x80) { - value |= 1; + keyFlags |= c_left; } if ((m_unk0x95[DIK_NUMPAD6] | m_unk0x95[DIK_RIGHT]) & 0x80) { - value |= 2; + keyFlags |= c_right; } if ((m_unk0x95[DIK_LCONTROL] | m_unk0x95[DIK_RCONTROL]) & 0x80) { - value |= 16; + keyFlags |= c_bit5; } - p_keys = value; + p_keyFlags = keyFlags; return SUCCESS; }