Skip to content

Commit 5028f30

Browse files
authored
Revert gamepad analog accel/brake back to face buttons (#19)
PR #17 bundled a gamepad change alongside the touch controls: it enabled analog stick-Y throttle for every joystick (the original only did so for the SideWinder Force Feedback Pro whitelist), which put accelerate/brake on the same thumbstick as steering. On a kart racer that couples the two — the stick's circular gate means you cannot floor the throttle and steer fully at the same time — so restore accelerate/brake to face buttons. Reverts the four analog-throttle chunks from #17: - PlayerControls::DetectAnalogDevice no longer force-enables analog throttle for any joystick (SideWinder whitelist only, as before). - PlayerControls::UpdateThrottle reads the throttle axis from the throttle slot again, not the steer slot. - ControlConfigScreen no longer greys out or axis-labels the accel/brake rows for gamepads, so they are bindable buttons again. All four functions now byte-match the decomp. Touch controls are unaffected (separate hooks in the same files). The versus stick-throttle fix (442792a) is subsumed: that bug only existed because of the analog-for-all-gamepads behavior being removed here.
1 parent eded9b3 commit 5028f30

2 files changed

Lines changed: 1 addition & 46 deletions

File tree

LEGORacers/src/menu/screens/controlconfigscreen.cpp

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,6 @@ void ControlConfigScreen::RefreshEventTexts()
256256
if (!(m_eventButtons[i].GetStateFlags() & MenuIcon::c_flagFocused)) {
257257
LegoU32 event = state.GetInputEvent(m_playerIndex, m_bindingIndices[m_selectedDevice], i);
258258

259-
// [library:input] Joystick accelerate/brake are analog (stick Y, see
260-
// PlayerControls::DetectAnalogDevice) like the steering pair: show the
261-
// axis name even over a leftover button binding.
262-
if (i >= 2 && i < 4 && m_devices[m_selectedDevice]->GetDeviceType() == 4) {
263-
event = 0;
264-
}
265-
266259
if (event) {
267260
InputDevice* device;
268261
if ((event & InputDevice::c_sourceMask) == InputDevice::c_sourceKeyboard) {
@@ -285,18 +278,6 @@ void ControlConfigScreen::RefreshEventTexts()
285278
m_eventTexts[i].ToUpperCase();
286279
}
287280
}
288-
// [library:input] Accelerate/brake rows: the stick's Y axis (axis-button
289-
// event 2) drives them on gamepads.
290-
else if (i < 4) {
291-
InputDevice* device = m_devices[m_selectedDevice];
292-
if (device->GetDeviceType() == 4 && (device->GetAxisMask() & 2)) {
293-
m_eventTexts[i].CopyFromBufSelection(
294-
(undefined2*) device->GetControlName(InputDevice::c_sourceJoystickAxisButton + 2),
295-
0
296-
);
297-
m_eventTexts[i].ToUpperCase();
298-
}
299-
}
300281
}
301282

302283
m_eventButtons[i].SetText(&m_eventTexts[i]);
@@ -311,17 +292,10 @@ LegoBool32 ControlConfigScreen::Update(undefined4 p_source)
311292
if (m_devices[m_selectedDevice]->GetDeviceType() == 3) {
312293
m_eventButtons[0].Enable(0);
313294
m_eventButtons[1].Enable(0);
314-
m_eventButtons[2].Enable(0);
315-
m_eventButtons[3].Enable(0);
316295
}
317296
else {
318297
m_eventButtons[0].Disable(0);
319298
m_eventButtons[1].Disable(0);
320-
// [library:input] Accelerate/brake ride the stick's Y axis on gamepads (see
321-
// PlayerControls::DetectAnalogDevice), matching how steering rides X — grey
322-
// their rows out like the steering pair.
323-
m_eventButtons[2].Disable(0);
324-
m_eventButtons[3].Disable(0);
325299
}
326300

327301
return MenuGameScreen::Update(p_source);

LEGORacers/src/race/playercontrols.cpp

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,7 @@ void PlayerControls::UpdateThrottle()
236236
LegoFloat reverseValue = 0.0f;
237237
DirectInputDevice* source;
238238

239-
// [library:input] Read the throttle axis from the steer slot's device (always the
240-
// gamepad on a joystick binding), not the throttle slot's: rebinding a button that
241-
// collides with the hidden accel/brake defaults makes the game refill slot 2 with a
242-
// keyboard event (entry 0) or nothing, and the original slot-2 read would then poll
243-
// an axis-less device and stick throttle would silently die.
244-
m_input.GetBinding(&source, 0);
239+
m_input.GetBinding(&source, 2);
245240
if (m_input.m_analogThrottle) {
246241
LegoFloat analogValue = -source->GetAxisValue(2);
247242
if (analogValue < 0.0f) {
@@ -534,20 +529,6 @@ LegoS32 PlayerControls::DetectAnalogDevice()
534529
m_input.m_analogThrottle = TRUE;
535530
}
536531

537-
// [library:input] The original only trusted its SideWinder whitelist with an
538-
// analog Y axis; every SDL gamepad has one. Enable analog throttle (stick
539-
// forward/back in UpdateThrottle) whenever the steer slot reads a joystick, so
540-
// one thumbstick drives steering and speed together. The steer slot is the
541-
// anchor because the throttle slot's device is not stable: rebinding a button
542-
// that collides with the hidden accel/brake defaults refills slot 2 with a
543-
// keyboard event (entry 0's fallback) or clears it, which must not turn the
544-
// stick throttle off.
545-
DirectInputDevice* throttleSource;
546-
m_input.GetBinding(&throttleSource, 0);
547-
if (throttleSource && throttleSource->GetDeviceType() == 4) {
548-
m_input.m_analogThrottle = TRUE;
549-
}
550-
551532
return result;
552533
}
553534

0 commit comments

Comments
 (0)