Skip to content

Commit a6e0baf

Browse files
committed
Matches
1 parent 3b220eb commit a6e0baf

4 files changed

Lines changed: 49 additions & 24 deletions

File tree

LEGORacers/include/onyxcircularbuffer0x1c.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
// VTABLE: LEGORACERS 0x004b0e84
1010
class OnyxCircularBuffer0x1c : public InputDevice::Callback {
1111
public:
12-
OnyxCircularBuffer0x1c();
13-
1412
struct Item {
1513
InputDevice* m_device; // 0x00
1614
undefined4 m_keyCode; // 0x04
@@ -20,11 +18,13 @@ class OnyxCircularBuffer0x1c : public InputDevice::Callback {
2018
undefined m_unk0x0e[0x10 - 0xe]; // 0x0e
2119
};
2220

21+
OnyxCircularBuffer0x1c();
22+
2323
void OnKeyDown(InputDevice* p_device, undefined4 p_keyCode, undefined4 p_arg3) override; // vtable+0x00
2424
void OnKeyUp(InputDevice* p_device, undefined4 p_keyCode, undefined4 p_arg3) override; // vtable+0x04
2525
void OnKeyRepeat(InputDevice* p_device, undefined4 p_keyCode, undefined4 p_arg3) override; // vtable+0x08
2626
virtual ~OnyxCircularBuffer0x1c(); // vtable+0x0c
27-
virtual void Allocate(LegoS32 p_capacity); // vtable+0x10
27+
virtual LegoBool32 Allocate(LegoS32 p_capacity); // vtable+0x10
2828
virtual LegoBool32 Reset(); // vtable+0x14
2929

3030
void FUN_0044b740();

LEGORacers/src/input/inputdevice.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ LegoBool32 InputDevice::DirectionalTrigger::DispatchRepeatEvent(LegoU32 p_time,
463463
{
464464
if (m_currentDirection) {
465465
Callback* callback = p_device->m_callback;
466+
466467
callback->OnKeyRepeat(p_device, MakeDirectionEvent(m_currentDirection), p_time);
467468
}
468469

LEGORacers/src/onyxbreeze0x248.cpp

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,37 +26,45 @@ void OnyxBreeze0x248::Initialize(InputManager* p_inputManager)
2626
if (m_inputManager != NULL) {
2727
Shutdown();
2828
}
29+
2930
m_inputManager = p_inputManager;
3031
m_unk0x208.Allocate(32);
32+
3133
KeyboardInputDevice* keyboard = m_inputManager->GetKeyboard();
3234
if (keyboard != NULL) {
3335
keyboard->SetCallback(&m_unk0x208);
3436
keyboard->SetRepeatDelays(250, 500);
3537
keyboard->Acquire();
3638
}
37-
m_mouse = m_inputManager->GetMouse();
38-
if (m_mouse != NULL) {
39-
m_mouse->SetCallback(&m_unk0x208);
40-
m_mouse->SetRepeatDelays(250, 500);
41-
m_mouse->SetExclusiveMode();
42-
m_mouse->Acquire();
39+
40+
MouseInputDevice* mouse = m_inputManager->GetMouse();
41+
m_mouse = mouse;
42+
if (mouse != NULL) {
43+
mouse->SetCallback(&m_unk0x208);
44+
mouse->SetRepeatDelays(250, 500);
45+
mouse->SetExclusiveMode();
46+
mouse->Acquire();
4347
}
48+
4449
for (LegoS32 i = 0; i < m_inputManager->GetJoystickCount(); i++) {
4550
JoystickInputDevice* joystick = m_inputManager->GetJoystick(i);
46-
joystick->SetCallback(&m_unk0x208);
47-
joystick->SetAxisButtonEventsEnabled(TRUE);
48-
joystick->Acquire();
49-
joystick->SetRepeatDelays(250, 500);
50-
joystick->SetDeadZonePercent(60);
51-
LegoS32 sourceId = joystick->AddDirectionalTrigger(&m_unk0x224);
52-
m_unk0x224.Configure(
53-
sourceId,
54-
InputDevice::c_sourceJoystick2 | 0x3,
55-
InputDevice::c_sourceJoystick2 | 0x0,
56-
InputDevice::c_sourceJoystick2 | 0x2,
57-
InputDevice::c_sourceJoystick2 | 0x1
58-
);
51+
if (joystick != NULL) {
52+
joystick->SetCallback(&m_unk0x208);
53+
joystick->SetAxisButtonEventsEnabled(TRUE);
54+
joystick->Acquire();
55+
joystick->SetRepeatDelays(250, 500);
56+
joystick->SetDeadZonePercent(60);
57+
LegoS32 sourceId = joystick->AddDirectionalTrigger(&m_unk0x224);
58+
m_unk0x224.Configure(
59+
sourceId,
60+
InputDevice::c_sourceJoystick2 | 0x3,
61+
InputDevice::c_sourceJoystick2 | 0x0,
62+
InputDevice::c_sourceJoystick2 | 0x2,
63+
InputDevice::c_sourceJoystick2 | 0x1
64+
);
65+
}
5966
}
67+
6068
FUN_0041fac0();
6169
}
6270

@@ -65,12 +73,14 @@ void OnyxBreeze0x248::Shutdown()
6573
{
6674
if (m_inputManager != NULL) {
6775
KeyboardInputDevice* keyboard = m_inputManager->GetKeyboard();
76+
6877
if (keyboard != NULL) {
6978
keyboard->SetCallback(NULL);
7079
keyboard->Unacquire();
7180
keyboard->SetRepeatEnabled(FALSE);
7281
keyboard->SetEventMappings(NULL, NULL);
7382
}
83+
7484
MouseInputDevice* mouse = m_inputManager->GetMouse();
7585
if (mouse != NULL) {
7686
mouse->SetCallback(NULL);
@@ -79,8 +89,10 @@ void OnyxBreeze0x248::Shutdown()
7989
mouse->SetRepeatEnabled(FALSE);
8090
m_mouse = NULL;
8191
}
92+
8293
for (LegoS32 i = 0; i < m_inputManager->GetJoystickCount(); i++) {
8394
JoystickInputDevice* joystick = m_inputManager->GetJoystick(i);
95+
8496
if (joystick != NULL) {
8597
joystick->SetCallback(NULL);
8698
joystick->Unacquire();
@@ -90,6 +102,7 @@ void OnyxBreeze0x248::Shutdown()
90102
joystick->RemoveDirectionalTrigger(&m_unk0x224);
91103
}
92104
}
105+
93106
m_unk0x208.Reset();
94107
m_inputManager = NULL;
95108
m_mouse = NULL;
@@ -107,10 +120,12 @@ void OnyxBreeze0x248::FUN_0041fac0()
107120
{
108121
for (LegoS32 i = 0; i < m_inputManager->GetJoystickCount(); i++) {
109122
JoystickInputDevice* joystick = m_inputManager->GetJoystick(i);
123+
110124
if (joystick != NULL) {
111125
for (LegoS32 j = 0; j < joystick->GetButtonCountFast(); j++) {
112126
m_unk0x004[j] = 4;
113127
}
128+
114129
joystick->SetEventMappings(m_unk0x004, NULL);
115130
}
116131
}

LEGORacers/src/onyxcircularbuffer0x1c.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,19 @@ void OnyxCircularBuffer0x1c::FUN_0044b740()
2828
}
2929

3030
// FUNCTION: LEGORACERS 0x0044b760
31-
void OnyxCircularBuffer0x1c::Allocate(LegoS32 p_capacity)
31+
LegoBool32 OnyxCircularBuffer0x1c::Allocate(LegoS32 p_capacity)
3232
{
3333
Reset();
34+
3435
m_items = new Item[p_capacity];
3536
if (m_items == NULL) {
3637
GOL_FATALERROR(c_golErrorOutOfMemory);
3738
}
39+
3840
::memset(m_items, 0, sizeof(Item) * p_capacity);
3941
m_capacity = p_capacity;
40-
m_capacity = TRUE;
42+
m_allocated = TRUE;
43+
return TRUE;
4144
}
4245

4346
// FUNCTION: LEGORACERS 0x0044b7c0
@@ -47,8 +50,10 @@ LegoBool32 OnyxCircularBuffer0x1c::Reset()
4750
if (m_items != NULL) {
4851
delete[] m_items;
4952
}
53+
5054
FUN_0044b740();
5155
}
56+
5257
return TRUE;
5358
}
5459

@@ -59,6 +64,7 @@ OnyxCircularBuffer0x1c::Item* OnyxCircularBuffer0x1c::FUN_0044b7f0()
5964
if (m_size == 0) {
6065
return NULL;
6166
}
67+
6268
m_readPos += 1;
6369
m_readPos %= m_capacity;
6470
m_size -= 1;
@@ -76,6 +82,7 @@ OnyxCircularBuffer0x1c::Item* OnyxCircularBuffer0x1c::FUN_0044b820(
7682
if (m_size == m_capacity) {
7783
return NULL;
7884
}
85+
7986
item->m_device = p_device;
8087
item->m_keyCode = p_keyCode;
8188
item->m_unk0x08 = p_arg3;
@@ -92,6 +99,7 @@ OnyxCircularBuffer0x1c::Item* OnyxCircularBuffer0x1c::FUN_0044b820(
9299
void OnyxCircularBuffer0x1c::OnKeyDown(InputDevice* p_device, undefined4 p_keyCode, undefined4 p_arg3)
93100
{
94101
Item* item = FUN_0044b820(p_device, p_keyCode, p_arg3);
102+
95103
if (item != NULL) {
96104
item->m_unk0x0c = TRUE;
97105
}
@@ -107,6 +115,7 @@ void OnyxCircularBuffer0x1c::OnKeyUp(InputDevice* p_device, undefined4 p_keyCode
107115
void OnyxCircularBuffer0x1c::OnKeyRepeat(InputDevice* p_device, undefined4 p_keyCode, undefined4 p_arg3)
108116
{
109117
Item* item = FUN_0044b820(p_device, p_keyCode, p_arg3);
118+
110119
if (item != NULL) {
111120
item->m_unk0x0c = TRUE;
112121
item->m_unk0x0d = TRUE;

0 commit comments

Comments
 (0)