From 457a82481d256221eb70628c6c6bffcd82243cf8 Mon Sep 17 00:00:00 2001 From: Pk11 Date: Sat, 30 Dec 2023 18:48:15 -0600 Subject: [PATCH] Make X clear string in keyboard (#226) --- arm9/source/keyboard.cpp | 8 ++++++-- arm9/source/language.inl | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/arm9/source/keyboard.cpp b/arm9/source/keyboard.cpp index c1e8c95..24be124 100644 --- a/arm9/source/keyboard.cpp +++ b/arm9/source/keyboard.cpp @@ -59,7 +59,7 @@ std::string kbdGetString(std::string label, int maxSize, std::string oldStr) { } font->printf(2 + cursorPosition, labelHeight, false, Alignment::left, Palette::blackWhite, "%s", stringPosition < (int)output.size() ? output.substr(stringPosition, charLen).c_str() : " "); - font->print(firstCol, labelHeight + 2, false, STR_START_RETURN_B_BACKSPACE, alignStart); + font->print(firstCol, labelHeight + 2, false, STR_START_RETURN_B_BACKSPACE_X_CLEAR, alignStart); font->update(false); do { @@ -67,7 +67,7 @@ std::string kbdGetString(std::string label, int maxSize, std::string oldStr) { pressed = keysDownRepeat(); key = keyboardUpdate(); swiWaitForVBlank(); - } while (!((pressed & (KEY_LEFT | KEY_RIGHT | KEY_B | KEY_START | KEY_TOUCH)) || (key != -1))); + } while (!((pressed & (KEY_LEFT | KEY_RIGHT | KEY_B | KEY_X | KEY_START | KEY_TOUCH)) || (key != -1))); switch(key) { case NOKEY: @@ -176,6 +176,10 @@ std::string kbdGetString(std::string label, int maxSize, std::string oldStr) { scrollPosition--; } } + } else if(pressed & KEY_X) { + output = ""; + stringPosition = 0; + scrollPosition = 0; } else if(pressed & KEY_START) { done = true; } diff --git a/arm9/source/language.inl b/arm9/source/language.inl index c0e05ea..c68195d 100644 --- a/arm9/source/language.inl +++ b/arm9/source/language.inl @@ -189,7 +189,7 @@ STRING(A_SELECT_B_CANCEL, "(\\A select, \\B cancel)") STRING(START_CANCEL, "(START cancel)") STRING(UDLR_CHANGE_ATTRIBUTES, "(\\D change attributes)") STRING(A_APPLY_B_CANCEL, "(\\A apply, \\B cancel)") -STRING(START_RETURN_B_BACKSPACE, "(START Return, \\B Backspace)") +STRING(START_RETURN_B_BACKSPACE_X_CLEAR, "(START Return, \\B Backspace, \\X Clear)") // Byte counts STRING(1_BYTE, "1 Byte")