Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

debug outputs added

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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_)
Note: See TracChangeset for help on using the changeset viewer.