diff --git a/stepmania/src/InputFilter.cpp b/stepmania/src/InputFilter.cpp index 14eab8c907..42b085fac3 100644 --- a/stepmania/src/InputFilter.cpp +++ b/stepmania/src/InputFilter.cpp @@ -23,6 +23,13 @@ InputFilter* INPUTFILTER = NULL; // global and accessable from anywhere in our p InputFilter::InputFilter() { queuemutex = new RageMutex; + memset( m_BeingHeld, 0, sizeof(m_BeingHeld) ); + memset( m_BeingForced, 0, sizeof(m_BeingForced) ); + memset( m_fSecsHeld, 0, sizeof(m_fSecsHeld) ); + for( int d=0; dUpdate( fDeltaTime ); /* Make sure that nothing gets inserted while we do this, to prevent @@ -70,7 +128,16 @@ void InputFilter::Update(float fDeltaTime) { for( int b=0; b < NUM_DEVICE_BUTTONS; b++ ) // foreach button { - if(!m_BeingHeld[d][b]) + DeviceInput di( (InputDevice)d,b,now); + + if( m_fSecsToForce[d][b] > 0 ) + { + m_fSecsToForce[d][b] -= fDeltaTime; + if( m_fSecsToForce[d][b] <= 0 ) + StopForcingKey( di ); + } + + if( !IsBeingPressed(di) ) continue; const float fOldHoldTime = m_fSecsHeld[d][b]; @@ -93,8 +160,6 @@ void InputFilter::Update(float fDeltaTime) } if( int(fOldHoldTime/fTimeBetweenRepeats) != int(fNewHoldTime/fTimeBetweenRepeats) ) { - RageTimer now; - DeviceInput di( (InputDevice)d,b,now); queue.push_back( InputEvent(di,iet) ); } } @@ -105,7 +170,7 @@ void InputFilter::Update(float fDeltaTime) bool InputFilter::IsBeingPressed( DeviceInput di ) { - return m_BeingHeld[di.device][di.button]; + return m_BeingHeld[di.device][di.button] || m_BeingForced[di.device][di.button]; } float InputFilter::GetSecsHeld( DeviceInput di ) diff --git a/stepmania/src/InputFilter.h b/stepmania/src/InputFilter.h index 9ff66a5370..c5f9f07c59 100644 --- a/stepmania/src/InputFilter.h +++ b/stepmania/src/InputFilter.h @@ -39,11 +39,17 @@ class RageMutex; class InputFilter { bool m_BeingHeld[NUM_INPUT_DEVICES][NUM_DEVICE_BUTTONS]; + bool m_BeingForced[NUM_INPUT_DEVICES][NUM_DEVICE_BUTTONS]; float m_fSecsHeld[NUM_INPUT_DEVICES][NUM_DEVICE_BUTTONS]; + /* If > 0, then when it reaches 0, stop forcing. */ + float m_fSecsToForce[NUM_INPUT_DEVICES][NUM_DEVICE_BUTTONS]; InputEventArray queue; RageMutex *queuemutex; + void ForceKey( DeviceInput di, float duration ); + void StopForcingKey( DeviceInput di ); + public: void ButtonPressed( DeviceInput di, bool Down ); void ResetDevice( InputDevice dev );