Files
itgmania212121/src/ScreenTestInput.cpp
T

158 lines
4.4 KiB
C++
Raw Normal View History

2003-10-11 07:47:34 +00:00
#include "global.h"
#include "ScreenTestInput.h"
#include "ScreenManager.h"
#include "RageLog.h"
#include "InputMapper.h"
#include "ThemeManager.h"
#include "ScreenDimensions.h"
2005-04-23 22:50:13 +00:00
#include "PrefsManager.h"
2005-06-03 19:03:13 +00:00
#include "RageInput.h"
#include "InputEventPlus.h"
2006-01-08 19:38:33 +00:00
#include "LocalizedString.h"
2003-10-11 07:47:34 +00:00
2006-03-19 02:06:31 +00:00
class DeviceList: public BitmapText
{
2006-03-19 02:06:31 +00:00
public:
void Update( float fDeltaTime )
{
//
// Update devices text
//
this->SetText( INPUTMAN->GetDisplayDevicesString() );
2006-03-19 02:32:51 +00:00
BitmapText::Update( fDeltaTime );
2006-03-19 02:06:31 +00:00
}
2003-10-11 07:47:34 +00:00
2006-10-20 00:17:51 +00:00
virtual DeviceList *Copy() const;
2006-03-19 02:06:31 +00:00
};
2003-10-11 07:47:34 +00:00
2006-03-19 02:06:31 +00:00
REGISTER_ACTOR_CLASS( DeviceList );
2003-10-11 07:47:34 +00:00
2006-01-08 19:38:33 +00:00
static LocalizedString CONTROLLER ( "ScreenTestInput", "Controller" );
static LocalizedString SECONDARY ( "ScreenTestInput", "secondary" );
static LocalizedString NOT_MAPPED ( "ScreenTestInput", "not mapped" );
2006-03-19 02:06:31 +00:00
class InputList: public BitmapText
2003-10-11 07:47:34 +00:00
{
2006-10-20 00:17:51 +00:00
virtual InputList *Copy() const;
2005-12-19 10:00:47 +00:00
2006-03-19 02:06:31 +00:00
void Update( float fDeltaTime )
2003-10-11 07:47:34 +00:00
{
2006-03-19 02:06:31 +00:00
//
// Update input texts
//
vector<RString> asInputs;
DeviceInput di;
vector<DeviceInput> DeviceInputs;
INPUTFILTER->GetPressedButtons( DeviceInputs );
FOREACH( DeviceInput, DeviceInputs, di )
2003-10-11 07:47:34 +00:00
{
if( !di->bDown && di->level == 0.0f )
continue;
2006-03-19 02:06:31 +00:00
RString sTemp;
sTemp += INPUTMAN->GetDeviceSpecificInputString(*di);
2007-01-18 04:23:20 +00:00
if( di->level == 1.0f )
sTemp += ssprintf(" - 1 " );
else
sTemp += ssprintf(" - %.3f ", di->level );
2006-03-19 02:06:31 +00:00
GameInput gi;
if( INPUTMAPPER->DeviceToGame(*di,gi) )
2005-05-08 08:54:35 +00:00
{
2006-09-30 08:24:05 +00:00
RString sName = GameButtonToLocalizedString( INPUTMAPPER->GetInputScheme(), gi.button );
2006-11-21 05:44:52 +00:00
sTemp += ssprintf(" - %s %d %s", CONTROLLER.GetValue().c_str(), gi.controller+1, sName.c_str() );
2006-03-19 02:06:31 +00:00
if( !PREFSMAN->m_bOnlyDedicatedMenuButtons )
{
GameButton mb = INPUTMAPPER->GetInputScheme()->GameButtonToMenuButton( gi.button );
if( mb != GameButton_Invalid && mb != gi.button )
2007-01-13 02:40:10 +00:00
{
RString sGameButtonString = GameButtonToLocalizedString( INPUTMAPPER->GetInputScheme(), mb );
sTemp += ssprintf( " - (%s %s)", sGameButtonString.c_str(), SECONDARY.GetValue().c_str() );
}
2006-03-19 02:06:31 +00:00
}
}
else
{
sTemp += " - "+NOT_MAPPED.GetValue();
2005-05-08 08:54:35 +00:00
}
2006-03-19 02:06:31 +00:00
RString sComment = INPUTFILTER->GetButtonComment( *di );
if( sComment != "" )
sTemp += " - " + sComment;
2005-05-08 09:19:35 +00:00
2006-03-19 02:06:31 +00:00
asInputs.push_back( sTemp );
}
this->SetText( join( "\n", asInputs ) );
2003-10-11 07:47:34 +00:00
2006-03-19 02:32:51 +00:00
BitmapText::Update( fDeltaTime );
}
2006-03-19 02:06:31 +00:00
};
2003-10-11 07:47:34 +00:00
2006-03-19 02:06:31 +00:00
REGISTER_ACTOR_CLASS( InputList );
REGISTER_SCREEN_CLASS( ScreenTestInput );
2003-10-11 07:47:34 +00:00
void ScreenTestInput::Input( const InputEventPlus &input )
2003-10-11 07:47:34 +00:00
{
2006-01-22 01:00:06 +00:00
RString sMessage = input.DeviceI.ToString();
switch( input.type )
{
case IET_FIRST_PRESS:
case IET_RELEASE:
2006-01-24 01:00:49 +00:00
switch( input.type )
{
2006-01-24 01:00:49 +00:00
case IET_FIRST_PRESS: sMessage += "Pressed"; break;
2007-03-25 23:41:32 +00:00
case IET_RELEASE: sMessage += "Released"; break;
}
2006-01-24 01:00:49 +00:00
MESSAGEMAN->Broadcast( sMessage );
}
Screen::Input( input ); // default handler
2003-10-11 07:47:34 +00:00
}
2006-09-15 01:47:24 +00:00
void ScreenTestInput::MenuStart( const InputEventPlus &input )
2003-10-11 08:52:07 +00:00
{
2006-09-15 01:47:24 +00:00
MenuBack( input );
2003-10-11 08:52:07 +00:00
}
2006-09-15 01:47:24 +00:00
void ScreenTestInput::MenuBack( const InputEventPlus &input )
2003-10-11 08:52:07 +00:00
{
if( input.type != IET_REPEAT )
return; // ignore
2006-01-24 01:00:49 +00:00
if( !IsTransitioning() )
2003-10-11 08:52:07 +00:00
{
SCREENMAN->PlayStartSound();
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.
*/