mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Merge pull request #3063 from thedax/win32OSKBypass
Win32: Allow user to change emulated PSP nickname, and add an OSK "bypass"
This commit is contained in:
commit
f203997c6e
7 changed files with 160 additions and 1 deletions
|
@ -161,6 +161,9 @@ void Config::Load(const char *iniFileName)
|
|||
pspConfig->Get("ButtonPreference", &iButtonPreference, PSP_SYSTEMPARAM_BUTTON_CROSS);
|
||||
pspConfig->Get("LockParentalLevel", &iLockParentalLevel, 0);
|
||||
pspConfig->Get("WlanAdhocChannel", &iWlanAdhocChannel, PSP_SYSTEMPARAM_ADHOC_CHANNEL_AUTOMATIC);
|
||||
#ifdef _WIN32
|
||||
pspConfig->Get("BypassOSKWithKeyboard", &bBypassOSKWithKeyboard, false);
|
||||
#endif
|
||||
pspConfig->Get("WlanPowerSave", &bWlanPowerSave, PSP_SYSTEMPARAM_WLAN_POWERSAVE_OFF);
|
||||
pspConfig->Get("EncryptSave", &bEncryptSave, true);
|
||||
|
||||
|
@ -281,6 +284,9 @@ void Config::Save()
|
|||
pspConfig->Set("WlanAdhocChannel", iWlanAdhocChannel);
|
||||
pspConfig->Set("WlanPowerSave", bWlanPowerSave);
|
||||
pspConfig->Set("EncryptSave", bEncryptSave);
|
||||
#ifdef _WIN32
|
||||
pspConfig->Set("BypassOSKWithKeyboard", bBypassOSKWithKeyboard);
|
||||
#endif
|
||||
|
||||
IniFile::Section *debugConfig = iniFile.GetOrCreateSection("Debugger");
|
||||
debugConfig->Set("DisasmWindowX", iDisasmWindowX);
|
||||
|
|
|
@ -139,6 +139,10 @@ public:
|
|||
bool bEncryptSave;
|
||||
int iWlanAdhocChannel;
|
||||
bool bWlanPowerSave;
|
||||
// TODO: Make this work with your platform, too!
|
||||
#ifdef _WIN32
|
||||
bool bBypassOSKWithKeyboard;
|
||||
#endif
|
||||
|
||||
// Debugger
|
||||
int iDisasmWindowX;
|
||||
|
|
|
@ -32,6 +32,14 @@
|
|||
#include <math.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "../Windows/InputBox.h"
|
||||
namespace MainWindow {
|
||||
extern HWND hwndMain;
|
||||
HINSTANCE GetHinstance();
|
||||
};
|
||||
#endif
|
||||
|
||||
const int numKeyCols[OSK_KEYBOARD_COUNT] = {12, 12, 13, 13, 12, 12, 12};
|
||||
const int numKeyRows[OSK_KEYBOARD_COUNT] = {4, 4, 5, 5, 5, 4, 4};
|
||||
|
||||
|
@ -732,12 +740,95 @@ void PSPOskDialog::RenderKeyboard()
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: Why does this have a 2 button press lag/delay when
|
||||
// re-opening the dialog box? I don't get it.
|
||||
// TODO: Use a wstring to allow Japanese/Russian/etc.. on _WIN32(others?)
|
||||
int PSPOskDialog::NativeKeyboard()
|
||||
{
|
||||
char *input = new char[FieldMaxLength()];
|
||||
memset(input, 0, sizeof(input));
|
||||
|
||||
if (status == SCE_UTILITY_STATUS_INITIALIZE)
|
||||
{
|
||||
status = SCE_UTILITY_STATUS_RUNNING;
|
||||
}
|
||||
|
||||
else if (status == SCE_UTILITY_STATUS_RUNNING)
|
||||
{
|
||||
|
||||
#ifdef _WIN32
|
||||
std::string initial_text;
|
||||
ConvertUCS2ToUTF8(initial_text, oskParams->fields[0].intext);
|
||||
|
||||
const size_t defaultText_len = 512;
|
||||
char defaultText[defaultText_len];
|
||||
|
||||
memset(defaultText, 0, sizeof(defaultText));
|
||||
|
||||
if(initial_text.length() < defaultText_len)
|
||||
strncat(defaultText, initial_text.c_str(), strlen(initial_text.c_str()));
|
||||
else {
|
||||
ERROR_LOG(HLE, "NativeKeyboard: initial text length is too long");
|
||||
strncat(defaultText, "VALUE", strlen("VALUE"));
|
||||
}
|
||||
|
||||
char windowTitle[defaultText_len];
|
||||
memset(windowTitle, 0, sizeof(windowTitle));
|
||||
|
||||
std::string description_text;
|
||||
ConvertUCS2ToUTF8(description_text, oskParams->fields[0].desc);
|
||||
|
||||
if(description_text.length() < defaultText_len)
|
||||
strncat(windowTitle, description_text.c_str(), strlen(description_text.c_str()));
|
||||
|
||||
size_t maxInputLength = FieldMaxLength();
|
||||
|
||||
if(!InputBox_GetString(0, MainWindow::hwndMain, windowTitle, defaultText, input, maxInputLength)) {
|
||||
strncat(input, "", strlen(""));
|
||||
}
|
||||
#endif
|
||||
// TODO: Insert your platform's native keyboard stuff here...
|
||||
|
||||
status = SCE_UTILITY_STATUS_FINISHED;
|
||||
}
|
||||
else if (status == SCE_UTILITY_STATUS_FINISHED)
|
||||
{
|
||||
status = SCE_UTILITY_STATUS_SHUTDOWN;
|
||||
}
|
||||
|
||||
u16_le *outText = oskParams->fields[0].outtext;
|
||||
for (u32 i = 0, end = oskParams->fields[0].outtextlength; i < end; ++i)
|
||||
{
|
||||
u16 value = 0;
|
||||
if (i < ARRAY_SIZE(input))
|
||||
value = input[i];
|
||||
outText[i] = value;
|
||||
}
|
||||
|
||||
oskParams->base.result = 0;
|
||||
oskParams->fields[0].result = PSP_UTILITY_OSK_RESULT_CHANGED;
|
||||
|
||||
delete [] input;
|
||||
input = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PSPOskDialog::Update()
|
||||
{
|
||||
buttons = __CtrlReadLatch();
|
||||
int selectedRow = selectedChar / numKeyCols[currentKeyboard];
|
||||
int selectedExtra = selectedChar % numKeyCols[currentKeyboard];
|
||||
|
||||
// TODO: Add your platforms here when you have a NativeKeyboard func.
|
||||
|
||||
#ifdef _WIN32
|
||||
// Fall back to the OSK/continue normally if we're in fullscreen. The dialog box
|
||||
// doesn't work right if in fullscreen.
|
||||
if(g_Config.bBypassOSKWithKeyboard && !g_Config.bFullScreen)
|
||||
return NativeKeyboard();
|
||||
#endif
|
||||
|
||||
u32 limit = FieldMaxLength();
|
||||
|
||||
if (status == SCE_UTILITY_STATUS_INITIALIZE)
|
||||
|
|
|
@ -178,6 +178,9 @@ private:
|
|||
void ConvertUCS2ToUTF8(std::string& _string, const PSPPointer<u16_le> em_address);
|
||||
void ConvertUCS2ToUTF8(std::string& _string, const wchar_t *input);
|
||||
void RenderKeyboard();
|
||||
#ifdef _WIN32
|
||||
int NativeKeyboard();
|
||||
#endif
|
||||
|
||||
std::wstring CombinationString(bool isInput); // for Japanese, Korean
|
||||
std::wstring CombinationKorean(bool isInput); // for Korea
|
||||
|
|
|
@ -72,6 +72,10 @@
|
|||
#include <QDir>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "Windows/InputBox.h"
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
namespace MainWindow {
|
||||
enum {
|
||||
|
@ -79,6 +83,7 @@ namespace MainWindow {
|
|||
};
|
||||
extern HWND hwndMain;
|
||||
void BrowseAndBoot(std::string defaultPath, bool browseDirectory = false);
|
||||
HINSTANCE GetHInstance();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1531,6 +1536,28 @@ void SystemScreen::render() {
|
|||
}
|
||||
y += 20;
|
||||
|
||||
// TODO: Come up with a way to display a keyboard for mobile users,
|
||||
// so until then, this is Windows/Desktop only.
|
||||
#ifdef _WIN32
|
||||
char nickname[512];
|
||||
memset(nickname, 0, sizeof(nickname));
|
||||
|
||||
sprintf(nickname, "%s %s", s->T("System Nickname: "), g_Config.sNickName.c_str());
|
||||
ui_draw2d.DrawTextShadow(UBUNTU24, nickname, x, y += stride, 0xFFFFFFFF, ALIGN_LEFT);
|
||||
|
||||
HLinear hlinearNick(x + 400, y, 10);
|
||||
if(UIButton(GEN_ID, hlinearNick, 110, 0, s->T("Change"), ALIGN_LEFT)) {
|
||||
const size_t name_len = 256;
|
||||
|
||||
char name[name_len];
|
||||
memset(name, 0, sizeof(name));
|
||||
|
||||
if(InputBox_GetString(MainWindow::GetHInstance(), MainWindow::hwndMain, "Enter a new PSP nickname", "PPSSPP", name, name_len))
|
||||
g_Config.sNickName.assign(name);
|
||||
else
|
||||
g_Config.sNickName.assign("PPSSPP");
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
bool time = g_Config.iTimeFormat > 0 ;
|
||||
UICheckBox(GEN_ID, x, y += stride, s->T("Time Format"), ALIGN_TOPLEFT, &time);
|
||||
|
|
|
@ -4,12 +4,14 @@
|
|||
|
||||
static TCHAR textBoxContents[256];
|
||||
static TCHAR out[256];
|
||||
static TCHAR windowTitle[256];
|
||||
|
||||
static INT_PTR CALLBACK InputBoxFunc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message) {
|
||||
case WM_INITDIALOG:
|
||||
SetWindowText(GetDlgItem(hDlg,IDC_INPUTBOX),textBoxContents);
|
||||
SetWindowText(hDlg, windowTitle);
|
||||
return TRUE;
|
||||
case WM_COMMAND:
|
||||
switch (wParam)
|
||||
|
@ -49,6 +51,32 @@ bool InputBox_GetString(HINSTANCE hInst, HWND hParent, TCHAR *title, TCHAR *defa
|
|||
return false;
|
||||
}
|
||||
|
||||
bool InputBox_GetString(HINSTANCE hInst, HWND hParent, TCHAR *title, TCHAR *defaultvalue, TCHAR *outvalue, size_t outlength)
|
||||
{
|
||||
const char *defaultTitle = "Input value";
|
||||
|
||||
if (defaultvalue && strlen(defaultvalue)<255)
|
||||
strcpy(textBoxContents,defaultvalue);
|
||||
else
|
||||
strcpy(textBoxContents,"");
|
||||
|
||||
|
||||
if(title && strlen(title) <= 0)
|
||||
strcpy(windowTitle, defaultTitle);
|
||||
else if(title && strlen(title) < 255)
|
||||
strcpy(windowTitle, title);
|
||||
else
|
||||
strcpy(windowTitle, defaultTitle);
|
||||
|
||||
if (IDOK==DialogBox(hInst,(LPCSTR)IDD_INPUTBOX,hParent,InputBoxFunc))
|
||||
{
|
||||
strncpy(outvalue, out, outlength);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool InputBox_GetHex(HINSTANCE hInst, HWND hParent, TCHAR *title, u32 defaultvalue, u32 &outvalue)
|
||||
{
|
||||
sprintf(textBoxContents,"%08x",defaultvalue);
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
#include "Globals.h"
|
||||
|
||||
#include "Common/CommonWindows.h"
|
||||
|
||||
bool InputBox_GetString(HINSTANCE hInst, HWND hParent, TCHAR *title, TCHAR *defaultvalue, TCHAR *outvalue);
|
||||
bool InputBox_GetString(HINSTANCE hInst, HWND hParent, TCHAR *title, TCHAR *defaultvalue, TCHAR *outvalue, size_t outlength);
|
||||
bool InputBox_GetHex(HINSTANCE hInst, HWND hParent, TCHAR *title, u32 defaultvalue, u32 &outvalue);
|
||||
|
|
Loading…
Add table
Reference in a new issue