wut  1.0.0-beta8
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  Unknown0 = 0,
41 };
42 
43 enum class LanguageType
44 {
45  Japanese = 0,
46  English = 1,
47 };
48 
49 enum class RegionType
50 {
51  Japan = 0,
52  USA = 1,
53  Europe = 2,
54 };
55 
56 enum class State
57 {
58  Unknown0 = 0,
59 };
60 
62 struct ConfigArg
63 {
65  {
66  memset(this, 0, sizeof(*this));
68  unk_0x04 = 4;
69  unk_0x0C = 0x7FFFF;
70  unk_0x10 = 19;
71  unk_0x14 = -1;
72  unk_0x9C = 1;
73  unk_0xA4 = -1;
74  }
75 
78  uint32_t unk_0x04;
79  uint32_t unk_0x08;
80  uint32_t unk_0x0C;
81  uint32_t unk_0x10;
82  int32_t unk_0x14;
83  WUT_UNKNOWN_BYTES(0x9C - 0x18);
84  uint32_t unk_0x9C;
85  WUT_UNKNOWN_BYTES(4);
86  int32_t unk_0xA4;
87 };
88 WUT_CHECK_OFFSET(ConfigArg, 0x00, languageType);
89 WUT_CHECK_OFFSET(ConfigArg, 0x04, unk_0x04);
90 WUT_CHECK_OFFSET(ConfigArg, 0x08, unk_0x08);
91 WUT_CHECK_OFFSET(ConfigArg, 0x0C, unk_0x0C);
92 WUT_CHECK_OFFSET(ConfigArg, 0x10, unk_0x10);
93 WUT_CHECK_OFFSET(ConfigArg, 0x14, unk_0x14);
94 WUT_CHECK_OFFSET(ConfigArg, 0x9C, unk_0x9C);
95 WUT_CHECK_OFFSET(ConfigArg, 0xA4, unk_0xA4);
96 WUT_CHECK_SIZE(ConfigArg, 0xA8);
97 
99 {
100  uint32_t unk_0x00 = 0;
101  uint32_t unk_0x04 = 0;
102  uint32_t unk_0x08 = 0;
103  int32_t unk_0x0C = -1;
104  uint32_t unk_0x10 = 0;
105  int32_t unk_0x14 = -1;
106 };
107 WUT_CHECK_OFFSET(ReceiverArg, 0x00, unk_0x00);
108 WUT_CHECK_OFFSET(ReceiverArg, 0x04, unk_0x04);
109 WUT_CHECK_OFFSET(ReceiverArg, 0x08, unk_0x08);
110 WUT_CHECK_OFFSET(ReceiverArg, 0x0C, unk_0x0C);
111 WUT_CHECK_OFFSET(ReceiverArg, 0x10, unk_0x10);
112 WUT_CHECK_OFFSET(ReceiverArg, 0x14, unk_0x14);
113 WUT_CHECK_SIZE(ReceiverArg, 0x18);
114 
117 {
121 };
122 WUT_CHECK_SIZE(KeyboardArg, 0xC0);
123 
126 {
127  uint32_t unk_0x00 = 1;
128  int32_t unk_0x04 = -1;
129  uint32_t unk_0x08 = 0;
130  uint32_t unk_0x0C = 0;
132  int32_t maxTextLength = -1;
133  uint32_t unk_0x14 = 0;
134  uint32_t unk_0x18 = 0;
135  bool unk_0x1C = false;
136  bool unk_0x1D = false;
137  bool unk_0x1E = false;
138  WUT_PADDING_BYTES(1);
139 };
140 WUT_CHECK_OFFSET(InputFormArg, 0x00, unk_0x00);
141 WUT_CHECK_OFFSET(InputFormArg, 0x04, unk_0x04);
142 WUT_CHECK_OFFSET(InputFormArg, 0x08, unk_0x08);
143 WUT_CHECK_OFFSET(InputFormArg, 0x0C, unk_0x0C);
144 WUT_CHECK_OFFSET(InputFormArg, 0x10, maxTextLength);
145 WUT_CHECK_OFFSET(InputFormArg, 0x14, unk_0x14);
146 WUT_CHECK_OFFSET(InputFormArg, 0x18, unk_0x18);
147 WUT_CHECK_OFFSET(InputFormArg, 0x1C, unk_0x1C);
148 WUT_CHECK_OFFSET(InputFormArg, 0x1D, unk_0x1D);
149 WUT_CHECK_OFFSET(InputFormArg, 0x1E, unk_0x1E);
150 WUT_CHECK_SIZE(InputFormArg, 0x20);
151 
153 struct AppearArg
154 {
159 };
160 WUT_CHECK_SIZE(AppearArg, 0xE0);
161 
163 struct CreateArg
164 {
166  void *workMemory = nullptr;
169  uint32_t unk_0x08 = 0;
171  FSClient *fsClient = nullptr;
172 };
173 WUT_CHECK_OFFSET(CreateArg, 0x00, workMemory);
174 WUT_CHECK_OFFSET(CreateArg, 0x04, regionType);
175 WUT_CHECK_OFFSET(CreateArg, 0x08, unk_0x08);
176 WUT_CHECK_OFFSET(CreateArg, 0x0C, fsClient);
177 WUT_CHECK_SIZE(CreateArg, 0x10);
178 
181 {
183  VPADStatus *vpad = nullptr;
185  KPADStatus *kpad[4] = { nullptr, nullptr, nullptr, nullptr };
186 };
187 WUT_CHECK_OFFSET(ControllerInfo, 0x00, vpad);
188 WUT_CHECK_OFFSET(ControllerInfo, 0x04, kpad);
189 WUT_CHECK_SIZE(ControllerInfo, 0x14);
190 
192 {
194  {
195  memset(this, 0, sizeof(*this));
196  }
197 
198  WUT_UNKNOWN_BYTES(0x1C);
199 };
200 WUT_CHECK_SIZE(DrawStringInfo, 0x1C);
201 
203 {
204  uint32_t unk_0x00 = 0;
205  uint32_t unk_0x04 = 0;
206 };
207 WUT_CHECK_OFFSET(KeyboardCondition, 0x00, unk_0x00);
208 WUT_CHECK_OFFSET(KeyboardCondition, 0x04, unk_0x04);
209 WUT_CHECK_SIZE(KeyboardCondition, 0x8);
210 
211 struct IEventReceiver;
212 struct IControllerEventObj;
213 struct ISoundObj;
214 
231 bool
232 AppearInputForm(const AppearArg& args);
233 
249 bool
250 AppearKeyboard(const KeyboardArg& args);
251 
260 void
262 
271 void
273 
287 void
288 Calc(const ControllerInfo &controllerInfo);
289 
290 void
292 
308 bool
309 Create(const CreateArg &args);
310 
322 void
323 Destroy();
324 
335 bool
337 
347 bool
349 
355 void
356 DrawDRC();
357 
363 void
364 DrawTV();
365 
366 void
367 GetDrawStringInfo(DrawStringInfo *drawStringInfo);
368 
378 const char16_t *
380 
381 void
382 GetKeyboardCondition(KeyboardCondition *keyboardCondition);
383 
384 State
386 
387 State
389 
403 uint32_t
404 GetWorkMemorySize(uint32_t unk);
405 
406 void
408 
409 bool
410 InitLearnDic(void *dictionary);
411 
412 bool
414 
428 bool
429 IsDecideCancelButton(bool *outIsSelected);
430 
444 bool
445 IsDecideOkButton(bool *outIsSelected);
446 
447 bool
448 IsKeyboardTarget(IEventReceiver *eventReceiver);
449 
460 bool
462 
473 bool
475 
482 bool
484 
491 void
492 MuteAllSound(bool muted);
493 
494 void
496 
509 void
510 SetCursorPos(int pos);
511 
519 void
520 SetEnableOkButton(bool enable);
521 
531 void
532 SetInputFormString(const char16_t *str);
533 
534 void
535 SetReceiver(const ReceiverArg &receiver);
536 
537 void
538 SetSelectFrom(int);
539 
540 void
541 SetUserControllerEventObj(IControllerEventObj *controllerEventObj);
542 
543 void
544 SetUserSoundObj(ISoundObj *soundObj);
545 
546 } // namespace swkbd
547 } // namespace nn
548 
549 #endif // ifdef __cplusplus
550 
bool IsNeedCalcSubThreadFont()
Determines whether the font data needs calculating.
void DrawTV()
Draw the keyboard to the TV.
bool IsNeedCalcSubThreadPredict()
Determines whether the prediction data needs calculating.
Arguments for swkbd the input form (text area).
Definition: swkbd_cpp.h:125
bool InitLearnDic(void *dictionary)
void SetCursorPos(int pos)
Set the character at which the cursor is positioned.
ConfigArg configArg
Configuration for the keyboard itself.
Definition: swkbd_cpp.h:119
Input and controller information for swkbd.
Definition: swkbd_cpp.h:180
LanguageType languageType
The language to use for input.
Definition: swkbd_cpp.h:77
const char16_t * GetInputFormString()
Get the string the user typed into the input form.
Definition: ac_cpp.h:14
RegionType regionType
The swkbd region to use.
Definition: swkbd_cpp.h:168
void SetReceiver(const ReceiverArg &receiver)
bool Create(const CreateArg &args)
Initialise the swkbd library and create the keyboard and input form.
int32_t maxTextLength
The maximum number of characters that can be entered, -1 for unlimited.
Definition: swkbd_cpp.h:132
void CalcSubThreadFont()
Calculate font data.
bool AppearInputForm(const AppearArg &args)
Show an input form (keyboard with text area) with the given configuration.
InputFormArg inputFormArg
Arguments for the input form (text area)
Definition: swkbd_cpp.h:158
bool DisappearKeyboard()
Hide a previously shown keyboard.
void ConfirmUnfixAll()
bool DisappearInputForm()
Hide a previously shown input form.
bool IsDecideCancelButton(bool *outIsSelected)
Gets the current status of the Cancel button on the keyboard.
uint32_t GetWorkMemorySize(uint32_t unk)
Get the required size for swkbd's work memory buffer.
ControllerType
Definition: swkbd_cpp.h:38
Arguments for the swkbd input form and keyboard.
Definition: swkbd_cpp.h:153
void SetSelectFrom(int)
void Calc(const ControllerInfo &controllerInfo)
Respond to user inputs and calculate the state of input buffers and graphics.
void CalcSubThreadPredict()
Calculate word prediction data.
void DrawDRC()
Draw the keyboard to the DRC.
KPADStatus * kpad[4]
Wiimote and extension controller inputs, see KPADRead.
Definition: swkbd_cpp.h:185
void SetEnableOkButton(bool enable)
Enables and disables the OK button on the keyboard.
bool IsSelectCursorActive()
Determines whether the selection cursor is active.
bool IsCoveredWithSubWindow()
void * workMemory
A pointer to a work memory buffer; see GetWorkMemorySize.
Definition: swkbd_cpp.h:166
The arguments used to initialise swkbd and pass in its required resources.
Definition: swkbd_cpp.h:163
Configuration options for the virtual keyboard.
Definition: swkbd_cpp.h:62
FSClient * fsClient
An FSClient for swkbd to use while loading resources.
Definition: swkbd_cpp.h:171
void GetDrawStringInfo(DrawStringInfo *drawStringInfo)
bool IsKeyboardTarget(IEventReceiver *eventReceiver)
void SetControllerRemo(ControllerType type)
State GetStateInputForm()
bool AppearKeyboard(const KeyboardArg &args)
Show a keyboard with the given configuration.
VPADStatus * vpad
DRC input information, see VPADRead.
Definition: swkbd_cpp.h:183
void InactivateSelectCursor()
void SetUserControllerEventObj(IControllerEventObj *controllerEventObj)
void Destroy()
Clean up and shut down the swkbd library.
State GetStateKeyboard()
Arguments for the swkbd keyboard.
Definition: swkbd_cpp.h:116
void GetKeyboardCondition(KeyboardCondition *keyboardCondition)
void SetUserSoundObj(ISoundObj *soundObj)
void MuteAllSound(bool muted)
Mutes or unmutes the sounds generated by the keyboard.
KeyboardArg keyboardArg
Arguments for the virtual keyboard.
Definition: swkbd_cpp.h:156
void SetInputFormString(const char16_t *str)
Sets the text in the input form.
bool IsDecideOkButton(bool *outIsSelected)
Gets the current status of the OK button on the keyboard.
ReceiverArg receiverArg
Definition: swkbd_cpp.h:120