Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 2, 2008, 9:31:20 PM (16 years ago)
Author:
rgrieder
Message:
  • SpaceShip is now a default listener for mouse input. still a hack..
  • several changes in InputManager.cc regarding joy sticks
  • Key bindings work, but not very advanced
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/input/src/core/InputManager.cc

    r1213 r1215  
    5555  {
    5656    RegisterObject(InputManager);
     57
     58    this->joySticks_.reserve(5);
     59    //this->activeJoyStickHandlers_.reserve(10);
     60    this->activeKeyHandlers_.reserve(10);
     61    this->activeMouseHandlers_.reserve(10);
    5762  }
    5863
     
    242247        {
    243248          OIS::JoyStick* stig = static_cast<OIS::JoyStick*>(inputSystem_->createInputObject(OIS::OISJoyStick, true));
    244           joySticks_[stig->getID()] = stig;
     249          joySticks_.push_back(stig);
    245250          // register our listener in OIS.
    246251          stig->setEventCallback(this);
     
    278283        delete keyHandlers_["keybinder"];
    279284
    280       activeKeyHandlers_.clear();
    281       activeMouseHandlers_.clear();
    282       activeJoyStickHandlers_.clear();
    283285      keyHandlers_.clear();
    284286      mouseHandlers_.clear();
    285287      joyStickHandlers_.clear();
    286 
    287       keysDown_.clear();
    288       mouseButtonsDown_.clear();
    289       joyStickButtonsDown_.clear();
    290288
    291289      _destroyKeyboard();
     
    314312      inputSystem_->destroyInputObject(keyboard_);
    315313    keyboard_ = 0;
     314    activeKeyHandlers_.clear();
     315    keysDown_.clear();
    316316    CCOUT(ORX_DEBUG) << "Keyboard destroyed." << std::endl;
    317317  }
     
    326326      inputSystem_->destroyInputObject(mouse_);
    327327    mouse_ = 0;
     328    activeMouseHandlers_.clear();
     329    mouseButtonsDown_.clear();
    328330    CCOUT(ORX_DEBUG) << "Mouse destroyed." << std::endl;
    329331  }
     
    337339    {
    338340      // note: inputSystem_ can never be 0, or else the code is mistaken
    339       for (std::map<int, OIS::JoyStick*>::iterator itstick = joySticks_.begin(); itstick != joySticks_.end(); itstick++)
    340       {
    341         if ((*itstick).second != 0)
    342           inputSystem_->destroyInputObject((*itstick).second);
    343       }
     341      for (unsigned int i = 0; i < joySticks_.size(); i++)
     342        if (joySticks_[i] != 0)
     343          inputSystem_->destroyInputObject(joySticks_[i]);
     344
    344345      joySticks_.clear();
     346      activeJoyStickHandlers_.clear();
     347      joyStickButtonsDown_.clear();
    345348    }
    346349    CCOUT(ORX_DEBUG) << "Joy sticks destroyed." << std::endl;
     
    375378        case IS_NORMAL:
    376379          // normal play mode
    377           if (keyHandlers_.find("keybinder") != keyHandlers_.end())
    378             activeKeyHandlers_.push_back(keyHandlers_["keybinder"]);
    379           if (mouseHandlers_.find("keybinder") != mouseHandlers_.end())
    380             activeMouseHandlers_.push_back(mouseHandlers_["keybinder"]);
    381           if (joyStickHandlers_.find("keybinder") != joyStickHandlers_.end())
    382           {
    383             for (std::map<int, OIS::JoyStick*>::const_iterator it = joySticks_.begin();
    384                   it != joySticks_.end(); it++)
    385               activeJoyStickHandlers_[(*it).first].push_back(joyStickHandlers_["keybinder"]);
    386           }
     380          // note: we assume that the handlers exist since otherwise, something's wrong anyway.
     381          activeKeyHandlers_.push_back(keyHandlers_["keybinder"]);
     382          activeMouseHandlers_.push_back(mouseHandlers_["keybinder"]);
     383          activeMouseHandlers_.push_back(mouseHandlers_["SpaceShip"]);
     384          for (std::vector<OIS::JoyStick*>::const_iterator it = joySticks_.begin();
     385                it != joySticks_.end(); it++)
     386            activeJoyStickHandlers_[*it].push_back(joyStickHandlers_["keybinder"]);
    387387          break;
    388388
     
    392392
    393393        case IS_CONSOLE:
    394           if (mouseHandlers_.find("keybinder") != mouseHandlers_.end())
    395             activeMouseHandlers_.push_back(mouseHandlers_["keybinder"]);
    396           if (joyStickHandlers_.find("keybinder") != joyStickHandlers_.end())
    397           {
    398             for (std::map<int, OIS::JoyStick*>::const_iterator it = joySticks_.begin();
    399                   it != joySticks_.end(); it++)
    400               activeJoyStickHandlers_[(*it).first].push_back(joyStickHandlers_["keybinder"]);
    401           }
    402 
    403           if (keyHandlers_.find("buffer") != keyHandlers_.end())
    404             activeKeyHandlers_.push_back(keyHandlers_["buffer"]);
    405           else
    406           {
    407             // someone fiddled with the InputBuffer
    408             CCOUT(2) << "Error: Cannot redirect input to console, InputBuffer instance missing." << std::endl;
    409             if (keyHandlers_.find("keybinder") != keyHandlers_.end())
    410               activeKeyHandlers_.push_back(keyHandlers_["keybinder"]);
    411             else
    412               // this is bad
    413               CCOUT(2) << "Error: Cannot reactivate key binder: not found!" << std::endl;
    414           }
     394          activeMouseHandlers_.push_back(mouseHandlers_["keybinder"]);
     395          for (std::vector<OIS::JoyStick*>::const_iterator it = joySticks_.begin();
     396                it != joySticks_.end(); it++)
     397            activeJoyStickHandlers_[*it].push_back(joyStickHandlers_["keybinder"]);
     398
     399          activeKeyHandlers_.push_back(keyHandlers_["buffer"]);
    415400          break;
    416401
     
    434419    {
    435420      OIS::KeyEvent keyArg(keyboard_, *itKey, 0);
    436       for (std::list<KeyHandler*>::const_iterator itKeyHandler = activeKeyHandlers_.begin();
    437             itKeyHandler != activeKeyHandlers_.end(); itKeyHandler++)
    438       {
    439         (*itKeyHandler)->keyHeld(keyArg);
    440       }
     421      for (unsigned int i = 0; i < activeKeyHandlers_.size(); i++)
     422        activeKeyHandlers_[i]->keyHeld(keyArg);
    441423    }
    442424
     
    446428    {
    447429      OIS::MouseEvent mouseButtonArg(mouse_, mouse_->getMouseState());
    448       for (std::list<MouseHandler*>::const_iterator itMouseHandler = activeMouseHandlers_.begin();
    449             itMouseHandler != activeMouseHandlers_.end(); itMouseHandler++)
    450       {
    451         (*itMouseHandler)->mouseHeld(mouseButtonArg, *itMouseButton);
    452       }
     430      for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
     431        activeMouseHandlers_[i]->mouseHeld(mouseButtonArg, *itMouseButton);
    453432    }
    454433
    455434    // call all the handlers for the held joy stick button events
    456     for (std::map<int, std::list <int> >::const_iterator itJoyStick = joyStickButtonsDown_.begin();
     435    for (std::map< OIS::JoyStick*, std::list <int> >::const_iterator itJoyStick = joyStickButtonsDown_.begin();
    457436          itJoyStick != joyStickButtonsDown_.end(); itJoyStick++)
    458437    {
    459       int id = (*itJoyStick).first;
     438      OIS::JoyStick* joyStick = (*itJoyStick).first;
    460439      for (std::list<int>::const_iterator itJoyStickButton = (*itJoyStick).second.begin();
    461440            itJoyStickButton != (*itJoyStick).second.end(); itJoyStickButton++)
    462441      {
    463         OIS::JoyStickEvent joyStickButtonArg(joySticks_[id], joySticks_[id]->getJoyStickState());
    464         for (std::list<JoyStickHandler*>::const_iterator itJoyStickHandler = activeJoyStickHandlers_[id].begin();
    465               itJoyStickHandler != activeJoyStickHandlers_[id].end(); itJoyStickHandler++)
    466         {
    467           (*itJoyStickHandler)->buttonHeld(joyStickButtonArg, *itJoyStickButton);
    468         }
    469       }
    470     }
    471   }
    472 
     442        OIS::JoyStickEvent joyStickButtonArg(joyStick, joyStick->getJoyStickState());
     443        for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
     444          activeJoyStickHandlers_[joyStick][i]->buttonHeld(i, joyStickButtonArg, *itJoyStickButton);
     445      }
     446    }
     447  }
     448
     449
     450  // ###### Key Events ######
    473451
    474452  /**
     
    478456  bool InputManager::keyPressed(const OIS::KeyEvent &e)
    479457  {
    480     // check whether the key is already in the list (can happen when focus was lost)
     458    // check whether the key already is in the list (can happen when focus was lost)
    481459    for (std::list<OIS::KeyCode>::iterator it = keysDown_.begin(); it != keysDown_.end(); it++)
    482460    {
     
    489467    keysDown_.push_back(e.key);
    490468
    491     for (std::list<KeyHandler*>::const_iterator it = activeKeyHandlers_.begin(); it != activeKeyHandlers_.end(); it++)
    492       (*it)->keyPressed(e);
     469    for (unsigned int i = 0; i < activeKeyHandlers_.size(); i++)
     470      activeKeyHandlers_[i]->keyPressed(e);
    493471
    494472    return true;
     
    511489    }
    512490
    513     for (std::list<KeyHandler*>::const_iterator it = activeKeyHandlers_.begin(); it != activeKeyHandlers_.end(); it++)
    514       (*it)->keyReleased(e);
    515 
    516     return true;
    517   }
     491    for (unsigned int i = 0; i < activeKeyHandlers_.size(); i++)
     492      activeKeyHandlers_[i]->keyReleased(e);
     493
     494    return true;
     495  }
     496
     497
     498  // ###### Mouse Events ######
    518499
    519500  /**
     
    523504  bool InputManager::mouseMoved(const OIS::MouseEvent &e)
    524505  {
    525     for (std::list<MouseHandler*>::const_iterator it = activeMouseHandlers_.begin(); it != activeMouseHandlers_.end(); it++)
    526       (*it)->mouseMoved(e);
     506    for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
     507      activeMouseHandlers_[i]->mouseMoved(e);
    527508
    528509    return true;
     
    536517  bool InputManager::mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id)
    537518  {
    538     // check whether the button is already in the list (can happen when focus was lost)
     519    // check whether the button already is in the list (can happen when focus was lost)
    539520    for (std::list<OIS::MouseButtonID>::iterator it = mouseButtonsDown_.begin(); it != mouseButtonsDown_.end(); it++)
    540521    {
     
    547528    mouseButtonsDown_.push_back(id);
    548529
    549     for (std::list<MouseHandler*>::const_iterator it = activeMouseHandlers_.begin(); it != activeMouseHandlers_.end(); it++)
    550       (*it)->mousePressed(e, id);
     530    for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
     531      activeMouseHandlers_[i]->mousePressed(e, id);
    551532
    552533    return true;
     
    570551    }
    571552
    572     for (std::list<MouseHandler*>::const_iterator it = activeMouseHandlers_.begin(); it != activeMouseHandlers_.end(); it++)
    573       (*it)->mouseReleased(e, id);
    574 
    575     return true;
    576   }
     553    for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
     554      activeMouseHandlers_[i]->mouseReleased(e, id);
     555
     556    return true;
     557  }
     558
     559
     560  // ###### Joy Stick Events ######
    577561
    578562  bool InputManager::buttonPressed(const OIS::JoyStickEvent &arg, int button)
    579563  {
    580     int devID = arg.device->getID();
    581 
    582     // check whether the button is already in the list (can happen when focus was lost)
    583     std::list<int>& buttonsDownList = joyStickButtonsDown_[devID];
     564    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
     565
     566    // check whether the button already is in the list (can happen when focus was lost)
     567    std::list<int>& buttonsDownList = joyStickButtonsDown_[joyStick];
    584568    for (std::list<int>::iterator it = buttonsDownList.begin(); it != buttonsDownList.end(); it++)
    585569    {
     
    590574      }
    591575    }
    592     joyStickButtonsDown_[devID].push_back(button);
    593 
    594     std::list<JoyStickHandler*>::iterator end = activeJoyStickHandlers_[devID].end();
    595     for (std::list<JoyStickHandler*>::const_iterator it = activeJoyStickHandlers_[devID].begin(); it != end; it++)
    596       (*it)->buttonPressed(arg, button);
     576    joyStickButtonsDown_[joyStick].push_back(button);
     577
     578    for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
     579      activeJoyStickHandlers_[joyStick][i]->buttonPressed(i, arg, button);
    597580
    598581    return true;
     
    601584  bool InputManager::buttonReleased(const OIS::JoyStickEvent &arg, int button)
    602585  {
    603     int devID = arg.device->getID();
     586    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
    604587
    605588    // remove the button from the joyStickButtonsDown_ list
    606     std::list<int>& buttonsDownList = joyStickButtonsDown_[devID];
     589    std::list<int>& buttonsDownList = joyStickButtonsDown_[joyStick];
    607590    for (std::list<int>::iterator it = buttonsDownList.begin(); it != buttonsDownList.end(); it++)
    608591    {
     
    614597    }
    615598
    616     std::list<JoyStickHandler*>::const_iterator end = activeJoyStickHandlers_[devID].end();
    617     for (std::list<JoyStickHandler*>::const_iterator it = activeJoyStickHandlers_[devID].begin(); it != end; it++)
    618       (*it)->buttonReleased(arg, button);
     599    for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
     600      activeJoyStickHandlers_[joyStick][i]->buttonReleased(i, arg, button);
    619601
    620602    return true;
     
    623605  bool InputManager::axisMoved(const OIS::JoyStickEvent &arg, int axis)
    624606  {
    625     int devID = arg.device->getID();
    626     std::list<JoyStickHandler*>::const_iterator end = activeJoyStickHandlers_[devID].end();
    627     for (std::list<JoyStickHandler*>::const_iterator it = activeJoyStickHandlers_[devID].begin(); it != end; it++)
    628       (*it)->axisMoved(arg, axis);
     607    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
     608    for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
     609      activeJoyStickHandlers_[joyStick][i]->axisMoved(i, arg, axis);
    629610
    630611    return true;
     
    633614  bool InputManager::sliderMoved(const OIS::JoyStickEvent &arg, int id)
    634615  {
    635     int devID = arg.device->getID();
    636     std::list<JoyStickHandler*>::const_iterator end = activeJoyStickHandlers_[devID].end();
    637     for (std::list<JoyStickHandler*>::const_iterator it = activeJoyStickHandlers_[devID].begin(); it != end; it++)
    638       (*it)->sliderMoved(arg, id);
     616    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
     617    for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
     618      activeJoyStickHandlers_[joyStick][i]->sliderMoved(i, arg, id);
    639619
    640620    return true;
     
    643623  bool InputManager::povMoved(const OIS::JoyStickEvent &arg, int id)
    644624  {
    645     int devID = arg.device->getID();
    646     std::list<JoyStickHandler*>::const_iterator end = activeJoyStickHandlers_[devID].end();
    647     for (std::list<JoyStickHandler*>::const_iterator it = activeJoyStickHandlers_[devID].begin(); it != end; it++)
    648       (*it)->povMoved(arg, id);
     625    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
     626    for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
     627      activeJoyStickHandlers_[joyStick][i]->povMoved(i, arg, id);
     628
     629    return true;
     630  }
     631
     632  bool InputManager::vector3Moved(const OIS::JoyStickEvent &arg, int id)
     633  {
     634    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
     635    for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
     636      activeJoyStickHandlers_[joyStick][i]->vector3Moved(i, arg, id);
    649637
    650638    return true;
     
    679667  }
    680668
    681   bool InputManager::isKeyboardInitialised()
    682   {
    683     return (_getSingleton().keyboard_ != 0);
    684   }
    685 
    686   bool InputManager::isMouseInitialised()
    687   {
    688     return (_getSingleton().mouse_ != 0);
    689   }
    690 
    691   bool InputManager::areJoySticksInitialised()
    692   {
    693     return (_getSingleton().joySticks_.size() > 0);
     669  int InputManager::numberOfKeyboards()
     670  {
     671    if (_getSingleton().keyboard_ != 0)
     672      return 1;
     673    else
     674      return 0;
     675  }
     676
     677  int InputManager::numberOfMice()
     678  {
     679    if (_getSingleton().mouse_ != 0)
     680      return 1;
     681    else
     682      return 0;
     683  }
     684
     685  int InputManager::numberOfJoySticks()
     686  {
     687    return _getSingleton().joySticks_.size();
    694688  }
    695689
     
    817811    if (mapIt == _getSingleton().keyHandlers_.end())
    818812      return false;
    819     // see whether the handler is already in the list
    820     for (std::list<KeyHandler*>::iterator it = _getSingleton().activeKeyHandlers_.begin();
     813    // see whether the handler already is in the list
     814    for (std::vector<KeyHandler*>::iterator it = _getSingleton().activeKeyHandlers_.begin();
    821815          it != _getSingleton().activeKeyHandlers_.end(); it++)
    822816    {
     
    844838      return false;
    845839    // look for the handler in the list
    846     for (std::list<KeyHandler*>::iterator it = _getSingleton().activeKeyHandlers_.begin();
     840    for (std::vector<KeyHandler*>::iterator it = _getSingleton().activeKeyHandlers_.begin();
    847841          it != _getSingleton().activeKeyHandlers_.end(); it++)
    848842    {
     
    869863    if (mapIt == _getSingleton().keyHandlers_.end())
    870864      return false;
    871     // see whether the handler is already in the list
    872     for (std::list<KeyHandler*>::iterator it = _getSingleton().activeKeyHandlers_.begin();
     865    // see whether the handler already is in the list
     866    for (std::vector<KeyHandler*>::iterator it = _getSingleton().activeKeyHandlers_.begin();
    873867          it != _getSingleton().activeKeyHandlers_.end(); it++)
    874868    {
     
    943937    if (mapIt == _getSingleton().mouseHandlers_.end())
    944938      return false;
    945     // see whether the handler is already in the list
    946     for (std::list<MouseHandler*>::iterator it = _getSingleton().activeMouseHandlers_.begin();
     939    // see whether the handler already is in the list
     940    for (std::vector<MouseHandler*>::iterator it = _getSingleton().activeMouseHandlers_.begin();
    947941          it != _getSingleton().activeMouseHandlers_.end(); it++)
    948942    {
     
    970964      return false;
    971965    // look for the handler in the list
    972     for (std::list<MouseHandler*>::iterator it = _getSingleton().activeMouseHandlers_.begin();
     966    for (std::vector<MouseHandler*>::iterator it = _getSingleton().activeMouseHandlers_.begin();
    973967          it != _getSingleton().activeMouseHandlers_.end(); it++)
    974968    {
     
    995989    if (mapIt == _getSingleton().mouseHandlers_.end())
    996990      return false;
    997     // see whether the handler is already in the list
    998     for (std::list<MouseHandler*>::iterator it = _getSingleton().activeMouseHandlers_.begin();
     991    // see whether the handler already is in the list
     992    for (std::vector<MouseHandler*>::iterator it = _getSingleton().activeMouseHandlers_.begin();
    999993          it != _getSingleton().activeMouseHandlers_.end(); it++)
    1000994    {
     
    10321026  bool InputManager::removeJoyStickHandler(const std::string &name)
    10331027  {
    1034     for (std::map<int, OIS::JoyStick*>::iterator itstick = _getSingleton().joySticks_.begin(); itstick != _getSingleton().joySticks_.end(); itstick++)
    1035       disableJoyStickHandler(name, (*itstick).first);
     1028    for (std::vector<OIS::JoyStick*>::iterator itstick = _getSingleton().joySticks_.begin();
     1029          itstick != _getSingleton().joySticks_.end(); itstick++)
     1030      disableJoyStickHandler(name, itstick - _getSingleton().joySticks_.begin());
    10361031
    10371032    std::map<std::string, JoyStickHandler*>::iterator it = _getSingleton().joyStickHandlers_.find(name);
     
    10661061    @return False if name or id was not found, true otherwise.
    10671062  */
    1068   bool InputManager::enableJoyStickHandler(const std::string& name, const int id)
    1069   {
    1070     // get pointer from the map with all stored handlers
     1063  bool InputManager::enableJoyStickHandler(const std::string& name, const int ID)
     1064  {
     1065    // get handler pointer from the map with all stored handlers
    10711066    std::map<std::string, JoyStickHandler*>::const_iterator handlerIt = _getSingleton().joyStickHandlers_.find(name);
    10721067    if (handlerIt == _getSingleton().joyStickHandlers_.end())
    10731068      return false;
    10741069
    1075     // check for existance of the ID
    1076     std::map<int, OIS::JoyStick*>::const_iterator joyStickIt = _getSingleton().joySticks_.find(id);
    1077     if (joyStickIt == _getSingleton().joySticks_.end())
    1078       return false;
    1079 
    1080     // see whether the handler is already in the list
    1081     for (std::list<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[id].begin();
    1082           it != _getSingleton().activeJoyStickHandlers_[id].end(); it++)
     1070    // check for existence of the ID
     1071    if ((unsigned int)ID >= _getSingleton().joySticks_.size())
     1072      return false;
     1073    OIS::JoyStick* joyStick = _getSingleton().joySticks_[ID];
     1074
     1075    // see whether the handler already is in the list
     1076    for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[joyStick].begin();
     1077          it != _getSingleton().activeJoyStickHandlers_[joyStick].end(); it++)
    10831078    {
    10841079      if ((*it) == (*handlerIt).second)
     
    10881083      }
    10891084    }
    1090     _getSingleton().activeJoyStickHandlers_[id].push_back((*handlerIt).second);
     1085    _getSingleton().activeJoyStickHandlers_[joyStick].push_back((*handlerIt).second);
    10911086    _getSingleton().stateRequest_ = IS_CUSTOM;
    10921087    return true;
     
    10981093    @return False if name or id was not found, true otherwise.
    10991094  */
    1100   bool InputManager::disableJoyStickHandler(const std::string &name, int id)
    1101   {
    1102     // get pointer from the map with all stored handlers
     1095  bool InputManager::disableJoyStickHandler(const std::string &name, int ID)
     1096  {
     1097    // get handler pointer from the map with all stored handlers
    11031098    std::map<std::string, JoyStickHandler*>::const_iterator handlerIt = _getSingleton().joyStickHandlers_.find(name);
    11041099    if (handlerIt == _getSingleton().joyStickHandlers_.end())
    11051100      return false;
    11061101
    1107     // check for existance of the ID
    1108     std::map<int, OIS::JoyStick*>::const_iterator joyStickIt = _getSingleton().joySticks_.find(id);
    1109     if (joyStickIt == _getSingleton().joySticks_.end())
    1110       return false;
     1102    // check for existence of the ID
     1103    if ((unsigned int)ID >= _getSingleton().joySticks_.size())
     1104      return false;
     1105    OIS::JoyStick* joyStick = _getSingleton().joySticks_[ID];
    11111106
    11121107    // look for the handler in the list
    1113     for (std::list<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[id].begin();
    1114           it != _getSingleton().activeJoyStickHandlers_[id].end(); it++)
     1108    for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[joyStick].begin();
     1109          it != _getSingleton().activeJoyStickHandlers_[joyStick].end(); it++)
    11151110    {
    11161111      if ((*it) == (*handlerIt).second)
    11171112      {
    1118         _getSingleton().activeJoyStickHandlers_[id].erase(it);
     1113        _getSingleton().activeJoyStickHandlers_[joyStick].erase(it);
    11191114        _getSingleton().stateRequest_ = IS_CUSTOM;
    11201115        return true;
    11211116      }
    11221117    }
    1123     _getSingleton().stateRequest_ = IS_CUSTOM;
    11241118    return true;
    11251119  }
     
    11301124    @return False if key handler is not active or doesn't exist, true otherwise.
    11311125  */
    1132   bool InputManager::isJoyStickHandlerActive(const std::string& name, const int id)
    1133   {
    1134     // get pointer from the map with all stored handlers
     1126  bool InputManager::isJoyStickHandlerActive(const std::string& name, const int ID)
     1127  {
     1128    // get handler pointer from the map with all stored handlers
    11351129    std::map<std::string, JoyStickHandler*>::const_iterator handlerIt = _getSingleton().joyStickHandlers_.find(name);
    11361130    if (handlerIt == _getSingleton().joyStickHandlers_.end())
    11371131      return false;
    11381132
    1139     // check for existance of the ID
    1140     std::map<int, OIS::JoyStick*>::const_iterator joyStickIt = _getSingleton().joySticks_.find(id);
    1141     if (joyStickIt == _getSingleton().joySticks_.end())
    1142       return false;
    1143 
    1144     // see whether the handler is already in the list
    1145     for (std::list<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[id].begin();
    1146           it != _getSingleton().activeJoyStickHandlers_[id].end(); it++)
     1133    // check for existence of the ID
     1134    if ((unsigned int)ID >= _getSingleton().joySticks_.size())
     1135      return false;
     1136    OIS::JoyStick* joyStick = _getSingleton().joySticks_[ID];
     1137
     1138    // see whether the handler already is in the list
     1139    for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[joyStick].begin();
     1140          it != _getSingleton().activeJoyStickHandlers_[joyStick].end(); it++)
    11471141    {
    11481142      if ((*it) == (*handlerIt).second)
Note: See TracChangeset for help on using the changeset viewer.