diff --git a/Core/Dialog/PSPOskDialog.cpp b/Core/Dialog/PSPOskDialog.cpp index 55bbe101cc..f2d186c5a5 100644 --- a/Core/Dialog/PSPOskDialog.cpp +++ b/Core/Dialog/PSPOskDialog.cpp @@ -20,9 +20,9 @@ #include "../HLE/sceCtrl.h" #define NUMKEYROWS 4 -#define KEYSPERROW 13 -#define NUMBEROFVALIDCHARS 44 -const char oskKeys[NUMKEYROWS][KEYSPERROW] = +#define KEYSPERROW 12 +#define NUMBEROFVALIDCHARS (KEYSPERROW * NUMKEYROWS) +const char oskKeys[NUMKEYROWS][KEYSPERROW + 1] = { {'1','2','3','4','5','6','7','8','9','0','-','+','\0'}, {'Q','W','E','R','T','Y','U','I','O','P','[',']','\0'}, @@ -67,10 +67,9 @@ int PSPOskDialog::Init(u32 oskPtr) memset(&oskParams, 0, sizeof(oskParams)); memset(&oskData, 0, sizeof(oskData)); // TODO: should this be init'd to oskIntext? - memset(inputChars, 0x00, sizeof(inputChars)); + inputChars.clear(); oskParamsAddr = oskPtr; selectedChar = 0; - currentInputChar = 0; if (Memory::IsValidAddress(oskPtr)) { @@ -87,69 +86,73 @@ int PSPOskDialog::Init(u32 oskPtr) return -1; } + // Eat any keys pressed before the dialog inited. + __CtrlReadLatch(); + return 0; } void PSPOskDialog::RenderKeyboard() { - int selectedRow = selectedChar / (KEYSPERROW-1); - int selectedExtra = selectedChar % (KEYSPERROW-1); - char SelectedLine[KEYSPERROW]; + int selectedRow = selectedChar / KEYSPERROW; + int selectedExtra = selectedChar % KEYSPERROW; + + char temp[2]; + temp[1] = '\0'; + + int limit = oskData.outtextlimit; + // TODO: Test more thoroughly. Encountered a game where this was 0. + if (limit <= 0) + limit = 16; + + const float keyboardLeftSide = (480.0f - (16.0f * KEYSPERROW)) / 2.0f; + float previewLeftSide = (480.0f - (16.0f * limit)) / 2.0f; PPGeDrawText(oskDesc.c_str(), 480/2, 20, PPGE_ALIGN_CENTER, 0.5f, 0xFFFFFFFF); - for (int i=0; i NUMBEROFVALIDCHARS) - { - selectedChar = 0; - } + selectedChar = (selectedChar + NUMBEROFVALIDCHARS) % NUMBEROFVALIDCHARS; // TODO : Dialogs should take control over input and not send them to the game while displaying if (IsButtonPressed(CTRL_CROSS)) { - if (currentInputChar < oskData.outtextlimit) - { - inputChars[currentInputChar]= oskKeys[selectedRow][selectedExtra]; - currentInputChar++; - } - else - { - currentInputChar = oskData.outtextlimit; // just in case - } + if ((int) inputChars.size() < limit) + inputChars += oskKeys[selectedRow][selectedExtra]; } else if (IsButtonPressed(CTRL_CIRCLE)) { - inputChars[currentInputChar] = 0x00; - currentInputChar--; + if (inputChars.size() > 0) + inputChars.resize(inputChars.size() - 1); } else if (IsButtonPressed(CTRL_START)) { @@ -224,12 +217,15 @@ void PSPOskDialog::Update() status = SCE_UTILITY_STATUS_SHUTDOWN; } - for (int i=0; i