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();