diff --git a/include/gui/keyboard.hpp b/include/gui/keyboard.hpp index ddd814b..794b5fe 100644 --- a/include/gui/keyboard.hpp +++ b/include/gui/keyboard.hpp @@ -30,15 +30,9 @@ #include namespace Input { - void DrawNumpad(); - void drawKeyboard(); - std::string Numpad(std::string Text); - std::string Numpad(uint maxLength, std::string Text); - // -1 if invaild text entered - int getUint(int max, std::string Text); - std::string getString(std::string Text); - std::string getStringLong(std::string Text); // For longer text. - std::string getString(uint maxLength, std::string Text, float inputTextSize = 0.6f); + std::string setkbdString(uint maxLength, std::string Text); + std::uint8_t setu8(std::string Text); + int setInt(int maxValue, std::string Text); } #endif \ No newline at end of file diff --git a/source/download/download.cpp b/source/download/download.cpp index ae29825..87d96d4 100644 --- a/source/download/download.cpp +++ b/source/download/download.cpp @@ -143,7 +143,7 @@ static size_t file_handle_data(char *ptr, size_t size, size_t nmemb, void *userd LightEvent_Clear(&waitCommit); file_toCommit_size = file_buffer_pos + tofill; file_buffer_pos = 0; - svcFlushProcessDataCache(CUR_PROCESS_HANDLE, g_buffers[g_index], file_toCommit_size); + svcFlushProcessDataCache(CUR_PROCESS_HANDLE, (u32)g_buffers[g_index], file_toCommit_size); g_index = !g_index; LightEvent_Signal(&readyToCommit); } @@ -207,7 +207,7 @@ Result downloadToFile(std::string url, std::string path) { LightEvent_Clear(&waitCommit); file_toCommit_size = file_buffer_pos; - svcFlushProcessDataCache(CUR_PROCESS_HANDLE, g_buffers[g_index], file_toCommit_size); + svcFlushProcessDataCache(CUR_PROCESS_HANDLE, (u32)g_buffers[g_index], file_toCommit_size); g_index = !g_index; if (!filecommit()) { retcode = -3; diff --git a/source/gui/keyboard.cpp b/source/gui/keyboard.cpp index 9d40694..3a97687 100644 --- a/source/gui/keyboard.cpp +++ b/source/gui/keyboard.cpp @@ -26,282 +26,72 @@ #include "config.hpp" #include "gfx.hpp" -#include "gui.hpp" #include "keyboard.hpp" -#include "structs.hpp" - -#include -#include -#include +#include "screenCommon.hpp" extern std::unique_ptr config; -extern C3D_RenderTarget* Top; -extern C3D_RenderTarget* Bottom; -bool caps = false, enter = false; -int shift = 0; +std::string Input::setkbdString(uint maxLength, std::string Text) { + C3D_FrameEnd(0); + SwkbdState state; + swkbdInit(&state, SWKBD_TYPE_NORMAL, 2, maxLength); + char temp[maxLength] = {0}; + swkbdSetHintText(&state, Text.c_str()); + swkbdSetValidation(&state, SWKBD_NOTBLANK_NOTEMPTY, SWKBD_FILTER_PROFANITY, 0); + SwkbdButton ret = swkbdInputText(&state, temp, sizeof(temp)); + temp[maxLength-1] = '\0'; -Structs::Key keysQWERTY[] = { - {"1", 0, 0}, {"2", 25, 0}, {"3", 50, 0}, {"4", 75, 0}, {"5", 100, 0}, {"6", 125, 0}, {"7", 150, 0}, {"8", 175, 0}, {"9", 200, 0}, {"0", 225, 0}, {"-", 250, 0}, {"=", 275, 0}, - {"q", 12, 22}, {"w", 37, 22}, {"e", 62, 22}, {"r", 87, 22}, {"t", 112, 22}, {"y", 137, 22}, {"u", 162, 22}, {"i", 187, 22}, {"o", 212, 22}, {"p", 237, 22}, {"[", 262, 22}, {"]", 287, 22}, - {"a", 25, 45}, {"s", 50, 45}, {"d", 75, 45}, {"f", 100, 45}, {"g", 125, 45}, {"h", 150, 45}, {"j", 175, 45}, {"k", 200, 45}, {"l", 225, 45}, {";", 250, 45}, {"'", 275, 45}, - {"z", 35, 67}, {"x", 60, 67}, {"c", 85, 67}, {"v", 110, 67}, {"b", 135, 67}, {"n", 160, 67}, {"m", 185, 67}, {",", 210, 67}, {".", 235, 67}, {"/", 260, 67}, {"\\", 210, 90}, -}; -Structs::Key keysQWERTYShift[] = { - {"!", 0, 0}, {"@", 25, 0}, {"#", 50, 0}, {"$", 75, 0}, {"%", 100, 0}, {"^", 125, 0}, {"&", 150, 0}, {"*", 175, 0}, {"(", 200, 0}, {")", 225, 0}, {"_", 250, 0}, {"+", 275, 0}, - {"Q", 12, 22}, {"W", 37, 22}, {"E", 62, 22}, {"R", 87, 22}, {"T", 112, 22}, {"Y", 137, 22}, {"U", 162, 22}, {"I", 187, 22}, {"O", 212, 22}, {"P", 237, 22}, {"{", 262, 22}, {"}", 287, 22}, - {"A", 25, 45}, {"S", 50, 45}, {"D", 75, 45}, {"F", 100, 45}, {"G", 125, 45}, {"H", 150, 45}, {"J", 175, 45}, {"K", 200, 45}, {"L", 225, 45}, {":", 250, 45}, {"\"", 275, 45}, - {"Z", 35, 67}, {"X", 60, 67}, {"C", 85, 67}, {"V", 110, 67}, {"B", 135, 67}, {"N", 160, 67}, {"M", 185, 67}, {"<,", 210, 67}, {">", 235, 67}, {"?", 260, 67}, {"\\", 210, 90}, -}; -Structs::Key modifierKeys[] = { - {"\uE071", 300, 0, 20}, // Backspace - {"\uE01D", 0, 45, 20}, // Caps Lock - {"\uE056", 300, 45, 20}, // Enter - {"\uE01B", 0, 67, 30}, // Left Shift - {"\uE01B", 285, 67, 35}, // Right Shift - {" ", 85, 90, 120}, // Space -}; - -Structs::Key NumpadStruct[] = { - {"1", 10, 30}, - {"2", 90, 30}, - {"3", 170, 30}, - - {"4", 10, 100}, - {"5", 90, 100}, - {"6", 170, 100}, - - {"7", 10, 170}, - {"8", 90, 170}, - {"9", 170, 170}, - - {"0", 250, 100}, - - {"Enter", 250, 170}, - - {"Backspace", 250, 30}, -}; - -Structs::ButtonPos Numbers [] = { - {10, 30, 60, 50}, // 1 - {90, 30, 60, 50}, // 2 - {170, 30, 60, 50}, // 3 - - {10, 100, 60, 50}, - {90, 100, 60, 50}, - {170, 100, 60, 50}, - - {10, 170, 60, 50}, - {90, 170, 60, 50}, - {170, 170, 60, 50}, - - {250, 100, 60, 50}, // 0. - - {250, 170, 60, 50}, // Enter. - - {250, 30, 60, 50}, // Backspace. -}; - -extern bool touching(touchPosition touch, Structs::ButtonPos button); - - -void Input::DrawNumpad() { - for(uint i = 0; i < (sizeof(NumpadStruct)/sizeof(NumpadStruct[0])); i++) { - Gui::Draw_Rect(NumpadStruct[i].x, NumpadStruct[i].y, 60, 50, config->barColor()); - char c[2] = {NumpadStruct[i].character[0]}; - Gui::DrawString(NumpadStruct[i].x+25, NumpadStruct[i].y+15, 0.72f, config->textColor(), c, 50); + if (ret == SWKBD_BUTTON_CONFIRM) { + return temp; } + + return ""; } -void Input::drawKeyboard() { - for(uint i = 0; i < (sizeof(keysQWERTY)/sizeof(keysQWERTY[0])); i++) { - C2D_DrawRectSolid(keysQWERTY[i].x, keysQWERTY[i].y+103, 0.5f, 20, 20, config->barColor() & C2D_Color32(255, 255, 255, 200)); - if (shift) { - char c[2] = {caps ? (char)toupper(keysQWERTYShift[i].character[0]) : keysQWERTYShift[i].character[0]}; - Gui::DrawString(keysQWERTYShift[i].x+(10-(Gui::GetStringWidth(0.50, c)/2)), keysQWERTYShift[i].y+103+(10-(Gui::GetStringHeight(0.50, c)/2)), 0.50, config->textColor(), c); - } else { - char c[2] = {caps ? (char)toupper(keysQWERTY[i].character[0]) : keysQWERTY[i].character[0]}; - Gui::DrawString(keysQWERTY[i].x+(10-(Gui::GetStringWidth(0.50, c)/2)), keysQWERTY[i].y+103+(10-(Gui::GetStringHeight(0.50, c)/2)), 0.50, config->textColor(), c); - } +int Input::setInt(int maxValue, std::string Text) { + Gui::clearTextBufs(); + C3D_FrameBegin(C3D_FRAME_SYNCDRAW); + C2D_TargetClear(Top, BLACK); + GFX::DrawTop(); + Gui::DrawStringCentered(0, config->useBars() ? 0 : 2, 0.7f, config->textColor(), Text, 400); + C3D_FrameEnd(0); + SwkbdState state; + swkbdInit(&state, SWKBD_TYPE_NUMPAD, 2, 3); + swkbdSetFeatures(&state, SWKBD_FIXED_WIDTH); + swkbdSetValidation(&state, SWKBD_NOTBLANK_NOTEMPTY, 0, 0); + char input[4] = {0}; + SwkbdButton ret = swkbdInputText(&state, input, sizeof(input)); + input[3] = '\0'; + + if (ret == SWKBD_BUTTON_CONFIRM) { + return (int)std::min(std::stoi(input), maxValue); + } else { + return -1; } - for(uint i = 0; i < (sizeof(modifierKeys)/sizeof(modifierKeys[0])); i++) { - std::string enter = modifierKeys[2].character; - std::string arrowUp = modifierKeys[3].character; - std::string backSpace = modifierKeys[0].character; - std::string caps = modifierKeys[1].character; - - C2D_DrawRectSolid(modifierKeys[i].x, modifierKeys[i].y+103, 0.5f, modifierKeys[i].w, 20, config->barColor() & C2D_Color32(255, 255, 255, 200)); - Gui::DrawString(modifierKeys[2].x+5, modifierKeys[2].y+105, 0.50, config->textColor(), enter); - Gui::DrawString(modifierKeys[3].x+7, modifierKeys[3].y+105, 0.45, config->textColor(), arrowUp); - Gui::DrawString(modifierKeys[4].x+10, modifierKeys[4].y+105, 0.45, config->textColor(), arrowUp); - - Gui::DrawString(modifierKeys[0].x+5, modifierKeys[0].y+105, 0.45, config->textColor(), backSpace); - Gui::DrawString(modifierKeys[1].x+5, modifierKeys[1].y+105, 0.45, config->textColor(), caps); - } + return -1; } -std::string Input::Numpad(std::string Text) { return Input::Numpad(-1, Text); } +std::uint8_t Input::setu8(std::string Text) { + Gui::clearTextBufs(); + C3D_FrameBegin(C3D_FRAME_SYNCDRAW); + C2D_TargetClear(Top, BLACK); + GFX::DrawTop(); + Gui::DrawStringCentered(0, config->useBars() ? 0 : 2, 0.7f, config->textColor(), Text, 400); + C3D_FrameEnd(0); + SwkbdState state; + swkbdInit(&state, SWKBD_TYPE_NUMPAD, 2, 3); + swkbdSetFeatures(&state, SWKBD_FIXED_WIDTH); + swkbdSetValidation(&state, SWKBD_NOTBLANK_NOTEMPTY, 0, 0); + char input[4] = {0}; + SwkbdButton ret = swkbdInputText(&state, input, sizeof(input)); + input[3] = '\0'; -std::string Input::Numpad(uint maxLength, std::string Text) { - int hDown; - touchPosition touch; - std::string string; - int keyDownDelay = 10, cursorBlink = 20; - enter = false; - while(1) { - do { - C3D_FrameEnd(0); - Gui::clearTextBufs(); - C3D_FrameBegin(C3D_FRAME_SYNCDRAW); - C2D_TargetClear(Top, BLACK); - C2D_TargetClear(Bottom, BLACK); - GFX::DrawTop(); - Gui::DrawString((400-Gui::GetStringWidth(0.55f, Text))/2, 2, 0.55f, config->textColor(), Text, 400); - Gui::DrawString(180, 217, 0.8, config->textColor(), (string+(cursorBlink-- > 0 ? "_" : "")).c_str(), 400); - if (cursorBlink < -20) cursorBlink = 20; - Gui::ScreenDraw(Bottom); - Gui::Draw_Rect(0, 0, 320, 240, config->bottomBG()); - DrawNumpad(); - scanKeys(); - hDown = keysDown(); - if (keyDownDelay > 0) { - keyDownDelay--; - } else if(keyDownDelay == 0) { - keyDownDelay--; - } - } while(!hDown); - if (keyDownDelay > 0) { - } - keyDownDelay = 10; - - if (hDown & KEY_TOUCH) { - touchRead(&touch); - if (string.length() < maxLength) { - if (touching(touch, Numbers[0])) { - string += "1"; - } else if (touching(touch, Numbers[1])) { - string += "2"; - } else if (touching(touch, Numbers[2])) { - string += "3"; - } else if (touching(touch, Numbers[3])) { - string += "4"; - } else if (touching(touch, Numbers[4])) { - string += "5"; - } else if (touching(touch, Numbers[5])) { - string += "6"; - } else if (touching(touch, Numbers[6])) { - string += "7"; - } else if (touching(touch, Numbers[7])) { - string += "8"; - } else if (touching(touch, Numbers[8])) { - string += "9"; - } else if (touching(touch, Numbers[9])) { - string += "0"; - } - } - } - - if (hDown & KEY_B || touching(touch, Numbers[11])) { - string = string.substr(0, string.length()-1); - } - - if (hDown & KEY_START || touching(touch, Numbers[10]) || enter) { - break; - } + if (ret == SWKBD_BUTTON_CONFIRM) { + return (u8)std::min(std::stoi(input), 255); + } else { + return -1; } - return string; - enter = false; -} - -int Input::getUint(int max, std::string Text) { - std::string s = Input::Numpad(3, Text); - if (s == "" || (atoi(s.c_str()) == 0 && s[0] != '0')) return -1; - int i = atoi(s.c_str()); - if (i > max) return 255; - return i; -} - -std::string Input::getString(std::string Text) { return Input::getString(-1, Text); } -std::string Input::getStringLong(std::string Text) { return Input::getString(-1, Text, 0.5f); } // For Long text. - -std::string Input::getString(uint maxLength, std::string Text, float inputTextSize) { - int hDown; - touchPosition touch; - std::string string; - int keyDownDelay = 10, cursorBlink = 20; - caps = false, shift = 0, enter = false; - while(1) { - do { - C3D_FrameEnd(0); - Gui::clearTextBufs(); - C3D_FrameBegin(C3D_FRAME_SYNCDRAW); - GFX::DrawTop(); - Gui::DrawString((400-Gui::GetStringWidth(0.55f, Text))/2, 2, 0.55f, config->textColor(), Text, 400); - GFX::DrawBottom(); - drawKeyboard(); - C2D_DrawRectSolid(0, 81, 0.5f, 320, 20, config->barColor() & C2D_Color32(200, 200, 200, 200)); - Gui::DrawString(2, 82, inputTextSize, config->textColor(), (string+(cursorBlink-- > 0 ? "_" : "")).c_str(), 316); - if (cursorBlink < -20) cursorBlink = 20; - scanKeys(); - hDown = keysDown(); - if (keyDownDelay > 0) { - keyDownDelay--; - } else if (keyDownDelay == 0) { - keyDownDelay--; - } - } while(!hDown); - if (keyDownDelay > 0) { - } - keyDownDelay = 10; - - if (hDown & KEY_TOUCH) { - touchRead(&touch); - if (string.length() < maxLength) { - // Check if a regular key was pressed - for(uint i = 0; i < (sizeof(keysQWERTY)/sizeof(keysQWERTY[0])); i++) { - if ((touch.px > keysQWERTY[i].x-2 && touch.px < keysQWERTY[i].x+18) && (touch.py > keysQWERTY[i].y+(103)-2 && touch.py < keysQWERTY[i].y+18+(103))) { - char c = (shift ? keysQWERTYShift[i] : keysQWERTY[i]).character[0]; - string += (shift || caps ? toupper(c) : c); - shift = 0; - break; - } - } - } - // Check if a modifier key was pressed - for(uint i = 0; i < (sizeof(modifierKeys)/sizeof(modifierKeys[0])); i++) { - if ((touch.px > modifierKeys[i].x-2 && touch.px < modifierKeys[i].x+modifierKeys[i].w+2) && (touch.py > modifierKeys[i].y+(103)-2 && touch.py < modifierKeys[i].y+18+(103))) { - if (modifierKeys[i].character == "\uE071") { - string = string.substr(0, string.length()-1); - } else if (modifierKeys[i].character == "\uE01D") { - caps = !caps; - } else if (modifierKeys[i].character == "\uE056") { - enter = true; - } else if (modifierKeys[i].character == "\uE01B") { - if (shift) shift = 0; - else shift = 1; - if (shift) { - keyDownDelay = -1; - } else { - keyDownDelay = 0; - } - } else if (modifierKeys[i].character == " ") { - if (string.length() < maxLength) { - shift = 0; - string += modifierKeys[5].character[0]; - } - } - break; - } - } - } else if (hDown & KEY_B) { - string = string.substr(0, string.length()-1); - } - - if (hDown & KEY_START || enter) { - break; - } - } - return string; + return -1; } \ No newline at end of file diff --git a/source/overlays/RGBSelection.cpp b/source/overlays/RGBSelection.cpp index ef96963..4939227 100644 --- a/source/overlays/RGBSelection.cpp +++ b/source/overlays/RGBSelection.cpp @@ -159,17 +159,17 @@ u32 Overlays::SelectRGB(u32 oldColor) { // Change RGB Value on the next button! if (hidKeysDown() & KEY_TOUCH) { if (touch.px >= 270 && touch.px <= 270 + 40 && touch.py >= 30 && touch.py <= 30 + 20) { - int temp = Input::getUint(255, Lang::get("ENTER_RED_RGB")); + int temp = Input::setu8(Lang::get("ENTER_RED_RGB")); if (temp != -1) { r = temp; } } else if (touch.px >= 270 && touch.px <= 270 + 40 && touch.py >= 80 && touch.py <= 80 + 20) { - int temp = Input::getUint(255, Lang::get("ENTER_GREEN_RGB")); + int temp = Input::setu8(Lang::get("ENTER_GREEN_RGB")); if (temp != -1) { g = temp; } } else if (touch.px >= 270 && touch.px <= 270 + 40 && touch.py >= 130 && touch.py <= 130 + 20) { - int temp = Input::getUint(255, Lang::get("ENTER_BLUE_RGB")); + int temp = Input::setu8(Lang::get("ENTER_BLUE_RGB")); if (temp != -1) { b = temp; } diff --git a/source/screens/scriptCreator.cpp b/source/screens/scriptCreator.cpp index f4daeb2..a9d68bc 100644 --- a/source/screens/scriptCreator.cpp +++ b/source/screens/scriptCreator.cpp @@ -172,17 +172,17 @@ void ScriptCreator::createNewJson(std::string fileName) { // Test. void ScriptCreator::createDownloadRelease() { // Repo. - std::string repo = Input::getString(50, "Enter the name of the Owner."); + std::string repo = Input::setkbdString(50, "Enter the name of the Owner."); repo += "/"; - repo += Input::getString(50, "Enter the name of the repo."); + repo += Input::setkbdString(50, "Enter the name of the repo."); // File. - std::string file = Input::getString(50, "Enter the name of the file."); + std::string file = Input::setkbdString(50, "Enter the name of the file."); // Output. - std::string output = Input::getString(50, "Enter the name of the Output path."); + std::string output = Input::setkbdString(50, "Enter the name of the Output path."); // Prerelease. bool prerelease = true; // Message. - std::string message = Input::getString(50, "Enter the Message."); + std::string message = Input::setkbdString(50, "Enter the Message."); this->editScript[this->entryName].push_back({{"type", "downloadRelease"}, {"repo", repo}, {"file", file}, {"output", output}, {"includePrerelease", prerelease}, {"message", message}}); Logging::writeToLog("Execute 'ScriptCreator::createDownloadRelease();'."); @@ -192,11 +192,11 @@ void ScriptCreator::createDownloadRelease() { void ScriptCreator::createDownloadFile() { // URL of the file. - std::string file = Input::getString(50, "Enter the URL of the file."); + std::string file = Input::setkbdString(50, "Enter the URL of the file."); // Output. - std::string output = Input::getString(50, "Enter the name of the Output path."); + std::string output = Input::setkbdString(50, "Enter the name of the Output path."); // Message. - std::string message = Input::getString(50, "Enter the Message."); + std::string message = Input::setkbdString(50, "Enter the Message."); this->editScript[this->entryName].push_back({{"type", "downloadFile"}, {"file", file}, {"output", output}, {"message", message}}); Logging::writeToLog("Execute 'ScriptCreator::createDownloadFile();'."); @@ -205,9 +205,9 @@ void ScriptCreator::createDownloadFile() { void ScriptCreator::createDeleteFile() { // URL of the file. - std::string file = Input::getString(50, "Enter the path to the file."); + std::string file = Input::setkbdString(50, "Enter the path to the file."); // Message. - std::string message = Input::getString(50, "Enter the Message."); + std::string message = Input::setkbdString(50, "Enter the Message."); this->editScript[this->entryName].push_back({{"type", "deleteFile"}, {"file", file}, {"message", message}}); Logging::writeToLog("Execute 'ScriptCreator::createDeleteFile();'."); @@ -216,13 +216,13 @@ void ScriptCreator::createDeleteFile() { void ScriptCreator::createExtractFile() { // File path. - std::string file = Input::getString(50, "Enter the path to the file."); + std::string file = Input::setkbdString(50, "Enter the path to the file."); // Input of the archive. - std::string input = Input::getString(50, "Enter the Input of what should be extracted."); + std::string input = Input::setkbdString(50, "Enter the Input of what should be extracted."); // Output path. - std::string output = Input::getString(50, "Enter the output path."); + std::string output = Input::setkbdString(50, "Enter the output path."); // Message. - std::string message = Input::getString(50, "Enter the Message."); + std::string message = Input::setkbdString(50, "Enter the Message."); this->editScript[this->entryName].push_back({{"type", "extractFile"}, {"file", file}, {"input", input}, {"output", output}, {"message", message}}); Logging::writeToLog("Execute 'ScriptCreator::createExtractFile();'."); @@ -231,9 +231,9 @@ void ScriptCreator::createExtractFile() { void ScriptCreator::createInstallCia() { // File path. - std::string file = Input::getString(50, "Enter the path to the CIA File."); + std::string file = Input::setkbdString(50, "Enter the path to the CIA File."); // Message. - std::string message = Input::getString(50, "Enter the Message."); + std::string message = Input::setkbdString(50, "Enter the Message."); this->editScript[this->entryName].push_back({{"type", "installCia"}, {"file", file}, {"message", message}}); Logging::writeToLog("Execute 'ScriptCreator::createInstallCia();'."); @@ -242,7 +242,7 @@ void ScriptCreator::createInstallCia() { void ScriptCreator::createMkDir() { // Directory path. - std::string directory = Input::getString(50, "Enter the directory path."); + std::string directory = Input::setkbdString(50, "Enter the directory path."); this->editScript[this->entryName].push_back({{"type", "mkdir"}, {"directory", directory}}); Logging::writeToLog("Execute 'ScriptCreator::createMkDir();'."); @@ -250,7 +250,7 @@ void ScriptCreator::createMkDir() { void ScriptCreator::createRmDir() { // Directory path. - std::string directory = Input::getString(50, "Enter the directory path."); + std::string directory = Input::setkbdString(50, "Enter the directory path."); this->editScript[this->entryName].push_back({{"type", "rmdir"}, {"directory", directory}}); Logging::writeToLog("Execute 'ScriptCreator::createRmDir();'."); @@ -258,17 +258,19 @@ void ScriptCreator::createRmDir() { void ScriptCreator::createMkFile() { // File path. - std::string file = Input::getString(50, "Enter the path to the new File."); + std::string file = Input::setkbdString(50, "Enter the path to the new File."); this->editScript[this->entryName].push_back({{"type", "mkfile"}, {"file", file}}); Logging::writeToLog("Execute 'ScriptCreator::createMkFile();'."); } void ScriptCreator::createTimeMsg() { + int seconds = 0; // Message. - std::string message = Input::getString(50, "Enter the Message."); + std::string message = Input::setkbdString(50, "Enter the Message."); // Seconds. - int seconds = Input::getUint(999, "Enter the Seconds for the Message to display."); + int temp = Input::setInt(999, "Enter the Seconds for the Message to display."); + if (temp != -1) seconds = temp; this->editScript[this->entryName].push_back({{"type", "timeMsg"}, {"message", message}, {"seconds", seconds}}); Logging::writeToLog("Execute 'ScriptCreator::createTimeMsg();'."); @@ -280,31 +282,31 @@ void ScriptCreator::createSaveConfig() { } void ScriptCreator::createBootTitle() { - std::string titleID = Input::getString(50, "Enter the TitleID."); + std::string titleID = Input::setkbdString(50, "Enter the TitleID."); bool isNAND = Msg::promptMsg("Is the current title a NAND title?"); - std::string message = Input::getString(50, "Enter the Message."); + std::string message = Input::setkbdString(50, "Enter the Message."); this->editScript[this->entryName].push_back({{"type", "bootTitle"}, {"TitleID", titleID}, {"NAND", isNAND}, {"message", message}}); Logging::writeToLog("Execute 'ScriptCreator::createBootTitle();'."); } void ScriptCreator::createPromptMessage() { - std::string message = Input::getString(50, "Enter the Message."); + std::string message = Input::setkbdString(50, "Enter the Message."); this->editScript[this->entryName].push_back({{"type", "promptMessage"}, {"message", message}}); Logging::writeToLog("Execute 'ScriptCreator::createPromptMessage();'."); } void ScriptCreator::createCopy() { - std::string source = Input::getString(50, "Enter the source location."); - std::string destination = Input::getString(50, "Enter the destination location."); - std::string message = Input::getString(50, "Enter the Message."); + std::string source = Input::setkbdString(50, "Enter the source location."); + std::string destination = Input::setkbdString(50, "Enter the destination location."); + std::string message = Input::setkbdString(50, "Enter the Message."); this->editScript[this->entryName].push_back({{"type", "copy"}, {"source", source}, {"destination", destination}, {"message", message}}); Logging::writeToLog("Execute 'ScriptCreator::createCopy();'."); } void ScriptCreator::createMove() { - std::string oldLocation = Input::getString(50, "Enter the old location."); - std::string newLocation = Input::getString(50, "Enter the new location."); - std::string message = Input::getString(50, "Enter the Message."); + std::string oldLocation = Input::setkbdString(50, "Enter the old location."); + std::string newLocation = Input::setkbdString(50, "Enter the new location."); + std::string message = Input::setkbdString(50, "Enter the Message."); this->editScript[this->entryName].push_back({{"type", "move"}, {"old", oldLocation}, {"new", newLocation}, {"message", message}}); Logging::writeToLog("Execute 'ScriptCreator::createMove();'."); } @@ -320,18 +322,22 @@ void ScriptCreator::save() { // Important to make Scripts valid. void ScriptCreator::setInfoStuff(void) { // Get needed things. - const std::string test = Input::getString(50, "Enter the Title of the script."); - const std::string test2 = Input::getString(50, "Enter the Author name of the script."); - const std::string test3 = Input::getString(80, "Enter the short description of the script."); - const std::string test4 = Input::getString(300, "Enter the long description of the script."); - int scriptRevision = Input::getUint(99, "Enter the script revision."); + const std::string test = Input::setkbdString(50, "Enter the Title of the script."); + const std::string test2 = Input::setkbdString(50, "Enter the Author name of the script."); + const std::string test3 = Input::setkbdString(80, "Enter the short description of the script."); + const std::string test4 = Input::setkbdString(300, "Enter the long description of the script."); + int scriptRevision = Input::setInt(99, "Enter the script revision."); // Set the real JSON stuff. this->setString("info", "title", test); this->setString("info", "author", test2); this->setString("info", "shortDesc", test3); this->setString("info", "description", test4); this->setInt("info", "version", SCRIPT_VERSION); - this->setInt("info", "revision", scriptRevision); + if (scriptRevision != -1) { + this->setInt("info", "revision", scriptRevision); + } else { + this->setInt("info", "revision", 1); + } } @@ -345,7 +351,7 @@ void ScriptCreator::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) { switch(Selection) { case 0: this->jsonFileName = config->scriptPath(); - this->jsonFileName += Input::getString(20, "Enter the name of the JSON file."); + this->jsonFileName += Input::setkbdString(20, "Enter the name of the JSON file."); if (this->jsonFileName != "") { this->jsonFileName += ".json"; this->createNewJson(this->jsonFileName); @@ -355,7 +361,7 @@ void ScriptCreator::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) { this->setInfoStuff(); } - this->entryName = Input::getString(50, "Enter the EntryName."); + this->entryName = Input::setkbdString(50, "Enter the EntryName."); this->Selection = 0; this->mode = 1; } @@ -366,7 +372,7 @@ void ScriptCreator::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) { this->jsonFileName = tempScript; if (access(this->jsonFileName.c_str(), F_OK) == 0) { this->openJson(this->jsonFileName); - this->entryName = Input::getString(50, "Enter the EntryName."); + this->entryName = Input::setkbdString(50, "Enter the EntryName."); this->Selection = 0; this->mode = 1; } @@ -387,7 +393,7 @@ void ScriptCreator::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) { if (hDown & KEY_TOUCH) { if (touching(touch, mainButtons[0])) { this->jsonFileName = config->scriptPath(); - this->jsonFileName += Input::getString(20, "Enter the name of the JSON file."); + this->jsonFileName += Input::setkbdString(20, "Enter the name of the JSON file."); if (this->jsonFileName != "") { this->jsonFileName += ".json"; this->createNewJson(this->jsonFileName); @@ -397,7 +403,7 @@ void ScriptCreator::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) { this->setInfoStuff(); } - this->entryName = Input::getString(50, "Enter the EntryName."); + this->entryName = Input::setkbdString(50, "Enter the EntryName."); this->Selection = 0; this->mode = 1; } @@ -407,7 +413,7 @@ void ScriptCreator::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) { this->jsonFileName = tempScript; if (access(this->jsonFileName.c_str(), F_OK) == 0) { this->openJson(this->jsonFileName); - this->entryName = Input::getString(50, "Enter the EntryName."); + this->entryName = Input::setkbdString(50, "Enter the EntryName."); this->Selection = 0; this->mode = 1; } @@ -526,7 +532,7 @@ void ScriptCreator::scriptLogic(u32 hDown, u32 hHeld, touchPosition touch) { this->createMove(); break; case 2: - this->entryName = Input::getString(50, "Enter the new entry."); + this->entryName = Input::setkbdString(50, "Enter the new entry."); break; } } @@ -567,7 +573,7 @@ void ScriptCreator::scriptLogic(u32 hDown, u32 hHeld, touchPosition touch) { } else if (touching(touch, creatorButtons[1])) { this->createMove(); } else if (touching(touch, creatorButtons[2])) { - this->entryName = Input::getString(50, "Enter the new entry."); + this->entryName = Input::setkbdString(50, "Enter the new entry."); } } } diff --git a/source/screens/settings.cpp b/source/screens/settings.cpp index 9679b33..6974795 100644 --- a/source/screens/settings.cpp +++ b/source/screens/settings.cpp @@ -305,7 +305,8 @@ void Settings::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) { config->musicPath(tempMusic); } } else if (Selection == 1) { - config->keyDelay(Input::getUint(255, Lang::get("ENTER_KEY_DELAY"))); + int temp = Input::setInt(255, Lang::get("ENTER_KEY_DELAY")); + if (temp != -1) config->keyDelay(temp); } else if (Selection == 2) { if (config->screenFade()) { if (Msg::promptMsg(Lang::get("TOGGLE_FADE_DISABLE"))) { @@ -340,7 +341,8 @@ void Settings::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) { config->musicPath(tempMusic); } } else if (touching(touch, mainButtons2[1])) { - config->keyDelay(Input::getUint(255, Lang::get("ENTER_KEY_DELAY"))); + int temp = Input::setInt(255, Lang::get("ENTER_KEY_DELAY")); + if (temp != -1) config->keyDelay(temp); } else if (touching(touch, mainButtons2[2])) { if (config->screenFade()) { if (Msg::promptMsg(Lang::get("TOGGLE_FADE_DISABLE"))) { @@ -555,7 +557,7 @@ void Settings::colorChanging(u32 hDown, u32 hHeld, touchPosition touch) { if (hDown & KEY_TOUCH) { if (touching(touch, mainButtons[0])) { - int temp = Input::getUint(255, Lang::get("ENTER_RED_RGB")); + int temp = Input::setu8(Lang::get("ENTER_RED_RGB")); if (temp != -1) { red = temp; if (colorMode == 0) { @@ -585,7 +587,7 @@ void Settings::colorChanging(u32 hDown, u32 hHeld, touchPosition touch) { } } } else if (touching(touch, mainButtons[1])) { - int temp = Input::getUint(255, Lang::get("ENTER_GREEN_RGB")); + int temp = Input::setu8(Lang::get("ENTER_GREEN_RGB")); if (temp != -1) { green = temp; if (colorMode == 0) { @@ -615,7 +617,7 @@ void Settings::colorChanging(u32 hDown, u32 hHeld, touchPosition touch) { } } } else if (touching(touch, mainButtons[2])) { - int temp = Input::getUint(255, Lang::get("ENTER_BLUE_RGB")); + int temp = Input::setu8(Lang::get("ENTER_BLUE_RGB")); if (temp != -1) { blue = temp; if (colorMode == 0) { diff --git a/source/screens/unistore.cpp b/source/screens/unistore.cpp index ade64c7..43d38e0 100644 --- a/source/screens/unistore.cpp +++ b/source/screens/unistore.cpp @@ -794,11 +794,11 @@ void UniStore::DrawGitHubScreen(void) const { void UniStore::GitHubLogic(u32 hDown, u32 hHeld, touchPosition touch) { if (hDown & KEY_TOUCH && touching(touch, GitHubPos[0])) { - OwnerAndRepo = Input::getStringLong(Lang::get("ENTER_OWNER_AND_REPO")); + OwnerAndRepo = Input::setkbdString(150, Lang::get("ENTER_OWNER_AND_REPO")); } if (hDown & KEY_TOUCH && touching(touch, GitHubPos[1])) { - fileName = Input::getStringLong(Lang::get("ENTER_FILENAME")); + fileName = Input::setkbdString(150, Lang::get("ENTER_FILENAME")); } if (hDown & KEY_TOUCH && touching(touch, GitHubPos[2])) { @@ -849,11 +849,11 @@ void UniStore::DrawFullURLScreen(void) const { void UniStore::FullURLLogic(u32 hDown, u32 hHeld, touchPosition touch) { if (hDown & KEY_TOUCH && touching(touch, GitHubPos[0])) { - FullURL = Input::getStringLong(Lang::get("ENTER_FULL_URL")); + FullURL = Input::setkbdString(150, Lang::get("ENTER_FULL_URL")); } if (hDown & KEY_TOUCH && touching(touch, GitHubPos[1])) { - fileName = Input::getStringLong(Lang::get("ENTER_FILENAME")); + fileName = Input::setkbdString(150, Lang::get("ENTER_FILENAME")); } if (hDown & KEY_TOUCH && touching(touch, GitHubPos[2])) { diff --git a/source/screens/unistore_v2.cpp b/source/screens/unistore_v2.cpp index ef5a540..0fc0d83 100644 --- a/source/screens/unistore_v2.cpp +++ b/source/screens/unistore_v2.cpp @@ -753,7 +753,7 @@ void UniStoreV2::Logic(u32 hDown, u32 hHeld, touchPosition touch) { // Search menu. if (hDown & KEY_TOUCH) { if (touching(touch, searchPos[0])) { - std::string temp = Input::getStringLong(Lang::get("ENTER_SEARCH")); + std::string temp = Input::setkbdString(50, Lang::get("ENTER_SEARCH")); if (temp != "") { this->selectedBox = 0; this->storePage = 0; @@ -834,7 +834,7 @@ void UniStoreV2::Logic(u32 hDown, u32 hHeld, touchPosition touch) { std::string temp; int amount; switch(this->searchSelection) { case 0: - temp = Input::getStringLong(Lang::get("ENTER_SEARCH")); + temp = Input::setkbdString(50, Lang::get("ENTER_SEARCH")); if (temp != "") { this->selectedBox = 0; this->storePage = 0;