From 45952b080cbad5096c71722e46d7dc99e8eadce2 Mon Sep 17 00:00:00 2001 From: Dennis Peeten Date: Tue, 27 May 2008 10:56:41 +0000 Subject: buttons up down bitmaps --- matchblox/common/message_input.h | 4 +++- matchblox/common/wiimote_utils.cpp | 8 ++++++++ matchblox/common/wiimote_utils.h | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/matchblox/common/message_input.h b/matchblox/common/message_input.h index 093d28e..646ec3a 100644 --- a/matchblox/common/message_input.h +++ b/matchblox/common/message_input.h @@ -50,7 +50,9 @@ struct rawdot { int rx, ry; }; struct input_payload_wiimote { - int btns, //button bitmask + int btns, //current button state + btnsDown, //buttons that that were pressed + btnsUp, //buttons that were released nrdots; double relX, //relative x coordinate of mouse cursor [0,1] relY, //relative y coordinate of mouse cursor [0,1] diff --git a/matchblox/common/wiimote_utils.cpp b/matchblox/common/wiimote_utils.cpp index 9098361..6d0d7a0 100644 --- a/matchblox/common/wiimote_utils.cpp +++ b/matchblox/common/wiimote_utils.cpp @@ -9,6 +9,7 @@ AbstractWiimote::AbstractWiimote() + : m_prevButtons(0) { m_pSensBarDotSmoother[0] = new C_Smoother(Vect3D_t(0.0, 0.0, 0.0)); m_pSensBarDotSmoother[0]->SetExponentialMovingAverage(0.2); @@ -28,6 +29,13 @@ void AbstractWiimote::FillWiimoteMsgPayload(input_payload_wiimote &f_payload, do ParseWiimote(f_payload); + //set the bttnsDown bitmap + f_payload.btnsDown = (f_payload.btns ^ m_prevButtons) & ~m_prevButtons; + //set the bttnsUp bitmap + f_payload.btnsUp = (f_payload.btns ^ m_prevButtons) & m_prevButtons; + + m_prevButtons = f_payload.btns; + f_payload.relX = f_payload.relY = f_payload.Zdist = 0.0; f_payload.posDataValid = CalcWiimoteRelativeCursorPos(f_payload, f_dSensBarLedDist); } diff --git a/matchblox/common/wiimote_utils.h b/matchblox/common/wiimote_utils.h index 9fdaac9..dc64e99 100644 --- a/matchblox/common/wiimote_utils.h +++ b/matchblox/common/wiimote_utils.h @@ -36,6 +36,8 @@ protected: bool CalcWiimoteRelativeCursorPos(input_payload_wiimote &f_pWiimoteMsg, double f_dSensBarLedDist); double CalcZDistInMM(Vect3D_t f_Dots[2], double f_dSensBarLedDist); + int m_prevButtons; + C_Smoother *m_pSensBarDotSmoother[2]; }; -- cgit v0.12