mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-24 22:02:39 +02:00
146 lines
3.9 KiB
C
146 lines
3.9 KiB
C
/**
|
|
* @file swkbd.h
|
|
* @brief Wrapper for using the swkbd LibraryApplet.
|
|
* @author yellows8
|
|
* @copyright libnx Authors
|
|
*/
|
|
#pragma once
|
|
#include "../types.h"
|
|
#include "../services/applet.h"
|
|
|
|
typedef bool (*SwkbdTextCheckCb)(void *); ///< TextCheck callback. TODO
|
|
|
|
/// Base swkbd arg struct.
|
|
typedef struct {
|
|
u32 unk_x0;
|
|
u16 okButtonText[18/2];
|
|
u16 leftButtonText;
|
|
u16 rightButtonText;
|
|
u16 unk_x1a;
|
|
u32 keySetDisableBitmask;
|
|
u32 initialCursorPos;
|
|
u16 headerText[130/2];
|
|
u16 subText[258/2];
|
|
u16 guideText[514/2];
|
|
u16 pad_x3aa;
|
|
u32 stringLenMax;
|
|
u32 unk_x3b0;
|
|
u32 passwordFlag;
|
|
u32 unk_x3b8;
|
|
u16 returnButtonFlag; ///< Controls whether the Return button is enabled, for newlines input. 0 = disabled, non-zero = enabled.
|
|
u8 blurBackground; ///< When enabled with value 1, the background is blurred.
|
|
u8 pad_x3bf;
|
|
u32 initialStringOffset;
|
|
u32 initialStringSize;
|
|
u32 userDicOffset;
|
|
s32 userDicEntries;
|
|
u8 textCheckFlag;
|
|
u8 pad_x3d1[7];
|
|
SwkbdTextCheckCb textCheckCb; ///< This really doesn't belong in a struct sent to another process, but official sw does this.
|
|
} SwkbdArgV0;
|
|
|
|
/// Arg struct for version 0x30007+.
|
|
typedef struct {
|
|
SwkbdArgV0 arg;
|
|
u64 unk_x3e0[4];
|
|
} SwkbdArgV7;
|
|
|
|
typedef struct {
|
|
SwkbdArgV7 arg;
|
|
|
|
u8* workbuf;
|
|
size_t workbuf_size;
|
|
s32 max_dictwords;
|
|
} SwkbdConfig;
|
|
|
|
/// User dictionary word.
|
|
typedef struct {
|
|
u8 unk_x0[0x64];
|
|
} SwkbdDictWord;
|
|
|
|
/**
|
|
* @brief Creates a SwkbdConfig struct.
|
|
* @param c SwkbdConfig struct.
|
|
* @param max_dictwords Max \ref SwkbdDictWord entries, 0 for none.
|
|
*/
|
|
Result swkbdCreate(SwkbdConfig* c, s32 max_dictwords);
|
|
|
|
/**
|
|
* @brief Closes a SwkbdConfig struct.
|
|
* @param c SwkbdConfig struct.
|
|
*/
|
|
void swkbdClose(SwkbdConfig* c);
|
|
|
|
/**
|
|
* @brief Sets the Ok button text. The default is "".
|
|
* @param c SwkbdConfig struct.
|
|
* @param str UTF-8 input string.
|
|
*/
|
|
void swkbdConfigSetOkButtonText(SwkbdConfig* c, const char* str);
|
|
|
|
/**
|
|
* @brief Sets the LeftOptionalSymbolKey. The default is "".
|
|
* @param c SwkbdConfig struct.
|
|
* @param str UTF-8 input string.
|
|
*/
|
|
void swkbdConfigSetLeftOptionalSymbolKey(SwkbdConfig* c, const char* str);
|
|
|
|
/**
|
|
* @brief Sets the RightOptionalSymbolKey. The default is "".
|
|
* @param c SwkbdConfig struct.
|
|
* @param str UTF-8 input string.
|
|
*/
|
|
void swkbdConfigSetRightOptionalSymbolKey(SwkbdConfig* c, const char* str);
|
|
|
|
/**
|
|
* @brief Sets the Header text. The default is "".
|
|
* @param c SwkbdConfig struct.
|
|
* @param str UTF-8 input string.
|
|
*/
|
|
void swkbdConfigSetHeaderText(SwkbdConfig* c, const char* str);
|
|
|
|
/**
|
|
* @brief Sets the Sub text. The default is "".
|
|
* @param c SwkbdConfig struct.
|
|
* @param str UTF-8 input string.
|
|
*/
|
|
void swkbdConfigSetSubText(SwkbdConfig* c, const char* str);
|
|
|
|
/**
|
|
* @brief Sets the Guide text. The default is "".
|
|
* @param c SwkbdConfig struct.
|
|
* @param str UTF-8 input string.
|
|
*/
|
|
void swkbdConfigSetGuideText(SwkbdConfig* c, const char* str);
|
|
|
|
/**
|
|
* @brief Sets the Initial text. The default is "".
|
|
* @param c SwkbdConfig struct.
|
|
* @param str UTF-8 input string.
|
|
*/
|
|
void swkbdConfigSetInitialText(SwkbdConfig* c, const char* str);
|
|
|
|
/**
|
|
* @brief Sets the user dictionary.
|
|
* @param c SwkbdConfig struct.
|
|
* @param input Input data.
|
|
* @param entries Total entries in the buffer.
|
|
*/
|
|
void swkbdConfigSetDictionary(SwkbdConfig* c, const SwkbdDictWord *input, s32 entries);
|
|
|
|
/**
|
|
* @brief Sets the TextCheck callback. TODO: this is not yet used.
|
|
* @param c SwkbdConfig struct.
|
|
* @param cb callback
|
|
*/
|
|
void swkbdConfigSetTextCheckCallback(SwkbdConfig* c, SwkbdTextCheckCb cb);
|
|
|
|
/**
|
|
* @brief Launch swkbd with the specified config. This will return once swkbd is finished running.
|
|
* @param c SwkbdConfig struct.
|
|
* @param out_string UTF-8 Output string buffer.
|
|
* @param out_string_size UTF-8 Output string buffer size, including NUL-terminator.
|
|
*/
|
|
Result swkbdShow(SwkbdConfig* c, char* out_string, size_t out_string_size);
|
|
|