Added swkbdInlineSetCustomizeDic/swkbdInlineUnsetCustomizeDic. Updated SwkbdChangedStringArg struct.

This commit is contained in:
yellows8 2019-01-21 18:33:15 -05:00
parent be8e196eb0
commit 4a119e4028
2 changed files with 56 additions and 4 deletions

View File

@ -132,6 +132,11 @@ typedef struct {
u8 unk_x0[0x64];
} SwkbdDictWord;
/// Input data for SwkbdInline request SetCustomizeDic.
typedef struct {
u8 unk_x0[0x70];
} SwkbdCustomizeDicInfo;
typedef struct {
u32 unk_x0;
u8 mode; ///< See \ref SwkbdInlineMode.
@ -197,8 +202,8 @@ typedef struct {
/// Struct data for SwkbdInline Interactive reply storage ChangedString*, at the end following the string.
typedef struct {
u32 stringLen; ///< String length in characters, without NUL-terminator.
s32 unk_x4;
s32 unk_x8;
s32 dicStartCursorPos; ///< Starting cursorPos for the current dictionary word in the current text string. -1 for none.
s32 dicEndCursorPos; ///< Ending cursorPos for the current dictionary word in the current text string. -1 for none.
s32 cursorPos; ///< Cursor position.
} SwkbdChangedStringArg;
@ -243,6 +248,9 @@ typedef struct {
bool directionalButtonAssignFlag;
SwkbdState state;
bool dicCustomInitialized;
AppletStorage dicStorage;
u8* interactive_tmpbuf;
size_t interactive_tmpbuf_size;
char* interactive_strbuf;
@ -506,6 +514,25 @@ void swkbdInlineSetCursorPos(SwkbdInline* s, s32 pos);
*/
void swkbdInlineSetUtf8Mode(SwkbdInline* s, bool flag);
/**
* @brief Sets the CustomizeDic.
* @note Not avilable when \ref SwkbdState is above \ref SwkbdState_Initialized. Can't be used if this was already used previously.
* @note The specified buffer must not be used after this, until \ref swkbdInlineClose is used.
* @param s SwkbdInline object.
* @param buffer 0x1000-byte aligned buffer.
* @param size 0x1000-byte aligned buffer size.
* @param info Input \ref SwkbdCustomizeDicInfo
*/
Result swkbdInlineSetCustomizeDic(SwkbdInline* s, void* buffer, size_t size, SwkbdCustomizeDicInfo *info);
/**
* @brief Request UnsetCustomizeDic.
* @note \ref swkbdInlineUpdate must be called at some point afterwards for this to take affect.
* @note Not avilable when \ref SwkbdState is above \ref SwkbdState_Initialized.
* @param s SwkbdInline object.
*/
void swkbdInlineUnsetCustomizeDic(SwkbdInline* s);
/**
* @brief Sets InputModeFadeType.
* @note \ref swkbdInlineUpdate must be called at some point afterwards for this to take affect.

View File

@ -427,6 +427,10 @@ Result swkbdInlineClose(SwkbdInline* s) {
s->interactive_strbuf = NULL;
s->interactive_strbuf_size = 0;
appletStorageCloseTmem(&s->dicStorage);
memset(s, 0, sizeof(SwkbdInline));
return rc;
}
@ -685,6 +689,27 @@ void swkbdInlineSetUtf8Mode(SwkbdInline* s, bool flag) {
_swkbdInlineSetBoolFlag(s, &s->calcArg.utf8Mode, flag, 0x20);
}
Result swkbdInlineSetCustomizeDic(SwkbdInline* s, void* buffer, size_t size, SwkbdCustomizeDicInfo *info) {
Result rc=0;
if (s->state > SwkbdState_Initialized || s->dicCustomInitialized) return MAKERESULT(Module_Libnx, LibnxError_AlreadyInitialized);
rc = appletCreateHandleStorageTmem(&s->dicStorage, buffer, size);
if (R_FAILED(rc)) return rc;
s->dicCustomInitialized = true;
rc = appletHolderPushInteractiveInData(&s->holder, &s->dicStorage);
if (R_FAILED(rc)) return rc;
rc = _swkbdSendRequest(s, SwkbdRequestCommand_SetCustomizeDic, info, sizeof(SwkbdCustomizeDicInfo));
return rc;
}
void swkbdInlineUnsetCustomizeDic(SwkbdInline* s) {
if (s->state > SwkbdState_Initialized || !s->dicCustomInitialized) return;
s->calcArg.flags |= 0x40;
}
void swkbdInlineSetInputModeFadeType(SwkbdInline* s, u8 type) {
if (s->calcArg.inputModeFadeType == type) return;
s->calcArg.inputModeFadeType = type;