Checkpoint/3ds/source/KeyboardManager.cpp

28 lines
1 KiB
C++
Raw Normal View History

#include "KeyboardManager.hpp"
std::u16string KeyboardManager::keyboard(const std::string& suggestion)
{
2019-05-06 20:51:09 +00:00
swkbdSetInitialText(&mSwkbd, suggestion.c_str());
char buf[CUSTOM_PATH_LEN] = {0};
2019-05-06 20:51:09 +00:00
SwkbdButton button = swkbdInputText(&mSwkbd, buf, CUSTOM_PATH_LEN);
buf[CUSTOM_PATH_LEN - 1] = '\0';
2019-07-16 19:19:25 +00:00
return button == SWKBD_BUTTON_CONFIRM ? StringUtils::removeForbiddenCharacters(StringUtils::UTF8toUTF16(buf)) : StringUtils::UTF8toUTF16("");
}
2019-05-02 21:22:07 +00:00
int KeyboardManager::numericPad(void)
{
static SwkbdState swkbd;
swkbdInit(&swkbd, SWKBD_TYPE_NUMPAD, 2, 3);
swkbdSetFeatures(&swkbd, SWKBD_FIXED_WIDTH);
swkbdSetValidation(&swkbd, SWKBD_NOTBLANK_NOTEMPTY, 0, 0);
2019-05-06 20:51:09 +00:00
char buf[4] = {0};
2019-05-02 21:22:07 +00:00
SwkbdButton button = swkbdInputText(&swkbd, buf, sizeof(buf));
2019-05-06 20:51:09 +00:00
buf[3] = '\0';
2019-05-02 21:22:07 +00:00
return button == SWKBD_BUTTON_CONFIRM ? atoi(buf) : -1;
}
KeyboardManager::KeyboardManager(void)
{
2019-05-06 20:51:09 +00:00
swkbdInit(&mSwkbd, SWKBD_TYPE_NORMAL, 2, CUSTOM_PATH_LEN - 1);
swkbdSetHintText(&mSwkbd, "Choose a name for your backup.");
}