diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index aa00a9c4f1..409abd96e5 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -853,6 +853,13 @@ const Style* GameState::GetCurrentStyle() const void GameState::SetCurrentStyle( const Style *pStyle ) { m_pCurStyle.Set( pStyle ); + if( INPUTMAPPER ) + { + if( GetCurrentStyle() && GetCurrentStyle()->m_StyleType == ONE_PLAYER_TWO_SIDES ) + INPUTMAPPER->SetJoinControllers( m_MasterPlayerNumber ); + else + INPUTMAPPER->SetJoinControllers( PLAYER_INVALID ); + } } bool GameState::IsPlayerEnabled( PlayerNumber pn ) const diff --git a/stepmania/src/InputMapper.cpp b/stepmania/src/InputMapper.cpp index 26f841af75..556b9ecd2b 100644 --- a/stepmania/src/InputMapper.cpp +++ b/stepmania/src/InputMapper.cpp @@ -1,15 +1,12 @@ #include "global.h" #include "InputMapper.h" #include "IniFile.h" -#include "GameManager.h" -#include "GameState.h" +#include "MessageManager.h" #include "RageLog.h" #include "InputFilter.h" #include "RageUtil.h" #include "PrefsManager.h" #include "RageInput.h" -#include "Game.h" -#include "Style.h" #include "SpecialFiles.h" #include "LocalizedString.h" @@ -21,12 +18,15 @@ namespace // lookup for efficiency from a DeviceInput to a GameInput // This is repopulated every time m_PItoDI changes by calling UpdateTempDItoPI(). map g_tempDItoGI; + + PlayerNumber g_JoinControllers; }; InputMapper* INPUTMAPPER = NULL; // global and accessable from anywhere in our program InputMapper::InputMapper() { + g_JoinControllers = PLAYER_INVALID; m_pInputScheme = NULL; } @@ -547,8 +547,6 @@ static const RString DEVICE_INPUT_SEPARATOR = ":"; // this isn't used in any key void InputMapper::ReadMappingsFromDisk() { - ASSERT( GAMEMAN != NULL ); - ClearAllMappings(); IniFile ini; @@ -773,8 +771,8 @@ bool InputMapper::GameToDevice( const GameInput &GameI, int iSlotNum, DeviceInpu PlayerNumber InputMapper::ControllerToPlayerNumber( GameController controller ) { - if( GAMESTATE->GetCurrentStyle() && GAMESTATE->GetCurrentStyle()->m_StyleType == ONE_PLAYER_TWO_SIDES ) - return GAMESTATE->m_MasterPlayerNumber; + if( g_JoinControllers != PLAYER_INVALID ) + return g_JoinControllers; else return (PlayerNumber) controller; } @@ -784,13 +782,19 @@ MenuButton InputMapper::GameToMenu( const GameInput &GameI ) return m_pInputScheme->GameInputToMenuButton( GameI ); } +/* If set (not PLAYER_INVALID), inputs from both GameControllers will be mapped + * to the specified player. If PLAYER_INVALID, GameControllers will be mapped + * individually. */ +void InputMapper::SetJoinControllers( PlayerNumber pn ) +{ + g_JoinControllers = pn; +} + + void InputMapper::MenuToGame( MenuButton MenuI, PlayerNumber pn, GameInput GameIout[4] ) { - if( GAMESTATE->GetCurrentStyle() ) - { - if( GAMESTATE->GetCurrentStyle()->m_StyleType == ONE_PLAYER_TWO_SIDES ) - pn = PLAYER_INVALID; - } + if( g_JoinControllers != PLAYER_INVALID ) + pn = PLAYER_INVALID; m_pInputScheme->MenuButtonToGameInputs( MenuI, pn, GameIout ); } diff --git a/stepmania/src/InputMapper.h b/stepmania/src/InputMapper.h index 8287f199b5..8c57cf3faa 100644 --- a/stepmania/src/InputMapper.h +++ b/stepmania/src/InputMapper.h @@ -11,6 +11,7 @@ const int NUM_GAME_TO_DEVICE_SLOTS = 5; // five device inputs may map to one game input const int NUM_SHOWN_GAME_TO_DEVICE_SLOTS = 3; const int NUM_USER_GAME_TO_DEVICE_SLOTS = 2; +#define NO_DEFAULT_KEY DeviceButton_Invalid class InputScheme { @@ -36,6 +37,8 @@ public: void SetInputScheme( const InputScheme *pInputScheme ); const InputScheme *GetInputScheme() const; + void SetJoinControllers( PlayerNumber pn ); + void ReadMappingsFromDisk(); void SaveMappingsToDisk();