[Orxonox-commit 5173] r9838 - code/branches/wiimote/src/libraries/core/input
georgr at orxonox.net
georgr at orxonox.net
Mon Dec 2 14:09:42 CET 2013
Author: georgr
Date: 2013-12-02 14:09:41 +0100 (Mon, 02 Dec 2013)
New Revision: 9838
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:
developing on 2 PCs is a lot of fun, bluetooth is a rare commodity... wiimote should connect properly now
Modified: code/branches/wiimote/src/libraries/core/input/InputManager.cc
===================================================================
--- code/branches/wiimote/src/libraries/core/input/InputManager.cc 2013-12-02 13:08:46 UTC (rev 9837)
+++ code/branches/wiimote/src/libraries/core/input/InputManager.cc 2013-12-02 13:09:41 UTC (rev 9838)
@@ -254,7 +254,7 @@
try
{
orxout()<< "Size of devices vector before wiimote insertion:" << devices_.size() << std::endl;
- devices_.push_back(new WiiMote(devices_.size(), *i));
+ devices_.push_back(new WiiMote((unsigned int)devices_.size(), *i, wii));
//devices_[2] = new WiiMote(devices_.size(), *(new CWiimote()));
orxout()<< "Size of devices vector after wiimote insertion:" << devices_.size() << std::endl;
Modified: code/branches/wiimote/src/libraries/core/input/WiiMote.cc
===================================================================
--- code/branches/wiimote/src/libraries/core/input/WiiMote.cc 2013-12-02 13:08:46 UTC (rev 9837)
+++ code/branches/wiimote/src/libraries/core/input/WiiMote.cc 2013-12-02 13:09:41 UTC (rev 9838)
@@ -13,21 +13,24 @@
if(p == NULL)
exit(0);
else
- orxout(user_warning) << 'pointer is not null, yay' << 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.getDeltaTime());
- int y = (int)((o.pitch-lastOrientation.pitch)*time.getDeltaTime());
- IntVector2 abs(0, 0);
- IntVector2 rel(x, y);
- IntVector2 clippingSize(1920, 1080);
- if(x!=0&&y!=0)
+ orxout(user_warning) << "pointer is not null, yay" << std::endl;
+ if (PWii->Poll())
{
- for (unsigned int i = 0; i < inputStates_.size(); ++i)
- inputStates_[i]->mouseMoved(abs, rel, clippingSize);
+ 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.getDeltaTime());
+ int y = (int)((o.pitch-lastOrientation.pitch)*time.getDeltaTime());
+ 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);
+ }
}
@@ -40,10 +43,10 @@
{
}
- WiiMote::WiiMote(unsigned int id, CWiimote & parent) : InputDevice(id)
+ WiiMote::WiiMote(unsigned int id, CWiimote & parent, CWii & parentWii) : InputDevice(id)
{
p = &parent;
-
+ PWii = &parentWii;
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-12-02 13:08:46 UTC (rev 9837)
+++ code/branches/wiimote/src/libraries/core/input/WiiMote.h 2013-12-02 13:09:41 UTC (rev 9838)
@@ -20,7 +20,7 @@
public:
//! Only resets the members
- WiiMote(unsigned int id, CWiimote & parent);
+ WiiMote(unsigned int id, CWiimote & parent, CWii & parentWii);
~WiiMote() { }
//! Returns the device class (derived) name as string
std::string getClassName() const {return deviceName;}
@@ -40,5 +40,6 @@
static const std::string deviceName;
void test(int x, int y);
CWiimote * p;
+ CWii * PWii; //parent "wii" the wiimote is registered to
};
};
More information about the Orxonox-commit
mailing list