From 2ebac0606107a5e6c49b6b8da6ddda75379e7717 Mon Sep 17 00:00:00 2001 From: yellows8 Date: Mon, 28 Jan 2019 16:54:38 -0500 Subject: [PATCH] Updated swkbdInlineMakeAppearArg, this now just writes defaults and sets type to the input param. Added swkbdInlineAppearArgSetOkButtonText. --- nx/include/switch/applets/swkbd.h | 16 +++++++---- nx/source/applets/swkbd.c | 46 +++---------------------------- 2 files changed, 15 insertions(+), 47 deletions(-) diff --git a/nx/include/switch/applets/swkbd.h b/nx/include/switch/applets/swkbd.h index 27744a95..0dd77c88 100644 --- a/nx/include/switch/applets/swkbd.h +++ b/nx/include/switch/applets/swkbd.h @@ -158,7 +158,7 @@ typedef struct { u8 returnButtonFlag; ///< Controls whether the Return button is enabled, for newlines input. 0 = disabled, non-zero = enabled. u16 unk_x29; u8 unk_x2b; - u32 flags; + u32 flags; ///< Bitmask 0x4: unknown. u8 unk_x30; u8 unk_x31[0x17]; } PACKED SwkbdAppearArg; @@ -476,13 +476,19 @@ void swkbdInlineAppear(SwkbdInline* s, SwkbdAppearArg* arg); void swkbdInlineDisappear(SwkbdInline* s); /** - * @brief Creates a \ref SwkbdAppearArg which can then be passed to \ref swkbdInlineAppear. + * @brief Creates a \ref SwkbdAppearArg which can then be passed to \ref swkbdInlineAppear. arg is initialized with the defaults, with type being set to the input type. * @param arg Output \ref SwkbdAppearArg. - * @param type Type. Must be 0..5, otherwise this will return. - * @param flag Unknown flag + * @param type \ref SwkbdType type * @param str Input UTF-8 string for the Ok button text, this can be empty/NULL to use the default. */ -void swkbdInlineMakeAppearArg(SwkbdAppearArg* arg, u32 type, bool flag, const char* str); +void swkbdInlineMakeAppearArg(SwkbdAppearArg* arg, SwkbdType type); + +/** + * @brief Sets okButtonText for the specified SwkbdAppearArg, which was previously initialized with \ref swkbdInlineMakeAppearArg. + * @param arg \ref SwkbdAppearArg + * @param str Input UTF-8 string for the Ok button text, this can be empty/NULL to use the default. + */ +void swkbdInlineAppearArgSetOkButtonText(SwkbdAppearArg* arg, const char* str); /** * @brief Sets the audio volume. diff --git a/nx/source/applets/swkbd.c b/nx/source/applets/swkbd.c index c63b2927..efed3616 100644 --- a/nx/source/applets/swkbd.c +++ b/nx/source/applets/swkbd.c @@ -643,54 +643,16 @@ void swkbdInlineDisappear(SwkbdInline* s) { s->calcArg.flags = (s->calcArg.flags & ~0x4) | 0x80; } -void swkbdInlineMakeAppearArg(SwkbdAppearArg* arg, u32 type, bool flag, const char* str) { +void swkbdInlineMakeAppearArg(SwkbdAppearArg* arg, SwkbdType type) { memset(arg, 0, sizeof(SwkbdAppearArg)); - u32 tmpval=0; - u8 tmpval2[2]={0}; - - switch(type) { - case 0: - tmpval = SwkbdType_NumPad; - 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 = SwkbdType_QWERTY; - break; - - case 4: - tmpval = SwkbdType_NumPad; - break; - - case 5: - tmpval = SwkbdType_Normal; - arg->keySetDisableBitmask = SwkbdKeyDisableBitmask_DownloadCode; - break; - - default: - return; - } - arg->unk_x20 = -1; arg->unk_x24 = -1; arg->unk_x30 = 1; - arg->type = tmpval; - arg->dicFlag = tmpval2[0]; - arg->returnButtonFlag = tmpval2[1]; - if (flag) arg->flags = 0x4; + arg->type = type; +} +void swkbdInlineAppearArgSetOkButtonText(SwkbdAppearArg* arg, const char* str) { _swkbdConvertToUTF16ByteSize(arg->okButtonText, str, sizeof(arg->okButtonText)); }