1 /*---------------------------------------------------------------------------*
2 Project: Horizon
3 File: hid_PadReader.h
4
5 Copyright (C)2009 Nintendo Co., Ltd. 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: 36566 $
14 *---------------------------------------------------------------------------*/
15
16 /* Please see man pages for details
17
18
19 */
20 #ifndef NN_HID_CTR_HID_PADREADER_H_
21 #define NN_HID_CTR_HID_PADREADER_H_
22
23 #include <nn/Handle.h>
24 #include <nn/Result.h>
25 #include <nn/types.h>
26 #include <nn/hid/CTR/hid_Result.h>
27 #include <nn/hid/CTR/hid_Api.h>
28 #include <nn/hid/CTR/hid_pad.h>
29 #include <nn/hid/CTR/hid_DeviceStatus.h>
30 #include <nn/hid/CTR/hid_AnalogStickClamper.h>
31 #include <nn/util/util_SizedEnum.h>
32 #include <nn/util/util_NonCopyable.h>
33
34 namespace nn {
35 namespace hid {
36 namespace CTR {
37
38 /* Please see man pages for details
39
40
41
42 */
43
44 class PadReader : private nn::util::NonCopyable<PadReader>
45 {
46 public:
47 /* Please see man pages for details
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72 */
73 typedef enum
74 {
75 /* Please see man pages for details */
76 STICK_CLAMP_MODE_CIRCLE = 0,
77 /* Please see man pages for details */
78 STICK_CLAMP_MODE_CROSS,
79 /* Please see man pages for details */
80 STICK_CLAMP_MODE_MINIMUM
81 } StickClampMode;
82
83 /* Please see man pages for details
84
85
86
87
88
89
90 */
91 PadReader(Pad& pad=GetPad( ));
92
93 /* Please see man pages for details
94
95
96 */
~PadReader()97 ~PadReader( ) {};
98
99 /* Please see man pages for details
100
101
102
103
104
105
106
107
108
109
110
111 */
112 void Read(PadStatus* pBufs, s32* pReadLen, s32 bufLen);
113
114 /* Please see man pages for details
115
116
117
118
119
120
121
122
123
124
125
126
127 */
128 bool ReadLatest(PadStatus* pBuf);
129
130 /* Please see man pages for details
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145 */
146 void SetStickClamp(s16 min, s16 max);
147
148 /* Please see man pages for details
149
150
151
152
153
154
155
156
157 */
158 void GetStickClamp(s16* pMin, s16* pMax) const;
159
160 /* Please see man pages for details
161
162
163
164
165
166
167 */
168 StickClampMode GetStickClampMode( ) const;
169
170 /* Please see man pages for details
171
172
173
174
175
176
177
178
179 */
180 void SetStickClampMode(StickClampMode mode);
181
182 /* Please see man pages for details
183
184
185
186
187
188
189 */
190 f32 NormalizeStick(s16 x);
191
192 /* Please see man pages for details
193
194
195
196
197
198
199
200
201
202
203 */
204 void NormalizeStickWithScale( f32* normalized_x, f32* normalized_y, s16 x, s16 y );
205
206 /* Please see man pages for details
207
208
209
210
211
212
213
214
215
216
217
218
219 */
220 void SetNormalizeStickScaleSettings( f32 scale, s16 threshold );
221
222 /* Please see man pages for details
223
224
225
226
227
228 */
229 void GetNormalizeStickScaleSettings( f32* scale, s16* threshold ) const;
230
231
232 protected:
233 Pad& m_Pad;
234 s32 m_IndexOfRead;
235 bit32 m_LatestHold;
236 s16 m_MinOfStickClampCircle;
237 s16 m_MinOfStickClampCross;
238 s16 m_MinOfStickClampMinimum;
239 s16 m_MaxOfStickClampCircle;
240 s16 m_MaxOfStickClampCross;
241 s16 m_MaxOfStickClampMinimum;
242 bool m_IsReadLatestFirst;
243 nn::util::SizedEnum1<StickClampMode> m_StickClampMode;
244 s16 m_Threshold;
245 f32 m_Scale;
246 f32 m_Stroke;
247 f32 m_StrokeVelocity;
248 f32 m_LastLength;
249 f32 m_LastDiff;
250 s64 m_TickOfRead;
251 };
252
253
254 // inline definitions
GetStickClamp(s16 * pMin,s16 * pMax)255 inline void PadReader::GetStickClamp(s16* pMin, s16* pMax) const
256 {
257 if (m_StickClampMode == STICK_CLAMP_MODE_CIRCLE)
258 {
259 *pMin = m_MinOfStickClampCircle;
260 *pMax = m_MaxOfStickClampCircle;
261 }
262 else if (m_StickClampMode == STICK_CLAMP_MODE_CROSS)
263 {
264 *pMin = m_MinOfStickClampCross;
265 *pMax = m_MaxOfStickClampCross;
266 }
267 else
268 {
269 *pMin = m_MinOfStickClampMinimum;
270 *pMax = m_MaxOfStickClampMinimum;
271 }
272 }
273
GetStickClampMode()274 inline PadReader::StickClampMode PadReader::GetStickClampMode( ) const
275 {
276 return m_StickClampMode;
277 }
278
SetStickClampMode(StickClampMode mode)279 inline void PadReader::SetStickClampMode(StickClampMode mode)
280 {
281 m_StickClampMode = mode;
282 }
283
284 /* Please see man pages for details
285
286
287
288
289
290
291 */
292 bool EnableSelectButton();
293
294 /* Please see man pages for details
295
296
297
298 */
299 void DisableSelectButton();
300
301 } // namespace CTR {
302 } // namespace hid {
303 } // namespace nn {
304
305 #endif // #ifndef NN_HID_CTR_HID_PADREADER_H_
306