Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9790


Ignore:
Timestamp:
Nov 18, 2013, 4:07:28 PM (10 years ago)
Author:
georgr
Message:

debug outputs added

Location:
code/branches/wiimote/src/libraries/core
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/wiimote/src/libraries/core/CMakeLists.txt

    r9667 r9790  
    9999    cpptcl_orxonox
    100100    ois_orxonox
     101    wiic_orxonox
     102    wiicpp_orxonox
    101103    tinyxml_orxonox
    102104    util
  • code/branches/wiimote/src/libraries/core/input/InputManager.cc

    r9723 r9790  
    6060#include "WiiMote.h"
    6161
     62
    6263namespace orxonox
    6364{
     
    217218        this->loadMouse();
    218219        this->loadJoySticks();
    219 
     220        this->loadWiiMote();
    220221        // Reorder states in case some joy sticks were added/removed
    221222        this->updateActiveStates();
    222         this->loadWiiMote();
     223
    223224        orxout(verbose, context::input) << "Input devices loaded." << endl;
    224225    }
     226
    225227    void InputManager::loadWiiMote()
    226228    {
    227         try
     229
     230        CWii wii; // Defaults to 4 remotes
     231        std::vector< ::CWiimote>::iterator i;
     232        int reloadWiimotes = 0;
     233        int index;
     234
     235        // Find and connect to the wiimotes
     236        std::vector<CWiimote>& wiimotes = wii.FindAndConnect();
     237        if (!wiimotes.size())
    228238        {
    229                 devices_.push_back(new WiiMote(234));
     239                cout << "No wiimotes found." << endl;
     240                }
     241
     242            // Setup the wiimotes
     243            for(index = 0, i = wiimotes.begin(); i != wiimotes.end(); ++i, ++index)
     244            {
     245                // Use a reference to make working with the iterator handy.
     246            CWiimote & wiimote = *i;
     247
     248            //Set Leds
     249            int LED_MAP[4] =
     250              {CWiimote::LED_1, CWiimote::LED_2,
     251               CWiimote::LED_3, CWiimote::LED_4};
     252            wiimote.SetLEDs(LED_MAP[index]);
     253
     254
    230255        }
    231         catch(std::exception& e)  //gotta catch em all
    232         {
    233                 orxout()<<"Exception loading WiiMote!!!1!11!";
    234         }
     256            try
     257            {
     258                orxout()<<devices_.size();
     259                    devices_.push_back(new WiiMote(devices_.size(), *(new CWiimote())));
     260                //devices_[2] = new WiiMote(devices_.size(), *(new CWiimote()));
     261
     262            }
     263            catch(std::exception& e)  //gotta catch em all
     264            {
     265                      orxout()<<"Exception loading WiiMote!!!1!11!";
     266            }
     267
    235268    }
    236269    //! Creates a new orxonox::Mouse
     
    436469            for (std::map<int, InputState*>::reverse_iterator rit = activeStates_.rbegin(); rit != activeStates_.rend(); ++rit)
    437470            {
    438                 if (rit->second->isInputDeviceEnabled(i) && (!occupied || rit->second->bAlwaysGetsInput_))
     471                orxout() << "Checking ID " << i <<std::endl;
     472                orxout() << "Checking condition 1: " << rit->second->isInputDeviceEnabled(i) <<std::endl;
     473                orxout() << "Checking condition 2: " << rit->second->bAlwaysGetsInput_ <<std::endl;
     474                orxout() << "Checking condition 3: " << !occupied <<std::endl;
     475                if (rit->second->isInputDeviceEnabled(i) && (!occupied || rit->second->bAlwaysGetsInput_))
    439476                {
     477                        orxout() << "Success with ID " << i <<std::endl;
    440478                    states.push_back(rit->second);
    441479                    if (!rit->second->bTransparent_)
  • code/branches/wiimote/src/libraries/core/input/InputState.cc

    r8729 r9790  
    5555    {
    5656        if (device < handlers_.size())
     57        {       orxout() << "Test we made it into the if clause" << std::endl;
    5758            return handlers_[device] != NULL;
     59        }
    5860        else
    5961            return false;
  • code/branches/wiimote/src/libraries/core/input/WiiMote.cc

    r9780 r9790  
    1010        void WiiMote::update(const Clock& time)
    1111        {
    12                 orxout()<<"fegit\n";
    13 
     12                orxout(user_warning) << this->inputStates_.size() << std::endl;
    1413        }
    1514        void WiiMote::clearBuffers()
     
    2120
    2221        }
    23         WiiMote::WiiMote(unsigned int id)  : InputDevice(id)
     22        WiiMote::WiiMote(unsigned int id, CWiimote & parent)  : InputDevice(id)
    2423        {
     24                p = &parent;
    2525        }
    2626}
  • code/branches/wiimote/src/libraries/core/input/WiiMote.h

    r9723 r9790  
    11
    22#include "InputDevice.h"
    3 //#include "InputState.h"
    43//#include "InputManager.h"
     4
     5#include <wiicpp/wiicpp/wiicpp.h>
    56
    67
     
    89namespace orxonox
    910{
     11
     12
     13
     14
    1015        class WiiMote : public InputDevice
    1116        {
     17
    1218         public:
    1319                        //! Only resets the members
    14                 WiiMote(unsigned int id);
     20                WiiMote(unsigned int id, CWiimote & parent);
    1521                ~WiiMote() { }
    1622                //! Returns the device class (derived) name as string
     
    2632                 //! List of all input states that receive events from this device
    2733                 std::vector<InputState*> inputStates_;
     34
    2835         private:
    2936                 static const std::string deviceName;
    3037                 void test(int x, int y);
     38                 CWiimote * p;
    3139        };
    3240};
Note: See TracChangeset for help on using the changeset viewer.