2003-10-11 07:47:34 +00:00
|
|
|
#include "global.h"
|
|
|
|
|
#include "ScreenTestInput.h"
|
|
|
|
|
#include "ScreenManager.h"
|
|
|
|
|
#include "RageLog.h"
|
|
|
|
|
#include "InputMapper.h"
|
|
|
|
|
#include "GameState.h"
|
|
|
|
|
#include "ThemeManager.h"
|
2004-07-25 17:07:32 +00:00
|
|
|
#include "Game.h"
|
2004-09-21 06:07:12 +00:00
|
|
|
#include "ScreenDimensions.h"
|
2004-12-04 04:39:51 +00:00
|
|
|
#include "GameManager.h"
|
2005-04-23 22:50:13 +00:00
|
|
|
#include "PrefsManager.h"
|
2005-06-03 19:03:13 +00:00
|
|
|
#include "RageInput.h"
|
2005-09-05 02:26:50 +00:00
|
|
|
#include "InputEventPlus.h"
|
2003-10-11 07:47:34 +00:00
|
|
|
|
|
|
|
|
|
2004-11-26 17:28:47 +00:00
|
|
|
REGISTER_SCREEN_CLASS( ScreenTestInput );
|
2004-05-01 23:19:33 +00:00
|
|
|
ScreenTestInput::ScreenTestInput( CString sClassName ) : ScreenWithMenuElements( sClassName )
|
2003-10-11 07:47:34 +00:00
|
|
|
{
|
|
|
|
|
LOG->Trace( "ScreenTestInput::ScreenTestInput()" );
|
2005-02-23 06:29:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenTestInput::Init()
|
|
|
|
|
{
|
|
|
|
|
ScreenWithMenuElements::Init();
|
2003-10-11 07:47:34 +00:00
|
|
|
|
2005-06-03 19:03:13 +00:00
|
|
|
m_textDevices.LoadFromFont( THEME->GetPathF("Common","normal") );
|
|
|
|
|
m_textDevices.SetXY( SCREEN_LEFT+20, SCREEN_TOP+80 );
|
|
|
|
|
m_textDevices.SetDiffuse( RageColor(1,1,1,1) );
|
|
|
|
|
m_textDevices.SetZoom( 0.7f );
|
|
|
|
|
m_textDevices.SetHorizAlign( Actor::align_left );
|
|
|
|
|
this->AddChild( &m_textDevices );
|
|
|
|
|
|
2005-02-06 03:32:53 +00:00
|
|
|
m_textInputs.LoadFromFont( THEME->GetPathF("Common","normal") );
|
2005-04-23 22:50:13 +00:00
|
|
|
m_textInputs.SetXY( SCREEN_CENTER_X-250, SCREEN_CENTER_Y );
|
2003-10-11 07:47:34 +00:00
|
|
|
m_textInputs.SetDiffuse( RageColor(1,1,1,1) );
|
2005-04-23 22:50:13 +00:00
|
|
|
m_textInputs.SetZoom( 0.7f );
|
|
|
|
|
m_textInputs.SetHorizAlign( Actor::align_left );
|
2003-10-11 07:47:34 +00:00
|
|
|
this->AddChild( &m_textInputs );
|
|
|
|
|
|
2005-05-09 04:17:17 +00:00
|
|
|
this->SortByDrawOrder();
|
2003-10-11 07:47:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ScreenTestInput::~ScreenTestInput()
|
|
|
|
|
{
|
|
|
|
|
LOG->Trace( "ScreenTestInput::~ScreenTestInput()" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ScreenTestInput::Update( float fDeltaTime )
|
|
|
|
|
{
|
|
|
|
|
Screen::Update( fDeltaTime );
|
|
|
|
|
|
2005-12-19 10:00:47 +00:00
|
|
|
//
|
|
|
|
|
// Update devices text
|
|
|
|
|
//
|
|
|
|
|
{
|
|
|
|
|
vector<InputDevice> vDevices;
|
|
|
|
|
vector<CString> vDescriptions;
|
|
|
|
|
vector<CString> vs;
|
|
|
|
|
INPUTMAN->GetDevicesAndDescriptions( vDevices, vDescriptions );
|
|
|
|
|
ASSERT( vDevices.size() == vDescriptions.size() );
|
|
|
|
|
for( unsigned i=0; i<vDevices.size(); ++i )
|
|
|
|
|
{
|
|
|
|
|
const CString 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) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Update input texts
|
|
|
|
|
//
|
2005-12-09 21:36:22 +00:00
|
|
|
vector<CString> asInputs;
|
2003-10-11 07:47:34 +00:00
|
|
|
|
|
|
|
|
DeviceInput di;
|
2005-12-28 20:41:51 +00:00
|
|
|
vector<DeviceInput> DeviceInputs;
|
|
|
|
|
INPUTFILTER->GetPressedButtons( DeviceInputs );
|
|
|
|
|
FOREACH( DeviceInput, DeviceInputs, di )
|
2003-10-11 07:47:34 +00:00
|
|
|
{
|
2005-12-28 20:41:51 +00:00
|
|
|
CString sTemp;
|
|
|
|
|
sTemp += INPUTMAN->GetDeviceSpecificInputString(*di);
|
|
|
|
|
|
|
|
|
|
GameInput gi;
|
|
|
|
|
if( INPUTMAPPER->DeviceToGame(*di,gi) )
|
2003-10-11 07:47:34 +00:00
|
|
|
{
|
2005-12-28 20:41:51 +00:00
|
|
|
CString sName = GAMESTATE->GetCurrentGame()->m_szButtonNames[gi.button];
|
|
|
|
|
sTemp += ssprintf(" - Controller %d %s", gi.controller+1, sName.c_str() );
|
2005-05-08 08:54:35 +00:00
|
|
|
|
2005-12-28 20:41:51 +00:00
|
|
|
if( !PREFSMAN->m_bOnlyDedicatedMenuButtons )
|
2005-05-08 08:54:35 +00:00
|
|
|
{
|
2005-12-28 20:41:51 +00:00
|
|
|
CString sSecondary = GAMEMAN->GetMenuButtonSecondaryFunction( GAMESTATE->GetCurrentGame(), gi.button );
|
|
|
|
|
if( !sSecondary.empty() )
|
|
|
|
|
sTemp += ssprintf(" - (%s secondary)", sSecondary.c_str() );
|
2005-05-08 08:54:35 +00:00
|
|
|
}
|
2005-12-28 20:41:51 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sTemp += " - not mapped";
|
|
|
|
|
}
|
2005-05-08 08:54:35 +00:00
|
|
|
|
2005-12-28 20:41:51 +00:00
|
|
|
CString sComment = INPUTFILTER->GetButtonComment( *di );
|
|
|
|
|
if( sComment != "" )
|
|
|
|
|
sTemp += " - " + sComment;
|
2005-05-08 09:19:35 +00:00
|
|
|
|
2005-12-28 20:41:51 +00:00
|
|
|
asInputs.push_back( sTemp );
|
2003-10-11 07:47:34 +00:00
|
|
|
}
|
|
|
|
|
|
2005-04-23 22:50:13 +00:00
|
|
|
m_textInputs.SetText( join( "\n", asInputs ) );
|
2003-10-11 07:47:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-09-05 02:26:50 +00:00
|
|
|
void ScreenTestInput::Input( const InputEventPlus &input )
|
2003-10-11 07:47:34 +00:00
|
|
|
{
|
2005-12-09 01:48:20 +00:00
|
|
|
CString sMessage = input.DeviceI.ToString();
|
2005-09-05 02:26:50 +00:00
|
|
|
switch( input.type )
|
2005-08-15 15:59:49 +00:00
|
|
|
{
|
|
|
|
|
case IET_FIRST_PRESS:
|
|
|
|
|
case IET_RELEASE:
|
|
|
|
|
{
|
2005-09-05 02:26:50 +00:00
|
|
|
switch( input.type )
|
2005-08-15 15:59:49 +00:00
|
|
|
{
|
|
|
|
|
case IET_FIRST_PRESS: sMessage += "Pressed"; break;
|
|
|
|
|
case IET_RELEASE: sMessage += "Released"; break;
|
|
|
|
|
}
|
|
|
|
|
MESSAGEMAN->Broadcast( sMessage );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-09-05 02:26:50 +00:00
|
|
|
if( input.type != IET_FIRST_PRESS && input.type != IET_SLOW_REPEAT )
|
2003-10-11 07:47:34 +00:00
|
|
|
return; // ignore
|
|
|
|
|
|
2005-09-05 02:26:50 +00:00
|
|
|
Screen::Input( input ); // default handler
|
2003-10-11 07:47:34 +00:00
|
|
|
}
|
|
|
|
|
|
2003-10-11 08:52:07 +00:00
|
|
|
void ScreenTestInput::MenuStart( PlayerNumber pn )
|
|
|
|
|
{
|
2003-12-20 21:36:09 +00:00
|
|
|
MenuBack(pn);
|
2003-10-11 08:52:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenTestInput::MenuBack( PlayerNumber pn )
|
|
|
|
|
{
|
2004-05-01 23:19:33 +00:00
|
|
|
if(!IsTransitioning())
|
2003-10-11 08:52:07 +00:00
|
|
|
{
|
2004-03-23 23:56:38 +00:00
|
|
|
SCREENMAN->PlayStartSound();
|
2005-10-13 22:17:13 +00:00
|
|
|
StartTransitioningScreen( SM_GoToPrevScreen );
|
2003-10-11 08:52:07 +00:00
|
|
|
}
|
|
|
|
|
}
|
2004-06-08 05:22:33 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* (c) 2003-2004 Chris Danford
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the
|
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
|
* distribute, and/or sell copies of the Software, and to permit persons to
|
|
|
|
|
* whom the Software is furnished to do so, provided that the above
|
|
|
|
|
* copyright notice(s) and this permission notice appear in all copies of
|
|
|
|
|
* the Software and that both the above copyright notice(s) and this
|
|
|
|
|
* permission notice appear in supporting documentation.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
|
|
|
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
|
|
|
|
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
|
|
|
|
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
|
|
|
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
|
|
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
*/
|