summaryrefslogtreecommitdiffstats
path: root/matchblox/common/wiimote_utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'matchblox/common/wiimote_utils.h')
-rw-r--r--matchblox/common/wiimote_utils.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/matchblox/common/wiimote_utils.h b/matchblox/common/wiimote_utils.h
new file mode 100644
index 0000000..edb59ce
--- /dev/null
+++ b/matchblox/common/wiimote_utils.h
@@ -0,0 +1,68 @@
+#ifndef WIIMOTE_UTILS_H
+
+#define WIIMOTE_UTILS_H
+
+#include "message_input.h"
+#include "typedefs.h"
+#include "C_Smoother.h"
+
+#define _USE_MATH_DEFINES
+#include <math.h>
+
+static double g_dWiimoteXCamResolution = 1016.0;
+static double g_dWiimoteYCamResolution = 760.0;
+static double g_dWiimoteRadPerPixel = (41.0 * (M_PI/180.0))/g_dWiimoteXCamResolution;
+
+//abstract wiimote needs to be inherited and the virtual functions implemented to communicate
+//with a wiimote lib
+class AbstractWiimote
+{
+public:
+ AbstractWiimote();
+ ~AbstractWiimote();
+
+ virtual bool Connect() = 0;
+ virtual void StartRumble() = 0;
+ virtual void StopRumble() = 0;
+ virtual void SetLeds(unsigned char bitmask) = 0;
+ virtual bool IsConnected() = 0;
+
+ void FillWiimoteMsgPayload(input_payload_wiimote &f_payload, double f_dSensBarLedDist);
+
+protected:
+ virtual void ParseWiimote(input_payload_wiimote &f_payload) = 0;
+
+ bool FindSensorBarDots(rawdot *f_rd, int f_iNumdots, Vect3D_t f_Dots[2]);
+ bool CalcWiimoteRelativeCursorPos(input_payload_wiimote &f_pWiimoteMsg, double f_dSensBarLedDist);
+ double CalcZDistInMM(Vect3D_t f_Dots[2], double f_dSensBarLedDist);
+
+ C_Smoother<Vect3D_t> *m_pSensBarDotSmoother[2];
+};
+
+#ifdef USE_WIIYOURSELF
+
+#include <wiimote.h>
+
+//implementation of an abstract wiimote using the wiiyourself! lib
+class WiiYourselfWiimote : public AbstractWiimote
+{
+public:
+ WiiYourselfWiimote();
+ ~WiiYourselfWiimote();
+
+ bool Connect();
+ void StartRumble();
+ void StopRumble();
+ void SetLeds(unsigned char bitmask);
+ bool IsConnected();
+
+ void ParseWiimote(input_payload_wiimote &f_payload);
+
+private:
+ wiimote *m_pWm;
+};
+
+#endif //USE_WIIYOURSELF
+
+
+#endif //WIIMOTE_UTILS_H \ No newline at end of file