[Orxonox-commit 5148] r9813 - code/branches/wiimote/src/libraries/core/input
georgr at orxonox.net
georgr at orxonox.net
Mon Nov 25 15:38:51 CET 2013
Author: georgr
Date: 2013-11-25 15:38:51 +0100 (Mon, 25 Nov 2013)
New Revision: 9813
Modified:
code/branches/wiimote/src/libraries/core/input/InputManager.cc
code/branches/wiimote/src/libraries/core/input/WiiMote.cc
code/branches/wiimote/src/libraries/core/input/WiiMote.h
Log:
Added some simple wobbling action. To be tested.
Modified: code/branches/wiimote/src/libraries/core/input/InputManager.cc
===================================================================
--- code/branches/wiimote/src/libraries/core/input/InputManager.cc 2013-11-25 14:33:02 UTC (rev 9812)
+++ code/branches/wiimote/src/libraries/core/input/InputManager.cc 2013-11-25 14:38:51 UTC (rev 9813)
@@ -233,10 +233,11 @@
int index;
// Find and connect to the wiimotes
- std::vector<CWiimote>& wiimotes = wii.FindAndConnect();
+ std::vector<CWiimote>& wiimotes = wii.FindAndConnect(30);
if (!wiimotes.size())
{
cout << "No wiimotes found." << endl;
+ return;
}
// Setup the wiimotes
Modified: code/branches/wiimote/src/libraries/core/input/WiiMote.cc
===================================================================
--- code/branches/wiimote/src/libraries/core/input/WiiMote.cc 2013-11-25 14:33:02 UTC (rev 9812)
+++ code/branches/wiimote/src/libraries/core/input/WiiMote.cc 2013-11-25 14:38:51 UTC (rev 9813)
@@ -10,6 +10,23 @@
void WiiMote::update(const Clock& time)
{
orxout(user_warning) << this->inputStates_.size() << std::endl;
+ CWiimote::EventTypes e = p->GetEvent();
+ if(p->Buttons.isPressed(CButtons::BUTTON_A))
+ orxout()<<"ZOMG!!1!"<<endl;
+ Orientation o;
+ p->Accelerometer.GetOrientation(o.pitch, o.roll, o.yaw);
+ int x = (int)(o.yaw-lastOrientation.yaw)*time.tickDt_;
+ int y = (int)(o.pitch-lastOrientation.pitch)*time.tickDt_;
+ IntVector2 abs(0, 0);
+ IntVector2 rel(x, y);
+ IntVector2 clippingSize(1920, 1080);
+ if(x!=0&&y!=0)
+ {
+ for (unsigned int i = 0; i < inputStates_.size(); ++i)
+ inputStates_[i]->mouseMoved(abs, rel, clippingSize);
+ }
+
+
}
void WiiMote::clearBuffers()
{
@@ -22,5 +39,10 @@
WiiMote::WiiMote(unsigned int id, CWiimote & parent) : InputDevice(id)
{
p = &parent;
+
+ lastOrientation.yaw = 0;
+ lastOrientation.roll = 0;
+ lastOrientation.pitch = 0;
+
}
}
Modified: code/branches/wiimote/src/libraries/core/input/WiiMote.h
===================================================================
--- code/branches/wiimote/src/libraries/core/input/WiiMote.h 2013-11-25 14:33:02 UTC (rev 9812)
+++ code/branches/wiimote/src/libraries/core/input/WiiMote.h 2013-11-25 14:38:51 UTC (rev 9813)
@@ -10,8 +10,11 @@
{
+ struct Orientation
+ {
+ float roll, pitch, yaw;
+ };
-
class WiiMote : public InputDevice
{
@@ -29,6 +32,7 @@
protected:
void calibrationStarted() { }
void calibrationStopped() { }
+ Orientation lastOrientation;
//! List of all input states that receive events from this device
//std::vector<InputState*> inputStates_;
More information about the Orxonox-commit
mailing list