1 | /* |
---|
2 | * wiicpp.h |
---|
3 | * |
---|
4 | * This file is part of WiiC, written by: |
---|
5 | * Gabriele Randelli |
---|
6 | * Email: randelli@dis.uniroma1.it |
---|
7 | * |
---|
8 | * Copyright 2010 |
---|
9 | * |
---|
10 | * This file is based on WiiuseCpp, written By: |
---|
11 | * James Thomas |
---|
12 | * Email: jt@missioncognition.org |
---|
13 | * |
---|
14 | * Copyright 2009 |
---|
15 | * |
---|
16 | * This program is free software; you can redistribute it and/or modify |
---|
17 | * it under the terms of the GNU General Public License as published by |
---|
18 | * the Free Software Foundation; either version 3 of the License, or |
---|
19 | * (at your option) any later version. |
---|
20 | * |
---|
21 | * This program is distributed in the hope that it will be useful, |
---|
22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
24 | * GNU General Public License for more details. |
---|
25 | * |
---|
26 | * You should have received a copy of the GNU General Public License |
---|
27 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
28 | * |
---|
29 | * $Header$ |
---|
30 | * |
---|
31 | */ |
---|
32 | |
---|
33 | #ifndef WIICPP_H_ |
---|
34 | #define WIICPP_H_ |
---|
35 | |
---|
36 | #include <vector> |
---|
37 | #include <wiicpp/wiic/wiic.h> |
---|
38 | #include <wiicpp/log/dataset.h> |
---|
39 | #include <wiicpp/log/logger.h> |
---|
40 | |
---|
41 | using namespace WiiC; |
---|
42 | |
---|
43 | class CButtonBase |
---|
44 | { |
---|
45 | public: |
---|
46 | CButtonBase(void *ButtonsPtr, void *ButtonsHeldPtr, void *ButtonsReleasedPtr); |
---|
47 | |
---|
48 | int isPressed(int Button); |
---|
49 | int isHeld(int Button); |
---|
50 | int isReleased(int Button); |
---|
51 | int isJustPressed(int Button); |
---|
52 | |
---|
53 | private: |
---|
54 | virtual short Cast(void *Ptr) {return *((short *)(Ptr));} // Inlined. |
---|
55 | |
---|
56 | void *mpBtnsPtr; |
---|
57 | void *mpBtnsHeldPtr; |
---|
58 | void *mpBtnsReleasedPtr; |
---|
59 | }; |
---|
60 | |
---|
61 | class CButtons : public CButtonBase |
---|
62 | { |
---|
63 | public: |
---|
64 | enum ButtonDefs |
---|
65 | { |
---|
66 | BUTTON_TWO = WIIMOTE_BUTTON_TWO, |
---|
67 | BUTTON_ONE = WIIMOTE_BUTTON_ONE, |
---|
68 | BUTTON_B = WIIMOTE_BUTTON_B, |
---|
69 | BUTTON_A = WIIMOTE_BUTTON_A, |
---|
70 | BUTTON_MINUS = WIIMOTE_BUTTON_MINUS, |
---|
71 | BUTTON_HOME = WIIMOTE_BUTTON_HOME, |
---|
72 | BUTTON_LEFT = WIIMOTE_BUTTON_LEFT, |
---|
73 | BUTTON_RIGHT = WIIMOTE_BUTTON_RIGHT, |
---|
74 | BUTTON_DOWN = WIIMOTE_BUTTON_DOWN, |
---|
75 | BUTTON_UP = WIIMOTE_BUTTON_UP, |
---|
76 | BUTTON_PLUS = WIIMOTE_BUTTON_PLUS, |
---|
77 | BUTTON_UNKNOWN = WIIMOTE_BUTTON_UNKNOWN, |
---|
78 | BUTTON_ALL = WIIMOTE_BUTTON_ALL |
---|
79 | }; |
---|
80 | |
---|
81 | CButtons(void *ButtonsPtr, void *ButtonsHeldPtr, void *ButtonsReleasedPtr); |
---|
82 | }; |
---|
83 | |
---|
84 | class CNunchukButtons : public CButtonBase |
---|
85 | { |
---|
86 | public: |
---|
87 | enum ButtonDefs |
---|
88 | { |
---|
89 | BUTTON_Z = NUNCHUK_BUTTON_Z, |
---|
90 | BUTTON_C = NUNCHUK_BUTTON_C, |
---|
91 | BUTTON_ALL = NUNCHUK_BUTTON_ALL |
---|
92 | }; |
---|
93 | |
---|
94 | CNunchukButtons(void *ButtonsPtr, void *ButtonsHeldPtr, void *ButtonsReleasedPtr); |
---|
95 | |
---|
96 | private: |
---|
97 | short Cast(void *Ptr) {return (short)(*((byte *)(Ptr)));} // Inlined using the different type. |
---|
98 | }; |
---|
99 | |
---|
100 | class CClassicButtons : public CButtonBase |
---|
101 | { |
---|
102 | public: |
---|
103 | enum ButtonDefs |
---|
104 | { |
---|
105 | BUTTON_X = CLASSIC_CTRL_BUTTON_X, |
---|
106 | BUTTON_Y = CLASSIC_CTRL_BUTTON_Y, |
---|
107 | BUTTON_B = CLASSIC_CTRL_BUTTON_B, |
---|
108 | BUTTON_A = CLASSIC_CTRL_BUTTON_A, |
---|
109 | BUTTON_MINUS = CLASSIC_CTRL_BUTTON_MINUS, |
---|
110 | BUTTON_HOME = CLASSIC_CTRL_BUTTON_HOME, |
---|
111 | BUTTON_LEFT = CLASSIC_CTRL_BUTTON_LEFT, |
---|
112 | BUTTON_RIGHT = CLASSIC_CTRL_BUTTON_RIGHT, |
---|
113 | BUTTON_DOWN = CLASSIC_CTRL_BUTTON_DOWN, |
---|
114 | BUTTON_UP = CLASSIC_CTRL_BUTTON_UP, |
---|
115 | BUTTON_PLUS = CLASSIC_CTRL_BUTTON_PLUS, |
---|
116 | BUTTON_ZR = CLASSIC_CTRL_BUTTON_ZR, |
---|
117 | BUTTON_ZL = CLASSIC_CTRL_BUTTON_ZL, |
---|
118 | BUTTON_FULL_R = CLASSIC_CTRL_BUTTON_FULL_R, |
---|
119 | BUTTON_FULL_L = CLASSIC_CTRL_BUTTON_FULL_L, |
---|
120 | BUTTON_ALL = CLASSIC_CTRL_BUTTON_ALL |
---|
121 | }; |
---|
122 | |
---|
123 | CClassicButtons(void *ButtonsPtr, void *ButtonsHeldPtr, void *ButtonsReleasedPtr); |
---|
124 | }; |
---|
125 | |
---|
126 | class CGH3Buttons : public CButtonBase |
---|
127 | { |
---|
128 | public: |
---|
129 | enum ButtonDefs |
---|
130 | { |
---|
131 | BUTTON_STRUM_UP = GUITAR_HERO_3_BUTTON_STRUM_UP, |
---|
132 | BUTTON_STRUM_DOWN = GUITAR_HERO_3_BUTTON_STRUM_DOWN, |
---|
133 | BUTTON_YELLOW = GUITAR_HERO_3_BUTTON_YELLOW, |
---|
134 | BUTTON_GREEN = GUITAR_HERO_3_BUTTON_GREEN, |
---|
135 | BUTTON_BLUE = GUITAR_HERO_3_BUTTON_BLUE, |
---|
136 | BUTTON_RED = GUITAR_HERO_3_BUTTON_RED, |
---|
137 | BUTTON_ORANGE = GUITAR_HERO_3_BUTTON_ORANGE, |
---|
138 | BUTTON_MINUS = GUITAR_HERO_3_BUTTON_MINUS, |
---|
139 | BUTTON_PLUS = GUITAR_HERO_3_BUTTON_PLUS, |
---|
140 | BUTTON_ALL = GUITAR_HERO_3_BUTTON_ALL |
---|
141 | }; |
---|
142 | |
---|
143 | CGH3Buttons(void *ButtonsPtr, void *ButtonsHeldPtr, void *ButtonsReleasedPtr); |
---|
144 | }; |
---|
145 | |
---|
146 | class CJoystick |
---|
147 | { |
---|
148 | public: |
---|
149 | CJoystick(struct joystick_t *JSPtr); |
---|
150 | |
---|
151 | void GetMaxCal(int &X, int &Y); |
---|
152 | void SetMaxCal(int X, int Y); |
---|
153 | |
---|
154 | void GetMinCal(int &X, int &Y); |
---|
155 | void SetMinCal(int X, int Y); |
---|
156 | |
---|
157 | void GetCenterCal(int &X, int &Y); |
---|
158 | void SetCenterCal(int X, int Y); |
---|
159 | |
---|
160 | void GetPosition(float &Angle, float &Magnitude); |
---|
161 | |
---|
162 | private: |
---|
163 | struct joystick_t *mpJoystickPtr; |
---|
164 | }; |
---|
165 | |
---|
166 | class CAccelerometer |
---|
167 | { |
---|
168 | public: |
---|
169 | CAccelerometer(struct accel_t *AccelCalPtr, |
---|
170 | struct vec3b_t *AccelerationPtr, int *AccelThresholdPtr, |
---|
171 | struct orient_t *OrientationPtr, float *OrientationThresholdPtr, |
---|
172 | struct gforce_t *GForcePtr); |
---|
173 | |
---|
174 | float SetSmoothAlpha(float Alpha); |
---|
175 | |
---|
176 | float GetOrientThreshold(); |
---|
177 | void SetOrientThreshold(float Threshold); |
---|
178 | |
---|
179 | int GetAccelThreshold(); |
---|
180 | void SetAccelThreshold(int Threshold); |
---|
181 | |
---|
182 | void GetOrientation(float &Pitch, float &Roll, float &Yaw); |
---|
183 | |
---|
184 | void GetGravityCalVector(float &X, float &Y, float &Z); |
---|
185 | void SetGravityCalVector(float X, float Y, float Z); |
---|
186 | |
---|
187 | void GetGravityVector(float &X, float &Y, float &Z); |
---|
188 | void GetRawGravityVector(float &X, float &Y, float &Z); |
---|
189 | |
---|
190 | private: |
---|
191 | struct accel_t *mpAccelCalibPtr; |
---|
192 | struct vec3b_t *mpAccelPtr; |
---|
193 | struct orient_t *mpOrientPtr; |
---|
194 | struct gforce_t *mpGForcePtr; |
---|
195 | int *mpAccelThresholdPtr; |
---|
196 | float *mpOrientThresholdPtr; |
---|
197 | }; |
---|
198 | |
---|
199 | class CGyroscope |
---|
200 | { |
---|
201 | public: |
---|
202 | CGyroscope(struct ang3s_t* RawGyro, struct ang3s_t* CalGyro, struct ang3f_t* AngleRate, unsigned char* Mode, struct motion_plus_t* MPPtr, |
---|
203 | int* GyroThresholdPtr); |
---|
204 | void GetRawRates(int& Roll, int& Pitch, int& Yaw); |
---|
205 | void GetRates(float& Roll, float& Pitch, float& Yaw); |
---|
206 | void Calibrate(); |
---|
207 | int GetGyroThreshold(); |
---|
208 | void SetGyroThreshold(int Threshold); |
---|
209 | |
---|
210 | private: |
---|
211 | struct ang3s_t* mpRawGyro; |
---|
212 | struct ang3s_t* mpCalGyro; |
---|
213 | struct ang3f_t* mpAngleRate; |
---|
214 | struct motion_plus_t* mpMPPtr; |
---|
215 | unsigned char* mpMode; |
---|
216 | int* mpGyroThresholdPtr; |
---|
217 | }; |
---|
218 | |
---|
219 | class CWeightSensor |
---|
220 | { |
---|
221 | public: |
---|
222 | CWeightSensor(struct pressure_t* RawWeight, struct pressure_t* LowCalWeight, struct pressure_t* MediumCalWeight, struct pressure_t* HighCalWeight, struct pressure_weight_t* Weight, struct balance_board_t* BBPtr); |
---|
223 | void GetRawWeight(int& TopLeft, int& TopRight, int& BottomLeft, int& BottomRight); |
---|
224 | void GetWeight(float& TotalWeight, float& TopLeft, float& TopRight, float& BottomLeft, float& BottomRight); |
---|
225 | void GetLowCalWeight(int& TopLeft, int& TopRight, int& BottomLeft, int& BottomRight); |
---|
226 | void GetMediumCalWeight(int& TopLeft, int& TopRight, int& BottomLeft, int& BottomRight); |
---|
227 | void GetHighCalWeight(int& TopLeft, int& TopRight, int& BottomLeft, int& BottomRight); |
---|
228 | |
---|
229 | private: |
---|
230 | struct pressure_t* mpRawWeight; |
---|
231 | struct pressure_t* mpLowCalWeight; |
---|
232 | struct pressure_t* mpMediumCalWeight; |
---|
233 | struct pressure_t* mpHighCalWeight; |
---|
234 | struct pressure_weight_t* mpWeight; |
---|
235 | struct balance_board_t* mpBBPtr; |
---|
236 | }; |
---|
237 | |
---|
238 | class CIRDot |
---|
239 | { |
---|
240 | public: |
---|
241 | CIRDot(); |
---|
242 | CIRDot(struct ir_dot_t *DotPtr); |
---|
243 | CIRDot(const CIRDot & copyin); |
---|
244 | |
---|
245 | int isVisible(); |
---|
246 | int GetSize(); |
---|
247 | int GetOrder(); |
---|
248 | void GetCoordinate(int &X, int &Y); |
---|
249 | void GetRawCoordinate(int &X, int &Y); |
---|
250 | |
---|
251 | private: |
---|
252 | struct ir_dot_t *mpDotPtr; |
---|
253 | }; |
---|
254 | |
---|
255 | class CIR |
---|
256 | { |
---|
257 | public: |
---|
258 | enum BarPositions |
---|
259 | { |
---|
260 | BAR_ABOVE = WIIC_IR_ABOVE, |
---|
261 | BAR_BELOW = WIIC_IR_BELOW |
---|
262 | }; |
---|
263 | |
---|
264 | enum AspectRatioSelections |
---|
265 | { |
---|
266 | ASPECT_4_3 = WIIC_ASPECT_4_3, |
---|
267 | ASPECT_16_9 = WIIC_ASPECT_16_9 |
---|
268 | }; |
---|
269 | |
---|
270 | enum OnOffSelection |
---|
271 | { |
---|
272 | OFF = 0, |
---|
273 | ON = 1 |
---|
274 | }; |
---|
275 | |
---|
276 | CIR(struct wiimote_t *wmPtr); |
---|
277 | |
---|
278 | void SetMode(OnOffSelection State); |
---|
279 | void SetVres(unsigned int x, unsigned int y); |
---|
280 | |
---|
281 | BarPositions GetBarPositionSetting(); |
---|
282 | void SetBarPosition(BarPositions PositionSelection); |
---|
283 | |
---|
284 | AspectRatioSelections GetAspectRatioSetting(); |
---|
285 | void SetAspectRatio(AspectRatioSelections AspectRatioSelection ); |
---|
286 | |
---|
287 | void SetSensitivity(int Level); |
---|
288 | int GetSensitivity(); |
---|
289 | |
---|
290 | int GetNumDots(); |
---|
291 | std::vector<CIRDot>& GetDots(); |
---|
292 | |
---|
293 | void GetOffset(int &X, int &Y); |
---|
294 | int GetState(); |
---|
295 | void GetCursorPositionAbsolute(int &X, int &Y); |
---|
296 | void GetCursorPosition(int &X, int &Y); |
---|
297 | float GetPixelDistance(); |
---|
298 | float GetDistance(); |
---|
299 | |
---|
300 | private: |
---|
301 | struct wiimote_t *mpWiimotePtr; |
---|
302 | std::vector<CIRDot> mpIRDotsVector; |
---|
303 | }; |
---|
304 | |
---|
305 | class CNunchuk |
---|
306 | { |
---|
307 | public: |
---|
308 | CNunchuk(struct expansion_t *ExpPtr); |
---|
309 | |
---|
310 | CNunchukButtons Buttons; |
---|
311 | CJoystick Joystick; |
---|
312 | CAccelerometer Accelerometer; |
---|
313 | |
---|
314 | private: |
---|
315 | struct nunchuk_t *mpNunchukPtr; |
---|
316 | }; |
---|
317 | |
---|
318 | class CClassic |
---|
319 | { |
---|
320 | public: |
---|
321 | CClassic(struct expansion_t *ExpPtr); |
---|
322 | |
---|
323 | float GetLShoulderButton(); |
---|
324 | float GetRShoulderButton(); |
---|
325 | |
---|
326 | CClassicButtons Buttons; |
---|
327 | CJoystick LeftJoystick; |
---|
328 | CJoystick RightJoystick; |
---|
329 | |
---|
330 | private: |
---|
331 | struct classic_ctrl_t *mpClassicPtr; |
---|
332 | }; |
---|
333 | |
---|
334 | class CGuitarHero3 |
---|
335 | { |
---|
336 | public: |
---|
337 | CGuitarHero3(struct expansion_t *ExpPtr); |
---|
338 | |
---|
339 | float GetWhammyBar(); |
---|
340 | |
---|
341 | CGH3Buttons Buttons; |
---|
342 | CJoystick Joystick; |
---|
343 | |
---|
344 | private: |
---|
345 | struct guitar_hero_3_t *mpGH3Ptr; |
---|
346 | }; |
---|
347 | |
---|
348 | |
---|
349 | class CMotionPlus |
---|
350 | { |
---|
351 | public: |
---|
352 | CMotionPlus(struct expansion_t* MPPtr); |
---|
353 | |
---|
354 | void Connect(struct wiimote_t* WiimotePtr); |
---|
355 | void Disconnect(struct wiimote_t* WiimotePtr); |
---|
356 | |
---|
357 | CGyroscope Gyroscope; |
---|
358 | private: |
---|
359 | struct motion_plus_t* mpMPPtr; |
---|
360 | }; |
---|
361 | |
---|
362 | class CBalanceBoard |
---|
363 | { |
---|
364 | public: |
---|
365 | CBalanceBoard(struct expansion_t* BBPtr); |
---|
366 | |
---|
367 | CWeightSensor WeightSensor; |
---|
368 | private: |
---|
369 | struct balance_board_t* mpBBPtr; |
---|
370 | }; |
---|
371 | |
---|
372 | class CExpansionDevice |
---|
373 | { |
---|
374 | public: |
---|
375 | enum ExpTypes |
---|
376 | { |
---|
377 | TYPE_NONE = EXP_NONE, |
---|
378 | TYPE_NUNCHUK = EXP_NUNCHUK, |
---|
379 | TYPE_CLASSIC = EXP_CLASSIC, |
---|
380 | TYPE_GUITAR_HERO_3 = EXP_GUITAR_HERO_3, |
---|
381 | TYPE_MOTION_PLUS = EXP_MOTION_PLUS, |
---|
382 | TYPE_BALANCE_BOARD = EXP_BALANCE_BOARD |
---|
383 | }; |
---|
384 | |
---|
385 | CExpansionDevice(struct expansion_t *ExpPtr); |
---|
386 | |
---|
387 | ExpTypes GetType(); |
---|
388 | |
---|
389 | CNunchuk Nunchuk; |
---|
390 | CClassic Classic; |
---|
391 | CGuitarHero3 GuitarHero3; |
---|
392 | CMotionPlus MotionPlus; |
---|
393 | CBalanceBoard BalanceBoard; |
---|
394 | |
---|
395 | private: |
---|
396 | struct expansion_t *mpExpansionPtr; |
---|
397 | }; |
---|
398 | |
---|
399 | |
---|
400 | class CWiimote |
---|
401 | { |
---|
402 | public: |
---|
403 | enum LEDS |
---|
404 | { |
---|
405 | LED_NONE = WIIMOTE_LED_NONE, |
---|
406 | LED_1 = WIIMOTE_LED_1, |
---|
407 | LED_2 = WIIMOTE_LED_2, |
---|
408 | LED_3 = WIIMOTE_LED_3, |
---|
409 | LED_4 = WIIMOTE_LED_4 |
---|
410 | |
---|
411 | }; |
---|
412 | |
---|
413 | enum Flags |
---|
414 | { |
---|
415 | FLAG_SMOOTHING = WIIC_SMOOTHING, |
---|
416 | FLAG_CONTINUOUS = WIIC_CONTINUOUS, |
---|
417 | FLAG_ORIENT_THRESH = WIIC_ORIENT_THRESH, |
---|
418 | FLAG_INIT_FLAGS = WIIC_INIT_FLAGS |
---|
419 | }; |
---|
420 | |
---|
421 | enum EventTypes |
---|
422 | { |
---|
423 | EVENT_NONE = WIIC_NONE, |
---|
424 | EVENT_EVENT = WIIC_EVENT, |
---|
425 | EVENT_STATUS = WIIC_STATUS, |
---|
426 | EVENT_CONNECT = WIIC_CONNECT, |
---|
427 | EVENT_DISCONNECT = WIIC_DISCONNECT, |
---|
428 | EVENT_UNEXPECTED_DISCONNECT = WIIC_UNEXPECTED_DISCONNECT, |
---|
429 | EVENT_READ_DATA = WIIC_READ_DATA, |
---|
430 | EVENT_NUNCHUK_INSERTED = WIIC_NUNCHUK_INSERTED, |
---|
431 | EVENT_NUNCHUK_REMOVED = WIIC_NUNCHUK_REMOVED, |
---|
432 | EVENT_CLASSIC_CTRL_INSERTED = WIIC_CLASSIC_CTRL_INSERTED, |
---|
433 | EVENT_CLASSIC_CTRL_REMOVED = WIIC_CLASSIC_CTRL_REMOVED, |
---|
434 | EVENT_GUITAR_HERO_3_CTRL_INSERTED = WIIC_GUITAR_HERO_3_CTRL_INSERTED, |
---|
435 | EVENT_GUITAR_HERO_3_CTRL_REMOVED = WIIC_GUITAR_HERO_3_CTRL_REMOVED, |
---|
436 | EVENT_MOTION_PLUS_INSERTED = WIIC_MOTION_PLUS_INSERTED, |
---|
437 | EVENT_MOTION_PLUS_REMOVED = WIIC_MOTION_PLUS_REMOVED, |
---|
438 | EVENT_BALANCE_BOARD_INSERTED = WIIC_BALANCE_BOARD_INSERTED, |
---|
439 | EVENT_BALANCE_BOARD_REMOVED = WIIC_BALANCE_BOARD_REMOVED |
---|
440 | }; |
---|
441 | |
---|
442 | enum OnOffSelection |
---|
443 | { |
---|
444 | OFF = 0, |
---|
445 | ON = 1 |
---|
446 | }; |
---|
447 | |
---|
448 | static const int EVENT_BUFFER_LENGTH = MAX_PAYLOAD; |
---|
449 | |
---|
450 | CWiimote(); |
---|
451 | CWiimote(struct wiimote_t *wmPtr); |
---|
452 | CWiimote(const CWiimote & copyin); |
---|
453 | ~CWiimote() { } |
---|
454 | |
---|
455 | void Disconnected(); |
---|
456 | |
---|
457 | void SetRumbleMode(OnOffSelection State); |
---|
458 | void ToggleRumble(); |
---|
459 | bool isRumbleEnabled(); |
---|
460 | |
---|
461 | int GetLEDs(); |
---|
462 | void SetLEDs(int LEDs); |
---|
463 | |
---|
464 | float GetBatteryLevel(); |
---|
465 | |
---|
466 | int GetHandshakeState(); |
---|
467 | |
---|
468 | EventTypes GetEvent(); |
---|
469 | const unsigned char *GetEventBuffer(); |
---|
470 | |
---|
471 | void SetSmoothing(bool Smooth); |
---|
472 | |
---|
473 | void SetMotionSensingMode(OnOffSelection State); |
---|
474 | void EnableMotionPlus(OnOffSelection State); |
---|
475 | |
---|
476 | /* Logging methods */ |
---|
477 | inline void LogStart(int type =WIIC_LOG_NONE, const string& file ="") { |
---|
478 | logType = type; |
---|
479 | logger.SetLogLevel(WIIC_LOG_START, type, file); |
---|
480 | } |
---|
481 | inline void LogStop() { logger.SetLogLevel(WIIC_LOG_STOP); } |
---|
482 | inline void Log(); |
---|
483 | |
---|
484 | /* Timestamp methods */ |
---|
485 | inline struct timeval GetTimestamp() const { return mpWiimotePtr->timestamp; } |
---|
486 | |
---|
487 | void EnableSpeaker(OnOffSelection State); |
---|
488 | void MuteSpeaker(OnOffSelection State); |
---|
489 | void PlaySound(); |
---|
490 | |
---|
491 | void ReadData(unsigned char *Buffer, unsigned int Offset, unsigned int Length); |
---|
492 | void WriteData(unsigned int Address, unsigned char *Data, unsigned int Length); |
---|
493 | |
---|
494 | void UpdateStatus(); |
---|
495 | |
---|
496 | int GetID(); |
---|
497 | const char* GetAddress(); |
---|
498 | |
---|
499 | int GetState(); |
---|
500 | |
---|
501 | int GetFlags(); |
---|
502 | int SetFlags(int Enable, int Disable); |
---|
503 | |
---|
504 | void Resync(); |
---|
505 | |
---|
506 | void Disconnect(); |
---|
507 | |
---|
508 | int isUsingACC(); |
---|
509 | int isUsingEXP(); |
---|
510 | int isUsingIR(); |
---|
511 | int isUsingSpeaker(); |
---|
512 | int isSpeakerMuted(); |
---|
513 | int isUsingMotionPlus(); |
---|
514 | int isLEDSet(int LEDNum); |
---|
515 | inline bool isLogEnabled() { return logger.isLogEnabled(); } |
---|
516 | |
---|
517 | CIR IR; |
---|
518 | CButtons Buttons; |
---|
519 | CAccelerometer Accelerometer; |
---|
520 | CExpansionDevice ExpansionDevice; |
---|
521 | |
---|
522 | struct wiimote_t *mpWiimotePtr; // Pointer to the wm structure |
---|
523 | private: |
---|
524 | int mpTempInt; |
---|
525 | float mpTempFloat; |
---|
526 | |
---|
527 | Logger logger; |
---|
528 | int logType; |
---|
529 | }; |
---|
530 | |
---|
531 | class CWii |
---|
532 | { |
---|
533 | public: |
---|
534 | |
---|
535 | CWii(); |
---|
536 | CWii(int MaxNumCWiimotes); |
---|
537 | virtual ~CWii(); |
---|
538 | |
---|
539 | int GetNumConnectedWiimotes(); |
---|
540 | |
---|
541 | void RefreshWiimotes(); |
---|
542 | |
---|
543 | CWiimote& GetByID(int ID, int Refresh=1); |
---|
544 | std::vector<CWiimote>& GetWiimotes(int Refresh=1); |
---|
545 | |
---|
546 | int Find(int timeout); |
---|
547 | int LoadRegisteredWiimotes(); |
---|
548 | std::vector<CWiimote>& Connect(bool autoreconnect =false); |
---|
549 | std::vector<CWiimote>& FindAndConnect(int timeout =5, bool rumbleAck = true, bool autoreconnect =false); |
---|
550 | |
---|
551 | int Poll(); |
---|
552 | |
---|
553 | private: |
---|
554 | struct wiimote_t **mpWiimoteArray; |
---|
555 | int mpWiimoteArraySize; |
---|
556 | std::vector<CWiimote> mpWiimotesVector; |
---|
557 | }; |
---|
558 | |
---|
559 | #endif /* WIICPP_H_ */ |
---|