From fc51cf2e5e33da0c10f4a154785d4b07124e0cc5 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 4 Jun 2013 22:39:42 -0700 Subject: [PATCH] Fix OSK on Android, wchar_t is not always 16 bits. Fixes #2073. --- Core/Dialog/PSPOskDialog.cpp | 27 +++++++++++++++++++++++---- Core/Dialog/PSPOskDialog.h | 10 +++++----- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/Core/Dialog/PSPOskDialog.cpp b/Core/Dialog/PSPOskDialog.cpp index 7c63e952ab..c2cce814e8 100755 --- a/Core/Dialog/PSPOskDialog.cpp +++ b/Core/Dialog/PSPOskDialog.cpp @@ -124,7 +124,7 @@ PSPOskDialog::PSPOskDialog() : PSPDialog() { PSPOskDialog::~PSPOskDialog() { } -void PSPOskDialog::ConvertUCS2ToUTF8(std::string& _string, const PSPPointer em_address) +void PSPOskDialog::ConvertUCS2ToUTF8(std::string& _string, const PSPPointer em_address) { if (!em_address.Valid()) { @@ -132,10 +132,29 @@ void PSPOskDialog::ConvertUCS2ToUTF8(std::string& _string, const PSPPointer> 6); + *string++ = 0x80 | (c & 0x3F); + } else { + *string++ = 0xE0 | (c >> 12); + *string++ = 0x80 | ((c >> 6) & 0x3F); + *string++ = 0x80 | (c & 0x3F); + } + } + *string++ = '\0'; + _string = stringBuffer; } -void PSPOskDialog::ConvertUCS2ToUTF8(std::string& _string, wchar_t* input) +void PSPOskDialog::ConvertUCS2ToUTF8(std::string& _string, const wchar_t *input) { char stringBuffer[2048]; char *string = stringBuffer; @@ -809,7 +828,7 @@ int PSPOskDialog::Update() status = SCE_UTILITY_STATUS_SHUTDOWN; } - wchar_t *outText = oskParams->fields[0].outtext; + u16 *outText = oskParams->fields[0].outtext; for (u32 i = 0, end = oskParams->fields[0].outtextlength; i < end; ++i) { u16 value = 0; diff --git a/Core/Dialog/PSPOskDialog.h b/Core/Dialog/PSPOskDialog.h index 7082f9566d..ac205dbde8 100644 --- a/Core/Dialog/PSPOskDialog.h +++ b/Core/Dialog/PSPOskDialog.h @@ -111,13 +111,13 @@ struct SceUtilityOskData /** Unknown. Pass 0. */ int unk_24; /** Description text */ - PSPPointer desc; + PSPPointer desc; /** Initial text */ - PSPPointer intext; + PSPPointer intext; // Length, in unsigned shorts, including the terminator. u32 outtextlength; /** Pointer to the output text */ - PSPPointer outtext; + PSPPointer outtext; /** Result. One of ::SceUtilityOskResult */ int result; // Number of characters to allow, not including terminator (if less than outtextlength - 1.) @@ -163,8 +163,8 @@ public: virtual int Shutdown(bool force = false); virtual void DoState(PointerWrap &p); private: - void ConvertUCS2ToUTF8(std::string& _string, const PSPPointer em_address); - void ConvertUCS2ToUTF8(std::string& _string, wchar_t* input); + void ConvertUCS2ToUTF8(std::string& _string, const PSPPointer em_address); + void ConvertUCS2ToUTF8(std::string& _string, const wchar_t *input); void RenderKeyboard(); std::wstring CombinationString(bool isInput); // for Japanese, Korean