SetRepeatRate, ResetRepeatRate, ResetKeyRepeat
This commit is contained in:
@@ -18,6 +18,13 @@
|
|||||||
|
|
||||||
InputFilter* INPUTFILTER = NULL; // global and accessable from anywhere in our program
|
InputFilter* INPUTFILTER = NULL; // global and accessable from anywhere in our program
|
||||||
|
|
||||||
|
static const float TIME_BEFORE_SLOW_REPEATS = 0.25f;
|
||||||
|
static const float TIME_BEFORE_FAST_REPEATS = 1.5f;
|
||||||
|
|
||||||
|
static const float SLOW_REPEATS_PER_SEC = 8;
|
||||||
|
static const float FAST_REPEATS_PER_SEC = 8;
|
||||||
|
|
||||||
|
static float g_fTimeBeforeSlow, g_fTimeBeforeFast, g_fTimeBetweenSlow, g_fTimeBetweenFast;
|
||||||
|
|
||||||
|
|
||||||
InputFilter::InputFilter()
|
InputFilter::InputFilter()
|
||||||
@@ -31,6 +38,7 @@ InputFilter::InputFilter()
|
|||||||
m_fSecsToForce[d][b] = -1;
|
m_fSecsToForce[d][b] = -1;
|
||||||
|
|
||||||
Reset();
|
Reset();
|
||||||
|
ResetRepeatRate();
|
||||||
}
|
}
|
||||||
|
|
||||||
InputFilter::~InputFilter()
|
InputFilter::~InputFilter()
|
||||||
@@ -44,6 +52,19 @@ void InputFilter::Reset()
|
|||||||
ResetDevice( InputDevice(i) );
|
ResetDevice( InputDevice(i) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InputFilter::SetRepeatRate( float fSlowDelay, float fSlowRate, float fFastDelay, float fFastRate )
|
||||||
|
{
|
||||||
|
g_fTimeBeforeSlow = fSlowDelay;
|
||||||
|
g_fTimeBeforeFast = fFastDelay;
|
||||||
|
g_fTimeBetweenSlow = 1/fSlowRate;
|
||||||
|
g_fTimeBetweenFast = 1/fFastRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InputFilter::ResetRepeatRate()
|
||||||
|
{
|
||||||
|
SetRepeatRate( TIME_BEFORE_SLOW_REPEATS, SLOW_REPEATS_PER_SEC, TIME_BEFORE_FAST_REPEATS, FAST_REPEATS_PER_SEC );
|
||||||
|
}
|
||||||
|
|
||||||
void InputFilter::ButtonPressed( DeviceInput di, bool Down )
|
void InputFilter::ButtonPressed( DeviceInput di, bool Down )
|
||||||
{
|
{
|
||||||
LockMut(*queuemutex);
|
LockMut(*queuemutex);
|
||||||
@@ -202,16 +223,16 @@ void InputFilter::Update(float fDeltaTime)
|
|||||||
|
|
||||||
float fTimeBetweenRepeats;
|
float fTimeBetweenRepeats;
|
||||||
InputEventType iet;
|
InputEventType iet;
|
||||||
if( fOldHoldTime > TIME_BEFORE_SLOW_REPEATS )
|
if( fOldHoldTime > g_fTimeBeforeSlow )
|
||||||
{
|
{
|
||||||
if( fOldHoldTime > TIME_BEFORE_FAST_REPEATS )
|
if( fOldHoldTime > g_fTimeBeforeFast )
|
||||||
{
|
{
|
||||||
fTimeBetweenRepeats = TIME_BETWEEN_FAST_REPEATS;
|
fTimeBetweenRepeats = g_fTimeBetweenFast;
|
||||||
iet = IET_FAST_REPEAT;
|
iet = IET_FAST_REPEAT;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fTimeBetweenRepeats = TIME_BETWEEN_SLOW_REPEATS;
|
fTimeBetweenRepeats = g_fTimeBetweenSlow;
|
||||||
iet = IET_SLOW_REPEAT;
|
iet = IET_SLOW_REPEAT;
|
||||||
}
|
}
|
||||||
if( int(fOldHoldTime/fTimeBetweenRepeats) != int(fNewHoldTime/fTimeBetweenRepeats) )
|
if( int(fOldHoldTime/fTimeBetweenRepeats) != int(fNewHoldTime/fTimeBetweenRepeats) )
|
||||||
@@ -234,6 +255,11 @@ float InputFilter::GetSecsHeld( DeviceInput di )
|
|||||||
return m_fSecsHeld[di.device][di.button];
|
return m_fSecsHeld[di.device][di.button];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InputFilter::ResetKeyRepeat( DeviceInput di )
|
||||||
|
{
|
||||||
|
m_fSecsHeld[di.device][di.button] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void InputFilter::GetInputEvents( InputEventArray &array )
|
void InputFilter::GetInputEvents( InputEventArray &array )
|
||||||
{
|
{
|
||||||
LockMut(*queuemutex);
|
LockMut(*queuemutex);
|
||||||
|
|||||||
@@ -15,13 +15,6 @@
|
|||||||
|
|
||||||
#include "RageInputDevice.h"
|
#include "RageInputDevice.h"
|
||||||
|
|
||||||
const float TIME_BEFORE_SLOW_REPEATS = 0.25f;
|
|
||||||
const float TIME_BEFORE_FAST_REPEATS = 1.5f;
|
|
||||||
|
|
||||||
//const float TIME_BETWEEN_SLOW_REPEATS = 0.25f;
|
|
||||||
const float TIME_BETWEEN_SLOW_REPEATS = 0.125f;
|
|
||||||
const float TIME_BETWEEN_FAST_REPEATS = 0.125f;
|
|
||||||
|
|
||||||
enum InputEventType { IET_FIRST_PRESS, IET_SLOW_REPEAT, IET_FAST_REPEAT, IET_RELEASE };
|
enum InputEventType { IET_FIRST_PRESS, IET_SLOW_REPEAT, IET_FAST_REPEAT, IET_RELEASE };
|
||||||
|
|
||||||
struct InputEvent : public DeviceInput
|
struct InputEvent : public DeviceInput
|
||||||
@@ -59,6 +52,10 @@ public:
|
|||||||
void Reset();
|
void Reset();
|
||||||
void Update(float fDeltaTime);
|
void Update(float fDeltaTime);
|
||||||
|
|
||||||
|
void SetRepeatRate( float fSlowDelay, float fSlowRate, float fFastDelay, float fFastRate );
|
||||||
|
void ResetRepeatRate();
|
||||||
|
void ResetKeyRepeat( DeviceInput di );
|
||||||
|
|
||||||
bool IsBeingPressed( DeviceInput di );
|
bool IsBeingPressed( DeviceInput di );
|
||||||
float GetSecsHeld( DeviceInput di );
|
float GetSecsHeld( DeviceInput di );
|
||||||
|
|
||||||
|
|||||||
@@ -630,3 +630,29 @@ float InputMapper::GetSecsHeld( StyleInput StyleI )
|
|||||||
StyleToGame( StyleI, GameI );
|
StyleToGame( StyleI, GameI );
|
||||||
return GetSecsHeld( GameI );
|
return GetSecsHeld( GameI );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InputMapper::ResetKeyRepeat( GameInput GameI )
|
||||||
|
{
|
||||||
|
for( int i=0; i<NUM_GAME_TO_DEVICE_SLOTS; i++ )
|
||||||
|
{
|
||||||
|
DeviceInput DeviceI;
|
||||||
|
if( GameToDevice( GameI, i, DeviceI ) )
|
||||||
|
INPUTFILTER->ResetKeyRepeat( DeviceI );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void InputMapper::ResetKeyRepeat( MenuInput MenuI )
|
||||||
|
{
|
||||||
|
GameInput GameI[4];
|
||||||
|
MenuToGame( MenuI, GameI );
|
||||||
|
for( int i=0; i<4; i++ )
|
||||||
|
if( GameI[i].IsValid() )
|
||||||
|
ResetKeyRepeat( GameI[i] );
|
||||||
|
}
|
||||||
|
|
||||||
|
void InputMapper::ResetKeyRepeat( StyleInput StyleI )
|
||||||
|
{
|
||||||
|
GameInput GameI;
|
||||||
|
StyleToGame( StyleI, GameI );
|
||||||
|
ResetKeyRepeat( GameI );
|
||||||
|
}
|
||||||
|
|||||||
@@ -62,6 +62,10 @@ public:
|
|||||||
bool IsButtonDown( MenuInput MenuI );
|
bool IsButtonDown( MenuInput MenuI );
|
||||||
bool IsButtonDown( StyleInput StyleI );
|
bool IsButtonDown( StyleInput StyleI );
|
||||||
|
|
||||||
|
void ResetKeyRepeat( GameInput GameI );
|
||||||
|
void ResetKeyRepeat( MenuInput MenuI );
|
||||||
|
void ResetKeyRepeat( StyleInput StyleI );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// all the DeviceInputs that map to a GameInput
|
// all the DeviceInputs that map to a GameInput
|
||||||
DeviceInput m_GItoDI[MAX_GAME_CONTROLLERS][MAX_GAME_BUTTONS][NUM_GAME_TO_DEVICE_SLOTS];
|
DeviceInput m_GItoDI[MAX_GAME_CONTROLLERS][MAX_GAME_BUTTONS][NUM_GAME_TO_DEVICE_SLOTS];
|
||||||
|
|||||||
Reference in New Issue
Block a user