1 /*---------------------------------------------------------------------------* 2 3 Copyright (C) 2010-2012 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 /** 15 * @file swkbd_AppearArg.h 16 * @brief Keyboard appearance arguments. 17 */ 18 //------------------------------------------------------------------------------ 19 #ifndef NN_SWKBD_APPEAR_ARG_H_ 20 #define NN_SWKBD_APPEAR_ARG_H_ 21 22 23 namespace nn { 24 //------------------------------------------------------------------------------ 25 namespace swkbd { 26 //------------------------------------------------------------------------------ 27 28 /** @ingroup keyboard_single 29 * Parameters for setting keyboard status. 30 */ 31 class ConfigArg 32 { 33 public: ConfigArg()34 explicit ConfigArg() 35 : mLangType( cLangType_Ja ) 36 , mControllerType( cControllerType_Drc ) 37 , mKeyboardMode( cKeyboardMode_Full ) 38 , mKeyboardFlag( cKeyboardFlag_All ) 39 , mFirstKeyboardCondition() 40 , mbFirstSelectCursor( false ) 41 , mOkString( NULL ) 42 , mNumericChar0( 0 /*L'\0'*/ ) 43 , mNumericChar1( 0 /*L'\0'*/ ) 44 , mbPredict( false ) 45 , mInvalidCharFlag( 0 ) 46 , mUserWordArray( NULL ) 47 , mNumUserWord( 0 ) 48 , mFrameRate( 1 ) 49 , mbDrawDpdCursor( false ) 50 , mFirstLockNo( -1 ) 51 { 52 for( s32 i = 0; i < cDicLangType_Max; ++i ) 53 { 54 mLearnDicBuf[i] = NULL; 55 mCustomizeDic[i] = NULL; 56 } 57 } 58 59 public: 60 LangType mLangType; ///< The language.<br/>You cannot specify a language that is not included in a region. The key map corresponding to the language you specify is used for the USB keyboard. 61 ControllerType mControllerType; ///< Controller type.<br/>Specify the controller type. If you want to display the keyboard on the TV, specify the Wii Remote. For display on the Wii U GamePad, specify the DRC. 62 KeyboardMode mKeyboardMode; ///< Keyboard mode.<br/>Set the keyboard mode. Specify the mode for either the full keyboard or one of the specialized keyboards to enter passwords, numbers, or NNIDs. (See <tt>nn::swkbd::KeyboardMode</tt>.) 63 u32 mKeyboardFlag; ///< Keyboard flag.<br/>Specify the bit flags representing the keyboard layouts you can switch between when using the full keyboard. (Specify a bitwise OR of <tt>nn::swkbd::KeyboardFlag</tt> values.) 64 KeyboardCondition mFirstKeyboardCondition; ///< The initial condition of the full keyboard (layout and tab numbers). 65 bool mbFirstSelectCursor; ///< Specifies whether to show the selection cursor at the start.<br/>Defaults to hidden if not set. 66 const char16* mOkString; ///< The string for the <b>OK</b> button.<br/>It can be a maximum of <tt>nn::swkbd::cOkStringLengthMax</tt> characters. Check for problems in the display of characters by visually checking the actual display. 67 char16 mNumericChar0; ///< The key label character shown to the left of the <tt>0</tt> key on the numerical keypad.<br/>If you are not using this key, specify <tt>0</tt>. 68 char16 mNumericChar1; ///< The key label character shown to the right of the <tt>0</tt> key on the numerical keyboard.<br/>If you are not using this key, specify <tt>0</tt>. 69 bool mbPredict; ///< Specifies whether to use the predictive text input feature.<br/>Specify <tt>true</tt> to use the feature. 70 u32 mInvalidCharFlag; ///< Flags for prohibited characters.<br/>Specify the bit flags (the <tt>nn::swkbd::InvalidChar</tt> values) for the group of characters (keys) you want to prohibit from being entered. 71 UserWord* mUserWordArray; ///< The array of user-registered words.<br/>Do not destroy until the keyboard is closed because the keyboard only remembers the pointer and does not keep a copy of the array. 72 s32 mNumUserWord; ///< The number of user-registered words.<br/>You can specify up to <tt>nn::swkbd::cUserWordMax</tt> words. 73 void* mLearnDicBuf[cDicLangType_Max]; ///< The learning dictionary data.<br/>Set for each language. Specify <tt>NULL</tt> if not making any particular specification. If nothing is set, the learning feature will not work when you confirm conversion candidates. 74 const void* mCustomizeDic[cDicLangType_Max]; ///< Customized dictionary data.<br/>Set for each language. Set the created dictionaries as "compressed and customized for a forward-lookup prefix match dictionaries" as defined by the iWnn predictive input library. Specify <tt>NULL</tt> if not making any particular specification. 75 s32 mFrameRate; /// < Sets the frame rate.<br/>Specify <tt>1</tt> for 60 fps, or <tt>2</tt> for 30 fps. Defaults to 60 fps if not set. 76 bool mbDrawDpdCursor; ///< Sets whether to draw the DPD pointer (the Wii Remote's direct pointing device).<br/>Specify <tt>false</tt> (the default) to show your own cursor. 77 s32 mFirstLockNo; ///< The initial state of the CAPS LOCK and SHIFT keys in password-entry mode.<br/>The setting is only enabled when <tt>nn::swkbd::cKeyboardMode_Password</tt> is specified for the mode. Specify <tt>0</tt> for CAPS LOCK and <tt>1</tt> for SHIFT. 78 }; 79 80 /** @ingroup keyboard_single 81 * Argument for receiving input from the keyboard. 82 */ 83 class ReceiverArg 84 { 85 public: ReceiverArg()86 explicit ReceiverArg() 87 : mEventReceiver( NULL ) 88 , mStringBuf( NULL ) 89 , mStringBufSize( 0 ) 90 , mFixedCharNumLimit( -1 ) 91 , mCursorPos( 0 ) 92 , mSelectFrom( -1 ) 93 { } 94 clear()95 void clear() 96 { 97 mEventReceiver = NULL; 98 mStringBuf = NULL; 99 mStringBufSize = 0; 100 mFixedCharNumLimit = -1; 101 mCursorPos = 0; 102 mSelectFrom = -1; 103 } 104 105 public: 106 IEventReceiver* mEventReceiver; ///< Class for receiving string change events. 107 char16* mStringBuf; ///< Text string buffer. 108 s32 mStringBufSize; ///< Text string buffer size. 109 s32 mFixedCharNumLimit; ///< Maximum number of characters in a fixed string. If the number of characters exceeds this value, the string is clipped regardless of the buffer size. This argument is required to implement a monospace input form. Specify <tt>-1</tt> if not necessary. 110 s32 mCursorPos; ///< Cursor position. 111 s32 mSelectFrom; ///< Selection start position. 112 }; 113 114 /** @ingroup keyboard_single 115 * Keyboard status configuration arguments. 116 */ 117 class KeyboardArg 118 { 119 public: KeyboardArg()120 explicit KeyboardArg() 121 : mConfigArg() 122 , mReceiverArg() 123 { } 124 public: 125 ConfigArg mConfigArg; ///< Keyboard status setting arguments. 126 ReceiverArg mReceiverArg; ///< Argument for receiving input from the keyboard. 127 }; 128 129 /** @ingroup basic_api 130 * Input form configuration arguments. 131 */ 132 class InputFormArg 133 { 134 public: InputFormArg()135 explicit InputFormArg() 136 : mInputFormType( cInputFormType_Proportional ) 137 , mCursorPos( -1 ) 138 , mFixedString( NULL ) 139 , mGuideString( NULL ) 140 , mTextMax( -1 ) 141 , mPasswordMode( cPasswordMode_Disable ) 142 , mSeparateFlag( 0 ) 143 , mbCursorValid( false ) 144 , mbSelectAllText( false ) 145 , mbCopyPaste( false ) 146 { } 147 public: 148 InputFormType mInputFormType; ///< Input form type.<br/>Specify either monospace mode or positional mode. 149 s32 mCursorPos; ///< The position of the text cursor.<br/>Specifying <tt>-1</tt> is like specifying the end. 150 const char16* mFixedString; ///< The default finalized string.<br/>Specify the string entered from the start in the input form. If a default value is not necessary, specify <tt>NULL</tt>. 151 const char16* mGuideString; ///< Specifies a string if a guide will be displayed.<br/>For example, a guide describing the purpose of the entries. You can specify up to <tt>nn::swkbd::cGuideStringLengthMax</tt> characters. 152 s32 mTextMax; ///< The maximum valid number of characters that can be input.<br/>If the mode is Proportional, "the number of characters entered"/"the maximum number of characters"is shown as a ratio in the lower right part of the input form. You can specify a value up to 9999. <br/>If the mode is Monospace, the limiting factor is the number of entry fields. You can specify a value up to 40. 153 PasswordMode mPasswordMode; ///< The mode for showing asterisks (***) when entering passwords.<br/>If not specified, the characters are shown as entered. 154 u32 mSeparateFlag; ///< The flag for the display position of the separator.<br/>Only enabled in Monospace mode. Sets the bits for the separation of the border around the monospace text. For example, set this value to <tt>0x00000088</tt> to add a 4, 4, 4 separation around a 12-digit friend code. 155 bool mbCursorValid; ///< The flag to display the cursor.<br/>Only enabled in Monospace mode. Specify <tt>true</tt> to show the text cursor. 156 bool mbSelectAllText; ///< The Select-All flag.<br/>Only enabled in Proportional mode. Specify <tt>true</tt> for all text to be selected by default. 157 bool mbCopyPaste; ///< The flag for the copy and paste feature.<br/>Only enabled in Proportional mode. Specify <tt>true</tt> to enable copy and paste. 158 }; 159 160 /** @ingroup basic_api 161 * Configuration arguments for the keyboard with the input form 162 */ 163 class AppearArg 164 { 165 public: AppearArg()166 explicit AppearArg() 167 : mKeyboardArg() 168 , mInputFormArg() 169 { } 170 171 /// Sets the language. The key map corresponding to the language you specify is used for the USB keyboard. setLangType(LangType lang)172 void setLangType( LangType lang ) 173 { 174 mKeyboardArg.mConfigArg.mLangType = lang; 175 } 176 177 /// Sets the type of controller that will operate the keyboard. If DRC is specified, the keyboard is displayed on the Wii U GamePad. If Wii Remote is specified, the keyboard is displayed on the TV setControllerType(ControllerType id)178 void setControllerType( ControllerType id ) 179 { 180 mKeyboardArg.mConfigArg.mControllerType = id; 181 } 182 183 /// Configures all the input form and keyboard settings suited for the specified use (the layout type). Settings like the keyboard mode and prohibited characters are overwritten, so we recommend calling this after configuring other settings. 184 void setLayout( LayoutType type, const char16* fixed_string = NULL, const char16* guide_string = NULL ) 185 { 186 if( type == nn::swkbd::cLayoutType_NNID ) 187 { 188 setKeyboardMode( cKeyboardMode_NNID ); 189 setInvalidChar( cInvalidCharFlag_NNID ); 190 setPredict( false ); 191 setInputForm( cInputFormType_Monospace 192 , fixed_string 193 , -1 194 , guide_string 195 , 16 196 , cPasswordMode_Disable 197 , 0x00000000 198 , true); 199 } 200 else if( type == nn::swkbd::cLayoutType_DownloadCode ) 201 { 202 setKeyboardMode( cKeyboardMode_NNID ); 203 setInvalidChar( cInvalidCharFlag_DownloadCode ); 204 setFirstLockNo(0/*CAPS LOCK*/); 205 setPredict( false ); 206 setInputForm( cInputFormType_Monospace 207 , fixed_string 208 , -1 209 , guide_string 210 , 16 211 , cPasswordMode_Disable 212 , 0x0000888 213 , true); 214 } 215 } 216 217 /// Sets the mode for the keyboard to use. In full keyboard mode, use the <tt>nn::swkbd::KeyboardFlag</tt> bit flags to specify the keyboard layouts that are available for use. 218 void setKeyboardMode( KeyboardMode mode, u32 flag = cKeyboardFlag_All ) 219 { 220 mKeyboardArg.mConfigArg.mKeyboardMode = mode; 221 mKeyboardArg.mConfigArg.mKeyboardFlag = flag; 222 } 223 224 /// Sets the initial condition of the full keyboard (layout and tab numbers). setFirstKeyboardCondition(const KeyboardCondition & condition)225 void setFirstKeyboardCondition( const KeyboardCondition& condition ) 226 { 227 mKeyboardArg.mConfigArg.mFirstKeyboardCondition = condition; 228 } 229 230 /// Sets whether to display a selection cursor from the beginning. Defaults to hidden if not set. setFirstCursor(bool visible)231 void setFirstCursor( bool visible ) 232 { 233 mKeyboardArg.mConfigArg.mbFirstSelectCursor = visible; 234 } 235 236 /// Sets the display label for the <b>OK</b> button in the bottom right of the keyboard. The maximum is <tt> nn::swkbd::cOkStringLengthMax</tt> characters. Check for problems in the display of characters by visually checking the actual display. setOkString(const char16 * ok_string)237 void setOkString( const char16* ok_string ) 238 { 239 mKeyboardArg.mConfigArg.mOkString = ok_string; 240 } 241 242 /// Sets whether to use the predictive text input feature. Specify <tt>true</tt> to use the feature. setPredict(bool b)243 void setPredict( bool b ) 244 { 245 mKeyboardArg.mConfigArg.mbPredict = b; 246 } 247 248 /// Sets the labels for the keys to the left and right of the 0 key on the numerical keyboard. setNumericChar(char16 c0,char16 c1)249 void setNumericChar( char16 c0, char16 c1 ) 250 { 251 mKeyboardArg.mConfigArg.mNumericChar0 = c0; 252 mKeyboardArg.mConfigArg.mNumericChar1 = c1; 253 } 254 255 /// Sets the flags for prohibited characters. Specify the bit flags (the <tt>nn::swkbd::InvalidChar</tt> values) for the group of characters (keys) you want to prohibit from being entered. setInvalidChar(u32 flag)256 void setInvalidChar( u32 flag ) 257 { 258 mKeyboardArg.mConfigArg.mInvalidCharFlag = flag; 259 } 260 261 /// Sets the array of user-registered words and the number of such words. Take care not to destroy the <tt>UserWord</tt> array that is passed to <span class="argument">user_word_array</span> while the keyboard is in use. setUserWord(UserWord * user_word_array,s32 num_user_word)262 void setUserWord( UserWord* user_word_array, s32 num_user_word ) 263 { 264 mKeyboardArg.mConfigArg.mUserWordArray = user_word_array; 265 mKeyboardArg.mConfigArg.mNumUserWord = num_user_word; 266 } 267 268 /// Sets the learning dictionary data for each language. If nothing is set, the learning feature will not work when you confirm conversion candidates. setLearnDicBuf(DicLangType type,void * buf)269 void setLearnDicBuf( DicLangType type, void* buf ) 270 { 271 mKeyboardArg.mConfigArg.mLearnDicBuf[type] = buf; 272 } 273 274 /// Sets the customized dictionaries. Set for each language. Set the created dictionaries as "compressed and customized for a forward-lookup prefix match dictionaries" as defined by the iWnn predictive input library. Specify <tt>NULL</tt> if not making any particular specification. setCustomizeDic(DicLangType type,const void * dic)275 void setCustomizeDic( DicLangType type, const void* dic ) 276 { 277 mKeyboardArg.mConfigArg.mCustomizeDic[type] = dic; 278 } 279 280 /// Sets the frame rate. Specify <tt>1</tt> for 60 fps or <tt>2</tt> for 30 fps. Defaults to 60 fps if not set. setFrameRate(s32 frame_rate)281 void setFrameRate( s32 frame_rate ) 282 { 283 mKeyboardArg.mConfigArg.mFrameRate = frame_rate; 284 } 285 286 /// Sets whether to draw the DPD pointer (the Wii Remote's direct pointing device). Specify <tt>false</tt> to show your own cursor. (Defaults to <tt>false</tt> if not set.) setDrawDpdCursor(bool draw_dpd)287 void setDrawDpdCursor( bool draw_dpd ) 288 { 289 mKeyboardArg.mConfigArg.mbDrawDpdCursor = draw_dpd; 290 } 291 292 /// Sets the initial state of the CAPS LOCK and SHIFT key in password-entry mode. The setting is only enabled when <tt>nn::swkbd::cKeyboardMode_Password</tt> is specified for the mode. Specify <tt>0</tt> in <span class="argument">lockNo</span> for CAPS LOCK, and <tt>1</tt> for SHIFT. setFirstLockNo(s32 lockNo)293 void setFirstLockNo( s32 lockNo ) 294 { 295 mKeyboardArg.mConfigArg.mFirstLockNo = lockNo; 296 } 297 298 /// Sets the state of the input form. 299 void setInputForm( InputFormType input_form_type 300 , const char16* fixed_string = NULL 301 , s32 cursor_pos = -1 302 , const char16* guide_string = NULL 303 , s32 text_max = -1 304 , PasswordMode mode = cPasswordMode_Disable 305 , u32 separate_flag = 0 306 , bool cursor_valid = false 307 , bool select_all_text_enable = false 308 , bool copy_paste_enable = false ) 309 { 310 mInputFormArg.mInputFormType = input_form_type; 311 mInputFormArg.mFixedString = fixed_string; 312 mInputFormArg.mCursorPos = cursor_pos; 313 mInputFormArg.mGuideString = guide_string; 314 mInputFormArg.mTextMax = text_max; 315 mInputFormArg.mPasswordMode = mode; 316 mInputFormArg.mSeparateFlag = separate_flag; 317 mInputFormArg.mbCursorValid = cursor_valid; 318 mInputFormArg.mbSelectAllText = select_all_text_enable; 319 mInputFormArg.mbCopyPaste = copy_paste_enable; 320 } 321 322 public: 323 KeyboardArg mKeyboardArg; 324 InputFormArg mInputFormArg; 325 }; 326 327 //------------------------------------------------------------------------------ 328 } // namespace swkbd 329 //------------------------------------------------------------------------------ 330 } // namespace nn 331 332 #endif /* NN_SWKBD_APPEAR_ARG_H_ */ 333 334