move InputScheme code into InputMapper

This commit is contained in:
Glenn Maynard
2006-09-30 22:36:01 +00:00
parent fa60068e06
commit 56d3ecf83d
3 changed files with 58 additions and 66 deletions
+58
View File
@@ -913,6 +913,64 @@ MultiPlayer InputMapper::InputDeviceToMultiPlayer( InputDevice id )
return enum_add2( MultiPlayer_1, id - DEVICE_JOY1 );
}
GameButton InputScheme::ButtonNameToIndex( const RString &sButtonName ) const
{
for( int i=0; i<m_iButtonsPerController; i++ )
if( stricmp(m_szButtonNames[i], sButtonName) == 0 )
return i;
return GameButton_Invalid;
}
MenuButton InputScheme::GameInputToMenuButton( GameInput GameI ) const
{
FOREACH_MenuButton(i)
if( m_DedicatedMenuButton[i] == GameI.button )
return i;
if( !PREFSMAN->m_bOnlyDedicatedMenuButtons )
{
FOREACH_MenuButton(i)
if( m_SecondaryMenuButton[i] == GameI.button )
return i;
}
return MenuButton_INVALID; // invalid GameInput
}
void InputScheme::MenuButtonToGameInputs( MenuButton MenuI, PlayerNumber pn, GameInput GameIout[4] ) const
{
ASSERT( MenuI != MenuButton_INVALID );
GameIout[0].MakeInvalid(); // initialize
GameIout[1].MakeInvalid();
GameIout[2].MakeInvalid();
GameIout[3].MakeInvalid();
vector<GameController> controller;
if( pn == PLAYER_INVALID )
{
controller.push_back( GAME_CONTROLLER_1 );
controller.push_back( GAME_CONTROLLER_2 );
}
else
{
controller.push_back( (GameController)pn );
}
GameButton button[2] = { m_DedicatedMenuButton[MenuI], m_SecondaryMenuButton[MenuI] };
int iNumButtonsUsing = PREFSMAN->m_bOnlyDedicatedMenuButtons ? 1 : 2;
for( size_t i=0; i<controller.size(); i++ )
{
for( int j=0; j<iNumButtonsUsing; j++ )
{
GameIout[i*2+j].controller = controller[i];
GameIout[i*2+j].button = button[j];
}
}
}
/*
* (c) 2001-2003 Chris Danford
* All rights reserved.