eliminate InputMapper dependency on GameState. GameState
now tells InputMapper if it should join players.
This commit is contained in:
@@ -853,6 +853,13 @@ const Style* GameState::GetCurrentStyle() const
|
|||||||
void GameState::SetCurrentStyle( const Style *pStyle )
|
void GameState::SetCurrentStyle( const Style *pStyle )
|
||||||
{
|
{
|
||||||
m_pCurStyle.Set( 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
|
bool GameState::IsPlayerEnabled( PlayerNumber pn ) const
|
||||||
|
|||||||
@@ -1,15 +1,12 @@
|
|||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "InputMapper.h"
|
#include "InputMapper.h"
|
||||||
#include "IniFile.h"
|
#include "IniFile.h"
|
||||||
#include "GameManager.h"
|
#include "MessageManager.h"
|
||||||
#include "GameState.h"
|
|
||||||
#include "RageLog.h"
|
#include "RageLog.h"
|
||||||
#include "InputFilter.h"
|
#include "InputFilter.h"
|
||||||
#include "RageUtil.h"
|
#include "RageUtil.h"
|
||||||
#include "PrefsManager.h"
|
#include "PrefsManager.h"
|
||||||
#include "RageInput.h"
|
#include "RageInput.h"
|
||||||
#include "Game.h"
|
|
||||||
#include "Style.h"
|
|
||||||
#include "SpecialFiles.h"
|
#include "SpecialFiles.h"
|
||||||
#include "LocalizedString.h"
|
#include "LocalizedString.h"
|
||||||
|
|
||||||
@@ -21,12 +18,15 @@ namespace
|
|||||||
// lookup for efficiency from a DeviceInput to a GameInput
|
// lookup for efficiency from a DeviceInput to a GameInput
|
||||||
// This is repopulated every time m_PItoDI changes by calling UpdateTempDItoPI().
|
// This is repopulated every time m_PItoDI changes by calling UpdateTempDItoPI().
|
||||||
map<DeviceInput, GameInput> g_tempDItoGI;
|
map<DeviceInput, GameInput> g_tempDItoGI;
|
||||||
|
|
||||||
|
PlayerNumber g_JoinControllers;
|
||||||
};
|
};
|
||||||
|
|
||||||
InputMapper* INPUTMAPPER = NULL; // global and accessable from anywhere in our program
|
InputMapper* INPUTMAPPER = NULL; // global and accessable from anywhere in our program
|
||||||
|
|
||||||
InputMapper::InputMapper()
|
InputMapper::InputMapper()
|
||||||
{
|
{
|
||||||
|
g_JoinControllers = PLAYER_INVALID;
|
||||||
m_pInputScheme = NULL;
|
m_pInputScheme = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -547,8 +547,6 @@ static const RString DEVICE_INPUT_SEPARATOR = ":"; // this isn't used in any key
|
|||||||
|
|
||||||
void InputMapper::ReadMappingsFromDisk()
|
void InputMapper::ReadMappingsFromDisk()
|
||||||
{
|
{
|
||||||
ASSERT( GAMEMAN != NULL );
|
|
||||||
|
|
||||||
ClearAllMappings();
|
ClearAllMappings();
|
||||||
|
|
||||||
IniFile ini;
|
IniFile ini;
|
||||||
@@ -773,8 +771,8 @@ bool InputMapper::GameToDevice( const GameInput &GameI, int iSlotNum, DeviceInpu
|
|||||||
|
|
||||||
PlayerNumber InputMapper::ControllerToPlayerNumber( GameController controller )
|
PlayerNumber InputMapper::ControllerToPlayerNumber( GameController controller )
|
||||||
{
|
{
|
||||||
if( GAMESTATE->GetCurrentStyle() && GAMESTATE->GetCurrentStyle()->m_StyleType == ONE_PLAYER_TWO_SIDES )
|
if( g_JoinControllers != PLAYER_INVALID )
|
||||||
return GAMESTATE->m_MasterPlayerNumber;
|
return g_JoinControllers;
|
||||||
else
|
else
|
||||||
return (PlayerNumber) controller;
|
return (PlayerNumber) controller;
|
||||||
}
|
}
|
||||||
@@ -784,13 +782,19 @@ MenuButton InputMapper::GameToMenu( const GameInput &GameI )
|
|||||||
return m_pInputScheme->GameInputToMenuButton( 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] )
|
void InputMapper::MenuToGame( MenuButton MenuI, PlayerNumber pn, GameInput GameIout[4] )
|
||||||
{
|
{
|
||||||
if( GAMESTATE->GetCurrentStyle() )
|
if( g_JoinControllers != PLAYER_INVALID )
|
||||||
{
|
|
||||||
if( GAMESTATE->GetCurrentStyle()->m_StyleType == ONE_PLAYER_TWO_SIDES )
|
|
||||||
pn = PLAYER_INVALID;
|
pn = PLAYER_INVALID;
|
||||||
}
|
|
||||||
|
|
||||||
m_pInputScheme->MenuButtonToGameInputs( MenuI, pn, GameIout );
|
m_pInputScheme->MenuButtonToGameInputs( MenuI, pn, GameIout );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
const int NUM_GAME_TO_DEVICE_SLOTS = 5; // five device inputs may map to one game input
|
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_SHOWN_GAME_TO_DEVICE_SLOTS = 3;
|
||||||
const int NUM_USER_GAME_TO_DEVICE_SLOTS = 2;
|
const int NUM_USER_GAME_TO_DEVICE_SLOTS = 2;
|
||||||
|
#define NO_DEFAULT_KEY DeviceButton_Invalid
|
||||||
|
|
||||||
class InputScheme
|
class InputScheme
|
||||||
{
|
{
|
||||||
@@ -36,6 +37,8 @@ public:
|
|||||||
|
|
||||||
void SetInputScheme( const InputScheme *pInputScheme );
|
void SetInputScheme( const InputScheme *pInputScheme );
|
||||||
const InputScheme *GetInputScheme() const;
|
const InputScheme *GetInputScheme() const;
|
||||||
|
void SetJoinControllers( PlayerNumber pn );
|
||||||
|
|
||||||
void ReadMappingsFromDisk();
|
void ReadMappingsFromDisk();
|
||||||
void SaveMappingsToDisk();
|
void SaveMappingsToDisk();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user