Translate non-keyboard input to keyboard input

This commit is contained in:
Ryan Dortmans
2004-11-26 23:33:07 +00:00
parent e2d265993f
commit 7bbfaaa061
12 changed files with 347 additions and 56 deletions
+6
View File
@@ -324,6 +324,8 @@ void PrefsManager::Init()
m_sMemoryCardProfileSubdir = PRODUCT_NAME;
m_iProductID = 1;
m_bEnableVirtualKeyboard = true;
#if defined(XBOX)
m_bEnableVirtualMemory = true;
m_iPageFileSize = 384;
@@ -589,6 +591,8 @@ void PrefsManager::ReadPrefsFromFile( CString sIni )
FixSlashesInPlace(m_sAdditionalSongFolders);
FixSlashesInPlace(m_sAdditionalFolders);
ini.GetValue( "Options", "EnableVirtualKeyboard", m_bEnableVirtualKeyboard );
#if defined(XBOX)
ini.GetValue( "Options", "EnableVirtualMemory", m_bEnableVirtualMemory );
ini.GetValue( "Options", "PageFileSize", m_iPageFileSize );
@@ -850,6 +854,8 @@ void PrefsManager::SaveGlobalPrefsToDisk() const
ini.SetValue( "Options", "AdditionalSongFolders", m_sAdditionalSongFolders);
ini.SetValue( "Options", "AdditionalFolders", m_sAdditionalFolders);
ini.SetValue( "Options", "EnableVirtualKeyboard", m_bEnableVirtualKeyboard );
#if defined(XBOX)
ini.SetValue( "Options", "EnableVirtualMemory", m_bEnableVirtualMemory );
ini.SetValue( "Options", "PageFileSize", m_iPageFileSize );
+3
View File
@@ -278,6 +278,9 @@ public:
/* Game-specific prefs: */
CString m_sDefaultModifiers;
// Virtual keyboard
bool m_bEnableVirtualKeyboard;
#if defined(XBOX)
// Virtual memory preferences
bool m_bEnableVirtualMemory;
+3 -13
View File
@@ -11,10 +11,7 @@
#include "ScreenTextEntry.h"
#include "ScreenPrompt.h"
#include "NetworkSyncServer.h"
#if defined(XBOX)
#include "archutils/Xbox/VirtualKeyboard.h"
#endif
#include "VirtualKeyboard.h"
enum {
PO_CONNECTION,
@@ -117,11 +114,7 @@ void ScreenNetworkOptions::MenuStart( PlayerNumber pn, const InputEventType type
case PO_CONNECTION:
if ( !NSMAN->useSMserver )
{
#if defined(XBOX)
XBOX_VKB.Reset(VKMODE_IP);
#endif
VIRTUALKB.Reset(VKMODE_IP);
SCREENMAN->TextEntry( SM_DoneConnecting, "Enter a Network Address\n127.0.0.1 to connect to yourself", PREFSMAN->m_sLastServer );
}
else {
@@ -136,10 +129,7 @@ void ScreenNetworkOptions::MenuStart( PlayerNumber pn, const InputEventType type
case NO_START_SERVER:
if (!NSMAN->isLanServer)
{
#if defined(XBOX)
XBOX_VKB.Reset(VKMODE_PROFILE);
#endif
VIRTUALKB.Reset(VKMODE_PROFILE);
SCREENMAN->TextEntry( SM_ServerNameEnter, "Enter a server name...", "", NULL );
}
break;
+2 -7
View File
@@ -11,12 +11,9 @@
#include "RageFile.h"
#include "ScreenTextEntry.h"
#include "ScreenManager.h"
#include "VirtualKeyboard.h"
#include <cstdlib>
#if defined(XBOX)
#include "archutils/Xbox/VirtualKeyboard.h"
#endif
#define EXISTINGBG_WIDTH THEME->GetMetricF(m_sName,"PackagesBGWidth")
#define WEBBG_WIDTH THEME->GetMetricF(m_sName,"WebBGWidth")
#define NUM_PACKAGES_SHOW THEME->GetMetricI(m_sName,"NumPackagesShow")
@@ -162,9 +159,7 @@ void ScreenPackages::MenuStart( PlayerNumber pn )
{
if ( m_iLinksPos == 0 )
{
#if defined(XBOX)
XBOX_VKB.Reset(VKMODE_PROFILE); // allow all characters
#endif
VIRTUALKB.Reset(VKMODE_PROFILE); // allow all characters
SCREENMAN->TextEntry( SM_BackFromURL, "Enter URL:", "http://" );
}
else
+2 -7
View File
@@ -8,10 +8,7 @@
#include "ScreenManager.h"
#include "ScreenTextEntry.h"
#include "ScreenPrompt.h"
#if defined(XBOX)
#include "archutils/Xbox/VirtualKeyboard.h"
#endif
#include "VirtualKeyboard.h"
enum {
@@ -179,9 +176,7 @@ void ScreenProfileOptions::MenuStart( PlayerNumber pn, const InputEventType type
{
case PO_CREATE_NEW:
#if defined(XBOX)
XBOX_VKB.Reset(VKMODE_PROFILE); // set the xbox virtual keyboard to profile mode
#endif
VIRTUALKB.Reset(VKMODE_PROFILE); // set the xbox virtual keyboard to profile mode
SCREENMAN->TextEntry( SM_DoneCreating, "Enter a profile name", "", NULL );
break;
+18 -19
View File
@@ -9,10 +9,7 @@
#include "ThemeManager.h"
#include "FontCharAliases.h"
#include "ScreenDimensions.h"
#if defined(XBOX)
#include "archutils/Xbox/VirtualKeyboard.h"
#endif
#include "VirtualKeyboard.h"
#define QUESTION_X (SCREEN_CENTER_X)
#define QUESTION_Y (SCREEN_CENTER_Y - 60)
@@ -100,27 +97,29 @@ void ScreenTextEntry::Input( const DeviceInput& DeviceI, const InputEventType ty
int button = DeviceI.button;
#if defined(XBOX)
bool nextChar = false;
int toAdd = XBOX_VKB.Translate(button, m_sAnswer, &nextChar);
if( toAdd != 0 && toAdd != KEY_BACK && toAdd != KEY_ESC && toAdd != KEY_ENTER )
if(PREFSMAN->m_bEnableVirtualKeyboard)
{
if(!nextChar)
bool nextChar = false;
int toAdd = VIRTUALKB.Translate(DeviceI, MenuI, m_sAnswer, &nextChar);
if( toAdd != 0 && toAdd != KEY_BACK && toAdd != KEY_ESC && toAdd != KEY_ENTER )
{
if(!m_sAnswer.empty())
m_sAnswer = m_sAnswer.erase( m_sAnswer.size()-1 );
if(!nextChar)
{
if(!m_sAnswer.empty())
m_sAnswer = m_sAnswer.erase( m_sAnswer.size()-1 );
}
m_sAnswer += toAdd;
UpdateText();
return;
}
m_sAnswer += toAdd;
UpdateText();
return;
button = toAdd;
}
button = toAdd;
#endif
switch( button )
{
+6
View File
@@ -2411,6 +2411,12 @@ cl /Zl /nologo /c verstub.cpp /Fo&quot;$(IntDir)&quot;\
<File
RelativePath="UnlockSystem.h">
</File>
<File
RelativePath=".\VirtualKeyboard.cpp">
</File>
<File
RelativePath=".\VirtualKeyboard.h">
</File>
</Filter>
<Filter
Name="Crypto"
+8
View File
@@ -3098,6 +3098,14 @@ SOURCE=.\UnlockSystem.cpp
SOURCE=.\UnlockSystem.h
# End Source File
# Begin Source File
SOURCE=.\VirtualKeyboard.cpp
# End Source File
# Begin Source File
SOURCE=.\VirtualKeyboard.h
# End Source File
# End Group
# Begin Group "Crypto"
+6
View File
@@ -2409,6 +2409,12 @@ cl /Zl /nologo /c verstub.cpp /Fo&quot;$(IntDir)&quot;\
<File
RelativePath="ezsockets.h">
</File>
<File
RelativePath=".\VirtualKeyboard.cpp">
</File>
<File
RelativePath=".\VirtualKeyboard.h">
</File>
</Filter>
<Filter
Name="Crypto"
+16 -10
View File
@@ -513,10 +513,10 @@ cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
RelativePath="ScreenNetEvaluation.h">
</File>
<File
RelativePath="ScreenNetSelectMusic.cpp">
RelativePath="ScreenNetRoom.cpp">
</File>
<File
RelativePath="ScreenNetSelectMusic.h">
RelativePath="ScreenNetRoom.h">
</File>
<File
RelativePath="ScreenNetSelectBase.cpp">
@@ -525,10 +525,10 @@ cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
RelativePath="ScreenNetSelectBase.h">
</File>
<File
RelativePath="ScreenNetRoom.cpp">
RelativePath="ScreenNetSelectMusic.cpp">
</File>
<File
RelativePath="ScreenNetRoom.h">
RelativePath="ScreenNetSelectMusic.h">
</File>
<File
RelativePath="ScreenNetworkOptions.cpp">
@@ -674,6 +674,12 @@ cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
<File
RelativePath="ScreenStyleSplash.h">
</File>
<File
RelativePath=".\ScreenSystemLayer.cpp">
</File>
<File
RelativePath=".\ScreenSystemLayer.h">
</File>
<File
RelativePath="ScreenTest.cpp">
</File>
@@ -1339,12 +1345,6 @@ cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
<File
RelativePath="archutils\Xbox\GraphicsWindow.h">
</File>
<File
RelativePath=".\archutils\Xbox\VirtualKeyboard.cpp">
</File>
<File
RelativePath=".\archutils\Xbox\VirtualKeyboard.h">
</File>
<File
RelativePath=".\archutils\Xbox\VirtualMemory.cpp">
</File>
@@ -2416,6 +2416,12 @@ cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
<File
RelativePath="UnlockSystem.h">
</File>
<File
RelativePath=".\VirtualKeyboard.cpp">
</File>
<File
RelativePath=".\VirtualKeyboard.h">
</File>
</Filter>
<Filter
Name="Crypto"
+219
View File
@@ -0,0 +1,219 @@
#include "global.h"
#include "VirtualKeyboard.h"
VirtualKeyboard VIRTUALKB;
VirtualKeyboard::VirtualKeyboard()
{
currentMode = VKMODE_PROFILE;
}
VirtualKeyboard::~VirtualKeyboard()
{
}
void VirtualKeyboard::Reset(VirtualKeyboardMode mode)
{
currentMode = mode;
}
int VirtualKeyboard::Translate(const DeviceInput& DeviceI, const MenuInput &MenuI, const wstring &cur_string, bool *nextChar)
{
*nextChar = false;
MenuButton button = MenuI.button;
if(button == MENU_BUTTON_LEFT)
return KEY_BACK;
else if(button == MENU_BUTTON_RIGHT)
{
*nextChar = true;
if(currentMode == VKMODE_PROFILE)
return ' ';
else
return '0';
}
else if(button == MENU_BUTTON_UP)
{
if(cur_string.empty())
{
*nextChar = true;
return 'a';
}
else
{
int c = cur_string[cur_string.size() - 1];
if(c == ' ')
c = 'a';
else if(c == 'z')
c = 'A';
else if(c == 'Z')
c = '0';
else if(c == '9' && currentMode != VKMODE_IP)
c = '!';
else if(c == '9' && currentMode == VKMODE_IP)
c = '.';
else if(c == '.' && currentMode == VKMODE_IP)
c = '0';
else if(c == '/')
c = ':';
else if(c == '@')
c = '[';
else if(c == '`')
c = '{';
else if(c == '~')
c = ' ';
else
c++;
return c;
}
}
else if(button == MENU_BUTTON_DOWN)
{
if(cur_string.empty())
{
*nextChar = true;
return 'z';
}
else
{
int c = cur_string[cur_string.size() - 1];
if(c == ' ')
c = '~';
else if(c == 'a')
c = ' ';
else if(c == 'A')
c = 'z';
else if(c == '0' && currentMode != VKMODE_IP)
c = 'Z';
else if(c == '0' && currentMode == VKMODE_IP)
c = '.';
else if(c == '.' && currentMode == VKMODE_IP)
c = '9';
else if(c == '!')
c = '9';
else if(c == ':')
c = '/';
else if(c == '[')
c = '@';
else if(c == '{')
c = '`';
else
c--;
return c;
}
}
else if(button == MENU_BUTTON_START)
return KEY_ENTER;
else if(button == MENU_BUTTON_BACK)
return KEY_ESC;
else
{
// platform specific handlers here
#if defined(XBOX)
int dButton = DeviceI.button;
if(dButton == JOY_1) // A
{
// make a space or .
if(currentMode != VKMODE_IP)
{
if(cur_string.empty())
*nextChar = true;
return ' ';
}
else if(currentMode == VKMODE_IP)
{
if(!cur_string.empty())
return '.';
else
return 0;
}
}
else if(dButton == JOY_4) // Y
{
// switch to next character type
if(cur_string.empty())
return 0;
int c = cur_string[cur_string.size() - 1];
if(c >= 'a' && c <= 'z')
{
c = toupper(c);
return c;
}
else if(c >= 'A' && c <= 'Z')
{
return '0';
}
else if(c >= '0' && c <= '9' && currentMode != VKMODE_IP)
{
return '!';
}
else if((c >= '!' && c <= '/') || (c >= ':' && c <= '@') ||
(c >= '[' && c <= '`') || (c >= '{' || c <= '~'))
{
return 'a';
}
}
else if(button == JOY_2) // B
{
// switch to previous character type
if(cur_string.empty())
return 0;
int c = cur_string[cur_string.size() - 1];
if(c >= 'a' && c <= 'z')
{
return '!';
}
else if(c >= 'A' && c <= 'Z')
{
return 'a';
}
else if(c >= '0' && c <= '9' && currentMode != VKMODE_IP)
{
return 'A';
}
else if((c >= '!' && c <= '/') || (c >= ':' && c <= '@') ||
(c >= '[' && c <= '`') || (c >= '{' || c <= '~'))
{
return '0';
}
}
#endif
return 0;
}
}
/*
* (c) 2004 Ryan Dortmans
* 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.
*/
+58
View File
@@ -0,0 +1,58 @@
/* Allows a user to input profile names or IP addresses without using a keyboard.
* Commands are mapped as follows:
* left - delete
* right - move cursor right (with space as default character)
* up/down - change right most character to next/previous character
*/
#if !defined(VIRTUAL_KEYBOARD_H)
#define VIRTUAL_KEYBOARD_H
#pragma once
#include "RageInputDevice.h"
#include "MenuInput.h"
enum VirtualKeyboardMode { VKMODE_PROFILE, VKMODE_IP };
class VirtualKeyboard
{
public:
VirtualKeyboard();
~VirtualKeyboard();
void Reset(VirtualKeyboardMode mode);
int Translate(const DeviceInput& DeviceI, const MenuInput &MenuI, const wstring &cur_string, bool *nextChar);
protected:
VirtualKeyboardMode currentMode;
};
extern VirtualKeyboard VIRTUALKB;
#endif
/*
* (c) 2004 Ryan Dortmans
* 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.
*/