show input device list on mapping screen

This commit is contained in:
Chris Danford
2006-01-26 06:17:57 +00:00
parent 58a8830b9d
commit 62833f56cb
5 changed files with 37 additions and 20 deletions
+18 -1
View File
@@ -62,7 +62,7 @@ bool RageInput::DevicesChanged()
return false;
}
void RageInput::GetDevicesAndDescriptions( vector<InputDevice>& vDevicesOut, vector<RString>& vDescriptionsOut )
void RageInput::GetDevicesAndDescriptions( vector<InputDevice>& vDevicesOut, vector<RString>& vDescriptionsOut ) const
{
for( unsigned i = 0; i < m_pDevices.size(); ++i )
m_pDevices[i]->GetDevicesAndDescriptions( vDevicesOut, vDescriptionsOut );
@@ -112,6 +112,23 @@ InputDeviceState RageInput::GetInputDeviceState( InputDevice id )
return InputDeviceState_INVALID;
}
RString RageInput::GetDisplayDevicesString() const
{
vector<InputDevice> vDevices;
vector<RString> vDescriptions;
vector<RString> vs;
GetDevicesAndDescriptions( vDevices, vDescriptions );
ASSERT( vDevices.size() == vDescriptions.size() );
for( unsigned i=0; i<vDevices.size(); ++i )
{
const RString sDescription = vDescriptions[i];
InputDevice device = vDevices[i];
if( sDescription == "MonkeyKeyboard" )
continue; // hide this
vs.push_back( ssprintf("%s (%s)", sDescription.c_str(), InputDeviceToString(device).c_str()) );
}
return join("\n",vs);
}
// lua start
#include "LuaBinding.h"
+2 -1
View File
@@ -17,11 +17,12 @@ public:
void LoadDrivers();
void Update();
bool DevicesChanged();
void GetDevicesAndDescriptions( vector<InputDevice>& vDevicesOut, vector<RString>& vsDescriptionsOut );
void GetDevicesAndDescriptions( vector<InputDevice>& vDevicesOut, vector<RString>& vsDescriptionsOut ) const;
void WindowReset();
void AddHandler( InputHandler *pHandler );
RString GetDeviceSpecificInputString( const DeviceInput &di );
InputDeviceState GetInputDeviceState( InputDevice id );
RString GetDisplayDevicesString() const;
// Lua
void PushSelf( lua_State *L );
+14
View File
@@ -38,6 +38,14 @@ void ScreenMapControllers::Init()
m_soundChange.Load( THEME->GetPathS(m_sName,"change"), true );
m_soundDelete.Load( THEME->GetPathS(m_sName,"delete"), true );
m_textDevices.LoadFromFont( THEME->GetPathF("Common","normal") );
m_textDevices.SetXY( SCREEN_CENTER_X, SCREEN_TOP+30 );
m_textDevices.SetDiffuse( RageColor(1,1,1,1) );
m_textDevices.SetZoom( 0.6f );
this->AddChild( &m_textDevices );
RString sButtons = BUTTONS_TO_MAP;
if( sButtons.empty() )
{
@@ -167,6 +175,12 @@ void ScreenMapControllers::Update( float fDeltaTime )
ScreenWithMenuElements::Update( fDeltaTime );
//
// Update devices text
//
m_textDevices.SetText( INPUTMAN->GetDisplayDevicesString() );
if( !m_WaitingForPress.IsZero() && m_DeviceIToMap.IsValid() ) // we're going to map an input
{
if( m_WaitingForPress.PeekDeltaTime() < g_fSecondsToWaitForInput )
+2 -2
View File
@@ -9,8 +9,6 @@
#include "ActorScroller.h"
#include "RageSound.h"
enum { NUM_SHOWN_GAME_TO_DEVICE_SLOTS = 3 };
class ScreenMapControllers : public ScreenWithMenuElements
{
public:
@@ -48,6 +46,8 @@ private:
};
vector<KeyToMap> m_KeysToMap;
BitmapText m_textDevices;
BitmapText m_textLabel[MAX_GAME_CONTROLLERS];
AutoActor m_sprExit;
+1 -16
View File
@@ -49,22 +49,7 @@ void ScreenTestInput::Update( float fDeltaTime )
//
// Update devices text
//
{
vector<InputDevice> vDevices;
vector<RString> vDescriptions;
vector<RString> vs;
INPUTMAN->GetDevicesAndDescriptions( vDevices, vDescriptions );
ASSERT( vDevices.size() == vDescriptions.size() );
for( unsigned i=0; i<vDevices.size(); ++i )
{
const RString sDescription = vDescriptions[i];
InputDevice device = vDevices[i];
if( sDescription == "MonkeyKeyboard" )
continue; // hide this
vs.push_back( ssprintf("%s (%s)", sDescription.c_str(), InputDeviceToString(device).c_str()) );
}
m_textDevices.SetText( join("\n",vs) );
}
m_textDevices.SetText( INPUTMAN->GetDisplayDevicesString() );
//
// Update input texts