wut  v1.7.0
Wii U Toolchain
swkbd_cpp.h
Go to the documentation of this file.
1 #pragma once
2 #include <wut.h>
3 #include <coreinit/filesystem.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 
19 namespace nn
20 {
21 
35 namespace swkbd
36 {
37 
38 enum class ControllerType
39 {
40  WiiRemote0 = 0,
41  WiiRemote1 = 1,
42  WiiRemote2 = 2,
43  WiiRemote3 = 3,
44  DrcGamepad = 4,
45 };
46 
48 enum 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,
73  TraditionalChinese = 11,
74  Invalid = 12,
75 };
76 
77 enum class RegionType
78 {
79  Japan = 0,
80  USA = 1,
81  Europe = 2,
82  China = 3,
83  Korea = 4,
84  Taiwan = 5,
85 };
86 
87 enum class State
88 {
90  Hidden = 0,
92  FadeIn = 1,
94  Visible = 2,
96  FadeOut = 3,
97 };
98 
99 enum class InputFormType
100 {
102  InputForm0 = 0,
104  Default = 1,
105 };
106 
107 enum class KeyboardMode
108 {
110  Full = 0,
112  Numpad = 1,
114  Utf8 = 2,
116  NNID = 3,
117 };
118 
119 enum class PasswordMode
120 {
122  Clear = 0,
124  Hide = 1,
126  Fade = 2,
127 };
128 
130 struct ConfigArg
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;
153  bool unk_0x18;
155  const char16_t *okString;
157  char16_t numpadCharLeft;
159  char16_t numpadCharRight;
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 };
174 WUT_CHECK_OFFSET(ConfigArg, 0x00, languageType);
175 WUT_CHECK_OFFSET(ConfigArg, 0x04, controllerType);
176 WUT_CHECK_OFFSET(ConfigArg, 0x08, keyboardMode);
177 WUT_CHECK_OFFSET(ConfigArg, 0x0C, accessFlags);
178 WUT_CHECK_OFFSET(ConfigArg, 0x10, unk_0x10);
179 WUT_CHECK_OFFSET(ConfigArg, 0x14, unk_0x14);
180 WUT_CHECK_OFFSET(ConfigArg, 0x18, unk_0x18);
181 WUT_CHECK_OFFSET(ConfigArg, 0x1C, okString);
182 WUT_CHECK_OFFSET(ConfigArg, 0x20, numpadCharLeft);
183 WUT_CHECK_OFFSET(ConfigArg, 0x22, numpadCharRight);
184 WUT_CHECK_OFFSET(ConfigArg, 0x24, showWordSuggestions);
185 WUT_CHECK_OFFSET(ConfigArg, 0x28, unk_0x28);
186 WUT_CHECK_OFFSET(ConfigArg, 0x29, unk_0x29);
187 WUT_CHECK_OFFSET(ConfigArg, 0x2A, unk_0x2A);
188 WUT_CHECK_OFFSET(ConfigArg, 0x2B, disableNewLine);
189 WUT_CHECK_OFFSET(ConfigArg, 0x9C, unk_0x9C);
190 WUT_CHECK_OFFSET(ConfigArg, 0xA0, drawSysWiiPointer);
191 WUT_CHECK_OFFSET(ConfigArg, 0xA4, unk_0xA4);
192 WUT_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 };
203 WUT_CHECK_OFFSET(ReceiverArg, 0x00, unk_0x00);
204 WUT_CHECK_OFFSET(ReceiverArg, 0x04, unk_0x04);
205 WUT_CHECK_OFFSET(ReceiverArg, 0x08, unk_0x08);
206 WUT_CHECK_OFFSET(ReceiverArg, 0x0C, unk_0x0C);
207 WUT_CHECK_OFFSET(ReceiverArg, 0x10, unk_0x10);
208 WUT_CHECK_OFFSET(ReceiverArg, 0x14, unk_0x14);
209 WUT_CHECK_SIZE(ReceiverArg, 0x18);
210 
213 {
217 };
218 WUT_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;
238  bool higlightInitialText = false;
240  bool showCopyPasteButtons = false;
241  WUT_PADDING_BYTES(1);
242 };
243 WUT_CHECK_OFFSET(InputFormArg, 0x00, type);
244 WUT_CHECK_OFFSET(InputFormArg, 0x04, unk_0x04);
245 WUT_CHECK_OFFSET(InputFormArg, 0x08, initialText);
246 WUT_CHECK_OFFSET(InputFormArg, 0x0C, hintText);
247 WUT_CHECK_OFFSET(InputFormArg, 0x10, maxTextLength);
248 WUT_CHECK_OFFSET(InputFormArg, 0x14, passwordMode);
249 WUT_CHECK_OFFSET(InputFormArg, 0x18, unk_0x18);
250 WUT_CHECK_OFFSET(InputFormArg, 0x1C, drawInput0Cursor);
251 WUT_CHECK_OFFSET(InputFormArg, 0x1D, higlightInitialText);
252 WUT_CHECK_OFFSET(InputFormArg, 0x1E, showCopyPasteButtons);
253 WUT_CHECK_SIZE(InputFormArg, 0x20);
254 
256 struct AppearArg
257 {
262 };
263 WUT_CHECK_SIZE(AppearArg, 0xE0);
264 
266 struct CreateArg
267 {
269  void *workMemory = nullptr;
272  uint32_t unk_0x08 = 0;
274  FSClient *fsClient = nullptr;
275 };
276 WUT_CHECK_OFFSET(CreateArg, 0x00, workMemory);
277 WUT_CHECK_OFFSET(CreateArg, 0x04, regionType);
278 WUT_CHECK_OFFSET(CreateArg, 0x08, unk_0x08);
279 WUT_CHECK_OFFSET(CreateArg, 0x0C, fsClient);
280 WUT_CHECK_SIZE(CreateArg, 0x10);
281 
284 {
286  VPADStatus *vpad = nullptr;
288  KPADStatus *kpad[4] = { nullptr, nullptr, nullptr, nullptr };
289 };
290 WUT_CHECK_OFFSET(ControllerInfo, 0x00, vpad);
291 WUT_CHECK_OFFSET(ControllerInfo, 0x04, kpad);
292 WUT_CHECK_SIZE(ControllerInfo, 0x14);
293 
295 {
297  {
298  memset(this, 0, sizeof(*this));
299  }
300 
301  WUT_UNKNOWN_BYTES(0x1C);
302 };
303 WUT_CHECK_SIZE(DrawStringInfo, 0x1C);
304 
306 {
308  uint32_t unk_0x00 = 0;
310  uint32_t unk_0x04 = 0;
311 };
312 WUT_CHECK_OFFSET(KeyboardCondition, 0x00, unk_0x00);
313 WUT_CHECK_OFFSET(KeyboardCondition, 0x04, unk_0x04);
314 WUT_CHECK_SIZE(KeyboardCondition, 0x8);
315 
316 struct IEventReceiver;
317 struct IControllerEventObj;
318 struct ISoundObj;
319 
336 bool
338 
354 bool
356 
365 void
367 
376 void
378 
392 void
393 Calc(const ControllerInfo &controllerInfo);
394 
395 void
397 
413 bool
414 Create(const CreateArg &args);
415 
427 void
429 
440 bool
442 
452 bool
454 
460 void
462 
468 void
470 
471 void
473 
483 const char16_t *
485 
486 void
488 
495 State
497 
498 State
500 
514 uint32_t
515 GetWorkMemorySize(uint32_t unk);
516 
517 void
519 
520 bool
521 InitLearnDic(void *dictionary);
522 
523 bool
525 
539 bool
540 IsDecideCancelButton(bool *outIsSelected);
541 
555 bool
556 IsDecideOkButton(bool *outIsSelected);
557 
558 bool
559 IsKeyboardTarget(IEventReceiver *eventReceiver);
560 
571 bool
573 
584 bool
586 
593 bool
595 
603 void
604 MuteAllSound(bool muted);
605 
606 void
608 
621 void
622 SetCursorPos(int pos);
623 
631 void
632 SetEnableOkButton(bool enable);
633 
643 void
644 SetInputFormString(const char16_t *str);
645 
646 void
647 SetReceiver(const ReceiverArg &receiver);
648 
649 void
651 
652 void
653 SetUserControllerEventObj(IControllerEventObj *controllerEventObj);
654 
655 void
656 SetUserSoundObj(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:76
void GetKeyboardCondition(KeyboardCondition *keyboardCondition)
VPADStatus * vpad
DRC input information, see VPADRead.
Definition: swkbd_cpp.h:286
void DrawDRC()
Draw the keyboard to the DRC.
@ 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
State GetStateKeyboard()
InputFormType type
The type of input form.
Definition: swkbd_cpp.h:224
void SetUserControllerEventObj(IControllerEventObj *controllerEventObj)
bool DisappearInputForm()
Hide a previously shown input form.
bool InitLearnDic(void *dictionary)
void CalcSubThreadPredict()
Calculate word prediction data.
void GetDrawStringInfo(DrawStringInfo *drawStringInfo)
void SetUserSoundObj(ISoundObj *soundObj)
bool IsDecideOkButton(bool *outIsSelected)
Gets the current status of the OK button on the keyboard.
void MuteAllSound(bool muted)
Mutes or unmutes the sounds generated by the keyboard.
bool IsCoveredWithSubWindow()
void InactivateSelectCursor()
bool IsSelectCursorActive()
Determines whether the selection cursor is active.
@ 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
bool IsNeedCalcSubThreadFont()
Determines whether the font data needs calculating.
const char16_t * initialText
Initial string to open the keyboard with.
Definition: swkbd_cpp.h:227
void SetCursorPos(int pos)
Set the character at which the cursor is positioned.
bool showCopyPasteButtons
Whether or not to show a copy and a paste button.
Definition: swkbd_cpp.h:240
bool AppearKeyboard(const KeyboardArg &args)
Show a keyboard with the given configuration.
void SetInputFormString(const char16_t *str)
Sets the text in the input form.
ControllerType
Definition: swkbd_cpp.h:39
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
bool Create(const CreateArg &args)
Initialise the swkbd library and create the keyboard and input form.
KeyboardArg keyboardArg
Arguments for the virtual keyboard.
Definition: swkbd_cpp.h:259
void SetControllerRemo(ControllerType type)
State GetStateInputForm()
Get the current state of the input form.
bool IsKeyboardTarget(IEventReceiver *eventReceiver)
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
bool AppearInputForm(const AppearArg &args)
Show an input form (keyboard with text area) with the given configuration.
void CalcSubThreadFont()
Calculate font data.
void SetSelectFrom(int)
bool DisappearKeyboard()
Hide a previously shown keyboard.
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 SetEnableOkButton(bool enable)
Enables and disables the OK button on the keyboard.
@ 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 '-'
void SetReceiver(const ReceiverArg &receiver)
void DrawTV()
Draw the keyboard to the TV.
void Calc(const ControllerInfo &controllerInfo)
Respond to user inputs and calculate the state of input buffers and graphics.
void ConfirmUnfixAll()
void Destroy()
Clean up and shut down the swkbd library.
uint32_t GetWorkMemorySize(uint32_t unk)
Get the required size for swkbd's work memory buffer.
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 IsDecideCancelButton(bool *outIsSelected)
Gets the current status of the Cancel button on the keyboard.
const char16_t * GetInputFormString()
Get the string the user typed into the input form.
bool IsNeedCalcSubThreadPredict()
Determines whether the prediction data needs calculating.
ReceiverArg receiverArg
Definition: swkbd_cpp.h:216
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:15
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