diff --git a/stepmania/src/InputQueue.cpp b/stepmania/src/InputQueue.cpp index b2c786a17d..e784da3e93 100644 --- a/stepmania/src/InputQueue.cpp +++ b/stepmania/src/InputQueue.cpp @@ -82,6 +82,26 @@ bool InputQueue::MatchesSequence( GameController c, const GameButton* button_seq return false; } +bool InputQueue::WasPressedRecently( GameController c, const GameButton button, const RageTimer &OldestTimeAllowed, InputEventPlus *pIEP ) +{ + for( int queue_index=m_aQueue[c].size()-1; queue_index>=0; queue_index-- ) // iterate newest to oldest + { + const InputEventPlus &iep = m_aQueue[c][queue_index]; + if( iep.DeviceI.ts < OldestTimeAllowed ) // buttons are too old. Stop searching because we're not going to find a match + return false; + + if( iep.GameI.button != button ) + continue; + + if( pIEP != NULL ) + *pIEP = iep; + + return true; + } + + return false; // didn't find the button +} + bool InputQueue::AllWerePressedRecently( GameController c, const GameButton* buttons, int iNumButtons, float fMaxSecondsBack ) { RageTimer OldestTimeAllowed; @@ -89,20 +109,8 @@ bool InputQueue::AllWerePressedRecently( GameController c, const GameButton* but for( int b=0; b=0; queue_index-- ) // iterate newest to oldest - { - const InputEventPlus &iep = m_aQueue[c][queue_index]; - if( iep.DeviceI.ts < OldestTimeAllowed ) // buttons are too old. Stop searching because we're not going to find a match - return false; - - if( iep.GameI.button == button ) - goto found_button; - } - return false; // didn't find the button -found_button: - ; // hush VC6 + if( !WasPressedRecently(c, buttons[b], OldestTimeAllowed) ) + return false; // didn't find the button } m_aQueue[c].clear(); // empty the queue so we don't match on it again diff --git a/stepmania/src/InputQueue.h b/stepmania/src/InputQueue.h index 946d70a877..c65a538464 100644 --- a/stepmania/src/InputQueue.h +++ b/stepmania/src/InputQueue.h @@ -9,6 +9,7 @@ const unsigned MAX_INPUT_QUEUE_LENGTH = 16; class InputEventPlus; +class RageTimer; class InputQueue { @@ -18,6 +19,7 @@ public: void RememberInput( const InputEventPlus &gi ); bool MatchesSequence( GameController c, const GameButton* button_sequence, int iNumButtons, float fMaxSecondsBack ); bool MatchesSequence( GameController c, const MenuButton* button_sequence, int iNumButtons, float fMaxSecondsBack ); + bool WasPressedRecently( GameController c, const GameButton button, const RageTimer &OldestTimeAllowed, InputEventPlus *pIEP = NULL ); bool AllWerePressedRecently( GameController c, const GameButton* buttons, int iNumButtons, float fMaxSecondsBack ); protected: