summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authoreray orçunus <erayorcunus@gmail.com>2020-08-16 16:10:59 +0200
committereray orçunus <erayorcunus@gmail.com>2020-08-16 16:10:59 +0200
commit980dd1b5a17440e9a272b7b47ad3553cd1ce11ff (patch)
treef0bc6cfc1030f3eaf25c53b4e22db3717fc49074 /src/core
parentMerge branch 'master' into miami (diff)
downloadre3-980dd1b5a17440e9a272b7b47ad3553cd1ce11ff.tar
re3-980dd1b5a17440e9a272b7b47ad3553cd1ce11ff.tar.gz
re3-980dd1b5a17440e9a272b7b47ad3553cd1ce11ff.tar.bz2
re3-980dd1b5a17440e9a272b7b47ad3553cd1ce11ff.tar.lz
re3-980dd1b5a17440e9a272b7b47ad3553cd1ce11ff.tar.xz
re3-980dd1b5a17440e9a272b7b47ad3553cd1ce11ff.tar.zst
re3-980dd1b5a17440e9a272b7b47ad3553cd1ce11ff.zip
Diffstat (limited to '')
-rw-r--r--src/core/Pad.cpp27
-rw-r--r--src/core/Pad.h4
2 files changed, 26 insertions, 5 deletions
diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp
index 6d6c30e4..222fe349 100644
--- a/src/core/Pad.cpp
+++ b/src/core/Pad.cpp
@@ -631,6 +631,11 @@ void CPad::Clear(bool bResetPlayerControls)
ShakeFreq = 0;
ShakeDur = 0;
+ for (int32 i = 0; i < DRUNK_STEERING_BUFFER_SIZE; i++)
+ SteeringLeftRightBuffer[i] = 0;
+
+ DrunkDrivingBufferUsed = 0;
+
if ( bResetPlayerControls )
DisablePlayerControls = PLAYERCONTROL_ENABLED;
@@ -1806,6 +1811,9 @@ void CPad::Update(int16 pad)
bHornHistory[iCurrHornHistory] = GetHorn();
+ for (int32 i = DRUNK_STEERING_BUFFER_SIZE - 2; i >= 0; i--) {
+ SteeringLeftRightBuffer[i + 1] = SteeringLeftRightBuffer[i];
+ }
if ( !bDisplayNoControllerMessage )
CGame::bDemoMode = false;
@@ -1899,6 +1907,7 @@ int16 CPad::GetSteeringLeftRight(void)
if ( ArePlayerControlsDisabled() )
return 0;
+ int16 value;
switch (CURMODE)
{
case 0:
@@ -1908,9 +1917,12 @@ int16 CPad::GetSteeringLeftRight(void)
int16 dpad = (NewState.DPadRight - NewState.DPadLeft) / 2;
if ( Abs(axis) > Abs(dpad) )
- return axis;
+ value = axis;
else
- return dpad;
+ value = dpad;
+
+ SteeringLeftRightBuffer[0] = value;
+ value = SteeringLeftRightBuffer[DrunkDrivingBufferUsed];
break;
}
@@ -1918,13 +1930,18 @@ int16 CPad::GetSteeringLeftRight(void)
case 1:
case 3:
{
- return NewState.LeftStickX;
-
+ SteeringLeftRightBuffer[0] = NewState.LeftStickX;
+ value = SteeringLeftRightBuffer[DrunkDrivingBufferUsed];
+ break;
+ }
+ default:
+ {
+ value = 0;
break;
}
}
- return 0;
+ return value;
}
int16 CPad::GetSteeringUpDown(void)
diff --git a/src/core/Pad.h b/src/core/Pad.h
index 4374bc1a..72851317 100644
--- a/src/core/Pad.h
+++ b/src/core/Pad.h
@@ -141,9 +141,12 @@ public:
enum
{
HORNHISTORY_SIZE = 5,
+ DRUNK_STEERING_BUFFER_SIZE = 10,
};
CControllerState NewState;
CControllerState OldState;
+ int16 SteeringLeftRightBuffer[DRUNK_STEERING_BUFFER_SIZE];
+ int32 DrunkDrivingBufferUsed;
CControllerState PCTempKeyState;
CControllerState PCTempJoyState;
CControllerState PCTempMouseState;
@@ -263,6 +266,7 @@ public:
static char *EditString(char *pStr, int32 nSize);
static int32 *EditCodesForControls(int32 *pRsKeys, int32 nSize);
uint32 InputHowLongAgo(void);
+ void SetDrunkInputDelay(int32 delay) { DrunkDrivingBufferUsed = delay; }
#ifdef XINPUT
void AffectFromXinput(uint32 pad);