implement a few legonavcontroller functions

This commit is contained in:
Misha 2024-03-24 09:21:16 -04:00
parent 3f03940fcb
commit 8e4d0f64d2
No known key found for this signature in database
GPG Key ID: 8441D12AEF33FED8
6 changed files with 185 additions and 15 deletions

View File

@ -37,6 +37,7 @@ class LegoCameraController : public LegoPointOfViewController {
virtual MxResult Create(); // vtable+0x44 virtual MxResult Create(); // vtable+0x44
void SetWorldTransform(const Vector3& p_at, const Vector3& p_dir, const Vector3& p_up); void SetWorldTransform(const Vector3& p_at, const Vector3& p_dir, const Vector3& p_up);
void FUN_10012320(MxFloat);
void FUN_100123e0(const Matrix4& p_transform, MxU32 p_und); void FUN_100123e0(const Matrix4& p_transform, MxU32 p_und);
Mx3DPointFloat GetWorldUp(); Mx3DPointFloat GetWorldUp();
Mx3DPointFloat GetWorldLocation(); Mx3DPointFloat GetWorldLocation();

View File

@ -113,6 +113,8 @@ class LegoInputManager : public MxPresenter {
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();
MxResult FUN_1005c160(MxU32& p_keys);
// SYNTHETIC: LEGO1 0x1005b8d0 // SYNTHETIC: LEGO1 0x1005b8d0
// LegoInputManager::`scalar deleting destructor' // LegoInputManager::`scalar deleting destructor'
@ -135,9 +137,7 @@ class LegoInputManager : public MxPresenter {
IDirectInput* m_directInput; // 0x8c IDirectInput* m_directInput; // 0x8c
IDirectInputDevice* m_directInputDevice; // 0x90 IDirectInputDevice* m_directInputDevice; // 0x90
undefined m_unk0x94; // 0x94 undefined m_unk0x94; // 0x94
undefined4 m_unk0x98; // 0x98 MxU8 m_unk0x95[256]; // 0x95
undefined m_unk0x9c[0xf8]; // 0x9c
undefined m_unk0x194; // 0x194
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

@ -81,8 +81,8 @@ class LegoNavController : public MxCore {
float CalculateNewTargetVel(int p_pos, int p_center, float p_max); float CalculateNewTargetVel(int p_pos, int p_center, float p_max);
float CalculateNewAccel(int p_pos, int p_center, float p_max, int p_min); float CalculateNewAccel(int p_pos, int p_center, float p_max, int p_min);
int FUN_10055750(MxBool& p_und); MxResult ProcessJoystickInput(MxBool& p_und);
int FUN_100558b0(); MxResult ProcessKeyboardInput();
int m_hMax; // 0x08 int m_hMax; // 0x08
int m_vMax; // 0x0c int m_vMax; // 0x0c

View File

@ -122,6 +122,12 @@ void LegoCameraController::SetWorldTransform(const Vector3& p_at, const Vector3&
m_matrix2 = m_matrix1; m_matrix2 = m_matrix1;
} }
// STUB: LEGO1 0x10012320
void LegoCameraController::FUN_10012320(MxFloat)
{
// TODO
}
// FUNCTION: LEGO1 0x100123e0 // FUNCTION: LEGO1 0x100123e0
void LegoCameraController::FUN_100123e0(const Matrix4& p_transform, MxU32 p_und) void LegoCameraController::FUN_100123e0(const Matrix4& p_transform, MxU32 p_und)
{ {

View File

@ -307,8 +307,8 @@ MxBool LegoNavController::CalculateNewPosDir(
float deltaTime = (currentTime - m_lastTime) / 1000.0; float deltaTime = (currentTime - m_lastTime) / 1000.0;
m_lastTime = currentTime; m_lastTime = currentTime;
if (FUN_100558b0() == -1) { if (ProcessKeyboardInput() == FAILURE) {
FUN_10055750(und); ProcessJoystickInput(und);
} }
if (m_useRotationalVel) { if (m_useRotationalVel) {
@ -471,18 +471,116 @@ MxResult LegoNavController::UpdateCameraLocation(MxU32 p_location)
return result; return result;
} }
// STUB: LEGO1 0x10055750 // FUNCTION: LEGO1 0x10055750
int LegoNavController::FUN_10055750(MxBool& p_und) MxResult LegoNavController::ProcessJoystickInput(MxBool& p_und)
{ {
// TODO LegoOmni* instance = LegoOmni::GetInstance();
return -1; if (instance->GetInputManager()) {
MxS32 joystickX;
MxS32 joystickY;
DWORD buttonState;
MxS32 povPosition;
if (instance->GetInputManager()
->GetJoystickState((MxU32*) &joystickX, (MxU32*) &joystickY, &buttonState, (MxU32*) &povPosition) !=
FAILURE) {
MxU32 yVal = (joystickY * m_vMax) / 100;
MxU32 xVal = (joystickX * m_hMax) / 100;
if (joystickX <= 45 || joystickX >= 55 || joystickY <= 45 || joystickY >= 55) {
m_linearVel = CalculateNewTargetVel(m_vMax - xVal, m_vMax / 2, m_maxLinearVel);
m_linearAccel = CalculateNewAccel(m_vMax - xVal, m_vMax / 2, m_maxLinearAccel, (int) m_minLinearAccel);
m_targetRotationalVel = CalculateNewTargetVel(yVal, m_hMax / 2, m_maxRotationalVel);
m_rotationalAccel =
CalculateNewAccel(yVal, m_hMax / 2, m_maxRotationalAccel, (int) m_minRotationalAccel);
}
else {
m_targetRotationalVel = 0.0;
m_targetLinearVel = 0.0;
m_linearAccel = m_maxLinearDeccel;
m_rotationalAccel = m_maxRotationalDeccel;
}
if (povPosition >= 0) {
LegoWorld* world = CurrentWorld();
if (world && world->GetCamera()) {
world->GetCamera()->FUN_10012320(povPosition * 0.017453333333333335);
p_und = TRUE;
}
}
return SUCCESS;
}
}
return FAILURE;
} }
// STUB: LEGO1 0x100558b0 // FUNCTION: LEGO1 0x100558b0
int LegoNavController::FUN_100558b0() MxResult LegoNavController::ProcessKeyboardInput()
{ {
// TODO LegoOmni* instance = LegoOmni::GetInstance();
return -1; MxBool bool1 = FALSE;
MxBool bool2 = FALSE;
MxU32 keys;
if (!instance->GetInputManager() || instance->GetInputManager()->FUN_1005c160(keys) == FAILURE) {
return FAILURE;
}
if (m_unk0x6c) {
m_targetRotationalVel = 0.0;
m_targetLinearVel = 0.0;
m_rotationalAccel = m_maxRotationalDeccel;
m_linearAccel = m_maxLinearDeccel;
m_unk0x6c = FALSE;
}
else if (keys) {
m_unk0x6c = TRUE;
MxS32 hMax;
if ((keys & 3) == 1) {
hMax = 0;
}
else if ((keys & 3) == 2) {
hMax = m_hMax;
}
else {
bool1 = TRUE;
m_rotationalAccel = m_maxRotationalDeccel;
m_targetRotationalVel = 0.0;
}
MxS32 vMax;
if ((keys & 12) == 4) {
vMax = 0;
}
else if ((keys & 12) == 8) {
vMax = m_vMax;
}
else {
bool2 = TRUE;
m_targetLinearVel = 0.0;
m_linearAccel = m_maxRotationalDeccel;
}
MxFloat val = keys & 0x10 ? 1.0f : 4.0f;
MxFloat val2 = keys & 0x10 ? 1.0f : 2.0f;
if (!bool1) {
m_targetRotationalVel = CalculateNewTargetVel(hMax, m_hMax / 2, m_maxRotationalVel);
m_rotationalAccel =
CalculateNewAccel(hMax, m_hMax / 2, m_maxRotationalAccel / val, (int) (m_minRotationalAccel / val2));
}
if (!bool2) {
m_targetLinearVel = CalculateNewTargetVel(m_vMax - vMax, m_vMax / 2, m_maxLinearVel);
m_linearAccel =
CalculateNewAccel(m_vMax - vMax, hMax / 2, m_maxLinearAccel / val, (int) (m_minLinearAccel / val2));
}
return SUCCESS;
}
return FAILURE;
} }
// STUB: LEGO1 0x10055a60 // STUB: LEGO1 0x10055a60

View File

@ -18,6 +18,9 @@ MxS32 g_unk0x100f31b0 = -1;
// GLOBAL: LEGO1 0x100f31b4 // GLOBAL: LEGO1 0x100f31b4
const char* g_unk0x100f31b4 = NULL; const char* g_unk0x100f31b4 = NULL;
// GLOBAL: LEGO1 0x100f67b8
MxBool g_unk0x100f67b8 = TRUE;
// FUNCTION: LEGO1 0x1005b790 // FUNCTION: LEGO1 0x1005b790
LegoInputManager::LegoInputManager() LegoInputManager::LegoInputManager()
{ {
@ -135,6 +138,68 @@ void LegoInputManager::ReleaseDX()
} }
} }
// FUNCTION: LEGO1 0x1005c0f0
void LegoInputManager::FUN_1005c0f0()
{
m_unk0x94 = 0;
if (m_directInputDevice) {
HRESULT hr = m_directInputDevice->GetDeviceState(256, &m_unk0x95);
if (hr == 0x8007001E || hr == 0x8007000c) {
if (m_directInputDevice->Acquire() == S_OK) {
hr = m_directInputDevice->GetDeviceState(256, &m_unk0x95);
}
}
if (hr == S_OK) {
m_unk0x94 = 1;
}
}
}
// FUNCTION: LEGO1 0x1005c160
MxResult LegoInputManager::FUN_1005c160(MxU32& p_keys)
{
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;
}
if (m_unk0x95[DIK_RIGHT] & 0x80 && GetAsyncKeyState(VK_RIGHT) == 0) {
m_unk0x95[DIK_RIGHT] = 0;
}
}
MxU32 value = 0;
if ((m_unk0x95[DIK_UP] | m_unk0x95[DIK_NUMPAD8]) & 0x80) {
value = 4;
}
if ((m_unk0x95[DIK_NUMPAD2] | m_unk0x95[DIK_DOWN]) & 0x80) {
value |= 8;
}
if ((m_unk0x95[DIK_NUMPAD4] | m_unk0x95[DIK_LEFT]) & 0x80) {
value |= 1;
}
if ((m_unk0x95[DIK_NUMPAD6] | m_unk0x95[DIK_RIGHT]) & 0x80) {
value |= 2;
}
if ((m_unk0x95[DIK_LCONTROL] | m_unk0x95[DIK_RCONTROL]) & 0x80) {
value |= 16;
}
p_keys = value;
return SUCCESS;
}
// FUNCTION: LEGO1 0x1005c240 // FUNCTION: LEGO1 0x1005c240
MxResult LegoInputManager::GetJoystickId() MxResult LegoInputManager::GetJoystickId()
{ {