RepeatStopKey: stop repeating a key until it's released
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user