1 /*---------------------------------------------------------------------------*
2 
3 Copyright (C) Nintendo.  All rights reserved.
4 
5 These coded instructions, statements, and computer programs contain
6 proprietary information of Nintendo of America Inc. and/or Nintendo
7 Company Ltd., and are protected by Federal copyright law.  They may
8 not be disclosed to third parties or copied or duplicated in any form,
9 in whole or in part, without the prior written consent of Nintendo.
10 
11  *---------------------------------------------------------------------------*/
12 
13 //------------------------------------------------------------------------------
14 /** @file  swkbd_Types.h
15 *   @brief  Definitions for keyboard library constants.
16 */
17 //------------------------------------------------------------------------------
18 #ifndef NN_SWKBD_TYPES_H_
19 #define NN_SWKBD_TYPES_H_
20 
21 /**
22 @namespace  nn
23 The <tt>nn</tt> namespace.
24 
25 @namespace  nn::swkbd
26 The <tt>swkbd</tt> namespace.
27 */
28 
29 namespace nn {
30 //------------------------------------------------------------------------------
31 namespace swkbd {
32 //------------------------------------------------------------------------------
33 
34 /// Unfinalized strings are forcibly finalized if this value is exceeded.
35 //(iwnn library <tt>nj_lib.h</tt> <tt>NJ_MAX_USER_LEN</tt> 40 or less)
36 const s32 cUnfixedStringLengthMax = 24;
37 
38 /// The maximum number of characters that can be displayed when using a proportional input form.
39 const s32 cProportionalStringTextMax = 9999;
40 
41 /// The maximum finalized string length when using a proportional input form.
42 const s32 cProportionalStringLengthMax = 65000;
43 
44 /// The maximum finalized string length when using a monospaced input form.
45 const s32 cMonospaceStringLengthMax = 40;
46 
47 /// The maximum guide string length.
48 const s32 cGuideStringLengthMax = 256;
49 
50 /// The maximum length of a finalized string.
51 const s32 cOkStringLengthMax = 8;
52 
53 /// The maximum number of words that can be registered in the user dictionary.
54 const s32 cUserWordMax = 500;
55 
56 /// The number of entries that can be added to the learning dictionary. (The actual number of learning candidates that can be presented is <span class="argument">nn::swkbd::cLearnWordMax</span> - <tt>NJ_MAX_LEN</tt> = 945 words.)
57 const s32 cLearnWordMax = 1000;
58 
59 /// The buffer size of the learning dictionary.
60 const s32 cLearnDicSize = ( 80 + 42 * cLearnWordMax );
61 
62 
63 /** @defgroup enum  Enumerations
64 * @{
65 */
66 
67 
68 /**
69 * Types of layouts for different uses.
70 *
71 * They are used to specify the settings for the input form and the keyboard for the use.
72 */
73 enum LayoutType
74 {
75     cLayoutType_NNID            ///< Layout for entering NNIDs.
76     , cLayoutType_DownloadCode  ///< Layout for entering download codes.
77 };
78 
79 
80 /**
81 * Flags specifying features not to use.
82 *
83 * You can use this to decrease the size of memory passed by the <tt>nn::swkbd::Create</tt> function.
84 * Do not specify features that have been set not to use.
85 */
86 enum LoadOffFlag
87 {
88     cLoadOffFlag_Monospace          = 1 << 0    ///< Monospaced input form( <tt>nn::swkbd::cInputFormType_Monospace</tt>).
89         , cLoadOffFlag_Proportional = 1 << 1    ///< Proportional input form ( <tt>nn::swkbd::cInputFormType_Proportional</tt>).
90         , cLoadOffFlag_All          = cLoadOffFlag_Monospace
91                                   | cLoadOffFlag_Proportional ///< All.
92 };
93 
94 /**
95 * The controller type.
96 *
97 * Use this function when you specify a controller to operate the keyboard.
98 *  - If Wii Remote is specified, the keyboard displays on the TV.
99 *  - If DRC is specified, the keyboard displays on the Wii U GamePad.
100 */
101 enum ControllerType
102 {
103     cControllerType_Remo0   ///< Wii Remote 0.
104     , cControllerType_Remo1   ///< Wii Remote 1.
105     , cControllerType_Remo2   ///< Wii Remote 2.
106     , cControllerType_Remo3   ///< Wii Remote 3.
107     , cControllerType_Drc     ///< Wii U GamePad (DRC).
108     , cControllerType_Max
109 };
110 
111 /// Input form type.
112 enum InputFormType
113 {
114     cInputFormType_Monospace      ///< Fixed width input form.
115     , cInputFormType_Proportional ///< Proportional input form.
116     , cInputFormType_Max
117 };
118 
119 /**
120 * Keyboard layout types.
121 *
122 * The following values are valid for the different regions.
123 *
124 * - JP region
125 *   - nn::swkbd::cKeyboardType_QwertyJP
126 *   - nn::swkbd::cKeyboardType_50on
127 *   - nn::swkbd::cKeyboardType_CellPhone
128 *   - nn::swkbd::cKeyboardType_Hand
129 *   - nn::swkbd::cKeyboardType_SignJP
130 * - US region
131 *   - nn::swkbd::cKeyboardType_QwertyUS_ENG
132 *   - nn::swkbd::cKeyboardType_QwertyUS_FRA
133 *   - nn::swkbd::cKeyboardType_QwertyUS_SPA
134 *   - nn::swkbd::cKeyboardType_QwertyUS_POR
135 *   - nn::swkbd::cKeyboardType_SignLatin
136 *   - nn::swkbd::cKeyboardType_SignUS
137 * - EU region
138 *   - nn::swkbd::cKeyboardType_QwertyEU_ENG
139 *   - nn::swkbd::cKeyboardType_QwertyEU_FRA
140 *   - nn::swkbd::cKeyboardType_QwertyEU_DEU
141 *   - nn::swkbd::cKeyboardType_QwertyEU_ITA
142 *   - nn::swkbd::cKeyboardType_QwertyEU_SPA
143 *   - nn::swkbd::cKeyboardType_QwertyEU_NLD
144 *   - nn::swkbd::cKeyboardType_QwertyEU_POR
145 *   - nn::swkbd::cKeyboardType_QwertyEU_RUS
146 *   - nn::swkbd::cKeyboardType_SignLatin
147 *   - nn::swkbd::cKeyboardType_SignUS
148 */
149 enum KeyboardType
150 {
151     cKeyboardType_QwertyJP      ///< PC Keyboard (Japanese).
152     , cKeyboardType_QwertyUS_ENG  ///< PC Keyboard (US English).
153     , cKeyboardType_QwertyUS_FRA  ///< PC Keyboard (US French).
154     , cKeyboardType_QwertyUS_SPA  ///< PC Keyboard (US Spanish).
155     , cKeyboardType_QwertyUS_POR  ///< PC Keyboard (US Portuguese).
156     , cKeyboardType_QwertyEU_ENG  ///< PC Keyboard (EU English).
157     , cKeyboardType_QwertyEU_FRA  ///< PC Keyboard (EU French).
158     , cKeyboardType_QwertyEU_DEU  ///< PC Keyboard (EU German).
159     , cKeyboardType_QwertyEU_ITA  ///< PC Keyboard (EU Italian).
160     , cKeyboardType_QwertyEU_SPA  ///< PC Keyboard (EU Spanish).
161     , cKeyboardType_QwertyEU_NLD  ///< PC Keyboard (EU Dutch).
162     , cKeyboardType_QwertyEU_POR  ///< PC Keyboard (EU Portuguese).
163     , cKeyboardType_QwertyEU_RUS  ///< PC Keyboard (EU Russian).
164     , cKeyboardType_50on          ///< Japanese kana keyboard.
165     , cKeyboardType_CellPhone     ///< Japanese cell phone keyboard.
166     , cKeyboardType_Hand          ///< Japanese handwritten input keyboard.
167     , cKeyboardType_SignJP        ///< Japanese symbol keyboard.
168     , cKeyboardType_SignLatin     ///< Latin script keyboard.
169     , cKeyboardType_SignUS        ///< US/EU symbol keyboard.
170     , cKeyboardType_Max
171 };
172 
173 /**
174 * Keyboard modes.
175 *
176 * Use the keyboard with the appropriate layout by specifying the mode that corresponds to the content of the input.
177 *
178 * - Full keyboard mode.
179 * In this mode, all keyboards that can be specified for a particular region are available.
180 *   - If you want to limit the keyboard types, specify this mode together with <tt>nn::swkbd::KeyboardFlag</tt>.
181 *
182 * - Numeric keyboard mode.
183 *   - Enables use of the keyboard specially designed for the entry of numbers.
184 *
185 * - Password keyboard mode.
186 *   - Enables use of keyboards for password entry that only have keys for letters, numbers, and ASCII symbols.
187 */
188 enum KeyboardMode
189 {
190     cKeyboardMode_Full      ///< Full keyboard.
191     , cKeyboardMode_Numeric   ///< Numerals.
192     , cKeyboardMode_Password  ///< Keyboard for passwords.
193     , cKeyboardMode_NNID      ///< Keyboard for NNID (Nintendo Network Account).
194     , cKeyboardMode_Max
195 };
196 
197 /**
198 * Flags representing the layout to use for the full keyboard.
199 *
200 * These flags specify the keyboard layouts usable when the keyboard mode (<tt>nn::swkbd::KeybaordMode</tt>) is <tt> nn::swkbd::cKeyboardMode_Full</tt>.
201 *
202 * Each flag corresponds to a <tt>nn::swkbd::KeyboardType</tt>.
203 * Flags for layouts that are disabled for a particular region are ignored.
204 */
205 enum KeyboardFlag
206 {
207     cKeyboardFlag_QwertyJP           = 1 << cKeyboardType_QwertyJP       ///< PC Keyboard (Japanese).
208         , cKeyboardFlag_QwertyUS_ENG = 1 << cKeyboardType_QwertyUS_ENG   ///< PC Keyboard (US English).
209         , cKeyboardFlag_QwertyUS_FRA = 1 << cKeyboardType_QwertyUS_FRA   ///< PC Keyboard (US French).
210         , cKeyboardFlag_QwertyUS_SPA = 1 << cKeyboardType_QwertyUS_SPA   ///< PC Keyboard (US Spanish).
211         , cKeyboardFlag_QwertyUS_POR = 1 << cKeyboardType_QwertyUS_POR   ///< PC Keyboard (US Portuguese).
212         , cKeyboardFlag_QwertyEU_ENG = 1 << cKeyboardType_QwertyEU_ENG   ///< PC Keyboard (EU English).
213         , cKeyboardFlag_QwertyEU_FRA = 1 << cKeyboardType_QwertyEU_FRA   ///< PC Keyboard (EU French).
214         , cKeyboardFlag_QwertyEU_DEU = 1 << cKeyboardType_QwertyEU_DEU   ///< PC Keyboard (EU German).
215         , cKeyboardFlag_QwertyEU_ITA = 1 << cKeyboardType_QwertyEU_ITA   ///< PC Keyboard (EU Italian).
216         , cKeyboardFlag_QwertyEU_SPA = 1 << cKeyboardType_QwertyEU_SPA   ///< PC Keyboard (EU Spanish).
217         , cKeyboardFlag_QwertyEU_NLD = 1 << cKeyboardType_QwertyEU_NLD   ///< PC Keyboard (EU Dutch).
218         , cKeyboardFlag_QwertyEU_POR = 1 << cKeyboardType_QwertyEU_POR   ///< PC Keyboard (EU Portuguese).
219         , cKeyboardFlag_QwertyEU_RUS = 1 << cKeyboardType_QwertyEU_RUS   ///< PC Keyboard (EU Russian).
220         , cKeyboardFlag_50on         = 1 << cKeyboardType_50on           ///< Japanese kana keyboard.
221         , cKeyboardFlag_CellPhone    = 1 << cKeyboardType_CellPhone      ///< Japanese cell phone keyboard.
222         , cKeyboardFlag_Hand         = 1 << cKeyboardType_Hand           ///< Japanese handwritten input keyboard.
223         , cKeyboardFlag_SignJP       = 1 << cKeyboardType_SignJP         ///< Japanese symbol keyboard.
224         , cKeyboardFlag_SignLatin    = 1 << cKeyboardType_SignLatin      ///< Latin script keyboard.
225         , cKeyboardFlag_SignUS       = 1 << cKeyboardType_SignUS         ///< US/EU symbol keyboard.
226         , cKeyboardFlag_All          = cKeyboardFlag_QwertyJP
227                                    | cKeyboardFlag_QwertyUS_ENG
228                                    | cKeyboardFlag_QwertyUS_FRA
229                                    | cKeyboardFlag_QwertyUS_SPA
230                                    | cKeyboardFlag_QwertyUS_POR
231                                    | cKeyboardFlag_QwertyEU_ENG
232                                    | cKeyboardFlag_QwertyEU_FRA
233                                    | cKeyboardFlag_QwertyEU_DEU
234                                    | cKeyboardFlag_QwertyEU_ITA
235                                    | cKeyboardFlag_QwertyEU_SPA
236                                    | cKeyboardFlag_QwertyEU_NLD
237                                    | cKeyboardFlag_QwertyEU_POR
238                                    | cKeyboardFlag_QwertyEU_RUS
239                                    | cKeyboardFlag_50on
240                                    | cKeyboardFlag_CellPhone
241                                    | cKeyboardFlag_Hand
242                                    | cKeyboardFlag_SignJP
243                                    | cKeyboardFlag_SignLatin
244                                    | cKeyboardFlag_SignUS      ///< All.
245 };
246 
247 /// Prohibited characters. (The relevant keys are disabled so the characters cannot be entered using the keyboard.)
248 enum InvalidChar
249 {
250     cInvalidCharFlag_Linefeed            = 1 << 0    ///< Prohibit newlines.
251         , cInvalidCharFlag_Space         = 1 << 1    ///< Prohibit spaces.
252         , cInvalidCharFlag_AtMark        = 1 << 2    ///< Prohibit @ symbols.
253         , cInvalidCharFlag_Percent       = 1 << 3    ///< Prohibit percent symbols.
254         , cInvalidCharFlag_Slash         = 1 << 4    ///< Prohibit slashes.
255         , cInvalidCharFlag_BackSlash     = 1 << 5    ///< Prohibit backslashes.
256         , cInvalidCharFlag_Numeric       = 1 << 6    ///< Prohibit numerals.
257         , cInvalidCharFlag_Heart         = 1 << 7    ///< Prohibit heart symbols.
258         , cInvalidCharFlag_EuroMark      = 1 << 8    ///< Prohibit Euro symbols.
259         , cInvalidCharFlag_OutsideOfSJIS = 1 << 9    ///< Prohibit glyphs not in SJIS range.
260         , cInvalidCharFlag_DownloadCode  = 1 << 10   ///< Prohibit characters that are not used for entering download codes (also specify <tt>nn::swkbd::cKeyboardMode_NNID</tt>.)
261         , cInvalidCharFlag_NNID          = 1 << 11   ///< Prohibit characters that are not used for entering NNIDs (also specify <tt>nn::swkbd::cKeyboardMode_NNID</tt>.)
262 };
263 
264 /// Password masking modes.
265 enum PasswordMode
266 {
267     cPasswordMode_Disable     ///< Do not mask passwords.
268     , cPasswordMode_Immediate ///< Mask passwords immediately after input.
269     , cPasswordMode_1sec      ///< Mask passwords after waiting one second or when the next character is input.
270     , cPasswordMode_Max
271 };
272 
273 /// Direction of cursor movement.
274 enum CursorMove
275 {
276     cCursorMove_Left          /// Cursor moves to the left.
277     , cCursorMove_Right       /// Cursor moves to the right.
278     , cCursorMove_Up          /// Cursor moves upward.
279     , cCursorMove_Down        /// Cursor moves downward.
280     , cCursorMove_Max
281 };
282 
283 /// Region types.
284 enum RegionType
285 {
286     cRegionType_Jp            ///< Japan.
287     , cRegionType_Us          ///< North America.
288     , cRegionType_Eu          ///< Europe.
289     , cRegionType_Cn          ///< China.
290     , cRegionType_Kr          ///< Korea.
291     , cRegionType_Tw          ///< Taiwan.
292     , cRegionType_Max
293 };
294 
295 /// Language types.
296 enum LangType
297 {
298     cLangType_Ja              ///< Japanese language.
299     , cLangType_En            ///< English.
300     , cLangType_Fr            ///< French.
301     , cLangType_Ge            ///< German.
302     , cLangType_It            ///< Italian.
303     , cLangType_Sp            ///< Spanish.
304     , cLangType_Cn            ///< Chinese.
305     , cLangType_Kr            ///< Korean language.
306     , cLangType_Du            ///< Dutch.
307     , cLangType_Po            ///< Portuguese.
308     , cLangType_Ru            ///< Russian.
309     , cLangType_Tw            ///< Traditional Chinese.
310     , cLangType_Max
311 };
312 
313 /**
314 * Dictionary languages when using the predictive text input feature.
315 *
316 * Dictionaries corresponding to languages supported by the keyboard type are loaded.
317 *
318 * For the PC keyboard (EU Russian), either the Russian language dictionary or the English language dictionary is loaded, and you switch between them using the tabs.
319 *
320 * For other keyboards, the dictionary for a single corresponding language is loaded.
321 *
322 * Dictionaries are not loaded for keyboards like the symbol keyboard that cannot use the predictive text input feature.
323 */
324 enum DicLangType
325 {
326     cDicLangType_JP           ///< JP Japanese.
327     , cDicLangType_US_ENG     ///< US English (US).
328     , cDicLangType_US_FRA     ///< US French.
329     , cDicLangType_US_SPA     ///< US Spanish.
330     , cDicLangType_US_POR     ///< US Portuguese (Brazil).
331     , cDicLangType_EU_ENG     ///< EU English (Britain).
332     , cDicLangType_EU_FRA     ///< EU French.
333     , cDicLangType_EU_DEU     ///< EU German.
334     , cDicLangType_EU_SPA     ///< EU Spanish.
335     , cDicLangType_EU_ITA     ///< EU Italian.
336     , cDicLangType_EU_NLD     ///< EU Dutch.
337     , cDicLangType_EU_POR     ///< EU Portuguese.
338     , cDicLangType_EU_RUS     ///< EU Russian.
339     , cDicLangType_Max
340     ,
341 };
342 
343 /// Display states of the keyboard and the input form.
344 enum State
345 {
346     cState_Blank          ///< Hidden.
347     , cState_Appear       ///< Appearing.
348     , cState_Display      ///< Displayed.
349     , cState_Disappear    ///< Hiding.
350     , cState_Max
351 };
352 
353 /** @} */
354 
355 /** @ingroup  keyboard_single
356 * Interface for receiving events from the keyboard.
357 */
358 class IEventReceiver
359 {
360 public:
361 /**
362 * Information about changes to fixed strings.
363 */
364     class DirtyInfo
365     {
366     public:
DirtyInfo()367         DirtyInfo()
368             : mDirtyFrom( -1 ), mDirtyTo( -1 )
369         { }
370     public:
371         s32 mDirtyFrom;     ///< Start position of the change to the finalized string.
372         s32 mDirtyTo;       ///< End position of the change to the finalized string.
373     };
374     /// Called when a string has been changed.
375     virtual void onDirtyString( const DirtyInfo& info ) = 0;
376 
377     /// Called when the cursor has been moved.
378     virtual void onCursorMove( CursorMove type ) = 0;
379 };
380 
381 /** @ingroup  keyboard_single
382 * Information about unfixed strings.
383 */
384 class DrawStringInfo
385 {
386 public:
DrawStringInfo()387     DrawStringInfo()
388         : mUnfixFrom( -1 ), mUnfixTo( -1 )
389           , mKanaFrom( -1 ), mKanaTo( -1 )
390           , mDeadKeyPos( -1 ), mCellPhonePos( -1 )
391           , mbUnfixJP( true )
392     { }
393 public:
394     s32  mUnfixFrom;     ///< Unfixed string starting position.
395     s32  mUnfixTo;       ///< Unfixed string ending position.
396     s32  mKanaFrom;      ///< Starting position of an unfinalized kana string.
397     s32  mKanaTo;        ///< Ending position of an unfinalized kana string.
398     s32  mDeadKeyPos;    ///< Unfinalized dead key position.
399     s32  mCellPhonePos;  ///< Cell phone rotation position.
400     bool mbUnfixJP;      ///< Indicates whether the unfixed string is a Japanese or European language string.
401 };
402 
403 /** @ingroup  basic_api
404 * Condition of the keyboard layout.
405 *
406 * Indicates the type of layout and where the tabs are located on the keyboard.
407 *
408 * Tab numbers are defined as follows. Where <tt>-1</tt> is specified, read that as the default tab number for each keyboard.
409 *
410 * PC keyboard (Japanese):<br/>
411 *  - 0: Letters
412 *  - 1: Numbers
413 *  - 2: ASCII symbols
414 *  - 3: Roman alphabet
415 *
416 * PC keyboard (Russian):<br/>
417 *  - 0: Letters
418 *  - 1: Numbers
419 *  - 2: ASCII symbols
420 *  - 3: Cyrillic characters
421 *
422 * PC keyboards (other than Japanese or Russian):<br/>
423 *  - 0: Letters
424 *  - 1: Numbers
425 *  - 2: ASCII symbols
426 *
427 * For Japanese kana keyboards:<br/>
428 *  - 0: Hiragana
429 *  - 1: Katakana
430 *  - 2: Uppercase letters
431 *  - 3: Lowercase letters
432 *  - 4: ASCII symbols
433 *
434 * Japanese phone keyboard:<br/>
435 *  - 0: Hiragana
436 *  - 1: Katakana
437 *  - 2: Letters
438 *  - 3: Numbers
439 *
440 * Japanese handwritten input keyboard:<br/>
441 *  - Tab numbers are not used
442 *
443 * For Japanese symbol keyboards, Latin script keyboards, and US/EU symbol keyboards:<br/>
444 *  - Tab numbers represent display page numbers in the symbol list.
445 */
446 class KeyboardCondition
447 {
448 public:
KeyboardCondition()449     KeyboardCondition() : mKeyboardType( cKeyboardType_Max ), mTabNo( -1 ) { }
450 public:
451     KeyboardType mKeyboardType;  ///< Keyboard type.
452     s32          mTabNo;         ///< Tab number.
453 };
454 
455 /** @ingroup  basic_api
456 *   Structure holding words registered in the user dictionary.
457 *
458 *  - For the Japanese language, specify the writing and the reading of the conversion candidate words you want to present.
459 *    - For example, for the word "Wii U," specify both its writing ("Wii U") and its reading ("うぃーゆー").
460 *  - Even when a user enters katakana, it is converted into hiragana when the dictionary is queried, so use hiragana to register the readings for words.
461 *
462 */
463 struct UserWord
464 {
465     char16 mReading[cUnfixedStringLengthMax + 1]; ///< The pronunciation (reading). You must use a terminating null character with the strings.
466     char16 mWord[cUnfixedStringLengthMax + 1];    ///< The term. You must use a terminating null character with the strings.
467 };
468 
469 //------------------------------------------------------------------------------
470 }   // namespace swkbd
471     //------------------------------------------------------------------------------
472 } // namespace nn
473 
474 #endif  /* NN_SWKBD_TYPES_H_ */
475