[Orxonox-commit 5125] r9790 - in code/branches/wiimote/src/libraries/core: . input
georgr at orxonox.net
georgr at orxonox.net
Mon Nov 18 16:07:28 CET 2013
Author: georgr
Date: 2013-11-18 16:07:28 +0100 (Mon, 18 Nov 2013)
New Revision: 9790
Modified:
code/branches/wiimote/src/libraries/core/CMakeLists.txt
code/branches/wiimote/src/libraries/core/input/InputManager.cc
code/branches/wiimote/src/libraries/core/input/InputState.cc
code/branches/wiimote/src/libraries/core/input/WiiMote.cc
code/branches/wiimote/src/libraries/core/input/WiiMote.h
Log:
debug outputs added
Modified: code/branches/wiimote/src/libraries/core/CMakeLists.txt
===================================================================
--- code/branches/wiimote/src/libraries/core/CMakeLists.txt 2013-11-18 15:05:55 UTC (rev 9789)
+++ code/branches/wiimote/src/libraries/core/CMakeLists.txt 2013-11-18 15:07:28 UTC (rev 9790)
@@ -98,6 +98,8 @@
${LUA5.1_LIBRARY}
cpptcl_orxonox
ois_orxonox
+ wiic_orxonox
+ wiicpp_orxonox
tinyxml_orxonox
util
LINK_LIBS_UNIX
Modified: code/branches/wiimote/src/libraries/core/input/InputManager.cc
===================================================================
--- code/branches/wiimote/src/libraries/core/input/InputManager.cc 2013-11-18 15:05:55 UTC (rev 9789)
+++ code/branches/wiimote/src/libraries/core/input/InputManager.cc 2013-11-18 15:07:28 UTC (rev 9790)
@@ -59,6 +59,7 @@
#include "WiiMote.h"
+
namespace orxonox
{
SetCommandLineSwitch(keyboard_no_grab).information("Whether not to exclusively grab the keyboard");
@@ -216,22 +217,54 @@
this->loadMouse();
this->loadJoySticks();
-
+ this->loadWiiMote();
// Reorder states in case some joy sticks were added/removed
this->updateActiveStates();
- this->loadWiiMote();
+
orxout(verbose, context::input) << "Input devices loaded." << endl;
}
+
void InputManager::loadWiiMote()
{
- try
+
+ CWii wii; // Defaults to 4 remotes
+ std::vector< ::CWiimote>::iterator i;
+ int reloadWiimotes = 0;
+ int index;
+
+ // Find and connect to the wiimotes
+ std::vector<CWiimote>& wiimotes = wii.FindAndConnect();
+ if (!wiimotes.size())
{
- devices_.push_back(new WiiMote(234));
+ cout << "No wiimotes found." << endl;
+ }
+
+ // Setup the wiimotes
+ for(index = 0, i = wiimotes.begin(); i != wiimotes.end(); ++i, ++index)
+ {
+ // Use a reference to make working with the iterator handy.
+ CWiimote & wiimote = *i;
+
+ //Set Leds
+ int LED_MAP[4] =
+ {CWiimote::LED_1, CWiimote::LED_2,
+ CWiimote::LED_3, CWiimote::LED_4};
+ wiimote.SetLEDs(LED_MAP[index]);
+
+
}
- catch(std::exception& e) //gotta catch em all
- {
- orxout()<<"Exception loading WiiMote!!!1!11!";
- }
+ try
+ {
+ orxout()<<devices_.size();
+ devices_.push_back(new WiiMote(devices_.size(), *(new CWiimote())));
+ //devices_[2] = new WiiMote(devices_.size(), *(new CWiimote()));
+
+ }
+ catch(std::exception& e) //gotta catch em all
+ {
+ orxout()<<"Exception loading WiiMote!!!1!11!";
+ }
+
}
//! Creates a new orxonox::Mouse
void InputManager::loadMouse()
@@ -435,8 +468,13 @@
states.clear();
for (std::map<int, InputState*>::reverse_iterator rit = activeStates_.rbegin(); rit != activeStates_.rend(); ++rit)
{
- if (rit->second->isInputDeviceEnabled(i) && (!occupied || rit->second->bAlwaysGetsInput_))
+ orxout() << "Checking ID " << i <<std::endl;
+ orxout() << "Checking condition 1: " << rit->second->isInputDeviceEnabled(i) <<std::endl;
+ orxout() << "Checking condition 2: " << rit->second->bAlwaysGetsInput_ <<std::endl;
+ orxout() << "Checking condition 3: " << !occupied <<std::endl;
+ if (rit->second->isInputDeviceEnabled(i) && (!occupied || rit->second->bAlwaysGetsInput_))
{
+ orxout() << "Success with ID " << i <<std::endl;
states.push_back(rit->second);
if (!rit->second->bTransparent_)
occupied = true;
Modified: code/branches/wiimote/src/libraries/core/input/InputState.cc
===================================================================
--- code/branches/wiimote/src/libraries/core/input/InputState.cc 2013-11-18 15:05:55 UTC (rev 9789)
+++ code/branches/wiimote/src/libraries/core/input/InputState.cc 2013-11-18 15:07:28 UTC (rev 9790)
@@ -54,7 +54,9 @@
bool InputState::isInputDeviceEnabled(unsigned int device)
{
if (device < handlers_.size())
+ { orxout() << "Test we made it into the if clause" << std::endl;
return handlers_[device] != NULL;
+ }
else
return false;
}
Modified: code/branches/wiimote/src/libraries/core/input/WiiMote.cc
===================================================================
--- code/branches/wiimote/src/libraries/core/input/WiiMote.cc 2013-11-18 15:05:55 UTC (rev 9789)
+++ code/branches/wiimote/src/libraries/core/input/WiiMote.cc 2013-11-18 15:07:28 UTC (rev 9790)
@@ -9,8 +9,7 @@
const std::string WiiMote::deviceName = "WiiMote";
void WiiMote::update(const Clock& time)
{
- orxout()<<"fegit\n";
-
+ orxout(user_warning) << this->inputStates_.size() << std::endl;
}
void WiiMote::clearBuffers()
{
@@ -20,7 +19,8 @@
{
}
- WiiMote::WiiMote(unsigned int id) : InputDevice(id)
+ WiiMote::WiiMote(unsigned int id, CWiimote & parent) : InputDevice(id)
{
+ p = &parent;
}
}
Modified: code/branches/wiimote/src/libraries/core/input/WiiMote.h
===================================================================
--- code/branches/wiimote/src/libraries/core/input/WiiMote.h 2013-11-18 15:05:55 UTC (rev 9789)
+++ code/branches/wiimote/src/libraries/core/input/WiiMote.h 2013-11-18 15:07:28 UTC (rev 9790)
@@ -1,17 +1,23 @@
#include "InputDevice.h"
-//#include "InputState.h"
//#include "InputManager.h"
+#include <wiicpp/wiicpp/wiicpp.h>
+
namespace orxonox
{
+
+
+
+
class WiiMote : public InputDevice
{
+
public:
//! Only resets the members
- WiiMote(unsigned int id);
+ WiiMote(unsigned int id, CWiimote & parent);
~WiiMote() { }
//! Returns the device class (derived) name as string
std::string getClassName() const {return deviceName;}
@@ -25,8 +31,10 @@
void calibrationStopped() { }
//! List of all input states that receive events from this device
std::vector<InputState*> inputStates_;
+
private:
static const std::string deviceName;
void test(int x, int y);
+ CWiimote * p;
};
};
More information about the Orxonox-commit
mailing list