From a12709b96d4394d1be88a4d0db791fd1c5f89bd6 Mon Sep 17 00:00:00 2001 From: mgaver Date: Tue, 23 Apr 2013 23:24:06 +0900 Subject: [PATCH 01/16] Update PSPOskDialog.cpp Add Korean keyboard and Russian keyboard. --- Core/Dialog/PSPOskDialog.cpp | 665 +++++++++++++++++++++++++++++++---- 1 file changed, 604 insertions(+), 61 deletions(-) diff --git a/Core/Dialog/PSPOskDialog.cpp b/Core/Dialog/PSPOskDialog.cpp index 4364b1ad0f..b4164ecd7a 100755 --- a/Core/Dialog/PSPOskDialog.cpp +++ b/Core/Dialog/PSPOskDialog.cpp @@ -30,8 +30,8 @@ #include #endif -const int numKeyCols[OSK_KEYBOARD_COUNT] = {12, 12, 13, 13}; -const int numKeyRows[OSK_KEYBOARD_COUNT] = {4, 4, 5, 5}; +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}; // Japanese(Kana) diacritics static const wchar_t diacritics[2][103] = @@ -46,6 +46,14 @@ static const wchar_t kor_cons[] = L"ㄱㄲㄴㄷㄸㄹㅁㅂㅃㅅㅆㅇㅈㅉ // Korean(Hangul) bowels, Some bowels are not used, them will be spacing static const wchar_t kor_vowel[] = L"ㅏㅐㅑㅒㅓㅔㅕㅖㅗ ㅛㅜ ㅠㅡ ㅣ"; +// Korean(Hangul) bowel Combination key +const int kor_vowelCom[] = {0,8,9,1,8,10,20,8,11,4,13,14,5,13,15,20,13,16,20,18,19}; + +// Korean(Hangul) last consonant(diacritics) +static const wchar_t kor_lcons[] = L"ㄱㄲㄳㄴㄵㄶㄷㄹㄺㄻㄼㄽㄾㄿㅀㅁㅂㅄㅅㅆㅇㅈㅊㅋㅌㅍㅎ"; + +// Korean(Hangul) last consonant Combination key +const int kor_lconsCom[] = {18,0,2,21,3,4,26,3,5,0,7,8,15,7,9,16,7,10,18,7,11,24,7,12,25,7,13,26,7,14,18,16,17}; static const wchar_t oskKeys[OSK_KEYBOARD_COUNT][5][14] = { @@ -79,22 +87,28 @@ static const wchar_t oskKeys[OSK_KEYBOARD_COUNT][5][14] = {L"エケセテネヘメ レ ェ ˚"}, {L"オコソトノホモヨルンォョ "}, }, - /* { - // Korean(Hangul) Lowercase + // Korean(Hangul) {L"1234567890-+"}, + {L"ㅃㅉㄸㄲㅆ!@#$%^&"}, {L"ㅂㅈㄷㄱㅅㅛㅕㅑㅐㅔ[]"}, {L"ㅁㄴㅇㄹㅎㅗㅓㅏㅣ;@~"}, {L"ㅋㅌㅊㅍㅠㅜㅡ<>/?|"}, }, { - // Korean(Hangul) Uppercase - {L"!@#$%^&*()_+"}, - {L"ㅃㅉㄸㄲㅆㅛㅕㅑㅒㅖ{}"}, - {L"ㅁㄴㅇㄹㅎㅗㅓㅏㅣ:\"`"}, - {L"ㅋㅌㅊㅍㅠㅜㅡ<>/?|"}, + // Russian Lowercase + {L"1234567890-+"}, + {L"йцукенгшщзхъ"}, + {L"фывапролджэё"}, + {L"ячсмитьбю/?|"}, + }, + { + // Russian Uppercase + {L"!@#$%^&*()_+"}, + {L"ЙЦУКЕНГШЩЗХЪ"}, + {L"ФЫВАПРОЛДЖЭЁ"}, + {L"ЯЧСМИТЬБЮ/?|"}, }, - */ }; @@ -164,7 +178,6 @@ void PSPOskDialog::ConvertUCS2ToUTF8(std::string& _string, wchar_t* input) _string = stringBuffer; } - int PSPOskDialog::Init(u32 oskPtr) { // Ignore if already running @@ -204,6 +217,8 @@ int PSPOskDialog::Init(u32 oskPtr) ConvertUCS2ToUTF8(oskIntext, oskData.intextPtr); ConvertUCS2ToUTF8(oskOuttext, oskData.outtextPtr); + i_level = 0; + inputChars = L""; u16 *src = (u16 *) Memory::GetPointer(oskData.intextPtr); @@ -224,7 +239,7 @@ int PSPOskDialog::Init(u32 oskPtr) return 0; } -std::wstring PSPOskDialog::CombinationString() +std::wstring PSPOskDialog::CombinationString(bool isInput) { std::wstring string; @@ -233,77 +248,548 @@ std::wstring PSPOskDialog::CombinationString() int selectedRow = selectedChar / numKeyCols[currentKeyboard]; int selectedCol = selectedChar % numKeyCols[currentKeyboard]; - if(oskKeys[currentKeyboard][selectedRow][selectedCol] == L'˝') + if(currentKeyboard == 4) { - for(u32 i = 0; i < inputChars.size(); i++) - { - if(i + 1 == inputChars.size()) - { - for(u32 j = 0; j < wcslen(diacritics[0]); j+=2) - { - if(inputChars[i] == diacritics[0][j]) - { - string += diacritics[0][j + 1]; - isCombinated = true; - break; - } - } + isCombinated = true; - if(isCombinated == false) - { - string += inputChars[i]; - } + if(inputChars.size() == 0) + { + wchar_t sw = oskKeys[currentKeyboard][selectedRow][selectedCol]; + + if (inputChars.size() < FieldMaxLength()) + { + string += sw; + + i_value[0] = GetIndex(kor_cons, sw); + + if(i_value[0] != -1 && isInput == true) + i_level = 1; } else { - string += inputChars[i]; + isCombinated = false; } } - } - else if(oskKeys[currentKeyboard][selectedRow][selectedCol] == L'˚') - { - for(u32 i = 0; i < inputChars.size(); i++) + else { - if(i + 1 == inputChars.size()) + for(u32 i = 0; i < inputChars.size(); i++) { - for(u32 j = 0; j < wcslen(diacritics[1]); j+=2) + if(i + 1 == inputChars.size()) { - if(inputChars[i] == diacritics[1][j]) + wchar_t sw = oskKeys[currentKeyboard][selectedRow][selectedCol]; + + if(i_level == 0) { - string += diacritics[1][j + 1]; - isCombinated = true; - break; + string += inputChars[i]; + if (inputChars.size() < FieldMaxLength()) + { + string += sw; + + i_value[0] = GetIndex(kor_cons, sw); + + if(i_value[0] != -1 && isInput == true) + i_level = 1; + } + else + { + isCombinated = false; + } + } + else if(i_level == 1) + { + i_value[1] = GetIndex(kor_vowel, sw); + + if(i_value[1] == -1) + { + string += inputChars[i]; + if (inputChars.size() < FieldMaxLength()) + { + string += sw; + + i_value[0] = GetIndex(kor_cons, sw); + + if(isInput == true) + { + if(i_value[0] != -1) + i_level = 1; + else + i_level = 0; + } + } + else + { + isCombinated = false; + } + } + else + { + u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C; + string += code; + + if(isInput == true) + { + i_level = 2; + } + } + } + else if(i_level == 2) + { + u32 tmp = GetIndex(kor_vowel, sw); + if(tmp != -1) + { + int tmp2 = -1; + for(int j = 0; j < sizeof(kor_vowelCom) / 4; j+=3) + { + if(kor_vowelCom[j] == tmp && kor_vowelCom[j + 1] == i_value[1]) + { + tmp2 = kor_vowelCom[j + 2]; + break; + } + } + if(tmp2 != -1) + { + if(isInput == true) + { + i_value[1] = tmp2; + } + + u16 code = 0xAC00 + i_value[0] * 0x24C + tmp2 * 0x1C; + + string += code; + } + else + { + string += inputChars[i]; + if (inputChars.size() < FieldMaxLength()) + { + string += sw; + + if(isInput == true) + { + i_level = 0; + } + } + else + { + isCombinated = false; + } + } + } + else + { + u32 tmp = GetIndex(kor_lcons, sw); + + if(tmp == -1) + { + string += inputChars[i]; + if (inputChars.size() < FieldMaxLength()) + { + string += sw; + + i_value[0] = GetIndex(kor_cons, sw); + + if(isInput == true) + { + if(i_value[0] != -1) + i_level = 1; + else + i_level = 0; + } + } + else + { + isCombinated = false; + } + } + else + { + u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C + tmp + 1; + + string += code; + + if(isInput == true) + { + i_level = 3; + i_value[2] = tmp; + } + } + } + } + else if(i_level == 3) + { + u32 tmp = GetIndex(kor_lcons, sw); + if(tmp != -1) + { + int tmp2 = -1; + for(int j = 0; j < sizeof(kor_lconsCom) / 4; j+=3) + { + if(kor_lconsCom[j] == tmp && kor_lconsCom[j + 1] == i_value[2]) + { + tmp2 = kor_lconsCom[j + 2]; + break; + } + } + if(tmp2 != -1) + { + if(isInput == true) + { + i_value[2] = tmp2; + } + + u16 code = 0xAC00 + i_value[0] * 0x24C + tmp2 * 0x1C + i_value[2] + 1; + + string += code; + } + else + { + string += inputChars[i]; + if (inputChars.size() < FieldMaxLength()) + { + string += sw; + + i_value[0] = GetIndex(kor_cons, sw); + + if(isInput == true) + { + if(i_value[0] != -1) + i_level = 1; + else + i_level = 0; + } + } + else + { + isCombinated = false; + } + } + } + else + { + u32 tmp = GetIndex(kor_vowel, sw); + if(tmp == -1) + { + string += inputChars[i]; + if (inputChars.size() < FieldMaxLength()) + { + string += sw; + + i_value[0] = GetIndex(kor_cons, sw); + + if(isInput == true) + { + if(i_value[0] != -1) + i_level = 1; + else + i_level = 0; + } + } + else + { + isCombinated = false; + } + } + else + { + if (inputChars.size() < FieldMaxLength()) + { + switch(i_value[2]) + { + case 2: + { + u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C + 1; + string += code; + + code = 0xAC00 + 9 * 0x24C + tmp * 0x1C; + string += code; + + if(isInput == true) + { + i_level = 1; + i_value[0] = 9; + i_value[1] = tmp; + } + break; + } + case 4: + { + u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C + 4; + string += code; + + code = 0xAC00 + 12 * 0x24C + tmp * 0x1C; + string += code; + + if(isInput == true) + { + i_level = 1; + i_value[0] = 12; + i_value[1] = tmp; + } + break; + } + case 5: + { + u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C + 4; + string += code; + + code = 0xAC00 + 18 * 0x24C + tmp * 0x1C; + string += code; + + if(isInput == true) + { + i_level = 1; + i_value[0] = 18; + i_value[1] = tmp; + } + break; + } + case 8: + { + u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C + 8; + string += code; + + code = 0xAC00 + tmp * 0x1C; + string += code; + + if(isInput == true) + { + i_level = 1; + i_value[0] = 0; + i_value[1] = tmp; + } + break; + } + case 9: + { + u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C + 8; + string += code; + + code = 0xAC00 + 6 * 0x24C + tmp * 0x1C; + string += code; + + if(isInput == true) + { + i_level = 1; + i_value[0] = 6; + i_value[1] = tmp; + } + break; + } + case 10: + { + u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C + 8; + string += code; + + code = 0xAC00 + 7 * 0x24C + tmp * 0x1C; + string += code; + + if(isInput == true) + { + i_level = 1; + i_value[0] = 7; + i_value[1] = tmp; + } + break; + } + case 11: + { + u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C + 8; + string += code; + + code = 0xAC00 + 9 * 0x24C + tmp * 0x1C; + string += code; + + if(isInput == true) + { + i_level = 1; + i_value[0] = 9; + i_value[1] = tmp; + } + break; + } + case 12: + { + u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C + 8; + string += code; + + code = 0xAC00 + 16 * 0x24C + tmp * 0x1C; + string += code; + + if(isInput == true) + { + i_level = 1; + i_value[0] = 16; + i_value[1] = tmp; + } + break; + } + case 13: + { + u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C + 8; + string += code; + + code = 0xAC00 + 17 * 0x24C + tmp * 0x1C; + string += code; + + if(isInput == true) + { + i_level = 1; + i_value[0] = 17; + i_value[1] = tmp; + } + break; + } + case 14: + { + u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C + 8; + string += code; + + code = 0xAC00 + 18 * 0x24C + tmp * 0x1C; + string += code; + + if(isInput == true) + { + i_level = 1; + i_value[0] = 18; + i_value[1] = tmp; + } + break; + } + case 17: + { + u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C + 17; + string += code; + + code = 0xAC00 + 9 * 0x24C + tmp * 0x1C; + string += code; + + if(isInput == true) + { + i_level = 1; + i_value[0] = 9; + i_value[1] = tmp; + } + break; + } + default: + { + string += inputChars[i]; + string += sw; + + if(isInput == true) + { + i_level = 0; + } + } + } + } + else + { + string += inputChars[i]; + isCombinated = false; + } + } + } } } - - if(isCombinated == false) + else { string += inputChars[i]; } } - else - { - string += inputChars[i]; - } } } else { - for(u32 i = 0; i < inputChars.size(); i++) + if(isInput == true) { - string += inputChars[i]; + i_level = 0; } - if (string.size() < FieldMaxLength()) + if(oskKeys[currentKeyboard][selectedRow][selectedCol] == L'˝') { - string += oskKeys[currentKeyboard][selectedRow][selectedCol]; + for(u32 i = 0; i < inputChars.size(); i++) + { + if(i + 1 == inputChars.size()) + { + for(u32 j = 0; j < wcslen(diacritics[0]); j+=2) + { + if(inputChars[i] == diacritics[0][j]) + { + string += diacritics[0][j + 1]; + isCombinated = true; + break; + } + } + + if(isCombinated == false) + { + string += inputChars[i]; + } + } + else + { + string += inputChars[i]; + } + } + } + else if(oskKeys[currentKeyboard][selectedRow][selectedCol] == L'˚') + { + for(u32 i = 0; i < inputChars.size(); i++) + { + if(i + 1 == inputChars.size()) + { + for(u32 j = 0; j < wcslen(diacritics[1]); j+=2) + { + if(inputChars[i] == diacritics[1][j]) + { + string += diacritics[1][j + 1]; + isCombinated = true; + break; + } + } + + if(isCombinated == false) + { + string += inputChars[i]; + } + } + else + { + string += inputChars[i]; + } + } + } + else + { + for(u32 i = 0; i < inputChars.size(); i++) + { + string += inputChars[i]; + } + + if (string.size() < FieldMaxLength()) + { + string += oskKeys[currentKeyboard][selectedRow][selectedCol]; + } + isCombinated = true; } - isCombinated = true; } return string; } +u32 PSPOskDialog::GetIndex(const wchar_t* src, wchar_t ch) +{ + for(u32 i = 0; i < wcslen(src); i++) + { + if(src[i] == ch) + { + return i; + } + } + + return -1; +} + u32 PSPOskDialog::FieldMaxLength() { if (oskData.outtextlimit > oskData.outtextlength - 1 || oskData.outtextlimit == 0) @@ -311,7 +797,6 @@ u32 PSPOskDialog::FieldMaxLength() return oskData.outtextlimit; } - void PSPOskDialog::RenderKeyboard() { int selectedRow = selectedChar / numKeyCols[currentKeyboard]; @@ -334,7 +819,7 @@ void PSPOskDialog::RenderKeyboard() std::wstring result; - result = CombinationString(); + result = CombinationString(false); for (u32 i = 0; i < limit; ++i) { @@ -343,7 +828,7 @@ void PSPOskDialog::RenderKeyboard() { temp[0] = result[i]; ConvertUCS2ToUTF8(buffer, temp); - PPGeDrawText(buffer.c_str(), previewLeftSide + (i * characterWidth), 40.0f, PPGE_ALIGN_CENTER, 0.5f, color); + PPGeDrawText(buffer.c_str(), previewLeftSide + (i * characterWidth), 40.0f, PPGE_ALIGN_HCENTER, 0.5f, color); } else { @@ -360,21 +845,21 @@ void PSPOskDialog::RenderKeyboard() ConvertUCS2ToUTF8(buffer, temp); - PPGeDrawText(buffer.c_str(), previewLeftSide + (i * characterWidth), 40.0f, PPGE_ALIGN_CENTER, 0.5f, color); + PPGeDrawText(buffer.c_str(), previewLeftSide + (i * characterWidth), 40.0f, PPGE_ALIGN_HCENTER, 0.5f, color); // Also draw the underline for the same reason. color = CalcFadedColor(0xFFFFFFFF); - PPGeDrawText("_", previewLeftSide + (i * characterWidth), 40.0f, PPGE_ALIGN_CENTER, 0.5f, color); + PPGeDrawText("_", previewLeftSide + (i * characterWidth), 40.0f, PPGE_ALIGN_HCENTER, 0.5f, color); } else { ConvertUCS2ToUTF8(buffer, temp); - PPGeDrawText(buffer.c_str(), previewLeftSide + (i * characterWidth), 40.0f, PPGE_ALIGN_CENTER, 0.5f, color); + PPGeDrawText(buffer.c_str(), previewLeftSide + (i * characterWidth), 40.0f, PPGE_ALIGN_HCENTER, 0.5f, color); } } else { - PPGeDrawText("_", previewLeftSide + (i * characterWidth), 40.0f, PPGE_ALIGN_CENTER, 0.5f, color); + PPGeDrawText("_", previewLeftSide + (i * characterWidth), 40.0f, PPGE_ALIGN_HCENTER, 0.5f, color); } } } @@ -454,8 +939,8 @@ int PSPOskDialog::Update() selectedChar = (selectedChar + (numKeyCols[currentKeyboard] * numKeyRows[currentKeyboard])) % (numKeyCols[currentKeyboard] * numKeyRows[currentKeyboard]); if (IsButtonPressed(CTRL_CROSS)) - { - inputChars = CombinationString(); + { + inputChars = CombinationString(true); } else if (IsButtonPressed(CTRL_SELECT)) { @@ -477,7 +962,65 @@ int PSPOskDialog::Update() else if (IsButtonPressed(CTRL_CIRCLE)) { if (inputChars.size() > 0) + { inputChars.resize(inputChars.size() - 1); + if(i_level != 0) + { + if(i_level == 1) + { + i_level = 0; + } + else if(i_level == 2) + { + int tmp = -1; + for(int i = 2; i < sizeof(kor_vowelCom) / 4; i+=3) + { + if(kor_vowelCom[i] == i_value[1]) + { + tmp = kor_vowelCom[i - 1]; + break; + } + } + + if(tmp != -1) + { + i_value[1] = tmp; + u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C; + inputChars += code; + } + else + { + i_level = 1; + u16 code = 0xAC00 + i_value[0] * 0x24C; + inputChars += code; + } + } + else if(i_level == 3) + { + int tmp = -1; + for(int i = 2; i < sizeof(kor_lconsCom) / 4; i+=3) + { + if(kor_lconsCom[i] == i_value[2]) + { + tmp = kor_vowelCom[i - 1]; + break; + } + } + if(tmp != -1) + { + i_value[2] = tmp; + u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C + i_value[2] + 1; + inputChars += code; + } + else + { + i_level = 2; + u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C; + inputChars += code; + } + } + } + } } else if (IsButtonPressed(CTRL_START)) { From 1525bc696fc3a7b091a3800c722cc10f1ca4bbcb Mon Sep 17 00:00:00 2001 From: mgaver Date: Tue, 23 Apr 2013 23:24:42 +0900 Subject: [PATCH 02/16] Update PSPOskDialog.h Add Korean keyboard and Russian keyboard. --- Core/Dialog/PSPOskDialog.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Core/Dialog/PSPOskDialog.h b/Core/Dialog/PSPOskDialog.h index 8905f88daa..c3677c11f1 100644 --- a/Core/Dialog/PSPOskDialog.h +++ b/Core/Dialog/PSPOskDialog.h @@ -146,9 +146,9 @@ enum OskKeyboardDisplay OSK_KEYBOARD_LATIN_UPPERCASE, OSK_KEYBOARD_HIRAGANA, OSK_KEYBOARD_KATAKANA, -/* OSK_KEYBOARD_KOREAN_LOWERCASE, - OSK_KEYBOARD_KOREAN_UPPERCASE, -*/ + OSK_KEYBOARD_KOREAN, + OSK_KEYBOARD_RUSSIAN_LOWERCASE, + OSK_KEYBOARD_RUSSIAN_UPPERCASE, // TODO: Something to do native? OSK_KEYBOARD_COUNT }; @@ -167,9 +167,10 @@ private: void ConvertUCS2ToUTF8(std::string& _string, wchar_t* input); void RenderKeyboard(); - std::wstring CombinationString(); // for Japanese, Korean + std::wstring CombinationString(bool isInput); // for Japanese, Korean u32 FieldMaxLength(); + u32 GetIndex(const wchar_t* src, wchar_t ch); SceUtilityOskParams *oskParams; SceUtilityOskData oskData; @@ -181,5 +182,8 @@ private: std::wstring inputChars; OskKeyboardDisplay currentKeyboard; bool isCombinated; + + int i_level; // for Korean Keyboard support + int i_value[3]; // for Korean Keyboard support }; From 9ae9b5fbe3cd5927644adb01cc14fe7ea1b5b03c Mon Sep 17 00:00:00 2001 From: mgaver Date: Tue, 23 Apr 2013 23:47:27 +0900 Subject: [PATCH 03/16] Update PSPOskDialog.cpp Fix Korean keyboard --- Core/Dialog/PSPOskDialog.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/Core/Dialog/PSPOskDialog.cpp b/Core/Dialog/PSPOskDialog.cpp index b4164ecd7a..1be4e74b9c 100755 --- a/Core/Dialog/PSPOskDialog.cpp +++ b/Core/Dialog/PSPOskDialog.cpp @@ -504,7 +504,7 @@ std::wstring PSPOskDialog::CombinationString(bool isInput) if(isInput == true) { - i_level = 1; + i_level = 2; i_value[0] = 9; i_value[1] = tmp; } @@ -520,7 +520,7 @@ std::wstring PSPOskDialog::CombinationString(bool isInput) if(isInput == true) { - i_level = 1; + i_level = 2; i_value[0] = 12; i_value[1] = tmp; } @@ -536,7 +536,7 @@ std::wstring PSPOskDialog::CombinationString(bool isInput) if(isInput == true) { - i_level = 1; + i_level = 2; i_value[0] = 18; i_value[1] = tmp; } @@ -552,7 +552,7 @@ std::wstring PSPOskDialog::CombinationString(bool isInput) if(isInput == true) { - i_level = 1; + i_level = 2; i_value[0] = 0; i_value[1] = tmp; } @@ -568,7 +568,7 @@ std::wstring PSPOskDialog::CombinationString(bool isInput) if(isInput == true) { - i_level = 1; + i_level = 2; i_value[0] = 6; i_value[1] = tmp; } @@ -584,7 +584,7 @@ std::wstring PSPOskDialog::CombinationString(bool isInput) if(isInput == true) { - i_level = 1; + i_level = 2; i_value[0] = 7; i_value[1] = tmp; } @@ -600,7 +600,7 @@ std::wstring PSPOskDialog::CombinationString(bool isInput) if(isInput == true) { - i_level = 1; + i_level = 2; i_value[0] = 9; i_value[1] = tmp; } @@ -616,7 +616,7 @@ std::wstring PSPOskDialog::CombinationString(bool isInput) if(isInput == true) { - i_level = 1; + i_level = 2; i_value[0] = 16; i_value[1] = tmp; } @@ -632,7 +632,7 @@ std::wstring PSPOskDialog::CombinationString(bool isInput) if(isInput == true) { - i_level = 1; + i_level = 2; i_value[0] = 17; i_value[1] = tmp; } @@ -648,7 +648,7 @@ std::wstring PSPOskDialog::CombinationString(bool isInput) if(isInput == true) { - i_level = 1; + i_level = 2; i_value[0] = 18; i_value[1] = tmp; } @@ -664,7 +664,7 @@ std::wstring PSPOskDialog::CombinationString(bool isInput) if(isInput == true) { - i_level = 1; + i_level = 2; i_value[0] = 9; i_value[1] = tmp; } @@ -991,8 +991,7 @@ int PSPOskDialog::Update() else { i_level = 1; - u16 code = 0xAC00 + i_value[0] * 0x24C; - inputChars += code; + inputChars += kor_cons[i_value[0]];; } } else if(i_level == 3) From f8681fde0837766c8b4165bfc8037e6f54acebae Mon Sep 17 00:00:00 2001 From: mgaver Date: Tue, 23 Apr 2013 23:55:01 +0900 Subject: [PATCH 04/16] Update PSPOskDialog.cpp Fix Korean keyboard. --- Core/Dialog/PSPOskDialog.cpp | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/Core/Dialog/PSPOskDialog.cpp b/Core/Dialog/PSPOskDialog.cpp index 1be4e74b9c..855f91c820 100755 --- a/Core/Dialog/PSPOskDialog.cpp +++ b/Core/Dialog/PSPOskDialog.cpp @@ -672,12 +672,34 @@ std::wstring PSPOskDialog::CombinationString(bool isInput) } default: { - string += inputChars[i]; - string += sw; + u32 tmp2 = GetIndex(kor_cons, kor_lcons[i_value[2]]); - if(isInput == true) + if(tmp2 != -1) { - i_level = 0; + u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C; + + string += code; + + u16 code = 0xAC00 + tmp2 * 0x24C + tmp * 0x1C; + + string += code; + + if(isInput == true) + { + i_value[0] = tmp2; + i_value[1] = tmp; + i_level = 2; + } + } + else + { + string += inputChars[i]; + string += sw; + + if(isInput == true) + { + i_level = 0; + } } } } From c937d232148127f427fed4cc0174b432a8bc0ef1 Mon Sep 17 00:00:00 2001 From: mgaver Date: Tue, 23 Apr 2013 23:55:30 +0900 Subject: [PATCH 05/16] Update PSPOskDialog.cpp Fix Korean keyboard. --- Core/Dialog/PSPOskDialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/Dialog/PSPOskDialog.cpp b/Core/Dialog/PSPOskDialog.cpp index 855f91c820..3a1a58194c 100755 --- a/Core/Dialog/PSPOskDialog.cpp +++ b/Core/Dialog/PSPOskDialog.cpp @@ -680,7 +680,7 @@ std::wstring PSPOskDialog::CombinationString(bool isInput) string += code; - u16 code = 0xAC00 + tmp2 * 0x24C + tmp * 0x1C; + code = 0xAC00 + tmp2 * 0x24C + tmp * 0x1C; string += code; From 5721412f29c2b6d6cecf847de2e27e70bba88b76 Mon Sep 17 00:00:00 2001 From: mgaver Date: Wed, 24 Apr 2013 00:00:01 +0900 Subject: [PATCH 06/16] Update PSPOskDialog.cpp Fix Korean keyboard. --- Core/Dialog/PSPOskDialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Core/Dialog/PSPOskDialog.cpp b/Core/Dialog/PSPOskDialog.cpp index 3a1a58194c..4708b136ca 100755 --- a/Core/Dialog/PSPOskDialog.cpp +++ b/Core/Dialog/PSPOskDialog.cpp @@ -306,10 +306,10 @@ std::wstring PSPOskDialog::CombinationString(bool isInput) { string += sw; - i_value[0] = GetIndex(kor_cons, sw); - if(isInput == true) { + i_value[0] = GetIndex(kor_cons, sw); + if(i_value[0] != -1) i_level = 1; else From 8545718c0d853bd46e5310f5ef5552215122bdcb Mon Sep 17 00:00:00 2001 From: mgaver Date: Wed, 24 Apr 2013 00:02:12 +0900 Subject: [PATCH 07/16] Update PSPOskDialog.cpp Fix Korean keyboard. --- Core/Dialog/PSPOskDialog.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Core/Dialog/PSPOskDialog.cpp b/Core/Dialog/PSPOskDialog.cpp index 4708b136ca..9c6090d6f3 100755 --- a/Core/Dialog/PSPOskDialog.cpp +++ b/Core/Dialog/PSPOskDialog.cpp @@ -386,10 +386,10 @@ std::wstring PSPOskDialog::CombinationString(bool isInput) { string += sw; - i_value[0] = GetIndex(kor_cons, sw); - if(isInput == true) { + i_value[0] = GetIndex(kor_cons, sw); + if(i_value[0] != -1) i_level = 1; else @@ -447,10 +447,10 @@ std::wstring PSPOskDialog::CombinationString(bool isInput) { string += sw; - i_value[0] = GetIndex(kor_cons, sw); - if(isInput == true) { + i_value[0] = GetIndex(kor_cons, sw); + if(i_value[0] != -1) i_level = 1; else @@ -473,10 +473,10 @@ std::wstring PSPOskDialog::CombinationString(bool isInput) { string += sw; - i_value[0] = GetIndex(kor_cons, sw); - if(isInput == true) { + i_value[0] = GetIndex(kor_cons, sw); + if(i_value[0] != -1) i_level = 1; else From f66b8b0251ab6a77836d79b89b8d875564c9695f Mon Sep 17 00:00:00 2001 From: mgaver Date: Wed, 24 Apr 2013 00:50:49 +0900 Subject: [PATCH 08/16] Update PSPOskDialog.cpp Change magic number to constant. --- Core/Dialog/PSPOskDialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/Dialog/PSPOskDialog.cpp b/Core/Dialog/PSPOskDialog.cpp index 9c6090d6f3..b13c81fb9e 100755 --- a/Core/Dialog/PSPOskDialog.cpp +++ b/Core/Dialog/PSPOskDialog.cpp @@ -248,7 +248,7 @@ std::wstring PSPOskDialog::CombinationString(bool isInput) int selectedRow = selectedChar / numKeyCols[currentKeyboard]; int selectedCol = selectedChar % numKeyCols[currentKeyboard]; - if(currentKeyboard == 4) + if(currentKeyboard == OSK_KEYBOARD_KOREAN) { isCombinated = true; From a1e18b975896753aebd51ccf1573259413eee5c8 Mon Sep 17 00:00:00 2001 From: mgaver Date: Wed, 24 Apr 2013 08:31:50 +0900 Subject: [PATCH 09/16] Update PSPOskDialog.cpp Clean up code --- Core/Dialog/PSPOskDialog.cpp | 749 ++++++++++++----------------------- 1 file changed, 256 insertions(+), 493 deletions(-) diff --git a/Core/Dialog/PSPOskDialog.cpp b/Core/Dialog/PSPOskDialog.cpp index b13c81fb9e..e851b3026e 100755 --- a/Core/Dialog/PSPOskDialog.cpp +++ b/Core/Dialog/PSPOskDialog.cpp @@ -124,25 +124,21 @@ void PSPOskDialog::ConvertUCS2ToUTF8(std::string& _string, const u32 em_address) char stringBuffer[2048]; char *string = stringBuffer; - if (em_address == 0) - { + if (em_address == 0) { _string = ""; return; } u16 *src = (u16 *) Memory::GetPointer(em_address); int c; - while (c = *src++) - { + while (c = *src++) { if (c < 0x80) *string++ = c; - else if (c < 0x800) - { + else if (c < 0x800) { *string++ = 0xC0 | (c >> 6); *string++ = 0x80 | (c & 0x3F); } - else - { + else { *string++ = 0xE0 | (c >> 12); *string++ = 0x80 | ((c >> 6) & 0x3F); *string++ = 0x80 | (c & 0x3F); @@ -158,17 +154,14 @@ void PSPOskDialog::ConvertUCS2ToUTF8(std::string& _string, wchar_t* input) char *string = stringBuffer; int c; - while (c = *input++) - { + while (c = *input++) { if (c < 0x80) *string++ = c; - else if (c < 0x800) - { + else if (c < 0x800) { *string++ = 0xC0 | (c >> 6); *string++ = 0x80 | (c & 0x3F); } - else - { + else { *string++ = 0xE0 | (c >> 12); *string++ = 0x80 | ((c >> 6) & 0x3F); *string++ = 0x80 | (c & 0x3F); @@ -184,21 +177,18 @@ int PSPOskDialog::Init(u32 oskPtr) if (status != SCE_UTILITY_STATUS_NONE && status != SCE_UTILITY_STATUS_SHUTDOWN) return SCE_ERROR_UTILITY_INVALID_STATUS; // Seems like this should crash? - if (!Memory::IsValidAddress(oskPtr)) - { + if (!Memory::IsValidAddress(oskPtr)) { ERROR_LOG_REPORT(HLE, "sceUtilityOskInitStart: invalid params (%08x)", oskPtr); return -1; } oskParams = Memory::GetStruct(oskPtr); - if (oskParams->base.size != sizeof(SceUtilityOskParams)) - { + if (oskParams->base.size != sizeof(SceUtilityOskParams)) { ERROR_LOG(HLE, "sceUtilityOskInitStart: invalid size (%d)", oskParams->base.size); return SCE_ERROR_UTILITY_INVALID_PARAM_SIZE; } // Also seems to crash. - if (!Memory::IsValidAddress(oskParams->fieldPtr)) - { + if (!Memory::IsValidAddress(oskParams->fieldPtr)) { ERROR_LOG_REPORT(HLE, "sceUtilityOskInitStart: invalid field data (%08x)", oskParams->fieldPtr); return -1; } @@ -223,11 +213,9 @@ int PSPOskDialog::Init(u32 oskPtr) u16 *src = (u16 *) Memory::GetPointer(oskData.intextPtr); int c; - while (c = *src++) - { + while (c = *src++) { inputChars += c; - if(c == 0x00) - { + if(c == 0x00) { break; } } @@ -239,6 +227,249 @@ int PSPOskDialog::Init(u32 oskPtr) return 0; } +std::wstring PSPOskDialog::CombinationKorean(bool isInput) +{ + std::wstring string; + + isCombinated = true; + + int selectedRow = selectedChar / numKeyCols[currentKeyboard]; + int selectedCol = selectedChar % numKeyCols[currentKeyboard]; + + if(inputChars.size() == 0) { + wchar_t sw = oskKeys[currentKeyboard][selectedRow][selectedCol]; + + if (inputChars.size() < FieldMaxLength()) { + string += sw; + + i_value[0] = GetIndex(kor_cons, sw); + + if(i_value[0] != -1 && isInput == true) + i_level = 1; + } else { + isCombinated = false; + } + } else { + for(u32 i = 0; i < inputChars.size(); i++) { + if(i + 1 == inputChars.size()) { + wchar_t sw = oskKeys[currentKeyboard][selectedRow][selectedCol]; + + if(i_level == 0) { + string += inputChars[i]; + if (inputChars.size() < FieldMaxLength()) { + string += sw; + + i_value[0] = GetIndex(kor_cons, sw); + + if(i_value[0] != -1 && isInput == true) + i_level = 1; + } else { + isCombinated = false; + } + } else if(i_level == 1) { + i_value[1] = GetIndex(kor_vowel, sw); + + if(i_value[1] == -1) { + string += inputChars[i]; + if (inputChars.size() < FieldMaxLength()) { + string += sw; + + if(isInput == true) { + i_value[0] = GetIndex(kor_cons, sw); + + if(i_value[0] != -1) + i_level = 1; + else + i_level = 0; + } + } else { + isCombinated = false; + } + } else { + u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C; + string += code; + + if(isInput == true) { + i_level = 2; + } + } + } else if(i_level == 2) { + u32 tmp = GetIndex(kor_vowel, sw); + if(tmp != -1) { + int tmp2 = -1; + for(int j = 0; j < sizeof(kor_vowelCom) / 4; j+=3) { + if(kor_vowelCom[j] == tmp && kor_vowelCom[j + 1] == i_value[1]) { + tmp2 = kor_vowelCom[j + 2]; + break; + } + } + if(tmp2 != -1) { + if(isInput == true) { + i_value[1] = tmp2; + } + + u16 code = 0xAC00 + i_value[0] * 0x24C + tmp2 * 0x1C; + + string += code; + } else { + string += inputChars[i]; + if (inputChars.size() < FieldMaxLength()) { + string += sw; + + if(isInput == true) { + i_level = 0; + } + } else { + isCombinated = false; + } + } + } else { + u32 tmp = GetIndex(kor_lcons, sw); + + if(tmp == -1) { + string += inputChars[i]; + if (inputChars.size() < FieldMaxLength()) { + string += sw; + + if(isInput == true) { + i_value[0] = GetIndex(kor_cons, sw); + + if(i_value[0] != -1) + i_level = 1; + else + i_level = 0; + } + } else { + isCombinated = false; + } + } else { + u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C + tmp + 1; + + string += code; + + if(isInput == true) { + i_level = 3; + i_value[2] = tmp; + } + } + } + } else if(i_level == 3) { + u32 tmp = GetIndex(kor_lcons, sw); + if(tmp != -1) { + int tmp2 = -1; + for(int j = 0; j < sizeof(kor_lconsCom) / 4; j+=3) { + if(kor_lconsCom[j] == tmp && kor_lconsCom[j + 1] == i_value[2]) { + tmp2 = kor_lconsCom[j + 2]; + break; + } + } + if(tmp2 != -1) { + if(isInput == true) { + i_value[2] = tmp2; + } + + u16 code = 0xAC00 + i_value[0] * 0x24C + tmp2 * 0x1C + i_value[2] + 1; + + string += code; + } + else { + string += inputChars[i]; + if (inputChars.size() < FieldMaxLength()) { + string += sw; + + if(isInput == true) { + i_value[0] = GetIndex(kor_cons, sw); + + if(i_value[0] != -1) + i_level = 1; + else + i_level = 0; + } + } else { + isCombinated = false; + } + } + } else { + u32 tmp = GetIndex(kor_vowel, sw); + if(tmp == -1) { + string += inputChars[i]; + if (inputChars.size() < FieldMaxLength()) { + string += sw; + + if(isInput == true) { + i_value[0] = GetIndex(kor_cons, sw); + + if(i_value[0] != -1) + i_level = 1; + else + i_level = 0; + } + } else { + isCombinated = false; + } + } else { + if (inputChars.size() < FieldMaxLength()) { + int tmp2 = -1; + for(int j = 0; j < sizeof(kor_lconsSpr) / 4; j+=3) { + if(kor_lconsSpr[j] == i_value[2]) { + tmp2 = j; + break; + } + } + if(tmp2 != -1) { + u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C + kor_lconsSpr[tmp2 + 1]; + string += code; + + code = 0xAC00 + kor_lconsSpr[tmp2 + 2] * 0x24C + tmp * 0x1C; + string += code; + + if(isInput == true) { + i_value[0] = kor_lconsSpr[tmp2 + 2]; + i_value[1] = tmp; + i_level = 2; + } + } else { + u32 tmp2 = GetIndex(kor_cons, kor_lcons[i_value[2]]); + + if(tmp2 != -1) { + u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C; + + string += code; + + code = 0xAC00 + tmp2 * 0x24C + tmp * 0x1C; + + string += code; + + if(isInput == true) { + i_value[0] = tmp2; + i_value[1] = tmp; + i_level = 2; + } + } else { + string += inputChars[i]; + string += sw; + + if(isInput == true) { + i_level = 0; + } + } + } + } else { + string += inputChars[i]; + isCombinated = false; + } + } + } + } + } else { + string += inputChars[i]; + } + } + } + + return string; +} + std::wstring PSPOskDialog::CombinationString(bool isInput) { std::wstring string; @@ -250,475 +481,7 @@ std::wstring PSPOskDialog::CombinationString(bool isInput) if(currentKeyboard == OSK_KEYBOARD_KOREAN) { - isCombinated = true; - - if(inputChars.size() == 0) - { - wchar_t sw = oskKeys[currentKeyboard][selectedRow][selectedCol]; - - if (inputChars.size() < FieldMaxLength()) - { - string += sw; - - i_value[0] = GetIndex(kor_cons, sw); - - if(i_value[0] != -1 && isInput == true) - i_level = 1; - } - else - { - isCombinated = false; - } - } - else - { - for(u32 i = 0; i < inputChars.size(); i++) - { - if(i + 1 == inputChars.size()) - { - wchar_t sw = oskKeys[currentKeyboard][selectedRow][selectedCol]; - - if(i_level == 0) - { - string += inputChars[i]; - if (inputChars.size() < FieldMaxLength()) - { - string += sw; - - i_value[0] = GetIndex(kor_cons, sw); - - if(i_value[0] != -1 && isInput == true) - i_level = 1; - } - else - { - isCombinated = false; - } - } - else if(i_level == 1) - { - i_value[1] = GetIndex(kor_vowel, sw); - - if(i_value[1] == -1) - { - string += inputChars[i]; - if (inputChars.size() < FieldMaxLength()) - { - string += sw; - - if(isInput == true) - { - i_value[0] = GetIndex(kor_cons, sw); - - if(i_value[0] != -1) - i_level = 1; - else - i_level = 0; - } - } - else - { - isCombinated = false; - } - } - else - { - u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C; - string += code; - - if(isInput == true) - { - i_level = 2; - } - } - } - else if(i_level == 2) - { - u32 tmp = GetIndex(kor_vowel, sw); - if(tmp != -1) - { - int tmp2 = -1; - for(int j = 0; j < sizeof(kor_vowelCom) / 4; j+=3) - { - if(kor_vowelCom[j] == tmp && kor_vowelCom[j + 1] == i_value[1]) - { - tmp2 = kor_vowelCom[j + 2]; - break; - } - } - if(tmp2 != -1) - { - if(isInput == true) - { - i_value[1] = tmp2; - } - - u16 code = 0xAC00 + i_value[0] * 0x24C + tmp2 * 0x1C; - - string += code; - } - else - { - string += inputChars[i]; - if (inputChars.size() < FieldMaxLength()) - { - string += sw; - - if(isInput == true) - { - i_level = 0; - } - } - else - { - isCombinated = false; - } - } - } - else - { - u32 tmp = GetIndex(kor_lcons, sw); - - if(tmp == -1) - { - string += inputChars[i]; - if (inputChars.size() < FieldMaxLength()) - { - string += sw; - - if(isInput == true) - { - i_value[0] = GetIndex(kor_cons, sw); - - if(i_value[0] != -1) - i_level = 1; - else - i_level = 0; - } - } - else - { - isCombinated = false; - } - } - else - { - u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C + tmp + 1; - - string += code; - - if(isInput == true) - { - i_level = 3; - i_value[2] = tmp; - } - } - } - } - else if(i_level == 3) - { - u32 tmp = GetIndex(kor_lcons, sw); - if(tmp != -1) - { - int tmp2 = -1; - for(int j = 0; j < sizeof(kor_lconsCom) / 4; j+=3) - { - if(kor_lconsCom[j] == tmp && kor_lconsCom[j + 1] == i_value[2]) - { - tmp2 = kor_lconsCom[j + 2]; - break; - } - } - if(tmp2 != -1) - { - if(isInput == true) - { - i_value[2] = tmp2; - } - - u16 code = 0xAC00 + i_value[0] * 0x24C + tmp2 * 0x1C + i_value[2] + 1; - - string += code; - } - else - { - string += inputChars[i]; - if (inputChars.size() < FieldMaxLength()) - { - string += sw; - - if(isInput == true) - { - i_value[0] = GetIndex(kor_cons, sw); - - if(i_value[0] != -1) - i_level = 1; - else - i_level = 0; - } - } - else - { - isCombinated = false; - } - } - } - else - { - u32 tmp = GetIndex(kor_vowel, sw); - if(tmp == -1) - { - string += inputChars[i]; - if (inputChars.size() < FieldMaxLength()) - { - string += sw; - - if(isInput == true) - { - i_value[0] = GetIndex(kor_cons, sw); - - if(i_value[0] != -1) - i_level = 1; - else - i_level = 0; - } - } - else - { - isCombinated = false; - } - } - else - { - if (inputChars.size() < FieldMaxLength()) - { - switch(i_value[2]) - { - case 2: - { - u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C + 1; - string += code; - - code = 0xAC00 + 9 * 0x24C + tmp * 0x1C; - string += code; - - if(isInput == true) - { - i_level = 2; - i_value[0] = 9; - i_value[1] = tmp; - } - break; - } - case 4: - { - u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C + 4; - string += code; - - code = 0xAC00 + 12 * 0x24C + tmp * 0x1C; - string += code; - - if(isInput == true) - { - i_level = 2; - i_value[0] = 12; - i_value[1] = tmp; - } - break; - } - case 5: - { - u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C + 4; - string += code; - - code = 0xAC00 + 18 * 0x24C + tmp * 0x1C; - string += code; - - if(isInput == true) - { - i_level = 2; - i_value[0] = 18; - i_value[1] = tmp; - } - break; - } - case 8: - { - u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C + 8; - string += code; - - code = 0xAC00 + tmp * 0x1C; - string += code; - - if(isInput == true) - { - i_level = 2; - i_value[0] = 0; - i_value[1] = tmp; - } - break; - } - case 9: - { - u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C + 8; - string += code; - - code = 0xAC00 + 6 * 0x24C + tmp * 0x1C; - string += code; - - if(isInput == true) - { - i_level = 2; - i_value[0] = 6; - i_value[1] = tmp; - } - break; - } - case 10: - { - u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C + 8; - string += code; - - code = 0xAC00 + 7 * 0x24C + tmp * 0x1C; - string += code; - - if(isInput == true) - { - i_level = 2; - i_value[0] = 7; - i_value[1] = tmp; - } - break; - } - case 11: - { - u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C + 8; - string += code; - - code = 0xAC00 + 9 * 0x24C + tmp * 0x1C; - string += code; - - if(isInput == true) - { - i_level = 2; - i_value[0] = 9; - i_value[1] = tmp; - } - break; - } - case 12: - { - u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C + 8; - string += code; - - code = 0xAC00 + 16 * 0x24C + tmp * 0x1C; - string += code; - - if(isInput == true) - { - i_level = 2; - i_value[0] = 16; - i_value[1] = tmp; - } - break; - } - case 13: - { - u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C + 8; - string += code; - - code = 0xAC00 + 17 * 0x24C + tmp * 0x1C; - string += code; - - if(isInput == true) - { - i_level = 2; - i_value[0] = 17; - i_value[1] = tmp; - } - break; - } - case 14: - { - u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C + 8; - string += code; - - code = 0xAC00 + 18 * 0x24C + tmp * 0x1C; - string += code; - - if(isInput == true) - { - i_level = 2; - i_value[0] = 18; - i_value[1] = tmp; - } - break; - } - case 17: - { - u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C + 17; - string += code; - - code = 0xAC00 + 9 * 0x24C + tmp * 0x1C; - string += code; - - if(isInput == true) - { - i_level = 2; - i_value[0] = 9; - i_value[1] = tmp; - } - break; - } - default: - { - u32 tmp2 = GetIndex(kor_cons, kor_lcons[i_value[2]]); - - if(tmp2 != -1) - { - u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C; - - string += code; - - code = 0xAC00 + tmp2 * 0x24C + tmp * 0x1C; - - string += code; - - if(isInput == true) - { - i_value[0] = tmp2; - i_value[1] = tmp; - i_level = 2; - } - } - else - { - string += inputChars[i]; - string += sw; - - if(isInput == true) - { - i_level = 0; - } - } - } - } - } - else - { - string += inputChars[i]; - isCombinated = false; - } - } - } - } - } - else - { - string += inputChars[i]; - } - } - } + string = CombinationKorean(isInput); } else { From 2dd7c17009a6d9f670f4181b7f3d458ea33d4b78 Mon Sep 17 00:00:00 2001 From: mgaver Date: Wed, 24 Apr 2013 08:33:06 +0900 Subject: [PATCH 10/16] Update PSPOskDialog.h Add function "CombinationKorean" --- Core/Dialog/PSPOskDialog.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Core/Dialog/PSPOskDialog.h b/Core/Dialog/PSPOskDialog.h index c3677c11f1..85a4cf4c2e 100644 --- a/Core/Dialog/PSPOskDialog.h +++ b/Core/Dialog/PSPOskDialog.h @@ -168,7 +168,8 @@ private: void RenderKeyboard(); std::wstring CombinationString(bool isInput); // for Japanese, Korean - + std::wstring CombinationKorean(bool isInput); // for Korea + u32 FieldMaxLength(); u32 GetIndex(const wchar_t* src, wchar_t ch); From 369413e352870a1890b307401e8bf6e371d4c1b4 Mon Sep 17 00:00:00 2001 From: mgaver Date: Wed, 24 Apr 2013 08:34:05 +0900 Subject: [PATCH 11/16] Update PSPOskDialog.cpp Add variables --- Core/Dialog/PSPOskDialog.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Core/Dialog/PSPOskDialog.cpp b/Core/Dialog/PSPOskDialog.cpp index e851b3026e..a0a5e7505f 100755 --- a/Core/Dialog/PSPOskDialog.cpp +++ b/Core/Dialog/PSPOskDialog.cpp @@ -55,6 +55,9 @@ static const wchar_t kor_lcons[] = L"ㄱㄲㄳㄴㄵㄶㄷㄹㄺㄻㄼㄽㄾㄿ // Korean(Hangul) last consonant Combination key const int kor_lconsCom[] = {18,0,2,21,3,4,26,3,5,0,7,8,15,7,9,16,7,10,18,7,11,24,7,12,25,7,13,26,7,14,18,16,17}; +// Korean(Hangul) last consonant Separation key +const int kor_lconsSpr[] = {2,1,9,4,4,12,5,4,18,8,8,0,9,8,6,10,8,7,11,8,9,12,8,16,13,8,17,14,8,18,17,17,9}; + static const wchar_t oskKeys[OSK_KEYBOARD_COUNT][5][14] = { { From efa41413efe717aad5de4ff4598a1f2e7b93d5e0 Mon Sep 17 00:00:00 2001 From: mgaver Date: Wed, 24 Apr 2013 08:38:25 +0900 Subject: [PATCH 12/16] Update PSPOskDialog.cpp Clean up code. --- Core/Dialog/PSPOskDialog.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Core/Dialog/PSPOskDialog.cpp b/Core/Dialog/PSPOskDialog.cpp index a0a5e7505f..3b6bd61809 100755 --- a/Core/Dialog/PSPOskDialog.cpp +++ b/Core/Dialog/PSPOskDialog.cpp @@ -140,8 +140,7 @@ void PSPOskDialog::ConvertUCS2ToUTF8(std::string& _string, const u32 em_address) else if (c < 0x800) { *string++ = 0xC0 | (c >> 6); *string++ = 0x80 | (c & 0x3F); - } - else { + } else { *string++ = 0xE0 | (c >> 12); *string++ = 0x80 | ((c >> 6) & 0x3F); *string++ = 0x80 | (c & 0x3F); @@ -163,8 +162,7 @@ void PSPOskDialog::ConvertUCS2ToUTF8(std::string& _string, wchar_t* input) else if (c < 0x800) { *string++ = 0xC0 | (c >> 6); *string++ = 0x80 | (c & 0x3F); - } - else { + } else { *string++ = 0xE0 | (c >> 12); *string++ = 0x80 | ((c >> 6) & 0x3F); *string++ = 0x80 | (c & 0x3F); @@ -374,8 +372,7 @@ std::wstring PSPOskDialog::CombinationKorean(bool isInput) u16 code = 0xAC00 + i_value[0] * 0x24C + tmp2 * 0x1C + i_value[2] + 1; string += code; - } - else { + } else { string += inputChars[i]; if (inputChars.size() < FieldMaxLength()) { string += sw; @@ -431,7 +428,7 @@ std::wstring PSPOskDialog::CombinationKorean(bool isInput) i_value[1] = tmp; i_level = 2; } - } else { + } else { u32 tmp2 = GetIndex(kor_cons, kor_lcons[i_value[2]]); if(tmp2 != -1) { From 6a15352b4433534107cc7a1f821bd4408eb43c49 Mon Sep 17 00:00:00 2001 From: mgaver Date: Wed, 24 Apr 2013 13:13:41 +0900 Subject: [PATCH 13/16] Update PSPOskDialog.cpp --- Core/Dialog/PSPOskDialog.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Core/Dialog/PSPOskDialog.cpp b/Core/Dialog/PSPOskDialog.cpp index 3b6bd61809..bc57e4d988 100755 --- a/Core/Dialog/PSPOskDialog.cpp +++ b/Core/Dialog/PSPOskDialog.cpp @@ -613,7 +613,7 @@ void PSPOskDialog::RenderKeyboard() { temp[0] = result[i]; ConvertUCS2ToUTF8(buffer, temp); - PPGeDrawText(buffer.c_str(), previewLeftSide + (i * characterWidth), 40.0f, PPGE_ALIGN_HCENTER, 0.5f, color); + PPGeDrawText(buffer.c_str(), previewLeftSide + (i * characterWidth), 40.0f, PPGE_ALIGN_CENTER, 0.5f, color); } else { @@ -630,21 +630,21 @@ void PSPOskDialog::RenderKeyboard() ConvertUCS2ToUTF8(buffer, temp); - PPGeDrawText(buffer.c_str(), previewLeftSide + (i * characterWidth), 40.0f, PPGE_ALIGN_HCENTER, 0.5f, color); + PPGeDrawText(buffer.c_str(), previewLeftSide + (i * characterWidth), 40.0f, PPGE_ALIGN_CENTER, 0.5f, color); // Also draw the underline for the same reason. color = CalcFadedColor(0xFFFFFFFF); - PPGeDrawText("_", previewLeftSide + (i * characterWidth), 40.0f, PPGE_ALIGN_HCENTER, 0.5f, color); + PPGeDrawText("_", previewLeftSide + (i * characterWidth), 40.0f, PPGE_ALIGN_CENTER, 0.5f, color); } else { ConvertUCS2ToUTF8(buffer, temp); - PPGeDrawText(buffer.c_str(), previewLeftSide + (i * characterWidth), 40.0f, PPGE_ALIGN_HCENTER, 0.5f, color); + PPGeDrawText(buffer.c_str(), previewLeftSide + (i * characterWidth), 40.0f, PPGE_ALIGN_CENTER, 0.5f, color); } } else { - PPGeDrawText("_", previewLeftSide + (i * characterWidth), 40.0f, PPGE_ALIGN_HCENTER, 0.5f, color); + PPGeDrawText("_", previewLeftSide + (i * characterWidth), 40.0f, PPGE_ALIGN_CENTER, 0.5f, color); } } } @@ -660,10 +660,10 @@ void PSPOskDialog::RenderKeyboard() temp[0] = oskKeys[currentKeyboard][row][col]; ConvertUCS2ToUTF8(buffer, temp); - PPGeDrawText(buffer.c_str(), keyboardLeftSide + (25.0f * col) + characterWidth / 2.0, 70.0f + (25.0f * row), PPGE_ALIGN_HCENTER, 0.6f, color); + PPGeDrawText(buffer.c_str(), keyboardLeftSide + (25.0f * col) + characterWidth / 2.0, 70.0f + (25.0f * row), PPGE_ALIGN_CENTER, 0.6f, color); if (selectedRow == row && col == selectedCol) - PPGeDrawText("_", keyboardLeftSide + (25.0f * col) + characterWidth / 2.0, 70.0f + (25.0f * row), PPGE_ALIGN_HCENTER, 0.6f, CalcFadedColor(0xFFFFFFFF)); + PPGeDrawText("_", keyboardLeftSide + (25.0f * col) + characterWidth / 2.0, 70.0f + (25.0f * row), PPGE_ALIGN_CENTER, 0.6f, CalcFadedColor(0xFFFFFFFF)); } } } From 58a3218f541c5766202c60cdbc2b450dbd456224 Mon Sep 17 00:00:00 2001 From: mgaver Date: Wed, 24 Apr 2013 18:00:47 +0900 Subject: [PATCH 14/16] Update PSPOskDialog.h --- Core/Dialog/PSPOskDialog.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Core/Dialog/PSPOskDialog.h b/Core/Dialog/PSPOskDialog.h index 85a4cf4c2e..886b229c5e 100644 --- a/Core/Dialog/PSPOskDialog.h +++ b/Core/Dialog/PSPOskDialog.h @@ -169,6 +169,7 @@ private: std::wstring CombinationString(bool isInput); // for Japanese, Korean std::wstring CombinationKorean(bool isInput); // for Korea + void RemoveKorean(); // for Korean character removal u32 FieldMaxLength(); u32 GetIndex(const wchar_t* src, wchar_t ch); From d1b862de21272838efd6c041c1dd0b8e52f84fb4 Mon Sep 17 00:00:00 2001 From: mgaver Date: Wed, 24 Apr 2013 19:50:39 +0900 Subject: [PATCH 15/16] Update PSPOskDialog.cpp --- Core/Dialog/PSPOskDialog.cpp | 152 +++++++++++++++++++---------------- 1 file changed, 83 insertions(+), 69 deletions(-) diff --git a/Core/Dialog/PSPOskDialog.cpp b/Core/Dialog/PSPOskDialog.cpp index bc57e4d988..811fb4d2d1 100755 --- a/Core/Dialog/PSPOskDialog.cpp +++ b/Core/Dialog/PSPOskDialog.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2012- PPSSPP Project. +// Copyright (c) 2012- PPSSPP Project. // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -127,14 +127,16 @@ void PSPOskDialog::ConvertUCS2ToUTF8(std::string& _string, const u32 em_address) char stringBuffer[2048]; char *string = stringBuffer; - if (em_address == 0) { + if (em_address == 0) + { _string = ""; return; } u16 *src = (u16 *) Memory::GetPointer(em_address); int c; - while (c = *src++) { + while (c = *src++) + { if (c < 0x80) *string++ = c; else if (c < 0x800) { @@ -156,7 +158,8 @@ void PSPOskDialog::ConvertUCS2ToUTF8(std::string& _string, wchar_t* input) char *string = stringBuffer; int c; - while (c = *input++) { + while (c = *input++) + { if (c < 0x80) *string++ = c; else if (c < 0x800) { @@ -178,18 +181,21 @@ int PSPOskDialog::Init(u32 oskPtr) if (status != SCE_UTILITY_STATUS_NONE && status != SCE_UTILITY_STATUS_SHUTDOWN) return SCE_ERROR_UTILITY_INVALID_STATUS; // Seems like this should crash? - if (!Memory::IsValidAddress(oskPtr)) { + if (!Memory::IsValidAddress(oskPtr)) + { ERROR_LOG_REPORT(HLE, "sceUtilityOskInitStart: invalid params (%08x)", oskPtr); return -1; } oskParams = Memory::GetStruct(oskPtr); - if (oskParams->base.size != sizeof(SceUtilityOskParams)) { + if (oskParams->base.size != sizeof(SceUtilityOskParams)) + { ERROR_LOG(HLE, "sceUtilityOskInitStart: invalid size (%d)", oskParams->base.size); return SCE_ERROR_UTILITY_INVALID_PARAM_SIZE; } // Also seems to crash. - if (!Memory::IsValidAddress(oskParams->fieldPtr)) { + if (!Memory::IsValidAddress(oskParams->fieldPtr)) + { ERROR_LOG_REPORT(HLE, "sceUtilityOskInitStart: invalid field data (%08x)", oskParams->fieldPtr); return -1; } @@ -214,9 +220,11 @@ int PSPOskDialog::Init(u32 oskPtr) u16 *src = (u16 *) Memory::GetPointer(oskData.intextPtr); int c; - while (c = *src++) { + while (c = *src++) + { inputChars += c; - if(c == 0x00) { + if(c == 0x00) + { break; } } @@ -562,6 +570,63 @@ std::wstring PSPOskDialog::CombinationString(bool isInput) return string; } +void PSPOskDialog::RemoveKorean() +{ + if(i_level == 1) + { + i_level = 0; + } + else if(i_level == 2) + { + int tmp = -1; + for(int i = 2; i < sizeof(kor_vowelCom) / 4; i+=3) + { + if(kor_vowelCom[i] == i_value[1]) + { + tmp = kor_vowelCom[i - 1]; + break; + } + } + + if(tmp != -1) + { + i_value[1] = tmp; + u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C; + inputChars += code; + } + else + { + i_level = 1; + inputChars += kor_cons[i_value[0]];; + } + } + else if(i_level == 3) + { + int tmp = -1; + for(int i = 2; i < sizeof(kor_lconsCom) / 4; i+=3) + { + if(kor_lconsCom[i] == i_value[2]) + { + tmp = kor_vowelCom[i - 1]; + break; + } + } + + if(tmp != -1) + { + i_value[2] = tmp; + u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C + i_value[2] + 1; + inputChars += code; + } + else + { + i_level = 2; + u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C; + inputChars += code; + } + } +} + u32 PSPOskDialog::GetIndex(const wchar_t* src, wchar_t ch) { for(u32 i = 0; i < wcslen(src); i++) @@ -613,7 +678,7 @@ void PSPOskDialog::RenderKeyboard() { temp[0] = result[i]; ConvertUCS2ToUTF8(buffer, temp); - PPGeDrawText(buffer.c_str(), previewLeftSide + (i * characterWidth), 40.0f, PPGE_ALIGN_CENTER, 0.5f, color); + PPGeDrawText(buffer.c_str(), previewLeftSide + (i * characterWidth), 40.0f, PPGE_ALIGN_HCENTER, 0.5f, color); } else { @@ -630,21 +695,21 @@ void PSPOskDialog::RenderKeyboard() ConvertUCS2ToUTF8(buffer, temp); - PPGeDrawText(buffer.c_str(), previewLeftSide + (i * characterWidth), 40.0f, PPGE_ALIGN_CENTER, 0.5f, color); + PPGeDrawText(buffer.c_str(), previewLeftSide + (i * characterWidth), 40.0f, PPGE_ALIGN_HCENTER, 0.5f, color); // Also draw the underline for the same reason. color = CalcFadedColor(0xFFFFFFFF); - PPGeDrawText("_", previewLeftSide + (i * characterWidth), 40.0f, PPGE_ALIGN_CENTER, 0.5f, color); + PPGeDrawText("_", previewLeftSide + (i * characterWidth), 40.0f, PPGE_ALIGN_HCENTER, 0.5f, color); } else { ConvertUCS2ToUTF8(buffer, temp); - PPGeDrawText(buffer.c_str(), previewLeftSide + (i * characterWidth), 40.0f, PPGE_ALIGN_CENTER, 0.5f, color); + PPGeDrawText(buffer.c_str(), previewLeftSide + (i * characterWidth), 40.0f, PPGE_ALIGN_HCENTER, 0.5f, color); } } else { - PPGeDrawText("_", previewLeftSide + (i * characterWidth), 40.0f, PPGE_ALIGN_CENTER, 0.5f, color); + PPGeDrawText("_", previewLeftSide + (i * characterWidth), 40.0f, PPGE_ALIGN_HCENTER, 0.5f, color); } } } @@ -660,10 +725,10 @@ void PSPOskDialog::RenderKeyboard() temp[0] = oskKeys[currentKeyboard][row][col]; ConvertUCS2ToUTF8(buffer, temp); - PPGeDrawText(buffer.c_str(), keyboardLeftSide + (25.0f * col) + characterWidth / 2.0, 70.0f + (25.0f * row), PPGE_ALIGN_CENTER, 0.6f, color); + PPGeDrawText(buffer.c_str(), keyboardLeftSide + (25.0f * col) + characterWidth / 2.0, 70.0f + (25.0f * row), PPGE_ALIGN_HCENTER, 0.6f, color); if (selectedRow == row && col == selectedCol) - PPGeDrawText("_", keyboardLeftSide + (25.0f * col) + characterWidth / 2.0, 70.0f + (25.0f * row), PPGE_ALIGN_CENTER, 0.6f, CalcFadedColor(0xFFFFFFFF)); + PPGeDrawText("_", keyboardLeftSide + (25.0f * col) + characterWidth / 2.0, 70.0f + (25.0f * row), PPGE_ALIGN_HCENTER, 0.6f, CalcFadedColor(0xFFFFFFFF)); } } } @@ -751,58 +816,7 @@ int PSPOskDialog::Update() inputChars.resize(inputChars.size() - 1); if(i_level != 0) { - if(i_level == 1) - { - i_level = 0; - } - else if(i_level == 2) - { - int tmp = -1; - for(int i = 2; i < sizeof(kor_vowelCom) / 4; i+=3) - { - if(kor_vowelCom[i] == i_value[1]) - { - tmp = kor_vowelCom[i - 1]; - break; - } - } - - if(tmp != -1) - { - i_value[1] = tmp; - u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C; - inputChars += code; - } - else - { - i_level = 1; - inputChars += kor_cons[i_value[0]];; - } - } - else if(i_level == 3) - { - int tmp = -1; - for(int i = 2; i < sizeof(kor_lconsCom) / 4; i+=3) - { - if(kor_lconsCom[i] == i_value[2]) - { - tmp = kor_vowelCom[i - 1]; - break; - } - } - if(tmp != -1) - { - i_value[2] = tmp; - u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C + i_value[2] + 1; - inputChars += code; - } - else - { - i_level = 2; - u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C; - inputChars += code; - } - } + RemoveKorean(); } } } @@ -855,4 +869,4 @@ void PSPOskDialog::DoState(PointerWrap &p) p.Do(selectedChar); p.Do(inputChars); p.DoMarker("PSPOskDialog"); -} +} From 832bf5517362e2c567caded54ed81e9372fabebd Mon Sep 17 00:00:00 2001 From: mgaver Date: Wed, 24 Apr 2013 19:51:46 +0900 Subject: [PATCH 16/16] Update PSPOskDialog.cpp --- Core/Dialog/PSPOskDialog.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Core/Dialog/PSPOskDialog.cpp b/Core/Dialog/PSPOskDialog.cpp index 811fb4d2d1..45f3e1d1ed 100755 --- a/Core/Dialog/PSPOskDialog.cpp +++ b/Core/Dialog/PSPOskDialog.cpp @@ -43,10 +43,10 @@ static const wchar_t diacritics[2][103] = // Korean(Hangul) consonant static const wchar_t kor_cons[] = L"ㄱㄲㄴㄷㄸㄹㅁㅂㅃㅅㅆㅇㅈㅉㅊㅋㅌㅍㅎ"; -// Korean(Hangul) bowels, Some bowels are not used, them will be spacing +// Korean(Hangul) vowels, Some bowels are not used, them will be spacing static const wchar_t kor_vowel[] = L"ㅏㅐㅑㅒㅓㅔㅕㅖㅗ ㅛㅜ ㅠㅡ ㅣ"; -// Korean(Hangul) bowel Combination key +// Korean(Hangul) vowel Combination key const int kor_vowelCom[] = {0,8,9,1,8,10,20,8,11,4,13,14,5,13,15,20,13,16,20,18,19}; // Korean(Hangul) last consonant(diacritics) @@ -869,4 +869,4 @@ void PSPOskDialog::DoState(PointerWrap &p) p.Do(selectedChar); p.Do(inputChars); p.DoMarker("PSPOskDialog"); -} +}