diff --git a/nx/include/switch/applets/swkbd.h b/nx/include/switch/applets/swkbd.h index 63c867a1..3b0946f9 100644 --- a/nx/include/switch/applets/swkbd.h +++ b/nx/include/switch/applets/swkbd.h @@ -110,15 +110,17 @@ typedef struct { typedef struct { u32 unk_x0; - u64 unk_x4; - u64 unk_xc; - u8 unk_x14[0x6]; + u16 str[9]; + u8 unk_x16[0x4]; u8 unk_x1a; u8 unk_x1b; u32 unk_x1c; s32 unk_x20; s32 unk_x24; - u64 unk_x28; + u8 unk_x28; + u16 unk_x29; + u8 unk_x2b; + u32 unk_x2c; u8 unk_x30; u8 unk_x31[0x17]; } SwkbdAppearArg; @@ -314,3 +316,27 @@ Result swkbdInlineLaunch(SwkbdInline* s); */ Result swkbdInlineUpdate(SwkbdInline* s); +/** + * @brief Appear the kbd and set \ref SwkbdAppearArg. The applet will not start displaying on the screen with this. + * @note \ref swkbdInlineUpdate must be called at some point afterwards for this to take affect. + * @param s SwkbdInline object. + * @param arg Input SwkbdAppearArg. + */ +void swkbdInlineAppear(SwkbdInline* s, SwkbdAppearArg* arg); + +/** + * @brief Disappear the kbd. + * @note \ref swkbdInlineUpdate must be called at some point afterwards for this to take affect. + * @param s SwkbdInline object. + */ +void swkbdInlineDisappear(SwkbdInline* s); + +/** + * @brief Creates a \ref SwkbdAppearArg which can then be passed to \ref swkbdInlineAppear. + * @param arg Output \ref SwkbdAppearArg. + * @param type Type. Must be 0..5, otherwise this will return. + * @param flag Unknown flag + * @param str Input UTF-8 string. + */ +void swkbdInlineMakeAppearArg(SwkbdAppearArg* arg, u32 type, bool flag, const char* str); + diff --git a/nx/source/applets/swkbd.c b/nx/source/applets/swkbd.c index 8d25b991..c3d00500 100644 --- a/nx/source/applets/swkbd.c +++ b/nx/source/applets/swkbd.c @@ -431,3 +431,65 @@ Result swkbdInlineUpdate(SwkbdInline* s) { return rc; } +void swkbdInlineAppear(SwkbdInline* s, SwkbdAppearArg* arg) { + memcpy(&s->calcArg.appearArg, arg, sizeof(SwkbdAppearArg)); + s->calcArg.flags = (s->calcArg.flags & ~0x80) | 0x4; +} + +void swkbdInlineDisappear(SwkbdInline* s) { + s->calcArg.flags = (s->calcArg.flags & ~0x4) | 0x80; +} + +void swkbdInlineMakeAppearArg(SwkbdAppearArg* arg, u32 type, bool flag, const char* str) { + memset(arg, 0, sizeof(SwkbdAppearArg)); + + u32 tmpval=0; + u8 tmpval2[2]={0}; + u32 tmpval3=0; + + switch(type) { + case 0: + tmpval = 1; + tmpval2[0] = tmpval; + break; + + case 1: + tmpval = 0x101; + tmpval2[0] = 1; + tmpval2[1] = 1; + break; + + case 2: + tmpval = 3; + tmpval2[0] = 1; + break; + + case 3: + tmpval = 2; + break; + + case 4: + tmpval = 1; + break; + + case 5: + tmpval = 0; + tmpval3 = 0x80; + break; + + default: + return; + } + + arg->unk_x20 = -1; + arg->unk_x24 = -1; + arg->unk_x30 = 1; + arg->unk_x0 = tmpval; + arg->unk_x1a = tmpval2[0]; + arg->unk_x28 = tmpval2[1]; + arg->unk_x1c = tmpval3; + if (flag) arg->unk_x2c = 0x4; + + _swkbdConvertToUTF16ByteSize(arg->str, str, sizeof(arg->str)); +} +