示例#1
0
void InputMapper::AddDefaultMappingsForCurrentGameIfUnmapped()
{
	// Clear default mappings.  Default mappings are in the third slot.
	FOREACH_ENUM( GameController,  i )
		FOREACH_ENUM( GameButton, j)
			ClearFromInputMap( GameInput(i, j), 2 );

	vector<AutoMappingEntry> aMaps;
	aMaps.reserve( 32 );

	FOREACH_CONST( AutoMappingEntry, g_DefaultKeyMappings.m_vMaps, iter )
		aMaps.push_back( *iter );
	FOREACH_CONST( AutoMappingEntry, m_pInputScheme->m_pAutoMappings->m_vMaps, iter )
		aMaps.push_back( *iter );

	/* There may be duplicate GAME_BUTTON maps.  Process the list backwards,
	 * so game-specific mappings override g_DefaultKeyMappings. */
	std::reverse( aMaps.begin(), aMaps.end() );

	FOREACH( AutoMappingEntry, aMaps, m )
	{
		DeviceButton key = m->m_deviceButton;
		DeviceInput DeviceI( DEVICE_KEYBOARD, key );
		GameInput GameI( m->m_bSecondController ? GameController_2 : GameController_1, m->m_gb );
		if( !IsMapped(DeviceI) )	// if this key isn't already being used by another user-made mapping
		{
			if( !GameI.IsValid() )
				ClearFromInputMap( DeviceI );
			else
				SetInputMap( DeviceI, GameI, 2 );
		}
	}
示例#2
0
void InputMapper::AddDefaultMappingsForCurrentGameIfUnmapped()
{
	// Clear default mappings.  Default mappings are in the third slot.
	for( int i=0; i<MAX_GAME_CONTROLLERS; i++ )
		for( int j=0; j<MAX_GAME_BUTTONS; j++ )
			ClearFromInputMap( GameInput((GameController)i,(GameButton)j), 2 );

	const Game* pGame = GAMESTATE->GetCurrentGame();
	for( int c=0; c<MAX_GAME_CONTROLLERS; c++ )
	{
		for( int b=0; b<pGame->m_iButtonsPerController; b++ )
		{
			int key = pGame->m_iDefaultKeyboardKey[c][b];
			if( key == NO_DEFAULT_KEY )
				continue;
			DeviceInput DeviceI( DEVICE_KEYBOARD, key );
			GameInput GameI( (GameController)c, (GameButton)b );
			if( !IsMapped(DeviceI) )	// if this key isn't already being used by another user-made mapping
				SetInputMap( DeviceI, GameI, 2 );   
		}
	}
}