summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDennis Peeten <dpeeten@onsneteindhoven.nl>2008-05-27 10:56:41 (GMT)
committerDennis Peeten <dpeeten@onsneteindhoven.nl>2008-05-27 10:56:41 (GMT)
commit45952b080cbad5096c71722e46d7dc99e8eadce2 (patch)
tree3be3ebf324571deb939c274be32e333c3fb25b10
parentea1ff55ac332ec38068f63e71e5fa6187fa37a57 (diff)
download2iv55-45952b080cbad5096c71722e46d7dc99e8eadce2.zip
2iv55-45952b080cbad5096c71722e46d7dc99e8eadce2.tar.gz
2iv55-45952b080cbad5096c71722e46d7dc99e8eadce2.tar.bz2
buttons up down bitmaps
-rw-r--r--matchblox/common/message_input.h4
-rw-r--r--matchblox/common/wiimote_utils.cpp8
-rw-r--r--matchblox/common/wiimote_utils.h2
3 files changed, 13 insertions, 1 deletions
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>(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<Vect3D_t> *m_pSensBarDotSmoother[2];
};