unify GameButton and MenuButton

This commit is contained in:
Glenn Maynard
2007-01-13 02:40:10 +00:00
parent d74c5689ff
commit ebcf1e0235
5 changed files with 24 additions and 52 deletions
+6 -18
View File
@@ -25,19 +25,6 @@ namespace
InputMapper* INPUTMAPPER = NULL; // global and accessable from anywhere in our program InputMapper* INPUTMAPPER = NULL; // global and accessable from anywhere in our program
static GameButton g_DedicatedMenuButtons[NUM_MenuButton] =
{
GAME_BUTTON_MENULEFT, // MENU_BUTTON_LEFT
GAME_BUTTON_MENURIGHT, // MENU_BUTTON_RIGHT
GAME_BUTTON_MENUUP, // MENU_BUTTON_UP
GAME_BUTTON_MENUDOWN, // MENU_BUTTON_DOWN
GAME_BUTTON_START, // MENU_BUTTON_START
GAME_BUTTON_SELECT, // MENU_BUTTON_SELECT
GAME_BUTTON_BACK, // MENU_BUTTON_BACK
GAME_BUTTON_COIN, // MENU_BUTTON_COIN
GAME_BUTTON_OPERATOR // MENU_BUTTON_OPERATOR
};
InputMapper::InputMapper() InputMapper::InputMapper()
{ {
g_JoinControllers = PLAYER_INVALID; g_JoinControllers = PLAYER_INVALID;
@@ -819,7 +806,9 @@ bool InputMapper::GameToDevice( const GameInput &GameI, int iSlotNum, DeviceInpu
PlayerNumber InputMapper::ControllerToPlayerNumber( GameController controller ) PlayerNumber InputMapper::ControllerToPlayerNumber( GameController controller )
{ {
if( g_JoinControllers != PLAYER_INVALID ) if( controller == GameController_Invalid )
return PLAYER_INVALID;
else if( g_JoinControllers != PLAYER_INVALID )
return g_JoinControllers; return g_JoinControllers;
else else
return (PlayerNumber) controller; return (PlayerNumber) controller;
@@ -972,9 +961,8 @@ GameButton InputScheme::ButtonNameToIndex( const RString &sButtonName ) const
MenuButton InputScheme::GameButtonToMenuButton( GameButton gb ) const MenuButton InputScheme::GameButtonToMenuButton( GameButton gb ) const
{ {
FOREACH_MenuButton(i) if( gb < GAME_BUTTON_NEXT )
if( g_DedicatedMenuButtons[i] == gb ) return gb;
return i;
if( !PREFSMAN->m_bOnlyDedicatedMenuButtons ) if( !PREFSMAN->m_bOnlyDedicatedMenuButtons )
return GetMenuButtonSecondaryFunction( gb ); return GetMenuButtonSecondaryFunction( gb );
@@ -1012,7 +1000,7 @@ void InputScheme::MenuButtonToGameInputs( MenuButton MenuI, PlayerNumber pn, Gam
} }
} }
GameButton button[2] = { g_DedicatedMenuButtons[MenuI], SecondaryGameButton }; GameButton button[2] = { MenuI, SecondaryGameButton };
int iNumButtonsUsing = PREFSMAN->m_bOnlyDedicatedMenuButtons ? 1 : 2; int iNumButtonsUsing = PREFSMAN->m_bOnlyDedicatedMenuButtons ? 1 : 2;
int iOut = 0; int iOut = 0;
-15
View File
@@ -4,21 +4,6 @@
#include "RageUtil.h" #include "RageUtil.h"
#include "LocalizedString.h" #include "LocalizedString.h"
static const char *MenuButtonNames[] =
{
"MenuLeft",
"MenuRight",
"MenuUp",
"MenuDown",
"MenuStart",
"MenuSelect",
"MenuBack",
"Coin",
"Operator"
};
XToString( MenuButton );
XToLocalizedString( MenuButton );
/* /*
* (c) 2006 Chris Danford * (c) 2006 Chris Danford
+13 -17
View File
@@ -3,25 +3,21 @@
#ifndef MENU_INPUT_H #ifndef MENU_INPUT_H
#define MENU_INPUT_H #define MENU_INPUT_H
enum MenuButton #include "GameInput.h"
{ typedef GameButton MenuButton;
MENU_BUTTON_LEFT = 0, #define MENU_BUTTON_LEFT GAME_BUTTON_MENULEFT
MENU_BUTTON_RIGHT, #define MENU_BUTTON_RIGHT GAME_BUTTON_MENURIGHT
MENU_BUTTON_UP, #define MENU_BUTTON_UP GAME_BUTTON_MENUUP
MENU_BUTTON_DOWN, #define MENU_BUTTON_DOWN GAME_BUTTON_MENUDOWN
MENU_BUTTON_START, #define MENU_BUTTON_START GAME_BUTTON_START
MENU_BUTTON_SELECT, #define MENU_BUTTON_SELECT GAME_BUTTON_SELECT
MENU_BUTTON_BACK, #define MENU_BUTTON_BACK GAME_BUTTON_BACK
MENU_BUTTON_COIN, #define MENU_BUTTON_COIN GAME_BUTTON_COIN
MENU_BUTTON_OPERATOR, #define MENU_BUTTON_OPERATOR GAME_BUTTON_OPERATOR
NUM_MenuButton, // leave this at the end #define MenuButton_Invalid GameButton_Invalid
MenuButton_Invalid #define NUM_MenuButton NUM_GameButton
};
#define FOREACH_MenuButton( m ) FOREACH_ENUM( MenuButton, m ) #define FOREACH_MenuButton( m ) FOREACH_ENUM( MenuButton, m )
const RString &MenuButtonToString( MenuButton mb );
const RString &MenuButtonToLocalizedString( MenuButton mb );
#endif #endif
/* /*
+1 -1
View File
@@ -105,7 +105,7 @@ void ScreenMapControllers::Init()
MenuButton mb = INPUTMAPPER->GetInputScheme()->GetMenuButtonSecondaryFunction( pKey->m_GameButton ); MenuButton mb = INPUTMAPPER->GetInputScheme()->GetMenuButtonSecondaryFunction( pKey->m_GameButton );
RString sText; RString sText;
if( mb != MenuButton_Invalid ) if( mb != MenuButton_Invalid )
sText = MenuButtonToLocalizedString( mb ); sText = GameButtonToLocalizedString( INPUTMAPPER->GetInputScheme(), mb );
ActorUtil::LoadAllCommands( *pSecondary, m_sName ); ActorUtil::LoadAllCommands( *pSecondary, m_sName );
pSecondary->SetText( sText ); pSecondary->SetText( sText );
m_Line[iRow].AddChild( pSecondary ); m_Line[iRow].AddChild( pSecondary );
+4 -1
View File
@@ -61,7 +61,10 @@ class InputList: public BitmapText
{ {
MenuButton mb = INPUTMAPPER->GetInputScheme()->GetMenuButtonSecondaryFunction( gi.button ); MenuButton mb = INPUTMAPPER->GetInputScheme()->GetMenuButtonSecondaryFunction( gi.button );
if( mb != MenuButton_Invalid ) if( mb != MenuButton_Invalid )
sTemp += ssprintf( " - (%s %s)", MenuButtonToLocalizedString(mb).c_str(), SECONDARY.GetValue().c_str() ); {
RString sGameButtonString = GameButtonToLocalizedString( INPUTMAPPER->GetInputScheme(), mb );
sTemp += ssprintf( " - (%s %s)", sGameButtonString.c_str(), SECONDARY.GetValue().c_str() );
}
} }
} }
else else