Skip to content
This repository has been archived by the owner on Aug 17, 2024. It is now read-only.

Commit

Permalink
Change wheel's toggle mod button to delay
Browse files Browse the repository at this point in the history
JustPressed returns true after mod is toggled and user hasn't magically
removed their finger before the next tick. So it keeps
enabling/disabling everything.
  • Loading branch information
ikt32 committed Sep 26, 2017
1 parent de71467 commit 56907df
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Gears/Input/ScriptControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,12 +426,12 @@ bool ScriptControls::ButtonReleased(WheelControlType control) {
return false;
}

bool ScriptControls::ButtonHeld(WheelControlType control) {
bool ScriptControls::ButtonHeld(WheelControlType control, int delay) {
if (!WheelControl.IsConnected(WheelButtonGUIDs[static_cast<int>(control)]) ||
WheelButton[static_cast<int>(control)] == -1) {
return false;
}
if (WheelControl.WasButtonHeldForMs(WheelButton[static_cast<int>(control)], WheelButtonGUIDs[static_cast<int>(control)], WButtonHeld))
if (WheelControl.WasButtonHeldForMs(WheelButton[static_cast<int>(control)], WheelButtonGUIDs[static_cast<int>(control)], delay))
return true;
return false;
}
Expand Down
3 changes: 1 addition & 2 deletions Gears/Input/ScriptControls.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class ScriptControls {
// Wheel controls
bool ButtonJustPressed(WheelControlType control);
bool ButtonReleased(WheelControlType control);
bool ButtonHeld(WheelControlType control);
bool ButtonHeld(WheelControlType control, int delay);
bool ButtonIn(WheelControlType control);
void CheckCustomButtons(bool justPeeking);
void StopForceFeedback();
Expand All @@ -201,7 +201,6 @@ class ScriptControls {
int SteerRight = 0;
int HandbrakeUp = 0;
int HandbrakeDown = 0;
int WButtonHeld = 1000;
int MaxTapTime = 200;

bool InvertSteer = false;
Expand Down
6 changes: 3 additions & 3 deletions Gears/script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ void update() {
}

if (controls.ButtonJustPressed(ScriptControls::KeyboardControlType::Toggle) ||
controls.ButtonJustPressed(ScriptControls::WheelControlType::Toggle) ||
controls.ButtonHeld(ScriptControls::WheelControlType::Toggle, 500) ||
controls.ButtonHeld(ScriptControls::ControllerControlType::Toggle) ||
controls.PrevInput == ScriptControls::Controller && controls.ButtonHeld(ScriptControls::LegacyControlType::Toggle)) {
toggleManual();
Expand Down Expand Up @@ -1991,8 +1991,8 @@ void handleVehicleButtons() {
}


if (controls.ButtonHeld(ScriptControls::WheelControlType::RadioPrev) ||
controls.ButtonHeld(ScriptControls::WheelControlType::RadioNext)) {
if (controls.ButtonHeld(ScriptControls::WheelControlType::RadioPrev, 1000) ||
controls.ButtonHeld(ScriptControls::WheelControlType::RadioNext, 1000)) {
if (AUDIO::GET_PLAYER_RADIO_STATION_INDEX() != RadioOff) {
vehData.RadioStationIndex = AUDIO::GET_PLAYER_RADIO_STATION_INDEX();
}
Expand Down

0 comments on commit 56907df

Please sign in to comment.