Rename c_bit5 to c_ctrl in LegoInputManager, change m_unk0x6c to m_isAccelerating and clear some local unknowns (#1458)

This commit is contained in:
Florian Kaiser
2025-05-09 16:40:00 +02:00
committed by GitHub
parent 711134b3b8
commit 3811d61ea4
4 changed files with 27 additions and 19 deletions

View File

@@ -74,7 +74,7 @@ public:
c_right = 0x02, c_right = 0x02,
c_up = 0x04, c_up = 0x04,
c_down = 0x08, c_down = 0x08,
c_bit5 = 0x10, c_ctrl = 0x10,
c_leftOrRight = c_left | c_right, c_leftOrRight = c_left | c_right,
c_upOrDown = c_up | c_down c_upOrDown = c_up | c_down

View File

@@ -155,7 +155,7 @@ protected:
float m_unk0x60; // 0x60 float m_unk0x60; // 0x60
float m_unk0x64; // 0x64 float m_unk0x64; // 0x64
float m_unk0x68; // 0x68 float m_unk0x68; // 0x68
MxBool m_unk0x6c; // 0x6c MxBool m_isAccelerating; // 0x6c
// one copy of defaults (these can be set by App.) // one copy of defaults (these can be set by App.)
static int g_defdeadZone; static int g_defdeadZone;

View File

@@ -135,7 +135,7 @@ LegoNavController::LegoNavController()
m_rotationalAccel = 0.0f; m_rotationalAccel = 0.0f;
m_trackDefault = FALSE; m_trackDefault = FALSE;
m_unk0x5d = FALSE; m_unk0x5d = FALSE;
m_unk0x6c = FALSE; m_isAccelerating = FALSE;
m_unk0x64 = 0.0f; m_unk0x64 = 0.0f;
m_unk0x68 = 0.0f; m_unk0x68 = 0.0f;
m_unk0x60 = 0.0f; m_unk0x60 = 0.0f;
@@ -564,8 +564,8 @@ MxResult LegoNavController::ProcessJoystickInput(MxBool& p_und)
// FUNCTION: LEGO1 0x100558b0 // FUNCTION: LEGO1 0x100558b0
MxResult LegoNavController::ProcessKeyboardInput() MxResult LegoNavController::ProcessKeyboardInput()
{ {
MxBool bool1 = FALSE; MxBool skipRotationVelAndAccelCalc = FALSE;
MxBool bool2 = FALSE; MxBool skipLinearVelAndAccelCalc = FALSE;
LegoInputManager* inputManager = LegoOmni::GetInstance()->GetInputManager(); LegoInputManager* inputManager = LegoOmni::GetInstance()->GetInputManager();
MxU32 keyFlags; MxU32 keyFlags;
@@ -574,18 +574,18 @@ MxResult LegoNavController::ProcessKeyboardInput()
} }
if (keyFlags == 0) { if (keyFlags == 0) {
if (m_unk0x6c) { if (m_isAccelerating) {
m_targetRotationalVel = 0.0; m_targetRotationalVel = 0.0;
m_targetLinearVel = 0.0; m_targetLinearVel = 0.0;
m_rotationalAccel = m_maxRotationalDeccel; m_rotationalAccel = m_maxRotationalDeccel;
m_linearAccel = m_maxLinearDeccel; m_linearAccel = m_maxLinearDeccel;
m_unk0x6c = FALSE; m_isAccelerating = FALSE;
} }
return FAILURE; return FAILURE;
} }
m_unk0x6c = TRUE; m_isAccelerating = TRUE;
MxS32 hMax; MxS32 hMax;
switch (keyFlags & LegoInputManager::c_leftOrRight) { switch (keyFlags & LegoInputManager::c_leftOrRight) {
@@ -598,7 +598,7 @@ MxResult LegoNavController::ProcessKeyboardInput()
default: default:
m_targetRotationalVel = 0.0; m_targetRotationalVel = 0.0;
m_rotationalAccel = m_maxRotationalDeccel; m_rotationalAccel = m_maxRotationalDeccel;
bool1 = TRUE; skipRotationVelAndAccelCalc = TRUE;
break; break;
} }
@@ -613,23 +613,31 @@ MxResult LegoNavController::ProcessKeyboardInput()
default: default:
m_targetLinearVel = 0.0; m_targetLinearVel = 0.0;
m_linearAccel = m_maxLinearDeccel; m_linearAccel = m_maxLinearDeccel;
bool2 = TRUE; skipLinearVelAndAccelCalc = TRUE;
break; break;
} }
MxFloat val = keyFlags & LegoInputManager::c_bit5 ? 1.0f : 4.0f; MxFloat maxAccelDivisor = keyFlags & LegoInputManager::c_ctrl ? 1.0f : 4.0f;
MxFloat val2 = keyFlags & LegoInputManager::c_bit5 ? 1.0f : 2.0f; MxFloat minAccelDivisor = keyFlags & LegoInputManager::c_ctrl ? 1.0f : 2.0f;
if (!bool1) { if (!skipRotationVelAndAccelCalc) {
m_targetRotationalVel = CalculateNewTargetVel(hMax, m_hMax / 2, m_maxRotationalVel); m_targetRotationalVel = CalculateNewTargetVel(hMax, m_hMax / 2, m_maxRotationalVel);
m_rotationalAccel = m_rotationalAccel = CalculateNewAccel(
CalculateNewAccel(hMax, m_hMax / 2, m_maxRotationalAccel / val, (int) (m_minRotationalAccel / val2)); hMax,
m_hMax / 2,
m_maxRotationalAccel / maxAccelDivisor,
(int) (m_minRotationalAccel / minAccelDivisor)
);
} }
if (!bool2) { if (!skipLinearVelAndAccelCalc) {
m_targetLinearVel = CalculateNewTargetVel(m_vMax - vMax, m_vMax / 2, m_maxLinearVel); m_targetLinearVel = CalculateNewTargetVel(m_vMax - vMax, m_vMax / 2, m_maxLinearVel);
m_linearAccel = m_linearAccel = CalculateNewAccel(
CalculateNewAccel(m_vMax - vMax, m_vMax / 2, m_maxLinearAccel / val, (int) (m_minLinearAccel / val2)); m_vMax - vMax,
m_vMax / 2,
m_maxLinearAccel / maxAccelDivisor,
(int) (m_minLinearAccel / minAccelDivisor)
);
} }
return SUCCESS; return SUCCESS;

View File

@@ -195,7 +195,7 @@ MxResult LegoInputManager::GetNavigationKeyStates(MxU32& p_keyFlags)
} }
if ((m_keyboardState[DIK_LCONTROL] | m_keyboardState[DIK_RCONTROL]) & 0x80) { if ((m_keyboardState[DIK_LCONTROL] | m_keyboardState[DIK_RCONTROL]) & 0x80) {
keyFlags |= c_bit5; keyFlags |= c_ctrl;
} }
p_keyFlags = keyFlags; p_keyFlags = keyFlags;