From f706f804836a5d7122daee4c5e5bb7eaf4cd1c0b Mon Sep 17 00:00:00 2001 From: Misha <106913236+MishaProductions@users.noreply.github.com> Date: Sat, 27 Jan 2024 16:55:59 -0500 Subject: [PATCH] implement LegoInputManager::Create (#495) * implement LegoInputManager::Create * Fixes * Add annotation * Add size assert --------- Co-authored-by: Christian Semmler --- .../legoomni/include/legocontrolmanager.h | 3 + .../lego/legoomni/include/legoinputmanager.h | 104 +++++++++++++----- .../src/control/legocontrolmanager.cpp | 2 + .../legoomni/src/input/legoinputmanager.cpp | 38 +++++-- 4 files changed, 109 insertions(+), 38 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legocontrolmanager.h b/LEGO1/lego/legoomni/include/legocontrolmanager.h index 385ee92b..e2861885 100644 --- a/LEGO1/lego/legoomni/include/legocontrolmanager.h +++ b/LEGO1/lego/legoomni/include/legocontrolmanager.h @@ -32,6 +32,9 @@ public: // SYNTHETIC: LEGO1 0x10028d40 // LegoControlManager::`scalar deleting destructor' + +private: + undefined m_padding0x08[0x58]; // 0x08 }; #endif // LEGOCONTROLMANAGER_H diff --git a/LEGO1/lego/legoomni/include/legoinputmanager.h b/LEGO1/lego/legoomni/include/legoinputmanager.h index b2b677b7..4d3d0f76 100644 --- a/LEGO1/lego/legoomni/include/legoinputmanager.h +++ b/LEGO1/lego/legoomni/include/legoinputmanager.h @@ -25,6 +25,29 @@ class LegoControlManager; // SIZE 0x18 class LegoEventQueue : public MxQueue {}; +// VTABLE: LEGO1 0x100d6a20 +// class MxCollection + +// VTABLE: LEGO1 0x100d6a38 +// class MxList + +// VTABLE: LEGO1 0x100d6a50 +// class MxPtrList + +// VTABLE: LEGO1 0x100d6a68 +// SIZE 0x18 +class LegoNotifyList : public MxPtrList { +protected: + // FUNCTION: LEGO1 0x10028830 + virtual MxS8 Compare(MxCore* p_element1, MxCore* p_element2) override + { + return p_element1 == p_element2 ? 0 : p_element1 < p_element2 ? -1 : 1; + } // vtable+0x14 + +public: + LegoNotifyList(MxBool p_ownership = FALSE) : MxPtrList(p_ownership) {} +}; + // VTABLE: LEGO1 0x100d8760 // SIZE 0x338 class LegoInputManager : public MxPresenter { @@ -78,47 +101,59 @@ public: // LegoInputManager::`scalar deleting destructor' private: - MxCriticalSection m_criticalSection; - MxList* m_unk0x5c; // list or hash table - LegoCameraController* m_camera; - LegoWorld* m_world; - LegoEventQueue* m_eventQueue; // +0x68 - undefined4 m_unk0x6c; - undefined4 m_unk0x70; - undefined4 m_unk0x74; - UINT m_timer; - UINT m_timeout; - undefined m_unk0x80; - undefined m_unk0x81; - LegoControlManager* m_controlManager; - MxBool m_unk0x88; - IDirectInput* m_directInput; - IDirectInputDevice* m_directInputDevice; - undefined m_unk0x94; - undefined4 m_unk0x98; - undefined m_unk0x9c[0xF8]; - undefined m_unk0x194; - MxBool m_unk0x195; - MxS32 m_joyid; - MxS32 m_joystickIndex; - JOYCAPS m_joyCaps; - MxBool m_useJoystick; - MxBool m_unk0x335; - MxBool m_unk0x336; + MxCriticalSection m_criticalSection; // 0x58 + LegoNotifyList* m_keyboardNotifyList; // 0x5c + LegoCameraController* m_camera; // 0x60 + LegoWorld* m_world; // 0x64 + LegoEventQueue* m_eventQueue; // 0x68 + undefined4 m_unk0x6c; // 0x6c + undefined4 m_unk0x70; // 0x70 + undefined4 m_unk0x74; // 0x74 + UINT m_timer; // 0x78 + UINT m_timeout; // 0x7c + undefined m_unk0x80; // 0x80 + undefined m_unk0x81; // 0x81 + LegoControlManager* m_controlManager; // 0x84 + MxBool m_unk0x88; // 0x88 + IDirectInput* m_directInput; // 0x8c + IDirectInputDevice* m_directInputDevice; // 0x90 + undefined m_unk0x94; // 0x94 + undefined4 m_unk0x98; // 0x98 + undefined m_unk0x9c[0xf8]; // 0x9c + undefined m_unk0x194; // 0x194 + MxBool m_unk0x195; // 0x195 + MxS32 m_joyid; // 0x198 + MxS32 m_joystickIndex; // 0x19c + JOYCAPS m_joyCaps; // 0x200 + MxBool m_useJoystick; // 0x334 + MxBool m_unk0x335; // 0x335 + MxBool m_unk0x336; // 0x336 }; // TEMPLATE: LEGO1 0x1005bb80 // MxCollection::Compare +// TEMPLATE: LEGO1 0x100288b0 +// MxCollection::Destroy + +// TEMPLATE: LEGO1 0x10028850 +// MxCollection::Compare + // TEMPLATE: LEGO1 0x1005bbe0 // MxCollection::~MxCollection +// TEMPLATE: LEGO1 0x10028860 +// MxCollection::~MxCollection + // TEMPLATE: LEGO1 0x1005bc30 // MxCollection::Destroy // TEMPLATE: LEGO1 0x1005bc80 // MxList::~MxList +// TEMPLATE: LEGO1 0x100288c0 +// MxList::~MxList + // SYNTHETIC: LEGO1 0x1005bd50 // MxCollection::`scalar deleting destructor' @@ -128,9 +163,24 @@ private: // SYNTHETIC: LEGO1 0x1005beb0 // LegoEventQueue::`scalar deleting destructor' +// SYNTHETIC: LEGO1 0x10028a10 +// MxCollection::`scalar deleting destructor' + +// SYNTHETIC: LEGO1 0x10028a80 +// MxList::`scalar deleting destructor' + +// SYNTHETIC: LEGO1 0x10028b30 +// MxPtrList::`scalar deleting destructor' + +// SYNTHETIC: LEGO1 0x10028950 +// LegoNotifyList::`scalar deleting destructor' + // TEMPLATE: LEGO1 0x1005bf20 // MxQueue::~MxQueue +// TEMPLATE: LEGO1 0x100289c0 +// MxPtrList::~MxPtrList + // SYNTHETIC: LEGO1 0x1005bf70 // MxQueue::`scalar deleting destructor' diff --git a/LEGO1/lego/legoomni/src/control/legocontrolmanager.cpp b/LEGO1/lego/legoomni/src/control/legocontrolmanager.cpp index 481bd9c5..5b51b8ec 100644 --- a/LEGO1/lego/legoomni/src/control/legocontrolmanager.cpp +++ b/LEGO1/lego/legoomni/src/control/legocontrolmanager.cpp @@ -1,5 +1,7 @@ #include "legocontrolmanager.h" +DECOMP_SIZE_ASSERT(LegoControlManager, 0x60); + // STUB: LEGO1 0x10028520 LegoControlManager::LegoControlManager() { diff --git a/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp b/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp index 87c72a63..ec871b47 100644 --- a/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp +++ b/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp @@ -4,8 +4,9 @@ #include "legoomni.h" #include "mxautolocker.h" -DECOMP_SIZE_ASSERT(LegoInputManager, 0x338); -DECOMP_SIZE_ASSERT(LegoEventQueue, 0x18); +DECOMP_SIZE_ASSERT(LegoInputManager, 0x338) +DECOMP_SIZE_ASSERT(LegoNotifyList, 0x18) +DECOMP_SIZE_ASSERT(LegoEventQueue, 0x18) // GLOBAL: LEGO1 0x100f31b0 MxS32 g_unk0x100f31b0 = -1; @@ -16,7 +17,7 @@ MxS32 g_unk0x100f31b4 = 0; // FUNCTION: LEGO1 0x1005b790 LegoInputManager::LegoInputManager() { - m_unk0x5c = NULL; + m_keyboardNotifyList = NULL; m_world = NULL; m_camera = NULL; m_eventQueue = NULL; @@ -40,7 +41,7 @@ LegoInputManager::LegoInputManager() m_timeout = 1000; } -// STUB: LEGO1 0x1005b8b0 +// FUNCTION: LEGO1 0x1005b8b0 MxResult LegoInputManager::Tickle() { ProcessEvents(); @@ -56,10 +57,25 @@ LegoInputManager::~LegoInputManager() // FUNCTION: LEGO1 0x1005b960 MxResult LegoInputManager::Create(HWND p_hwnd) { - // TODO - if (m_eventQueue == NULL) - m_eventQueue = new LegoEventQueue(); - return SUCCESS; + MxResult result = SUCCESS; + + m_controlManager = new LegoControlManager; + + if (!m_keyboardNotifyList) + m_keyboardNotifyList = new LegoNotifyList; + + if (!m_eventQueue) + m_eventQueue = new LegoEventQueue; + + CreateAndAcquireKeyboard(p_hwnd); + GetJoystickId(); + + if (!m_keyboardNotifyList || !m_eventQueue || !m_directInputDevice) { + Destroy(); + result = FAILURE; + } + + return result; } // FUNCTION: LEGO1 0x1005bfe0 @@ -67,9 +83,9 @@ void LegoInputManager::Destroy() { ReleaseDX(); - if (m_unk0x5c) - delete m_unk0x5c; - m_unk0x5c = NULL; + if (m_keyboardNotifyList) + delete m_keyboardNotifyList; + m_keyboardNotifyList = NULL; if (m_eventQueue) delete m_eventQueue;