From 8b279db97fbdbe22dcf0f77276dea14311c6de5c Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 13 Jan 2007 05:41:40 +0000 Subject: [PATCH] cleaner, more consistent SecondaryFunction handling --- stepmania/src/InputMapper.cpp | 90 ++++++++++++++++------------------- stepmania/src/InputMapper.h | 5 +- 2 files changed, 43 insertions(+), 52 deletions(-) diff --git a/stepmania/src/InputMapper.cpp b/stepmania/src/InputMapper.cpp index 70ee3e9255..e693ff69e4 100644 --- a/stepmania/src/InputMapper.cpp +++ b/stepmania/src/InputMapper.cpp @@ -828,7 +828,7 @@ void InputMapper::SetJoinControllers( PlayerNumber pn ) } -void InputMapper::MenuToGame( GameButton MenuI, PlayerNumber pn, GameInput GameIout[4] ) +void InputMapper::MenuToGame( GameButton MenuI, PlayerNumber pn, vector &GameIout ) { if( g_JoinControllers != PLAYER_INVALID ) pn = PLAYER_INVALID; @@ -857,10 +857,10 @@ bool InputMapper::IsBeingPressed( const GameInput &GameI, MultiPlayer mp, const bool InputMapper::IsBeingPressed( GameButton MenuI, PlayerNumber pn ) { - GameInput GameI[4]; + vector GameI; MenuToGame( MenuI, pn, GameI ); - for( int i=0; i<4; i++ ) - if( GameI[i].IsValid() && IsBeingPressed(GameI[i]) ) + for( size_t i=0; i GameI; MenuToGame( MenuI, pn, GameI ); - for( int i=0; i<4; i++ ) - if( GameI[i].IsValid() ) - RepeatStopKey( GameI[i] ); + for( size_t i=0; i GameI; MenuToGame( MenuI, pn, GameI ); - for( int i=0; i<4; i++ ) - if( GameI[i].IsValid() ) - fMaxSecsHeld = max( fMaxSecsHeld, GetSecsHeld(GameI[i]) ); + for( size_t i=0; i GameI; MenuToGame( MenuI, pn, GameI ); - for( int i=0; i<4; i++ ) - if( GameI[i].IsValid() ) - ResetKeyRepeat( GameI[i] ); + for( size_t i=0; i &GameIout ) const { ASSERT( MenuI != GameButton_Invalid ); - GameIout[0].MakeInvalid(); // initialize - GameIout[1].MakeInvalid(); - GameIout[2].MakeInvalid(); - GameIout[3].MakeInvalid(); - - vector controller; - if( pn == PLAYER_INVALID ) + vector aGameButtons; + MenuButtonToGameButtons( MenuI, aGameButtons ); + FOREACH( GameButton, aGameButtons, gb ) { - controller.push_back( GAME_CONTROLLER_1 ); - controller.push_back( GAME_CONTROLLER_2 ); - } - else - { - controller.push_back( (GameController)pn ); - } - - GameButton SecondaryGameButton = GameButton_Invalid; - for( GameButton gb=GAME_BUTTON_NEXT; gbm_bOnlyDedicatedMenuButtons ? 1 : 2; +void InputScheme::MenuButtonToGameButtons( GameButton MenuI, vector &aGameButtons ) const +{ + ASSERT( MenuI != GameButton_Invalid ); - int iOut = 0; - for( size_t i=0; im_bOnlyDedicatedMenuButtons ) + return; + + for( GameButton gb=GAME_BUTTON_NEXT; gb &GameIout ) const; + void MenuButtonToGameButtons( GameButton MenuI, vector &aGameButtons ) const; GameButton GetMenuButtonSecondaryFunction( GameButton gb ) const; const GameButtonInfo *GetGameButtonInfo( GameButton gb ) const; const char *GetGameButtonName( GameButton gb ) const; @@ -83,7 +84,7 @@ public: bool GameToDevice( const GameInput &GameI, int iSlotNum, DeviceInput& DeviceI ); // return true if there is a mapping from pad to device GameButton GameButtonToMenuButton( GameButton gb ); - void MenuToGame( GameButton MenuI, PlayerNumber pn, GameInput GameIout[4] ); + void MenuToGame( GameButton MenuI, PlayerNumber pn, vector &GameIout ); PlayerNumber ControllerToPlayerNumber( GameController controller ); float GetSecsHeld( const GameInput &GameI, MultiPlayer mp = MultiPlayer_Invalid );