Skip to content

Commit e6137eb

Browse files
committed
DirectInput initialization
1 parent c49aaa3 commit e6137eb

25 files changed

Lines changed: 1789 additions & 127 deletions

CMakeLists.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ target_include_directories(goldp PRIVATE
125125
"${PROJECT_SOURCE_DIR}/util"
126126
)
127127
target_link_libraries(goldp PRIVATE
128-
ddraw
129-
dxguid
128+
ddraw
129+
dxguid
130130
)
131131

132132
set_property(TARGET goldp PROPERTY OUTPUT_NAME "GolDP")
@@ -171,11 +171,17 @@ add_executable(legoracers WIN32
171171
LEGORacers/src/imaginarytool0x368.cpp
172172
LEGORacers/src/imaginarywrench0x23bc.cpp
173173
LEGORacers/src/videoplayer.cpp
174+
LEGORacers/src/joystickdevice.cpp
175+
LEGORacers/src/keyboarddevice.cpp
176+
LEGORacers/src/mousedevice.cpp
177+
LEGORacers/src/directinputdevice.cpp
178+
LEGORacers/src/inputdevice.cpp
174179
LEGORacers/racers.rc
175180
util/decomp.cpp
176181
${COMMON_SOURCES}
177182
)
178183
target_compile_definitions(legoracers PRIVATE BUILDING_LEGORACERS)
184+
target_compile_definitions(legoracers PRIVATE DIRECTINPUT_VERSION=0x500)
179185
reccmp_add_target(legoracers ID LEGORACERS)
180186

181187
target_include_directories(legoracers PRIVATE
@@ -189,6 +195,7 @@ target_include_directories(legoracers PRIVATE
189195
target_link_libraries(legoracers PRIVATE
190196
dinput
191197
dsound
198+
dxguid
192199
ole32
193200
strmiids
194201
winmm

GolDP/src/fluffygloomkins0x118.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "fluffygloomkins0x118.h"
22

3-
DECOMP_SIZE_ASSERT(FluffyGloomkins, 0x118);
3+
DECOMP_SIZE_ASSERT(FluffyGloomkins, 0x118)
44

55
// STUB: GOLDP 0x10017190
66
FluffyGloomkins::FluffyGloomkins()

GolDP/src/smallcocoon0xc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
#include <stdlib.h>
66

7-
DECOMP_SIZE_ASSERT(SmallCocoon0xc, 0xc);
8-
DECOMP_SIZE_ASSERT(SmallCocoon0xc::Item, 0xc);
7+
DECOMP_SIZE_ASSERT(SmallCocoon0xc, 0xc)
8+
DECOMP_SIZE_ASSERT(SmallCocoon0xc::Item, 0xc)
99

1010
// FUNCTION: GOLDP 0x100281c0
1111
SmallCocoon0xc::SmallCocoon0xc()

GolDP/src/zoweeblubberworth0xf0.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "zoweeblubberworth0xf0.h"
22

3-
DECOMP_SIZE_ASSERT(ZoweeBlubberworth0xf0, 0xf0);
3+
DECOMP_SIZE_ASSERT(ZoweeBlubberworth0xf0, 0xf0)
44

55
// FUNCTION: GOLDP 0x1002c030
66
ZoweeBlubberworth0xf0::ZoweeBlubberworth0xf0()
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#ifndef DIRECTINPUTDEVICE_H
2+
#define DIRECTINPUTDEVICE_H
3+
4+
#include "compat.h"
5+
#include "decomp.h"
6+
#include "inputdevice.h"
7+
8+
#include <dinput.h>
9+
10+
struct CreateDirectInputDeviceParams {
11+
LPDIRECTINPUT m_dinput; // 0x00
12+
LPCDIDATAFORMAT m_dataFormat; // 0x04
13+
HWND m_hWnd; // 0x08
14+
const GUID* m_guid; // 0x0c
15+
undefined4 m_unk0x10; // 0x10
16+
OpalVault0xf0* m_opalVault; // 0x14
17+
};
18+
19+
// VTABLE: LEGORACERS 0x004b11b8
20+
// SIZE 0xcc
21+
class DirectInputDevice : public InputDevice {
22+
public:
23+
DirectInputDevice();
24+
25+
void VTable0x00() override;
26+
~DirectInputDevice() override;
27+
LegoBool32 VTable0x10() override;
28+
undefined4 VTable0x14(undefined4) override;
29+
30+
// FIXME: VTable0x18 and VTable0x1c are pure virtual in original executable?
31+
// virtual undefined4 VTable0x18();
32+
// virtual LegoS32 VTable0x1c();
33+
undefined2* VTable0x24(undefined4) override;
34+
LegoFloat VTable0x2c(undefined4) override;
35+
undefined4 VTable0x38() override;
36+
undefined4 VTable0x3c() override;
37+
undefined4 VTable0x40() override;
38+
undefined4 VTable0x44() override;
39+
// FUNCTION: LEGORACERS 0x0044f220 FOLDED
40+
undefined4 VTable0x48() override { return m_cooperativeLevel & DISCL_BACKGROUND; }
41+
42+
// FUNCTION: LEGORACERS 0x0044f230 FOLDED
43+
undefined4 VTable0x4c() override { return m_cooperativeLevel & DISCL_EXCLUSIVE; }
44+
undefined4 VTable0x50() override;
45+
undefined4 VTable0x54() override;
46+
LegoBool32 VTable0x58() override;
47+
LegoS32 VTable0x5c() override;
48+
LegoBool32 VTable0x60() override;
49+
virtual LegoBool32 VTable0x64(CreateDirectInputDeviceParams* p_params);
50+
virtual void VTable0x68(const DIDEVICEOBJECTDATA& p_data) = 0;
51+
52+
void FUN_0044ff50(undefined4);
53+
54+
// SYNTHETIC: LEGORACERS 0x0044f9e0
55+
// DirectInputDevice::`scalar deleting destructor'
56+
57+
const GUID& GetGuid() const { return m_deviceGuid; }
58+
59+
protected:
60+
void FUN_0044fa50();
61+
void FUN_0044faa0();
62+
void FUN_0044fb30();
63+
undefined4 FUN_0044fda0(const GUID& p_guid) const;
64+
LegoBool32 FUN_0044fef0();
65+
undefined4 FUN_00450170(HRESULT p_hResult);
66+
67+
undefined4 m_unk0x9c; // 0x9c
68+
LPDIRECTINPUTDEVICE2A m_device; // 0xa0
69+
HWND m_hWnd; // 0xa4
70+
LPDIRECTINPUTEFFECT m_effect; // 0xa8
71+
undefined4 m_unk0xac; // 0xac
72+
GUID m_deviceGuid; // 0xb0
73+
DWORD m_cooperativeLevel; // 0xc0
74+
undefined2* m_unk0xc4; // 0xc4
75+
undefined2* m_unk0xc8; // 0xc8
76+
};
77+
78+
#endif // DIRECTINPUTDEVICE_H

LEGORacers/include/inputdevice.h

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
#ifndef INPUTDEVICE_H
2+
#define INPUTDEVICE_H
3+
4+
#include "decomp.h"
5+
#include "types.h"
6+
7+
class OpalVault0xf0;
8+
9+
class InputDevice;
10+
11+
class InputCallback {
12+
public:
13+
virtual void OnKeyDown(InputDevice& p_device, undefined2 p_keyCode) = 0; // vtable+0x00
14+
virtual void OnKeyUp(InputDevice& p_device, undefined2 p_keyCode) = 0; // vtable+0x04
15+
};
16+
17+
// VTABLE: LEGORACERS 0x004b0e9c
18+
// SIZE 0x9c
19+
class InputDevice {
20+
public:
21+
22+
enum {
23+
SOURCE_KEYBOARD = 0x10000000,
24+
SOURCE_MOUSE = 0x20000000,
25+
SOURCE_JOYSTICK1 = 0x30000000,
26+
SOURCE_JOYSTICK2 = 0x40000000,
27+
SOURCE_MASK = 0xf0000000,
28+
};
29+
30+
static inline LegoU32 GetKeySource(LegoU32 p_event)
31+
{
32+
return p_event & SOURCE_MASK;
33+
}
34+
35+
static inline LegoU32 MakeEvent(LegoU32 p_source, LegoU32 p_value)
36+
{
37+
return p_source | p_value;
38+
}
39+
40+
InputDevice();
41+
virtual void VTable0x00();
42+
virtual void VTable0x04(undefined4, LegoBool p_arg2, LegoBool32);
43+
virtual void VTable0x08(undefined4, LegoFloat) = 0;
44+
virtual ~InputDevice();
45+
virtual LegoBool32 VTable0x10();
46+
virtual undefined4 VTable0x14(undefined4);
47+
virtual undefined4 VTable0x18();
48+
virtual LegoS32 VTable0x1c();
49+
virtual undefined4 VTable0x20();
50+
virtual undefined2* VTable0x24(undefined4);
51+
virtual void VTable0x28(undefined4) = 0;
52+
virtual LegoFloat VTable0x2c(undefined4) = 0;
53+
virtual LegoFloat VTable0x30(undefined4) = 0;
54+
virtual undefined4 VTable0x34(undefined4) = 0;
55+
virtual undefined4 VTable0x38() = 0;
56+
virtual undefined4 VTable0x3c() = 0;
57+
virtual undefined4 VTable0x40() = 0;
58+
virtual undefined4 VTable0x44() = 0;
59+
virtual undefined4 VTable0x48() = 0;
60+
virtual undefined4 VTable0x4c() = 0;
61+
virtual undefined4 VTable0x50();
62+
virtual undefined4 VTable0x54();
63+
virtual LegoBool32 VTable0x58() = 0;
64+
virtual LegoS32 VTable0x5c() = 0;
65+
virtual LegoBool32 VTable0x60() = 0;
66+
67+
void FUN_0044b9f0();
68+
void FUN_0044bab0(undefined4 p_arg1, undefined4 p_arg2);
69+
void FUN_0044bad0(const LegoChar* p_str);
70+
void FUN_0044baf0(undefined2* p_arg1, undefined2* p_arg2);
71+
undefined2* FUN_0044bb20();
72+
undefined2* FUN_0044bb40();
73+
void FUN_0044bb60(float p_arg1, float p_arg2, undefined4 p_arg3);
74+
void FUN_0044bc60(undefined4);
75+
void FUN_0044bda0();
76+
void FUN_0044bdf0(undefined4 p_arg);
77+
LegoBool32 FUN_0044be10(undefined4);
78+
undefined2 FUN_0044be70(const LegoChar*);
79+
80+
const LegoBool32 GetUnk0x18() const { return m_unk0x18; }
81+
void SetUnk0x28(undefined4 p_arg) { m_unk0x28 = p_arg; }
82+
83+
// SYNTHETIC: LEGORACERS 0x0044b920
84+
// InputDevice::`scalar deleting destructor'
85+
86+
protected:
87+
undefined4 m_unk0x04[4]; // 0x04
88+
OpalVault0xf0* m_opalVault; // 0x14
89+
LegoBool32 m_unk0x18; // 0x18
90+
undefined4 m_unk0x1c; // 0x1c
91+
undefined4 m_unk0x20; // 0x20
92+
undefined4 m_unk0x24; // 0x24
93+
undefined4 m_unk0x28; // 0x28
94+
undefined2* m_unk0x2c; // 0x2c
95+
undefined2* m_unk0x30; // 0x30
96+
undefined4 m_unk0x34; // 0x34
97+
undefined4 m_unk0x38; // 0x38
98+
undefined4 m_unk0x3c; // 0x3c
99+
undefined4 m_unk0x40; // 0x40
100+
undefined4 m_unk0x44; // 0x44
101+
undefined4 m_buttonCount; // 0x48
102+
undefined4 m_axisCount; // 0x4c
103+
LegoS32 m_unk0x50; // 0x50
104+
undefined4 m_devSubType; // 0x54
105+
undefined4 m_devType; // 0x58
106+
undefined4 m_unk0x5c; // 0x5c
107+
LegoChar m_unk0x60[32]; // 0x60
108+
undefined m_unk0x80[0x90 - 0x80]; // 0x80
109+
undefined4 m_unk0x90; // 0x90
110+
undefined2* m_unk0x94; // 0x94
111+
InputCallback* m_callback; // 0x98
112+
};
113+
114+
#include "compat.h"
115+
116+
#include <dinput.h>
117+
#include <windows.h>
118+
119+
#endif // INPUTDEVICE_H

LEGORacers/include/jasperauxinterface.h

Lines changed: 0 additions & 28 deletions
This file was deleted.

LEGORacers/include/jaspercore0xf0.h

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
#define JASPERCORE0XF0_H
33

44
#include "decomp.h"
5-
#include "jasperauxinterface.h"
65
#include "types.h"
76

87
#include <dinput.h>
98

9+
class JoystickInputDevice;
10+
class KeyboardInputDevice;
11+
class MouseInputDevice;
12+
1013
// VTABLE: LEGORACERS 0x004b0f00
1114
// SIZE 0xf0
1215
class JasperCore0xf0 {
@@ -18,36 +21,32 @@ class JasperCore0xf0 {
1821
virtual LegoS32 Init() = 0; // vtable+0x0c
1922
virtual LegoS32 VTable0x10(LegoS32) = 0; // vtable+0x10
2023
virtual LegoS32 VTable0x14() = 0; // vtable+0x14
21-
virtual LegoS32 VTable0x18(); // vtable+0x18
22-
virtual LegoS32 VTable0x1c(); // vtable+0x1c
23-
virtual LegoS32 VTable0x20(); // vtable+0x20
24-
virtual void VTable0x24(); // vtable+0x24
2524

2625
// SYNTHETIC: LEGORACERS 0x0044bf40
2726
// JasperCore0xf0::`scalar deleting destructor'
2827

29-
JasperAuxInterface* GetUnk0xa0() { return m_unk0xa0; }
28+
MouseInputDevice* GetMouse() { return m_mouse; }
3029

3130
void FUN_0044bfd0();
3231
void FUN_0044c040();
3332

3433
protected:
35-
undefined m_unk0x04[0x40]; // 0x04
36-
undefined4 m_unk0x44; // 0x44
37-
undefined4 m_unk0x48; // 0x48
38-
undefined m_unk0x4c[0x40]; // 0x4c
39-
undefined4 m_unk0x8c; // 0x8c
40-
undefined4 m_unk0x90; // 0x90
41-
undefined4 m_unk0x94; // 0x94
42-
undefined4 m_unk0x98; // 0x98
43-
undefined4 m_unk0x9c; // 0x9c
44-
JasperAuxInterface* m_unk0xa0; // 0xa0
34+
undefined m_unk0x04[0x40]; // 0x04
35+
undefined4 m_unk0x44; // 0x44
36+
undefined4 m_unk0x48; // 0x48
37+
undefined m_unk0x4c[0x40]; // 0x4c
38+
undefined4 m_unk0x8c; // 0x8c
39+
undefined4 m_unk0x90; // 0x90
40+
undefined4 m_unk0x94; // 0x94
41+
LegoS32 m_unk0x98; // 0x98
42+
KeyboardInputDevice* m_keyboard; // 0x9c
43+
MouseInputDevice* m_mouse; // 0xa0
4544

4645
protected:
47-
undefined m_unk0xa4[0x40]; // 0xa4
48-
LPDIRECTINPUT m_directInput; // 0xe4
49-
undefined m_unk0xe8[0xec - 0xe8]; // 0xe8
50-
undefined4 m_unk0xec; // 0xec
46+
JoystickInputDevice* m_joysticks[16]; // 0xa4
47+
LPDIRECTINPUT m_directInput; // 0xe4
48+
undefined m_unk0xe8[0xec - 0xe8]; // 0xe8
49+
HWND m_hWnd; // 0xec
5150
};
5251

5352
#endif // JASPERCORE0XF0_H

0 commit comments

Comments
 (0)