2018-06-17 08:22:37 +00:00
|
|
|
#include "KeyboardManager.hpp"
|
|
|
|
|
|
|
|
std::u16string KeyboardManager::keyboard(const std::string& suggestion)
|
|
|
|
{
|
2019-05-06 20:51:09 +00:00
|
|
|
swkbdSetInitialText(&mSwkbd, suggestion.c_str());
|
2018-06-17 08:22:37 +00:00
|
|
|
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';
|
2018-06-17 08:22:37 +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;
|
|
|
|
}
|
|
|
|
|
2018-06-17 08:22:37 +00:00
|
|
|
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.");
|
2018-06-17 08:22:37 +00:00
|
|
|
}
|