SetRepeatRate, ResetRepeatRate, ResetKeyRepeat

This commit is contained in:
Glenn Maynard
2003-11-25 21:46:30 +00:00
parent 729d179d27
commit 9b2f146605
4 changed files with 64 additions and 11 deletions
+30 -4
View File
@@ -18,6 +18,13 @@
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()
@@ -31,6 +38,7 @@ InputFilter::InputFilter()
m_fSecsToForce[d][b] = -1;
Reset();
ResetRepeatRate();
}
InputFilter::~InputFilter()
@@ -44,6 +52,19 @@ void InputFilter::Reset()
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 )
{
LockMut(*queuemutex);
@@ -202,16 +223,16 @@ void InputFilter::Update(float fDeltaTime)
float fTimeBetweenRepeats;
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;
}
else
{
fTimeBetweenRepeats = TIME_BETWEEN_SLOW_REPEATS;
fTimeBetweenRepeats = g_fTimeBetweenSlow;
iet = IET_SLOW_REPEAT;
}
if( int(fOldHoldTime/fTimeBetweenRepeats) != int(fNewHoldTime/fTimeBetweenRepeats) )
@@ -234,6 +255,11 @@ float InputFilter::GetSecsHeld( DeviceInput di )
return m_fSecsHeld[di.device][di.button];
}
void InputFilter::ResetKeyRepeat( DeviceInput di )
{
m_fSecsHeld[di.device][di.button] = 0;
}
void InputFilter::GetInputEvents( InputEventArray &array )
{
LockMut(*queuemutex);
+4 -7
View File
@@ -15,13 +15,6 @@
#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 };
struct InputEvent : public DeviceInput
@@ -59,6 +52,10 @@ public:
void Reset();
void Update(float fDeltaTime);
void SetRepeatRate( float fSlowDelay, float fSlowRate, float fFastDelay, float fFastRate );
void ResetRepeatRate();
void ResetKeyRepeat( DeviceInput di );
bool IsBeingPressed( DeviceInput di );
float GetSecsHeld( DeviceInput di );
+26
View File
@@ -630,3 +630,29 @@ float InputMapper::GetSecsHeld( StyleInput StyleI )
StyleToGame( StyleI, 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 );
}
+4
View File
@@ -62,6 +62,10 @@ public:
bool IsButtonDown( MenuInput MenuI );
bool IsButtonDown( StyleInput StyleI );
void ResetKeyRepeat( GameInput GameI );
void ResetKeyRepeat( MenuInput MenuI );
void ResetKeyRepeat( StyleInput StyleI );
protected:
// all the DeviceInputs that map to a GameInput
DeviceInput m_GItoDI[MAX_GAME_CONTROLLERS][MAX_GAME_BUTTONS][NUM_GAME_TO_DEVICE_SLOTS];