play command when InputDeviceState changes
This commit is contained in:
@@ -10,25 +10,28 @@
|
|||||||
#include "LuaBinding.h"
|
#include "LuaBinding.h"
|
||||||
|
|
||||||
static const char *ControllerStateButtonNames[] = {
|
static const char *ControllerStateButtonNames[] = {
|
||||||
"Up",
|
"UpLeft",
|
||||||
"Down",
|
"UpRight",
|
||||||
"Left",
|
"Center",
|
||||||
"Right",
|
"DownLeft",
|
||||||
|
"DownRight",
|
||||||
};
|
};
|
||||||
XToString( ControllerStateButton );
|
XToString( ControllerStateButton );
|
||||||
|
|
||||||
static const DeviceButton ControllerStateButtonToDeviceButton[] = {
|
static const DeviceButton ControllerStateButtonToDeviceButton[] = {
|
||||||
JOY_UP,
|
JOY_BUTTON_1,
|
||||||
JOY_DOWN,
|
JOY_BUTTON_2,
|
||||||
JOY_LEFT,
|
JOY_BUTTON_3,
|
||||||
JOY_RIGHT,
|
JOY_BUTTON_4,
|
||||||
|
JOY_BUTTON_5,
|
||||||
};
|
};
|
||||||
// TODO: Generalize for all game types
|
// TODO: Generalize for all game types
|
||||||
static const GameButton ControllerStateButtonToGameButton[] = {
|
static const GameButton ControllerStateButtonToGameButton[] = {
|
||||||
DANCE_BUTTON_UP,
|
PUMP_BUTTON_UPLEFT,
|
||||||
DANCE_BUTTON_DOWN,
|
PUMP_BUTTON_UPRIGHT,
|
||||||
DANCE_BUTTON_LEFT,
|
PUMP_BUTTON_CENTER,
|
||||||
DANCE_BUTTON_RIGHT,
|
PUMP_BUTTON_DOWNLEFT,
|
||||||
|
PUMP_BUTTON_DOWNRIGHT,
|
||||||
};
|
};
|
||||||
|
|
||||||
REGISTER_ACTOR_CLASS( ControllerStateDisplay )
|
REGISTER_ACTOR_CLASS( ControllerStateDisplay )
|
||||||
@@ -37,6 +40,7 @@ ControllerStateDisplay::ControllerStateDisplay()
|
|||||||
{
|
{
|
||||||
m_bIsLoaded = false;
|
m_bIsLoaded = false;
|
||||||
m_mp = MultiPlayer_Invalid;
|
m_mp = MultiPlayer_Invalid;
|
||||||
|
m_idsLast = InputDeviceState_Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControllerStateDisplay::LoadMultiPlayer( MultiPlayer mp )
|
void ControllerStateDisplay::LoadMultiPlayer( MultiPlayer mp )
|
||||||
@@ -53,11 +57,12 @@ void ControllerStateDisplay::LoadInternal( MultiPlayer mp, GameController gc )
|
|||||||
{
|
{
|
||||||
ASSERT( !m_bIsLoaded );
|
ASSERT( !m_bIsLoaded );
|
||||||
m_bIsLoaded = true;
|
m_bIsLoaded = true;
|
||||||
|
m_mp = mp;
|
||||||
|
|
||||||
|
LuaThreadVariable varElement( "MultiPlayer", LuaReference::Create(m_mp) );
|
||||||
m_sprFrame.Load( THEME->GetPathG("ControllerStateDisplay", "frame") );
|
m_sprFrame.Load( THEME->GetPathG("ControllerStateDisplay", "frame") );
|
||||||
this->AddChild( m_sprFrame );
|
this->AddChild( m_sprFrame );
|
||||||
|
|
||||||
m_mp = mp;
|
|
||||||
FOREACH_ENUM( ControllerStateButton, b )
|
FOREACH_ENUM( ControllerStateButton, b )
|
||||||
{
|
{
|
||||||
Button &button = m_Buttons[ b ];
|
Button &button = m_Buttons[ b ];
|
||||||
@@ -74,6 +79,17 @@ void ControllerStateDisplay::Update( float fDelta )
|
|||||||
{
|
{
|
||||||
ActorFrame::Update( fDelta );
|
ActorFrame::Update( fDelta );
|
||||||
|
|
||||||
|
if( m_mp != MultiPlayer_Invalid )
|
||||||
|
{
|
||||||
|
InputDevice id = InputMapper::MultiPlayerToInputDevice( m_mp );
|
||||||
|
InputDeviceState ids = INPUTMAN->GetInputDeviceState(id);
|
||||||
|
if( ids != m_idsLast )
|
||||||
|
{
|
||||||
|
PlayCommand( InputDeviceStateToString(ids) );
|
||||||
|
}
|
||||||
|
m_idsLast = ids;
|
||||||
|
}
|
||||||
|
|
||||||
FOREACH_ENUM( ControllerStateButton, b )
|
FOREACH_ENUM( ControllerStateButton, b )
|
||||||
{
|
{
|
||||||
Button &button = m_Buttons[ b ];
|
Button &button = m_Buttons[ b ];
|
||||||
@@ -98,7 +114,7 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
LUA_REGISTER_DERIVED_CLASS( ControllerStateDisplay, Actor )
|
LUA_REGISTER_DERIVED_CLASS( ControllerStateDisplay, ActorFrame )
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) 2001-2004 Chris Danford
|
* (c) 2001-2004 Chris Danford
|
||||||
|
|||||||
@@ -12,10 +12,11 @@
|
|||||||
|
|
||||||
enum ControllerStateButton
|
enum ControllerStateButton
|
||||||
{
|
{
|
||||||
ControllerStateButton_Up,
|
ControllerStateButton_UpLeft,
|
||||||
ControllerStateButton_Down,
|
ControllerStateButton_UpRight,
|
||||||
ControllerStateButton_Left,
|
ControllerStateButton_Center,
|
||||||
ControllerStateButton_Right,
|
ControllerStateButton_DownLeft,
|
||||||
|
ControllerStateButton_DownRight,
|
||||||
NUM_ControllerStateButton
|
NUM_ControllerStateButton
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -55,6 +56,8 @@ protected:
|
|||||||
GameInput gi;
|
GameInput gi;
|
||||||
};
|
};
|
||||||
Button m_Buttons[NUM_ControllerStateButton];
|
Button m_Buttons[NUM_ControllerStateButton];
|
||||||
|
|
||||||
|
InputDeviceState m_idsLast;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user