Skip to content

Commit 788260a

Browse files
authored
PeridotTraceState0x438::InitializeInputBindings (isledecomp#253)
1 parent 52fa955 commit 788260a

7 files changed

Lines changed: 243 additions & 67 deletions

File tree

LEGORacers/include/input/inputdevice.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ class InputDevice {
123123
static LegoU32 MakeEvent(LegoU32 p_source, LegoU32 p_value) { return p_source | p_value; }
124124

125125
LegoBool32 IsCreated() const { return m_created; }
126+
LegoS32 GetButtonCountFast() const { return m_buttonCount; }
127+
undefined4 GetDeviceSubType() const { return m_deviceSubType; }
128+
undefined4 GetDeviceType() const { return m_deviceType; }
129+
undefined4 GetDeviceId() const { return m_deviceId; }
126130
void SetForceFeedbackAvailable(undefined4 p_forceFeedbackAvailable)
127131
{
128132
m_forceFeedbackAvailable = p_forceFeedbackAvailable;

LEGORacers/include/input/inputmanager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class InputManager {
3030
LegoBool32 IsMouseAvailable() const { return m_mouseAvailable; }
3131
LegoS32 GetJoystickCount() const { return m_joystickCount; }
3232
JoystickInputDevice* GetJoystick(LegoS32 p_index) const { return m_joysticks[p_index]; }
33+
JoystickInputDevice* FindJoystickByDeviceId(LegoS32 p_deviceId) const;
3334

3435
void RestoreSuspendedDevices();
3536
void SuspendActiveDevices();

LEGORacers/include/peridottrace0x4e0.h

Lines changed: 64 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include "displaydriverguid.h"
66
#include "types.h"
77

8+
#include <string.h>
9+
810
class GolFile;
911
class GolString;
1012
class InputManager;
@@ -48,6 +50,7 @@ class PeridotTrace0x4a8 : public PeridotTraceBase0x24 {
4850
undefined* GetUnk0x24() { return m_unk0x24; }
4951
void FUN_004426d0(undefined4, undefined4, undefined4);
5052
undefined4 FUN_00442770(GolFile& p_file);
53+
void FUN_00442c20(void* p_unk0x04);
5154
undefined4 FUN_004439b0();
5255

5356
private:
@@ -101,9 +104,9 @@ class PeridotTraceState0x438 {
101104
PeridotTraceState0x438();
102105
~PeridotTraceState0x438();
103106

104-
void FUN_0042e920(InputManager* p_inputManager);
105-
void FUN_0042e950();
106-
void FUN_0042e960(InputManager* p_inputManager);
107+
void Initialize(InputManager* p_inputManager);
108+
void Reset();
109+
void InitializeInputBindings(InputManager* p_inputManager);
107110
void FUN_0042eb60(PeridotTrace0x4a8*, undefined4);
108111
void FUN_0042ef80(PeridotTrace0x4a8*);
109112
void SetLanguageResourcePath();
@@ -117,13 +120,13 @@ class PeridotTraceState0x438 {
117120
void SetUnk0x00(undefined4 p_arg1) { m_unk0x00 = p_arg1; }
118121
undefined4 GetUnk0x00() const { return m_unk0x00; }
119122
undefined4 GetUnk0x04() const { return m_unk0x04; }
120-
LegoU8 GetUnk0x0c() const { return m_unk0x0c; }
121-
LegoU8 GetUnk0x1f() const { return m_unk0x1f; }
122-
LegoU8 GetUnk0x20() const { return m_unk0x20; }
123-
LegoU8 GetUnk0x21() const { return m_unk0x21; }
124-
LegoU8 GetLanguageIndex() const { return m_languageIndex; }
123+
LegoU8 GetUnk0x0c() const { return m_state.m_unk0x0c; }
124+
LegoU8 GetUnk0x1f() const { return m_state.m_unk0x1f; }
125+
LegoU8 GetUnk0x20() const { return m_state.m_unk0x20; }
126+
LegoU8 GetUnk0x21() const { return m_state.m_unk0x21; }
127+
LegoU8 GetLanguageIndex() const { return m_state.m_languageIndex; }
125128
LegoU8 GetUnk0x22() const { return GetLanguageIndex(); }
126-
LegoU8 GetUnk0x23() const { return m_unk0x23; }
129+
LegoU8 GetUnk0x23() const { return m_state.m_unk0x23; }
127130
LegoU8 FUN_0042f1f0() const;
128131

129132
private:
@@ -150,26 +153,58 @@ class PeridotTraceState0x438 {
150153
SerializedGuidWord m_words[sizeof(GUID) / sizeof(LegoU32)]; // 0x00
151154
};
152155

153-
undefined4 m_unk0x00; // 0x00
154-
undefined4 m_unk0x04; // 0x04
155-
InputManager* m_inputManager; // 0x08
156-
LegoU8 m_unk0x0c; // 0x0c
157-
SerializedGuid m_displayDriverGuid; // 0x0d
158-
undefined m_unk0x1d; // 0x1d
159-
undefined m_unk0x1e; // 0x1e
160-
LegoU8 m_unk0x1f; // 0x1f
161-
LegoU8 m_unk0x20; // 0x20
162-
LegoU8 m_unk0x21; // 0x21
163-
LegoU8 m_languageIndex; // 0x22
164-
undefined m_unk0x23; // 0x23
165-
LegoU8 m_unk0x24; // 0x24
166-
LegoU8 m_unk0x25; // 0x25
167-
LegoU16 m_unk0x26; // 0x26
168-
LegoU32 m_unk0x28[13]; // 0x28
169-
LegoU32 m_unk0x5c[13]; // 0x5c
170-
undefined2 m_unk0x90[13][14]; // 0x90
171-
undefined2 m_unk0x1fc[13][14]; // 0x1fc
172-
undefined m_unk0x368[0x438 - 0x368]; // 0x368
156+
// SIZE 0x28
157+
struct InputBindingEntry {
158+
LegoU8 m_deviceType; // 0x00
159+
LegoU8 m_deviceSubType; // 0x01
160+
LegoU8 m_unk0x02; // 0x02
161+
undefined m_unk0x03; // 0x03
162+
LegoU32 m_events[9]; // 0x04
163+
};
164+
165+
// SIZE 0xd0
166+
struct InputBindingState {
167+
LegoU8 m_unk0x00; // 0x00
168+
LegoU8 m_unk0x01; // 0x01
169+
LegoU8 m_unk0x02; // 0x02
170+
LegoU8 m_unk0x03; // 0x03
171+
LegoU8 m_unk0x04; // 0x04
172+
LegoU8 m_unk0x05; // 0x05
173+
LegoU8 m_unk0x06; // 0x06
174+
LegoU8 m_unk0x07; // 0x07
175+
InputBindingEntry m_entries[5]; // 0x08
176+
};
177+
178+
// SIZE 0x42c
179+
struct PersistentState {
180+
void Clear() { ::memset(this, 0, sizeof(*this)); }
181+
182+
LegoU8 m_unk0x0c; // 0x000
183+
SerializedGuid m_displayDriverGuid; // 0x001
184+
undefined m_unk0x1d; // 0x011
185+
undefined m_unk0x1e; // 0x012
186+
LegoU8 m_unk0x1f; // 0x013
187+
LegoU8 m_unk0x20; // 0x014
188+
LegoU8 m_unk0x21; // 0x015
189+
LegoU8 m_languageIndex; // 0x016
190+
undefined m_unk0x23; // 0x017
191+
LegoU8 m_unk0x24; // 0x018
192+
LegoU8 m_unk0x25; // 0x019
193+
LegoU16 m_unk0x26; // 0x01a
194+
LegoU32 m_unk0x28[13]; // 0x01c
195+
LegoU32 m_unk0x5c[13]; // 0x050
196+
undefined2 m_unk0x90[13][14]; // 0x084
197+
undefined2 m_unk0x1fc[13][14]; // 0x1f0
198+
InputBindingState m_inputBindings; // 0x35c
199+
};
200+
201+
void Initialize();
202+
LegoU8 GetRegistryLanguageIndex();
203+
204+
undefined4 m_unk0x00; // 0x00
205+
undefined4 m_unk0x04; // 0x04
206+
InputManager* m_inputManager; // 0x08
207+
PersistentState m_state; // 0x0c
173208
};
174209

175210
// SIZE 0x250

LEGORacers/src/citrinegrove0x1f4c.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void CitrineGrove0x1f4c::FUN_004432e0(InputManager* p_inputManager, LegoBool32 p
3838
{
3939
char path[128];
4040

41-
m_unk0x18c4.FUN_0042e920(p_inputManager);
41+
m_unk0x18c4.Initialize(p_inputManager);
4242
if (g_searchPaths[0] != NULL) {
4343
::strcpy(path, g_searchPaths[0]);
4444
size_t len = strlen(path);

LEGORacers/src/input/inputmanager.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,15 @@ void InputManager::SuspendActiveDevices()
7575
m_mouse->Unacquire();
7676
}
7777
}
78+
79+
// FUNCTION: LEGORACERS 0x0044c0c0
80+
JoystickInputDevice* InputManager::FindJoystickByDeviceId(LegoS32 p_deviceId) const
81+
{
82+
for (LegoS32 i = 0; i < m_joystickCount; i++) {
83+
if (m_joysticks[i]->GetDeviceId() == p_deviceId) {
84+
return m_joysticks[i];
85+
}
86+
}
87+
88+
return NULL;
89+
}

LEGORacers/src/peridottrace0x4a8.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ undefined4 PeridotTrace0x4a8::FUN_00442770(GolFile& p_file)
3434
return 0;
3535
}
3636

37+
// STUB: LEGORACERS 0x00442c20
38+
void PeridotTrace0x4a8::FUN_00442c20(void*)
39+
{
40+
// TODO
41+
STUB(0x00442c20);
42+
}
43+
3744
// STUB: LEGORACERS 0x004437e0
3845
PeridotTrace0x4e0::PeridotTrace0x4e0()
3946
{

0 commit comments

Comments
 (0)