1 /*---------------------------------------------------------------------------*
2 Project: Horizon
3 File: cfg_UserInfo.h
4 
5 Copyright (C) Nintendo.  All rights reserved.
6 
7 These coded instructions, statements, and computer programs contain
8 proprietary information of Nintendo of America Inc. and/or Nintendo
9 Company Ltd., and are protected by Federal copyright law.  They may
10 not be disclosed to third parties or copied or duplicated in any form,
11 in whole or in part, without the prior written consent of Nintendo.
12 
13 $Rev: 27772 $
14  *---------------------------------------------------------------------------*/
15 
16 #ifndef NN_CFG_CTR_CFG_USER_INFO_H_
17 #define NN_CFG_CTR_CFG_USER_INFO_H_
18 
19 #include <nn/types.h>
20 #include <nn/config.h>
21 #include <nn/cfg/CTR/cfg_CountryCode.h>
22 
23 namespace nn {
24 namespace cfg {
25 namespace CTR {
26 
27 /*---------------------------------------------------------------------------*
28 * User Information
29  *---------------------------------------------------------------------------*/
30 /*!
31 @brief  Specifies the maximum string length of the user name. (Including the terminator.)
32 */
33 const u8 CFG_USER_NAME_LENGTH               = 11;
34 
35 /*!
36 @brief  Stores the user name.
37 
38 User names obtained from the <tt>nn::cfg::CTR::GetUserName</tt> function are guaranteed to be <tt>NULL</tt> terminated.
39 
40 The <tt>isNgUserName</tt> member variable stores the result of checking the user name from System Settings.
41 The name is checked in Japanese for the Japanese region, in U.S. English and the system language for the North American region, and in U.K. English and the system language for the European region.
42 
43 */
44 struct UserName
45 {
46     wchar_t userName[CFG_USER_NAME_LENGTH]; //!< The user name.
47     bool isNgUserName;                      //!< Indicates whether the user name contains profanity. This has a value of <tt>true</tt> when the string contains profanity.
48     NN_PADDING1;
49 };
50 
51 /*!
52 @brief  Stores a birthday.
53 */
54 struct Birthday
55 {
56     s8  month;  //!< Stores the birthday month (1-12).
57     s8  day;    //!< Stores the birthday day (1-31).
58 };
59 
60 
61 /*---------------------------------------------------------------------------*
62 *  Simple Address Information
63  *---------------------------------------------------------------------------*/
64 /*!
65 @brief  Specifies the country code storage location in a <tt>SimpleAddress</tt> ID.
66 */
67 const u8    CFG_SIMPLE_ADDRESS_ID_COUNTRY_SHIFT         = 24;
68 /*!
69 @brief  Specifies the region code storage location in a <tt>SimpleAddress</tt> ID.
70 */
71 const u8    CFG_SIMPLE_ADDRESS_ID_REGION_SHIFT          = 16;
72 /*!
73 @brief  Specifies the country code mask for a <tt>SimpleAddress</tt> ID.
74 */
75 const u32   CFG_SIMPLE_ADDRESS_ID_COUNTRY_MASK          = 0xffU << CFG_SIMPLE_ADDRESS_ID_COUNTRY_SHIFT;
76 /*!
77 @brief  Specifies the region code mask for a <tt>SimpleAddress</tt> ID.
78 */
79 const u32   CFG_SIMPLE_ADDRESS_ID_REGION_MASK           = 0xffU << CFG_SIMPLE_ADDRESS_ID_REGION_SHIFT;
80 /*!
81 @brief  Specifies the reserved area mask for a <tt>SimpleAddress</tt> ID.
82 */
83 const u32   CFG_SIMPLE_ADDRESS_ID_RESERVED_MASK         = 0x0000ffff;
84 
85 /*!
86 @brief  Specifies an undefined ID for <tt>SimpleAddress</tt>.
87 */
88 const u32   CFG_SIMPLE_ADDRESS_ID_NOT_DEFINED           = 0xffffffff;
89 /*!
90 @brief  Specifies an undefined country code for <tt>SimpleAddress</tt>.
91 */
92 const u32   CFG_SIMPLE_ADDRESS_ID_COUNTRY_UNDEFINED     = 0x00U << CFG_SIMPLE_ADDRESS_ID_COUNTRY_SHIFT;
93 /*!
94 @brief  Specifies an undefined country code for <tt>SimpleAddress</tt>.
95 */
96 const u32   CFG_SIMPLE_ADDRESS_ID_COUNTRY_UNDEFINED2   = 0xffU << CFG_SIMPLE_ADDRESS_ID_COUNTRY_SHIFT;
97 /*!
98 @brief  Specifies an undefined region code for <tt>SimpleAddress</tt>.
99 */
100 const u32   CFG_SIMPLE_ADDRESS_ID_REGION_UNDEFINED     = 0x00U << CFG_SIMPLE_ADDRESS_ID_REGION_SHIFT;
101 /*!
102 @brief  Specifies an undefined region code for <tt>SimpleAddress</tt>.
103 */
104 const u32   CFG_SIMPLE_ADDRESS_ID_REGION_UNDEFINED2    = 0xffU << CFG_SIMPLE_ADDRESS_ID_REGION_SHIFT;
105 
106 /*!
107 @brief  Specifies the number of languages for the country/region name in simple address information.
108 */
109 const u8    CFG_SIMPLE_ADDRESS_NUM_LANGUAGES   = 16;
110 /*!
111 @brief  Specifies the maximum length of country/region names in simple address information.
112 */
113 const u8    CFG_SIMPLE_ADDRESS_NAME_LENGTH     = 64;
114 
115 /*!
116 @brief  Specifies the size of memory required to get simple address information.
117 */
118 const u32   CFG_SIMPLE_ADDRESS_WORKMEMORY_SIZE = 256 * 1024;
119 
120 
121 /*!
122 @brief  Stores the user's simple address information configured in the System Settings.
123 
124 The size of this structure is at least 4 KB.
125 Be careful not to exhaust the stack if the user's simple address information is placed in the stack.
126 The country and region names in the simple address information retrieved from the <tt>nn::cfg::CTR::GetSimpleAddress</tt> function are guaranteed to be <tt>NULL</tt> terminated.
127 
128 */
129 struct SimpleAddress
130 {
131     u32 id;                                                                                 //!< Simple address information ID. The country code is stored in the upper 8 bits, and the region code is stored in the following 8 bits. The lower 16 bits are reserved.
132     wchar_t countryName[CFG_SIMPLE_ADDRESS_NUM_LANGUAGES][CFG_SIMPLE_ADDRESS_NAME_LENGTH];  //!< Stores country names in each language.
133     wchar_t regionName [CFG_SIMPLE_ADDRESS_NUM_LANGUAGES][CFG_SIMPLE_ADDRESS_NAME_LENGTH];  //!< Stores region names in each language (such as the names of states or prefectures). If a region is not selected, stores "—." If regions cannot be selected for the specified country setting, stores the country name.
134     u16 latitude;                                                                           //!< The latitude. Values in the range from <tt>0x0000</tt> through <tt>0x4000</tt> represent the range from 0 through +90 degrees. Values from <tt>0xC000</tt> through <tt>0xFFFF</tt> represent the range from -90 through -0.005 degrees. Positive angles indicate the northern hemisphere; negative angles indicate the southern hemisphere.
135     u16 longitude;                                                                          //!< The longitude. Values from <tt>0x0000</tt> through <tt>0x7FFF</tt> represent the range from 0 through +179.995 degrees. Values from <tt>0x8000</tt> through <tt>0xFFFF</tt> represent the range from -180 through -0.005 degrees. Positive angles indicate the eastern hemisphere; negative angles indicate the western hemisphere.
136 };
137 
138 /*!
139 @brief  Stores the ID in simple address information.
140 */
141 struct SimpleAddressId
142 {
143     u32 id;     //!< Simple address information ID.
144 
145     /*!
146 @brief  Gets only the country code part of the simple address information ID.
147 @return  Returns the country code.
148 */
GetCountryCodeSimpleAddressId149     CfgCountryCode GetCountryCode(void) const
150     {
151         return static_cast<CfgCountryCode>((id & CFG_SIMPLE_ADDRESS_ID_COUNTRY_MASK) >> CFG_SIMPLE_ADDRESS_ID_COUNTRY_SHIFT);
152     }
153 
154     /*!
155 @brief  Gets only the region code part of the simple address information ID.
156 @return  Returns the region code.
157 */
GetRegionCodeSimpleAddressId158     u8 GetRegionCode(void) const
159     {
160         return (id & CFG_SIMPLE_ADDRESS_ID_REGION_MASK) >> CFG_SIMPLE_ADDRESS_ID_REGION_SHIFT;
161     }
162 };
163 
164 } // end of namespace CTR
165 } // end of namespace cfg
166 } // end of namespace nn
167 
168 #endif      // NN_CFG_CTR_CFG_USER_INFO_H_
169