diff --git a/nx/include/switch/applets/swkbd.h b/nx/include/switch/applets/swkbd.h index e123b7e5..01af0d3b 100644 --- a/nx/include/switch/applets/swkbd.h +++ b/nx/include/switch/applets/swkbd.h @@ -210,8 +210,8 @@ typedef struct { u8 dicFlag; ///< Enables dictionary usage when non-zero (including the system dictionary). u8 unk_x1b; u32 keySetDisableBitmask; ///< See SwkbdKeyDisableBitmask_*. - s32 unk_x20; - s32 unk_x24; + s32 stringLenMax; ///< When non-negative and non-zero, specifies the max string length. When the input is too long, swkbd will stop accepting more input until text is deleted via the B button (Backspace). + s32 stringLenMin; ///< When non-negative and non-zero, specifies the min string length. When the input is too short, swkbd will display an icon and disable the ok-button. u8 returnButtonFlag; ///< Controls whether the Return button is enabled, for newlines input. 0 = disabled, non-zero = enabled. u8 unk_x29; ///< [10.0.0+] When value 1-2, \ref swkbdInlineAppear / \ref swkbdInlineAppearEx will set keytopAsFloating=0 and footerScalable=1. u8 unk_x2a; @@ -805,6 +805,24 @@ void swkbdInlineAppearArgSetLeftButtonText(SwkbdAppearArg* arg, const char* str) */ void swkbdInlineAppearArgSetRightButtonText(SwkbdAppearArg* arg, const char* str); +/** + * @brief Sets the stringLenMax for the specified SwkbdAppearArg, which was previously initialized with \ref swkbdInlineMakeAppearArg. + * @param arg \ref SwkbdAppearArg + * @param stringLenMax Max string length + */ +static inline void swkbdInlineAppearArgSetStringLenMax(SwkbdAppearArg* arg, s32 stringLenMax) { + arg->stringLenMax = stringLenMax; +} + +/** + * @brief Sets the stringLenMin for the specified SwkbdAppearArg, which was previously initialized with \ref swkbdInlineMakeAppearArg. + * @param arg \ref SwkbdAppearArg + * @param stringLenMin Min string length + */ +static inline void swkbdInlineAppearArgSetStringLenMin(SwkbdAppearArg* arg, s32 stringLenMin) { + arg->stringLenMin = stringLenMin; +} + /** * @brief Sets the audio volume. * @note \ref swkbdInlineUpdate must be called at some point afterwards for this to take affect. diff --git a/nx/source/applets/swkbd.c b/nx/source/applets/swkbd.c index 529ed225..94ae163e 100644 --- a/nx/source/applets/swkbd.c +++ b/nx/source/applets/swkbd.c @@ -393,8 +393,8 @@ Result swkbdInlineCreate(SwkbdInline* s) { s->calcArg.appearArg.type = SwkbdType_QWERTY; s->calcArg.unk_x6 = 1; s->calcArg.unk_x7 = 1; - s->calcArg.appearArg.unk_x20 = -1; - s->calcArg.appearArg.unk_x24 = -1; + s->calcArg.appearArg.stringLenMax = -1; + s->calcArg.appearArg.stringLenMin = -1; s->calcArg.appearArg.unk_x30 = 1; s->calcArg.enableBackspace = 1; @@ -896,8 +896,8 @@ void swkbdInlineDisappear(SwkbdInline* s) { void swkbdInlineMakeAppearArg(SwkbdAppearArg* arg, SwkbdType type) { memset(arg, 0, sizeof(SwkbdAppearArg)); - arg->unk_x20 = -1; - arg->unk_x24 = -1; + arg->stringLenMax = -1; + arg->stringLenMin = -1; arg->unk_x30 = 1; arg->type = type; }