00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __OPENKN_CONTROLLER__WIIMOTE_NUNCHUK_HPP__
00025 #define __OPENKN_CONTROLLER__WIIMOTE_NUNCHUK_HPP__
00026
00027
00028
00029
00030 #include "InputController.hpp"
00031
00032
00033
00034
00035 #include <wiiuse.h>
00036 #include <queue>
00037
00038 namespace kn{
00039
00040
00041
00046 static const unsigned int EVENT_NONE= 0x0;
00047
00052 static const unsigned int EVENT_BUTTON_C_UP= 0x1;
00057 static const unsigned int EVENT_BUTTON_C_DOWN= 0x2;
00062 static const unsigned int EVENT_BUTTON_Z_UP= 0x4;
00067 static const unsigned int EVENT_BUTTON_Z_DOWN= 0x8;
00068
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00093
00094
00095
00096
00097
00102 class Nunchuk : public InputController{
00103
00104 private:
00105
00106 std::queue<unsigned int> eventsqueue;
00108 static const unsigned int maxevents = 10;
00110 wiimote * wm;
00112 public:
00119 Nunchuk(void):InputController(){}
00120
00129 Nunchuk(wiimote* wiimote);
00130
00137 ~Nunchuk(void){clearEvents();}
00138
00144 void addEvent(const unsigned int& event);
00145
00152 void clearEvents(void);
00153
00163 unsigned int popEvent(void) { if(eventsqueue.empty()){ return EVENT_NONE; this->updateAsNotUpdated();} unsigned int ev = eventsqueue.front(); eventsqueue.pop(); return ev;}
00164
00172 unsigned int topEvent(void) { if(eventsqueue.empty()){ return EVENT_NONE; this->updateAsNotUpdated();} return eventsqueue.front();}
00173
00184 unsigned int popError(void) {return 0;}
00185
00196 unsigned int topError(void) {return 0;}
00197
00207 float getRoll(void)const{if(wm->exp.type==EXP_NUNCHUK)return wm->exp.nunchuk.orient.roll; return 0.0;}
00208
00218 float getAbsoluteRoll(void)const{if(wm->exp.type==EXP_NUNCHUK)return wm->exp.nunchuk.orient.a_roll; return 0.0;}
00219
00229 float getPitch(void)const{if(wm->exp.type==EXP_NUNCHUK)return wm->exp.nunchuk.orient.pitch; return 0.0;}
00230
00240 float getAbsolutePitch(void)const{if(wm->exp.type==EXP_NUNCHUK)return wm->exp.nunchuk.orient.a_pitch; return 0.0;}
00241
00251 float getXForce(void)const{if(wm->exp.type==EXP_NUNCHUK)return wm->exp.nunchuk.gforce.x; return 0.0;}
00252
00262 float getYForce(void)const{if(wm->exp.type==EXP_NUNCHUK)return wm->exp.nunchuk.gforce.y; return 0.0;}
00263
00273 float getZForce(void)const{if(wm->exp.type==EXP_NUNCHUK)return wm->exp.nunchuk.gforce.z; return 0.0;}
00274
00275
00276
00277
00289 float getJoystickAngle(void)const{if(wm->exp.type==EXP_NUNCHUK)return wm->exp.nunchuk.js.ang; return 0.0;}
00290
00300 float getJoystickMagnitude(void)const{if(wm->exp.type==EXP_NUNCHUK)return wm->exp.nunchuk.js.mag; return 0.0;}
00301
00309 bool isConnected(void)const{return (wm->exp.type==EXP_NUNCHUK);}
00310
00311
00312
00313 };
00314
00315 }
00316
00317
00318 #endif