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
-60
View File
@@ -1,66 +1,6 @@
#include "global.h"
#include "Game.h"
#include "RageLog.h"
#include "RageUtil.h"
#include "PrefsManager.h"
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];
}
}
}
TapNoteScore Game::MapTapNoteScore( TapNoteScore tns ) const
{
-6
View File
@@ -3,10 +3,6 @@
#ifndef GAMEDEF_H
#define GAMEDEF_H
#include "GameInput.h"
#include "MenuInput.h"
#include "GameConstantsAndTypes.h"
#include "RageInputDevice.h"
#include "InputMapper.h"
struct lua_State;
@@ -30,8 +26,6 @@ struct lua_State;
// MenuLeft and MenuRight as long as "MenuLeft (optional)" and "MenuRight (optional)" are not mapped.
//
#define NO_DEFAULT_KEY DeviceButton_Invalid
class Game
{
public:
+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.