wut v1.8.0
Wii U Toolchain
Loading...
Searching...
No Matches
swkbd_cpp.h
Go to the documentation of this file.
1#pragma once
2#include <wut.h>
4#include <nn/result.h>
5#include <padscore/kpad.h>
6#include <vpad/input.h>
7#include <string.h>
8
17#ifdef __cplusplus
18
19namespace nn
20{
21
35namespace swkbd
36{
37
39{
40 WiiRemote0 = 0,
41 WiiRemote1 = 1,
42 WiiRemote2 = 2,
43 WiiRemote3 = 3,
44 DrcGamepad = 4,
45};
46
48enum class LanguageType
49{
51 Japanese = 0,
53 English = 1,
55 French = 2,
57 German = 3,
59 Italian = 4,
61 Spanish = 5,
65 Korean = 7,
67 Dutch = 8,
69 Portuguese = 9,
71 Russian = 10,
74 Invalid = 12,
75};
76
77enum class RegionType
78{
79 Japan = 0,
80 USA = 1,
81 Europe = 2,
82 China = 3,
83 Korea = 4,
84 Taiwan = 5,
85};
86
87enum class State
88{
90 Hidden = 0,
92 FadeIn = 1,
94 Visible = 2,
96 FadeOut = 3,
97};
98
99enum class InputFormType
100{
102 InputForm0 = 0,
104 Default = 1,
105};
106
107enum class KeyboardMode
108{
110 Full = 0,
112 Numpad = 1,
114 Utf8 = 2,
116 NNID = 3,
117};
118
119enum class PasswordMode
120{
122 Clear = 0,
124 Hide = 1,
126 Fade = 2,
127};
128
131{
133 {
134 memset(this, 0, sizeof(*this));
138 accessFlags = 0x7FFFF;
139 unk_0x10 = 19;
140 unk_0x14 = -1;
141 unk_0x9C = 1;
142 unk_0xA4 = -1;
143 }
144
150 uint32_t accessFlags; // Bitmasked!
151 uint32_t unk_0x10;
152 int32_t unk_0x14;
155 const char16_t *okString;
162 WUT_PADDING_BYTES(3);
163 uint8_t unk_0x28;
164 uint8_t unk_0x29;
165 uint8_t unk_0x2A;
168 WUT_UNKNOWN_BYTES(0x9C - 0x2C);
169 uint32_t unk_0x9C;
172 int32_t unk_0xA4;
173};
174WUT_CHECK_OFFSET(ConfigArg, 0x00, languageType);
175WUT_CHECK_OFFSET(ConfigArg, 0x04, controllerType);
176WUT_CHECK_OFFSET(ConfigArg, 0x08, keyboardMode);
177WUT_CHECK_OFFSET(ConfigArg, 0x0C, accessFlags);
178WUT_CHECK_OFFSET(ConfigArg, 0x10, unk_0x10);
179WUT_CHECK_OFFSET(ConfigArg, 0x14, unk_0x14);
180WUT_CHECK_OFFSET(ConfigArg, 0x18, unk_0x18);
181WUT_CHECK_OFFSET(ConfigArg, 0x1C, okString);
182WUT_CHECK_OFFSET(ConfigArg, 0x20, numpadCharLeft);
183WUT_CHECK_OFFSET(ConfigArg, 0x22, numpadCharRight);
184WUT_CHECK_OFFSET(ConfigArg, 0x24, showWordSuggestions);
185WUT_CHECK_OFFSET(ConfigArg, 0x28, unk_0x28);
186WUT_CHECK_OFFSET(ConfigArg, 0x29, unk_0x29);
187WUT_CHECK_OFFSET(ConfigArg, 0x2A, unk_0x2A);
188WUT_CHECK_OFFSET(ConfigArg, 0x2B, disableNewLine);
189WUT_CHECK_OFFSET(ConfigArg, 0x9C, unk_0x9C);
190WUT_CHECK_OFFSET(ConfigArg, 0xA0, drawSysWiiPointer);
191WUT_CHECK_OFFSET(ConfigArg, 0xA4, unk_0xA4);
192WUT_CHECK_SIZE(ConfigArg, 0xA8);
193
195{
196 uint32_t unk_0x00 = 0;
197 uint32_t unk_0x04 = 0;
198 uint32_t unk_0x08 = 0;
199 int32_t unk_0x0C = -1;
200 uint32_t unk_0x10 = 0;
201 int32_t unk_0x14 = -1;
202};
203WUT_CHECK_OFFSET(ReceiverArg, 0x00, unk_0x00);
204WUT_CHECK_OFFSET(ReceiverArg, 0x04, unk_0x04);
205WUT_CHECK_OFFSET(ReceiverArg, 0x08, unk_0x08);
206WUT_CHECK_OFFSET(ReceiverArg, 0x0C, unk_0x0C);
207WUT_CHECK_OFFSET(ReceiverArg, 0x10, unk_0x10);
208WUT_CHECK_OFFSET(ReceiverArg, 0x14, unk_0x14);
209WUT_CHECK_SIZE(ReceiverArg, 0x18);
210
218WUT_CHECK_SIZE(KeyboardArg, 0xC0);
219
222{
225 int32_t unk_0x04 = -1;
227 const char16_t *initialText = nullptr;
229 const char16_t *hintText = nullptr;
231 int32_t maxTextLength = -1;
234 uint32_t unk_0x18 = 0;
236 bool drawInput0Cursor = false;
241 WUT_PADDING_BYTES(1);
242};
243WUT_CHECK_OFFSET(InputFormArg, 0x00, type);
244WUT_CHECK_OFFSET(InputFormArg, 0x04, unk_0x04);
245WUT_CHECK_OFFSET(InputFormArg, 0x08, initialText);
246WUT_CHECK_OFFSET(InputFormArg, 0x0C, hintText);
247WUT_CHECK_OFFSET(InputFormArg, 0x10, maxTextLength);
248WUT_CHECK_OFFSET(InputFormArg, 0x14, passwordMode);
249WUT_CHECK_OFFSET(InputFormArg, 0x18, unk_0x18);
250WUT_CHECK_OFFSET(InputFormArg, 0x1C, drawInput0Cursor);
251WUT_CHECK_OFFSET(InputFormArg, 0x1D, higlightInitialText);
252WUT_CHECK_OFFSET(InputFormArg, 0x1E, showCopyPasteButtons);
253WUT_CHECK_SIZE(InputFormArg, 0x20);
254
263WUT_CHECK_SIZE(AppearArg, 0xE0);
264
267{
269 void *workMemory = nullptr;
272 uint32_t unk_0x08 = 0;
274 FSClient *fsClient = nullptr;
275};
276WUT_CHECK_OFFSET(CreateArg, 0x00, workMemory);
277WUT_CHECK_OFFSET(CreateArg, 0x04, regionType);
278WUT_CHECK_OFFSET(CreateArg, 0x08, unk_0x08);
279WUT_CHECK_OFFSET(CreateArg, 0x0C, fsClient);
280WUT_CHECK_SIZE(CreateArg, 0x10);
281
284{
286 VPADStatus *vpad = nullptr;
288 KPADStatus *kpad[4] = { nullptr, nullptr, nullptr, nullptr };
289};
290WUT_CHECK_OFFSET(ControllerInfo, 0x00, vpad);
291WUT_CHECK_OFFSET(ControllerInfo, 0x04, kpad);
292WUT_CHECK_SIZE(ControllerInfo, 0x14);
293
295{
297 {
298 memset(this, 0, sizeof(*this));
299 }
300
301 WUT_UNKNOWN_BYTES(0x1C);
302};
303WUT_CHECK_SIZE(DrawStringInfo, 0x1C);
304
306{
308 uint32_t unk_0x00 = 0;
310 uint32_t unk_0x04 = 0;
311};
312WUT_CHECK_OFFSET(KeyboardCondition, 0x00, unk_0x00);
313WUT_CHECK_OFFSET(KeyboardCondition, 0x04, unk_0x04);
314WUT_CHECK_SIZE(KeyboardCondition, 0x8);
315
316struct IEventReceiver;
317struct IControllerEventObj;
318struct ISoundObj;
319
336bool
338
354bool
356
365void
367
376void
378
392void
393Calc(const ControllerInfo &controllerInfo);
394
395void
397
413bool
414Create(const CreateArg &args);
415
427void
429
440bool
442
452bool
454
460void
462
468void
470
471void
473
483const char16_t *
485
486void
488
495State
497
498State
500
514uint32_t
515GetWorkMemorySize(uint32_t unk);
516
517void
519
520bool
521InitLearnDic(void *dictionary);
522
523bool
525
539bool
540IsDecideCancelButton(bool *outIsSelected);
541
555bool
556IsDecideOkButton(bool *outIsSelected);
557
558bool
559IsKeyboardTarget(IEventReceiver *eventReceiver);
560
571bool
573
584bool
586
593bool
595
603void
604MuteAllSound(bool muted);
605
606void
608
621void
623
631void
632SetEnableOkButton(bool enable);
633
643void
644SetInputFormString(const char16_t *str);
645
646void
647SetReceiver(const ReceiverArg &receiver);
648
649void
651
652void
653SetUserControllerEventObj(IControllerEventObj *controllerEventObj);
654
655void
656SetUserSoundObj(ISoundObj *soundObj);
657
658} // namespace swkbd
659} // namespace nn
660
661#endif // ifdef __cplusplus
662
A structure containing the Wii Remote data.
Definition kpad.h:92
VPADStatus * vpad
DRC input information, see VPADRead.
Definition swkbd_cpp.h:286
void InactivateSelectCursor()
@ InputForm0
Input form seen when adding an NNID on Friends List or creating a folder on the System Menu....
@ Default
The default input layout that is usually used (Page design)
const char16_t * hintText
Hint string.
Definition swkbd_cpp.h:229
InputFormType type
The type of input form.
Definition swkbd_cpp.h:224
bool IsNeedCalcSubThreadPredict()
Determines whether the prediction data needs calculating.
void DrawTV()
Draw the keyboard to the TV.
void CalcSubThreadFont()
Calculate font data.
void SetUserSoundObj(ISoundObj *soundObj)
bool InitLearnDic(void *dictionary)
bool AppearInputForm(const AppearArg &args)
Show an input form (keyboard with text area) with the given configuration.
const char16_t * GetInputFormString()
Get the string the user typed into the input form.
bool AppearKeyboard(const KeyboardArg &args)
Show a keyboard with the given configuration.
bool IsDecideOkButton(bool *outIsSelected)
Gets the current status of the OK button on the keyboard.
void SetSelectFrom(int)
@ FadeIn
The input form / keyboard is drawing the fade in animation.
@ Hidden
The input form / keyboard is completely hidden.
@ Visible
The input form / keyboard is done drawing the fade in animation and completely visible.
@ FadeOut
The input form / keyboard is drawing the fade out animation.
nn::swkbd::PasswordMode passwordMode
Which password inputting preset to use.
Definition swkbd_cpp.h:233
RegionType regionType
The swkbd region to use.
Definition swkbd_cpp.h:271
void Calc(const ControllerInfo &controllerInfo)
Respond to user inputs and calculate the state of input buffers and graphics.
const char16_t * initialText
Initial string to open the keyboard with.
Definition swkbd_cpp.h:227
void GetDrawStringInfo(DrawStringInfo *drawStringInfo)
void CalcSubThreadPredict()
Calculate word prediction data.
void SetReceiver(const ReceiverArg &receiver)
void SetEnableOkButton(bool enable)
Enables and disables the OK button on the keyboard.
bool showCopyPasteButtons
Whether or not to show a copy and a paste button.
Definition swkbd_cpp.h:240
bool drawInput0Cursor
Whether or not to draw a cursor. Exclusive to the inputform0 input form type.
Definition swkbd_cpp.h:236
ConfigArg configArg
Configuration for the keyboard itself.
Definition swkbd_cpp.h:215
FSClient * fsClient
An FSClient for swkbd to use while loading resources.
Definition swkbd_cpp.h:274
void SetUserControllerEventObj(IControllerEventObj *controllerEventObj)
uint32_t GetWorkMemorySize(uint32_t unk)
Get the required size for swkbd's work memory buffer.
void DrawDRC()
Draw the keyboard to the DRC.
KeyboardArg keyboardArg
Arguments for the virtual keyboard.
Definition swkbd_cpp.h:259
void * workMemory
A pointer to a work memory buffer; see GetWorkMemorySize.
Definition swkbd_cpp.h:269
bool higlightInitialText
Whether or not to highlight the initial string. Exclusive to the Default input form type.
Definition swkbd_cpp.h:238
void SetInputFormString(const char16_t *str)
Sets the text in the input form.
bool DisappearKeyboard()
Hide a previously shown keyboard.
bool IsDecideCancelButton(bool *outIsSelected)
Gets the current status of the Cancel button on the keyboard.
void GetKeyboardCondition(KeyboardCondition *keyboardCondition)
InputFormArg inputFormArg
Arguments for the input form (text area)
Definition swkbd_cpp.h:261
KPADStatus * kpad[4]
Wiimote and extension controller inputs, see KPADRead.
Definition swkbd_cpp.h:288
@ Fade
Hides the charater after a few seconds.
@ Hide
Hides the text.
@ Clear
Show clear text.
void MuteAllSound(bool muted)
Mutes or unmutes the sounds generated by the keyboard.
void Destroy()
Clean up and shut down the swkbd library.
@ Numpad
Numpad used for entering for example a DNS address.
@ Utf8
ascii, possibly used for passwords ?
@ Full
The one that fully allows utf-16LE(char16_t) charaters.
@ NNID
the one thats used for registering an nnid full alphabet, numbers, '_' and '-'
bool IsCoveredWithSubWindow()
State GetStateInputForm()
Get the current state of the input form.
void SetCursorPos(int pos)
Set the character at which the cursor is positioned.
void ConfirmUnfixAll()
LanguageType
If the LanguageType and RegionType are not compatible, the LanguageType will be set to English,...
Definition swkbd_cpp.h:49
@ TraditionalChinese
Must be used in combination with RegionType::Taiwan.
@ Portuguese
Must be used in combination with RegionType::USA or RegionType::Europe.
@ Italian
Must be used in combination with RegionType::Europe.
@ Dutch
Must be used in combination with RegionType::Europe.
@ English
Must be used in combination with RegionType::USA or RegionType::Europe.
@ German
Must be used in combination with RegionType::Europe.
@ French
Must be used in combination with RegionType::USA or RegionType::Europe.
@ Spanish
Must be used in combination with RegionType::USA or RegionType::Europe.
@ SimplifiedChinese
Must be used in combination with RegionType::China.
@ Korean
Must be used in combination with RegionType::Korea.
@ Russian
Must be used in combination with RegionType::Europe.
@ Japanese
Must be used in combination with RegionType::Japan.
int32_t maxTextLength
The maximum number of characters that can be entered, -1 for unlimited.
Definition swkbd_cpp.h:231
bool IsSelectCursorActive()
Determines whether the selection cursor is active.
bool IsNeedCalcSubThreadFont()
Determines whether the font data needs calculating.
bool IsKeyboardTarget(IEventReceiver *eventReceiver)
State GetStateKeyboard()
bool Create(const CreateArg &args)
Initialise the swkbd library and create the keyboard and input form.
void SetControllerRemo(ControllerType type)
ReceiverArg receiverArg
Definition swkbd_cpp.h:216
bool DisappearInputForm()
Hide a previously shown input form.
Arguments for the swkbd input form and keyboard.
Definition swkbd_cpp.h:257
Input and controller information for swkbd.
Definition swkbd_cpp.h:284
The arguments used to initialise swkbd and pass in its required resources.
Definition swkbd_cpp.h:267
Arguments for swkbd the input form (text area).
Definition swkbd_cpp.h:222
Arguments for the swkbd keyboard.
Definition swkbd_cpp.h:213
Definition ac_cpp.h:16
Configuration options for the virtual keyboard.
Definition swkbd_cpp.h:131
char16_t numpadCharLeft
The left side button exclusive to the numpad keyboard mode.
Definition swkbd_cpp.h:157
bool showWordSuggestions
Bool to either enable or disable word suggestions.
Definition swkbd_cpp.h:161
const char16_t * okString
Text that's displayed on the "OK" button.
Definition swkbd_cpp.h:155
ControllerType controllerType
Definition swkbd_cpp.h:147
uint32_t accessFlags
TODO: find all bit flags.
Definition swkbd_cpp.h:150
KeyboardMode keyboardMode
Definition swkbd_cpp.h:148
bool drawSysWiiPointer
Draws the system Wii remote pointer.
Definition swkbd_cpp.h:171
char16_t numpadCharRight
The right side button exclusive to the numpad keyboard mode.
Definition swkbd_cpp.h:159
bool disableNewLine
If true it'll disable the new Line character on the keyboard.
Definition swkbd_cpp.h:167
LanguageType languageType
The language to use for input.
Definition swkbd_cpp.h:146