GetDeviceSpecificInputString and DeviceInputToLocalizedString are

the same: "a string suitable for display", but just formatted slightly
differently.  Handle these the same way (so hopefully a way to merge
them will become visible).

This also fixes the RageInputDevice dependency on RageInput.
This commit is contained in:
Glenn Maynard
2006-06-15 06:07:45 +00:00
parent 7578717a5a
commit 3c9897989c
7 changed files with 63 additions and 48 deletions
-44
View File
@@ -7,8 +7,6 @@
#include "RageInputDevice.h"
#include "RageUtil.h"
#include "EnumHelper.h"
#include "LocalizedString.h"
#include "RageInput.h"
static map<DeviceButton,RString> g_mapNamesToString;
static map<RString,DeviceButton> g_mapStringToNames;
@@ -150,48 +148,6 @@ RString DeviceButtonToString( DeviceButton key )
return "unknown";
}
static LocalizedString HOME ( "DeviceButton", "Home" );
static LocalizedString END ( "DeviceButton", "End" );
static LocalizedString UP ( "DeviceButton", "Up" );
static LocalizedString DOWN ( "DeviceButton", "Down" );
static LocalizedString SPACE ( "DeviceButton", "Space" );
static LocalizedString SHIFT ( "DeviceButton", "Shift" );
static LocalizedString CTRL ( "DeviceButton", "Ctrl" );
static LocalizedString ALT ( "DeviceButton", "Alt" );
static LocalizedString INSERT ( "DeviceButton", "Insert" );
static LocalizedString DELETE ( "DeviceButton", "Delete" );
static LocalizedString PGUP ( "DeviceButton", "PgUp" );
static LocalizedString PGDN ( "DeviceButton", "PgDn" );
static LocalizedString BACKSLASH ( "DeviceButton", "Backslash" );
/* Return the name of the button, as it probably appears on the device itself, such as a keycap;
* eg. "a". */
RString DeviceInputToLocalizedString( DeviceInput di )
{
switch( di.button )
{
case KEY_HOME: return HOME.GetValue();
case KEY_END: return END.GetValue();
case KEY_UP: return UP.GetValue();
case KEY_DOWN: return DOWN.GetValue();
case KEY_SPACE: return SPACE.GetValue();
case KEY_LSHIFT: case KEY_RSHIFT: return SHIFT.GetValue();
case KEY_LCTRL: case KEY_RCTRL: return CTRL.GetValue();
case KEY_LALT: case KEY_RALT: return ALT.GetValue();
case KEY_INSERT: return INSERT.GetValue();
case KEY_DEL: return DELETE.GetValue();
case KEY_PGUP: return PGUP.GetValue();
case KEY_PGDN: return PGDN.GetValue();
case KEY_BACKSLASH: return BACKSLASH.GetValue();
default:
wchar_t c = INPUTMAN->DeviceInputToChar(di,false);
if( c )
return Capitalize( WStringToRString(wstring()+c) );
return Capitalize( DeviceButtonToString(di.button) );
}
}
DeviceButton StringToDeviceButton( const RString& s )
{
InitNames();