Fix swkbd for nro + dictionary

This commit is contained in:
J-D-K
2019-01-08 15:44:10 -05:00
parent bd78f186aa
commit 9551d85e0f
5 changed files with 80 additions and 12 deletions

View File

@@ -38,7 +38,7 @@ INCLUDES := inc
EXEFS_SRC := exefs_src
APP_TITLE := JKSV
APP_AUTHOR := JK
APP_VERSION := 12/23/2018
APP_VERSION := 01/08/2018
ROMFS := romfs
#---------------------------------------------------------------------------------

View File

@@ -13,15 +13,20 @@ extern "C"
{
void userAppInit(void)
{
appletInitialize();
romfsInit();
hidInitialize();
nsInitialize();
setsysInitialize();
accountInitialize();
void *add = NULL;
svcSetHeapSize(&add, 0x12000000);
}
void userAppExit(void)
{
appletExit();
romfsExit();
hidExit();
nsExit();

View File

@@ -11,7 +11,7 @@
#include "util.h"
#include "file.h"
#define VER_STRING "v. 12/22/2018"
#define VER_STRING "v. 01/08/2018"
//background that can be drawn from "/JKSV/back.jpg"
//txtSide and fldSide are to fake alpha blending so the framerate doesn't suffer

View File

@@ -58,11 +58,11 @@ namespace ui
{
const std::string dict[] =
{
util::getDateTime(util::DATE_FMT_YMD),
util::getDateTime(util::DATE_FMT_YDM),
util::getDateTime(util::DATE_FMT_HOYSTE),
data::curUser.getUsernameSafe(),
data::curData.getTitleSafe()
util::getDateTime(util::DATE_FMT_YMD).c_str(),
util::getDateTime(util::DATE_FMT_YDM).c_str(),
util::getDateTime(util::DATE_FMT_HOYSTE).c_str(),
data::curUser.getUsernameSafe().c_str(),
data::curData.getTitleSafe(),
};
folder = util::getStringInput("", "Enter a folder name", 64, 5, dict);
}

View File

@@ -11,6 +11,59 @@
static const char verboten[] = { ',', '/', '\\', '<', '>', ':', '"', '|', '?', '*'};
//Missing swkbd config funcs for now
typedef enum
{
SwkbdPosStart = 0,
SwkbdPosEnd = 1
} SwkbdInitPos;
void swkbdConfigSetMaxLength(SwkbdConfig *c, unsigned int maxLength)
{
c->arg.arg.stringLenMax = maxLength;
}
void swkbdConfigSetType(SwkbdConfig *c, SwkbdType type)
{
c->arg.arg.type = type;
}
void swkbdConfigSetInitialPos(SwkbdConfig *c, SwkbdInitPos pos)
{
c->arg.arg.initialCursorPos = pos;
}
void swkbdConfigSetDisableBitmask(SwkbdConfig *c, uint32_t bits)
{
c->arg.arg.keySetDisableBitmask = bits;
}
void swkbdConfigBlurBackground(SwkbdConfig *c, bool blur)
{
c->arg.arg.blurBackground = blur;
}
typedef struct
{
uint16_t read[0x32 / sizeof(uint16_t)];
uint16_t word[0x32 / sizeof(uint16_t)];
} dictWord;
void swkbdDictWordCreate(dictWord *w, const char *read, const char *word)
{
memset(w->read, 0, 0x32);
memset(w->word, 0, 0x32);
uint16_t tmp[0x32 / sizeof(uint16_t)];
memset(tmp, 0, 0x32);
utf8_to_utf16(tmp, (uint8_t *)read, 0x30);
memcpy(w->read, tmp, 0x30);
utf8_to_utf16(tmp, (uint8_t *)word, 0x30);
memcpy(w->word, tmp, 0x30);
}
namespace util
{
std::string getDateTime(int fmt)
@@ -154,13 +207,23 @@ namespace util
{
SwkbdConfig swkbd;
swkbdCreate(&swkbd, dictCnt);
swkbdConfigMakePresetDefault(&swkbd);
swkbdConfigBlurBackground(&swkbd, true);
swkbdConfigSetInitialText(&swkbd, def.c_str());
swkbd.arg.arg.type = SwkbdType_QWERTY;
swkbdConfigSetHeaderText(&swkbd, head.c_str());
swkbdConfigSetOkButtonText(&swkbd, "Done");
swkbd.arg.arg.initialCursorPos = 1;
swkbd.arg.arg.stringLenMax = maxLength;
swkbdConfigSetGuideText(&swkbd, head.c_str());
swkbdConfigSetInitialPos(&swkbd, SwkbdPosEnd);
swkbdConfigSetType(&swkbd, SwkbdType_QWERTY);
swkbdConfigSetMaxLength(&swkbd, maxLength);
swkbdConfigSetDisableBitmask(&swkbd, SwkbdKeyDisableBitmask_Backslash | SwkbdKeyDisableBitmask_ForwardSlash | SwkbdKeyDisableBitmask_Percent);
if(dictCnt > 0)
{
dictWord words[dictCnt];
for(unsigned i = 0; i < dictCnt; i++)
swkbdDictWordCreate(&words[i], dictWords[i].c_str(), dictWords[i].c_str());
swkbdConfigSetDictionary(&swkbd, (SwkbdDictWord *)words, dictCnt);
}
char out[maxLength];
memset(out, 0, maxLength);