RepeatStopKey: stop repeating a key until it's released

This commit is contained in:
Glenn Maynard
2006-09-14 20:39:54 +00:00
parent a05fe7e8ab
commit f652510cc5
4 changed files with 45 additions and 0 deletions
+21
View File
@@ -43,6 +43,7 @@ namespace
}
DeviceInputList g_CurrentState;
set<DeviceInput> g_DisableRepeat;
}
/*
@@ -178,6 +179,9 @@ void InputFilter::CheckButtonChange( ButtonState &bs, DeviceInput di, const Rage
di.ts = bs.m_BeingHeldTime;
ReportButtonChange( di, bs.m_bLastReportedHeld? IET_FIRST_PRESS:IET_RELEASE );
if( !bs.m_bLastReportedHeld )
g_DisableRepeat.erase( di );
}
void InputFilter::ReportButtonChange( const DeviceInput &di, InputEventType t )
@@ -245,6 +249,10 @@ void InputFilter::Update( float fDeltaTime )
continue;
}
/* If repeats are disabled for this button, skip. */
if( g_DisableRepeat.find(di) != g_DisableRepeat.end() )
continue;
const float fOldHoldTime = bs.m_fSecsHeld;
bs.m_fSecsHeld += fDeltaTime;
const float fNewHoldTime = bs.m_fSecsHeld;
@@ -320,6 +328,19 @@ void InputFilter::ResetKeyRepeat( const DeviceInput &di )
GetButtonState( di ).m_fSecsHeld = 0;
}
/* Stop repeating the specified key until released. */
void InputFilter::RepeatStopKey( const DeviceInput &di )
{
LockMut(*queuemutex);
/* If the button is up, do nothing. */
ButtonState &bs = GetButtonState( di );
if( !bs.m_bLastReportedHeld )
return;
g_DisableRepeat.insert( di );
}
void InputFilter::GetInputEvents( vector<InputEvent> &array )
{
array.clear();
+1
View File
@@ -47,6 +47,7 @@ public:
void SetRepeatRate( float fDelay, float fRepeatRate );
void ResetRepeatRate();
void ResetKeyRepeat( const DeviceInput &di );
void RepeatStopKey( const DeviceInput &di );
// If aButtonState is NULL, use the last reported state.
bool IsBeingPressed( const DeviceInput &di, const DeviceInputList *pButtonState = NULL ) const;
+20
View File
@@ -811,6 +811,26 @@ bool InputMapper::IsBeingPressed( const MenuInput &MenuI, PlayerNumber pn )
return false;
}
void InputMapper::RepeatStopKey( const GameInput &GameI )
{
for( int i=0; i<NUM_GAME_TO_DEVICE_SLOTS; i++ )
{
DeviceInput DeviceI;
if( GameToDevice( GameI, i, DeviceI ) )
INPUTFILTER->RepeatStopKey( DeviceI );
}
}
void InputMapper::RepeatStopKey( MenuButton MenuI, PlayerNumber pn )
{
GameInput GameI[4];
MenuToGame( MenuI, pn, GameI );
for( int i=0; i<4; i++ )
if( GameI[i].IsValid() )
RepeatStopKey( GameI[i] );
}
float InputMapper::GetSecsHeld( const GameInput &GameI, MultiPlayer mp )
{
float fMaxSecsHeld = 0;
+3
View File
@@ -49,6 +49,9 @@ public:
void ResetKeyRepeat( const GameInput &GameI );
void ResetKeyRepeat( const MenuInput &MenuI, PlayerNumber pn );
void RepeatStopKey( const GameInput &GameI );
void RepeatStopKey( MenuButton MenuI, PlayerNumber pn );
struct Mapping
{
bool IsEndMarker() const { return iSlotIndex==-1; }