From 76e6382e7d42b624e6bc96b316b5429d025af933 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Thu, 22 Sep 2005 23:59:31 +0000 Subject: [PATCH] Fix up repeat logic: instead of waiting g_fTimeBeforeSlow for the first repeat, it was waiting g_fTimeBeforeSlow+g_fTimeBetweenRepeats, ignoring the first repeat). Adjust TIME_BEFORE_SLOW_REPEATS so the rate doesn't actually change. Set correct timestamps for IET_REPEAT events. --- stepmania/src/InputFilter.cpp | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/stepmania/src/InputFilter.cpp b/stepmania/src/InputFilter.cpp index b4870cbee2..ff789a8e14 100644 --- a/stepmania/src/InputFilter.cpp +++ b/stepmania/src/InputFilter.cpp @@ -26,7 +26,7 @@ static Preference g_fInputDebounceTime( "InputDebounceTime", 0 ); 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_SLOW_REPEATS = 0.375f; static const float TIME_BEFORE_FAST_REPEATS = 1.5f; static const float REPEATS_PER_SEC = 8; @@ -178,21 +178,41 @@ void InputFilter::Update(float fDeltaTime) bs.m_fSecsHeld += fDeltaTime; const float fNewHoldTime = bs.m_fSecsHeld; + float fTimeBeforeRepeats; InputEventType iet; if( fNewHoldTime > g_fTimeBeforeSlow ) { if( fNewHoldTime > g_fTimeBeforeFast ) { + fTimeBeforeRepeats = g_fTimeBeforeFast; iet = IET_FAST_REPEAT; } else { + fTimeBeforeRepeats = g_fTimeBeforeSlow; iet = IET_SLOW_REPEAT; } - if( int(fOldHoldTime/g_fTimeBetweenRepeats) != int(fNewHoldTime/g_fTimeBetweenRepeats) ) + + float fRepeatTime; + if( fOldHoldTime < fTimeBeforeRepeats ) { - queue.push_back( InputEvent(di,iet) ); + fRepeatTime = fTimeBeforeRepeats; } + else + { + float fAdjustedOldHoldTime = fOldHoldTime - fTimeBeforeRepeats; + float fAdjustedNewHoldTime = fNewHoldTime - fTimeBeforeRepeats; + if( int(fAdjustedOldHoldTime/g_fTimeBetweenRepeats) == int(fAdjustedNewHoldTime/g_fTimeBetweenRepeats) ) + continue; + fRepeatTime = ftruncf( fNewHoldTime, g_fTimeBetweenRepeats ); + } + + /* Set the timestamp to the exact time of the repeat. This way, + * as long as tab/` aren't being used, the timestamp will always + * increase steadily during repeats. */ + di.ts = bs.m_BeingHeldTime + fRepeatTime; + + queue.push_back( InputEvent(di,iet) ); } } }