Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 14, 2008, 11:44:17 AM (17 years ago)
Author:
rgrieder
Message:

merged input branch into merge branch

File:
1 edited

Legend:

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

    r1268 r1272  
    3030  @file
    3131  @brief Implementation of the InputManager that captures all the input from OIS
    32          and redirects it to handlers if necessary.
     32         and redirects it to handlers.
    3333 */
    3434
     
    5252  InputManager::InputManager() :
    5353      inputSystem_(0), keyboard_(0), mouse_(0),
    54       state_(IS_UNINIT), stateRequest_(IS_UNINIT)
     54      joySticksSize_(0),
     55      state_(IS_UNINIT), stateRequest_(IS_UNINIT),
     56      keyboardModifiers_(0)
    5557  {
    5658    RegisterObject(InputManager);
    57 
    58     this->joySticks_.reserve(5);
    59     //this->activeJoyStickHandlers_.reserve(10);
    60     this->activeKeyHandlers_.reserve(10);
    61     this->activeMouseHandlers_.reserve(10);
    6259  }
    6360
     
    8784    @param windowHeight The height of the render window
    8885  */
    89   bool InputManager::_initialise(const size_t windowHnd, const int windowWidth, const int windowHeight,
    90         const bool createKeyboard, const bool createMouse, const bool createJoySticks)
     86  bool InputManager::_initialise(const size_t windowHnd, int windowWidth, int windowHeight,
     87        bool createKeyboard, bool createMouse, bool createJoySticks)
    9188  {
    9289    if (state_ == IS_UNINIT)
     
    146143    addKeyHandler(binder, "keybinder");
    147144    addMouseHandler(binder, "keybinder");
     145    addJoyStickHandler(binder, "keybinder");
    148146
    149147    // Read all the key bindings and assign them
     
    235233  bool InputManager::_initialiseJoySticks()
    236234  {
    237     if (joySticks_.size() > 0)
     235    if (joySticksSize_ > 0)
    238236    {
    239237      CCOUT(2) << "Warning: Joy sticks already initialised, skipping." << std::endl;
     
    266264      return false;
    267265    }
     266    joySticksSize_ = joySticks_.size();
     267    activeJoyStickHandlers_.resize(joySticksSize_);
     268    joyStickButtonsDown_.resize(joySticksSize_);
    268269    return success;
    269270  }
     
    337338  void InputManager::_destroyJoySticks()
    338339  {
    339     if (joySticks_.size() > 0)
     340    if (joySticksSize_ > 0)
    340341    {
    341342      // note: inputSystem_ can never be 0, or else the code is mistaken
    342       for (unsigned int i = 0; i < joySticks_.size(); i++)
     343      for (unsigned int i = 0; i < joySticksSize_; i++)
    343344        if (joySticks_[i] != 0)
    344345          inputSystem_->destroyInputObject(joySticks_[i]);
    345346
    346347      joySticks_.clear();
     348      joySticksSize_ = 0;
    347349      activeJoyStickHandlers_.clear();
    348350      joyStickButtonsDown_.clear();
     
    373375        activeKeyHandlers_.clear();
    374376        activeMouseHandlers_.clear();
    375         activeJoyStickHandlers_.clear();
     377        for (unsigned int i = 0; i < joySticksSize_; i++)
     378          activeJoyStickHandlers_[i].clear();
    376379
    377380        switch (stateRequest_)
     
    383386          activeMouseHandlers_.push_back(mouseHandlers_["keybinder"]);
    384387          activeMouseHandlers_.push_back(mouseHandlers_["SpaceShip"]);
    385           for (std::vector<OIS::JoyStick*>::const_iterator it = joySticks_.begin();
    386                 it != joySticks_.end(); it++)
    387             activeJoyStickHandlers_[*it].push_back(joyStickHandlers_["keybinder"]);
     388          for (unsigned int i = 0; i < joySticksSize_; i++)
     389            activeJoyStickHandlers_[i].push_back(joyStickHandlers_["keybinder"]);
    388390          break;
    389391
     
    394396        case IS_CONSOLE:
    395397          activeMouseHandlers_.push_back(mouseHandlers_["keybinder"]);
    396           for (std::vector<OIS::JoyStick*>::const_iterator it = joySticks_.begin();
    397                 it != joySticks_.end(); it++)
    398             activeJoyStickHandlers_[*it].push_back(joyStickHandlers_["keybinder"]);
     398          activeMouseHandlers_.push_back(mouseHandlers_["SpaceShip"]);
     399          for (unsigned int i = 0; i < joySticksSize_; i++)
     400            activeJoyStickHandlers_[i].push_back(joyStickHandlers_["keybinder"]);
    399401
    400402          activeKeyHandlers_.push_back(keyHandlers_["buffer"]);
     
    413415    if (keyboard_)
    414416      keyboard_->capture();
     417    for (unsigned  int i = 0; i < joySticksSize_; i++)
     418      joySticks_[i]->capture();
    415419
    416420
    417421    // call all the handlers for the held key events
    418     for (std::list<OIS::KeyCode>::const_iterator itKey = keysDown_.begin();
    419           itKey != keysDown_.end(); itKey++)
    420     {
    421       OIS::KeyEvent keyArg(keyboard_, *itKey, 0);
    422       for (unsigned int i = 0; i < activeKeyHandlers_.size(); i++)
    423         activeKeyHandlers_[i]->keyHeld(keyArg);
    424     }
     422    for (unsigned int iKey = 0; iKey < keysDown_.size(); iKey++)
     423      for (unsigned int iHandler = 0; iHandler < activeKeyHandlers_.size(); iHandler++)
     424        activeKeyHandlers_[iHandler]->keyHeld(KeyEvent(keysDown_[iKey], keyboardModifiers_));
    425425
    426426    // call all the handlers for the held mouse button events
    427     for (std::list<OIS::MouseButtonID>::const_iterator itMouseButton = mouseButtonsDown_.begin();
    428           itMouseButton != mouseButtonsDown_.end(); itMouseButton++)
    429     {
    430       OIS::MouseEvent mouseButtonArg(mouse_, mouse_->getMouseState());
    431       for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
    432         activeMouseHandlers_[i]->mouseHeld(mouseButtonArg, *itMouseButton);
    433     }
     427    for (unsigned int iButton = 0; iButton < mouseButtonsDown_.size(); iButton++)
     428      for (unsigned int iHandler = 0; iHandler < activeMouseHandlers_.size(); iHandler++)
     429        activeMouseHandlers_[iHandler]->mouseButtonHeld(mouse_->getMouseState(), mouseButtonsDown_[iButton]);
    434430
    435431    // call all the handlers for the held joy stick button events
    436     for (std::map< OIS::JoyStick*, std::list <int> >::const_iterator itJoyStick = joyStickButtonsDown_.begin();
    437           itJoyStick != joyStickButtonsDown_.end(); itJoyStick++)
    438     {
    439       OIS::JoyStick* joyStick = (*itJoyStick).first;
    440       for (std::list<int>::const_iterator itJoyStickButton = (*itJoyStick).second.begin();
    441             itJoyStickButton != (*itJoyStick).second.end(); itJoyStickButton++)
    442       {
    443         OIS::JoyStickEvent joyStickButtonArg(joyStick, joyStick->getJoyStickState());
    444         for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
    445           activeJoyStickHandlers_[joyStick][i]->buttonHeld(i, joyStickButtonArg, *itJoyStickButton);
    446       }
    447     }
    448   }
    449 
     432    for (unsigned int iJoyStick  = 0; iJoyStick < joySticksSize_; iJoyStick++)
     433      for (unsigned int iButton   = 0; iButton   < joyStickButtonsDown_[iJoyStick].size(); iButton++)
     434        for (unsigned int iHandler = 0; iHandler  < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
     435          activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonHeld(
     436              JoyStickState(joySticks_[iJoyStick]->getJoyStickState(), iJoyStick), joyStickButtonsDown_[iJoyStick][iButton]);
     437  }
    450438
    451439  // ###### Key Events ######
     
    458446  {
    459447    // check whether the key already is in the list (can happen when focus was lost)
    460     for (std::list<OIS::KeyCode>::iterator it = keysDown_.begin(); it != keysDown_.end(); it++)
    461     {
    462       if (*it == e.key)
    463       {
    464         keysDown_.erase(it);
    465         break;
    466       }
    467     }
    468     keysDown_.push_back(e.key);
     448    unsigned int iKey = 0;
     449    while (iKey < keysDown_.size() && keysDown_[iKey].key != (KeyCode::Enum)e.key)
     450      iKey++;
     451    if (iKey == keysDown_.size())
     452      keysDown_.push_back(Key(e));
     453
     454    // update modifiers
     455    if(e.key == OIS::KC_RMENU    || e.key == OIS::KC_LMENU)
     456      keyboardModifiers_ |= KeyboardModifier::Alt;   // alt key
     457    if(e.key == OIS::KC_RCONTROL || e.key == OIS::KC_LCONTROL)
     458      keyboardModifiers_ |= KeyboardModifier::Ctrl;  // ctrl key
     459    if(e.key == OIS::KC_RSHIFT   || e.key == OIS::KC_LSHIFT)
     460      keyboardModifiers_ |= KeyboardModifier::Shift; // shift key
    469461
    470462    for (unsigned int i = 0; i < activeKeyHandlers_.size(); i++)
    471       activeKeyHandlers_[i]->keyPressed(e);
     463      activeKeyHandlers_[i]->keyPressed(KeyEvent(e, keyboardModifiers_));
    472464
    473465    return true;
     
    481473  {
    482474    // remove the key from the keysDown_ list
    483     for (std::list<OIS::KeyCode>::iterator it = keysDown_.begin(); it != keysDown_.end(); it++)
    484     {
    485       if (*it == e.key)
    486       {
    487         keysDown_.erase(it);
     475    for (unsigned int iKey = 0; iKey < keysDown_.size(); iKey++)
     476    {
     477      if (keysDown_[iKey].key == (KeyCode::Enum)e.key)
     478      {
     479        keysDown_.erase(keysDown_.begin() + iKey);
    488480        break;
    489481      }
    490482    }
    491483
     484    // update modifiers
     485    if(e.key == OIS::KC_RMENU    || e.key == OIS::KC_LMENU)
     486      keyboardModifiers_ &= ~KeyboardModifier::Alt;   // alt key
     487    if(e.key == OIS::KC_RCONTROL || e.key == OIS::KC_LCONTROL)
     488      keyboardModifiers_ &= ~KeyboardModifier::Ctrl;  // ctrl key
     489    if(e.key == OIS::KC_RSHIFT   || e.key == OIS::KC_LSHIFT)
     490      keyboardModifiers_ &= ~KeyboardModifier::Shift; // shift key
     491
    492492    for (unsigned int i = 0; i < activeKeyHandlers_.size(); i++)
    493       activeKeyHandlers_[i]->keyReleased(e);
     493      activeKeyHandlers_[i]->keyReleased(KeyEvent(e, keyboardModifiers_));
    494494
    495495    return true;
     
    505505  bool InputManager::mouseMoved(const OIS::MouseEvent &e)
    506506  {
    507     for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
    508       activeMouseHandlers_[i]->mouseMoved(e);
     507    // check for actual moved event
     508    if (e.state.X.rel != 0 || e.state.Y.rel != 0)
     509    {
     510      for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
     511        activeMouseHandlers_[i]->mouseMoved(e.state);
     512    }
     513
     514    // check for mouse scrolled event
     515    if (e.state.Z.rel != 0)
     516    {
     517      for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
     518        activeMouseHandlers_[i]->mouseScrolled(e.state);
     519    }
    509520
    510521    return true;
     
    519530  {
    520531    // check whether the button already is in the list (can happen when focus was lost)
    521     for (std::list<OIS::MouseButtonID>::iterator it = mouseButtonsDown_.begin(); it != mouseButtonsDown_.end(); it++)
    522     {
    523       if (*it == id)
    524       {
    525         mouseButtonsDown_.erase(it);
    526         break;
    527       }
    528     }
    529     mouseButtonsDown_.push_back(id);
     532    unsigned int iButton = 0;
     533    while (iButton < mouseButtonsDown_.size() && mouseButtonsDown_[iButton] != (MouseButton::Enum)id)
     534      iButton++;
     535    if (iButton == mouseButtonsDown_.size())
     536      mouseButtonsDown_.push_back((MouseButton::Enum)id);
    530537
    531538    for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
    532       activeMouseHandlers_[i]->mousePressed(e, id);
     539      activeMouseHandlers_[i]->mouseButtonPressed(e.state, (MouseButton::Enum)id);
    533540
    534541    return true;
     
    543550  {
    544551    // remove the button from the keysDown_ list
    545     for (std::list<OIS::MouseButtonID>::iterator it = mouseButtonsDown_.begin(); it != mouseButtonsDown_.end(); it++)
    546     {
    547       if (*it == id)
    548       {
    549         mouseButtonsDown_.erase(it);
     552    for (unsigned int iButton = 0; iButton < mouseButtonsDown_.size(); iButton++)
     553    {
     554      if (mouseButtonsDown_[iButton] == (MouseButton::Enum)id)
     555      {
     556        mouseButtonsDown_.erase(mouseButtonsDown_.begin() + iButton);
    550557        break;
    551558      }
     
    553560
    554561    for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
    555       activeMouseHandlers_[i]->mouseReleased(e, id);
     562      activeMouseHandlers_[i]->mouseButtonReleased(e.state, (MouseButton::Enum)id);
    556563
    557564    return true;
     
    563570  bool InputManager::buttonPressed(const OIS::JoyStickEvent &arg, int button)
    564571  {
     572    // use the device to identify which one called the method
    565573    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
     574    unsigned int iJoyStick = 0;
     575    while (joySticks_[iJoyStick] != joyStick)
     576      iJoyStick++;
    566577
    567578    // check whether the button already is in the list (can happen when focus was lost)
    568     std::list<int>& buttonsDownList = joyStickButtonsDown_[joyStick];
    569     for (std::list<int>::iterator it = buttonsDownList.begin(); it != buttonsDownList.end(); it++)
    570     {
    571       if (*it == button)
    572       {
    573         buttonsDownList.erase(it);
     579    std::vector<int> buttonsDown = joyStickButtonsDown_[iJoyStick];
     580    unsigned int iButton = 0;
     581    while (iButton < buttonsDown.size() && buttonsDown[iButton] != button)
     582      iButton++;
     583    if (iButton == buttonsDown.size())
     584      buttonsDown.push_back(button);
     585
     586    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
     587      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonPressed(JoyStickState(arg.state, iJoyStick), button);
     588
     589    return true;
     590  }
     591
     592  bool InputManager::buttonReleased(const OIS::JoyStickEvent &arg, int button)
     593  {
     594    // use the device to identify which one called the method
     595    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
     596    unsigned int iJoyStick = 0;
     597    while (joySticks_[iJoyStick] != joyStick)
     598      iJoyStick++;
     599
     600    // remove the button from the joyStickButtonsDown_ list
     601    std::vector<int> buttonsDown = joyStickButtonsDown_[iJoyStick];
     602    for (unsigned int iButton = 0; iButton < buttonsDown.size(); iButton++)
     603    {
     604      if (buttonsDown[iButton] == button)
     605      {
     606        buttonsDown.erase(buttonsDown.begin() + iButton);
    574607        break;
    575608      }
    576609    }
    577     joyStickButtonsDown_[joyStick].push_back(button);
    578 
    579     for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
    580       activeJoyStickHandlers_[joyStick][i]->buttonPressed(i, arg, button);
    581 
    582     return true;
    583   }
    584 
    585   bool InputManager::buttonReleased(const OIS::JoyStickEvent &arg, int button)
    586   {
     610
     611    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
     612      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonReleased(JoyStickState(arg.state, iJoyStick), button);
     613
     614    return true;
     615  }
     616
     617  bool InputManager::axisMoved(const OIS::JoyStickEvent &arg, int axis)
     618  {
     619    // use the device to identify which one called the method
    587620    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
    588 
    589     // remove the button from the joyStickButtonsDown_ list
    590     std::list<int>& buttonsDownList = joyStickButtonsDown_[joyStick];
    591     for (std::list<int>::iterator it = buttonsDownList.begin(); it != buttonsDownList.end(); it++)
    592     {
    593       if (*it == button)
    594       {
    595         buttonsDownList.erase(it);
    596         break;
    597       }
    598     }
    599 
    600     for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
    601       activeJoyStickHandlers_[joyStick][i]->buttonReleased(i, arg, button);
    602 
    603     return true;
    604   }
    605 
    606   bool InputManager::axisMoved(const OIS::JoyStickEvent &arg, int axis)
    607   {
     621    unsigned int iJoyStick = 0;
     622    while (joySticks_[iJoyStick] != joyStick)
     623      iJoyStick++;
     624
     625    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
     626      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickAxisMoved(JoyStickState(arg.state, iJoyStick), axis);
     627
     628    return true;
     629  }
     630
     631  bool InputManager::sliderMoved(const OIS::JoyStickEvent &arg, int id)
     632  {
     633    // use the device to identify which one called the method
    608634    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
    609     for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
    610       activeJoyStickHandlers_[joyStick][i]->axisMoved(i, arg, axis);
    611 
    612     return true;
    613   }
    614 
    615   bool InputManager::sliderMoved(const OIS::JoyStickEvent &arg, int id)
    616   {
     635    unsigned int iJoyStick = 0;
     636    while (joySticks_[iJoyStick] != joyStick)
     637      iJoyStick++;
     638
     639    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
     640      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickSliderMoved(JoyStickState(arg.state, iJoyStick), id);
     641
     642    return true;
     643  }
     644
     645  bool InputManager::povMoved(const OIS::JoyStickEvent &arg, int id)
     646  {
     647    // use the device to identify which one called the method
    617648    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
    618     for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
    619       activeJoyStickHandlers_[joyStick][i]->sliderMoved(i, arg, id);
    620 
    621     return true;
    622   }
    623 
    624   bool InputManager::povMoved(const OIS::JoyStickEvent &arg, int id)
    625   {
     649    unsigned int iJoyStick = 0;
     650    while (joySticks_[iJoyStick] != joyStick)
     651      iJoyStick++;
     652
     653    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
     654      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickPovMoved(JoyStickState(arg.state, iJoyStick), id);
     655
     656    return true;
     657  }
     658
     659  bool InputManager::vector3Moved(const OIS::JoyStickEvent &arg, int id)
     660  {
     661    // use the device to identify which one called the method
    626662    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
    627     for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
    628       activeJoyStickHandlers_[joyStick][i]->povMoved(i, arg, id);
    629 
    630     return true;
    631   }
    632 
    633   bool InputManager::vector3Moved(const OIS::JoyStickEvent &arg, int id)
    634   {
    635     OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
    636     for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
    637       activeJoyStickHandlers_[joyStick][i]->vector3Moved(i, arg, id);
     663    unsigned int iJoyStick = 0;
     664    while (joySticks_[iJoyStick] != joyStick)
     665      iJoyStick++;
     666
     667    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
     668      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickVector3Moved(JoyStickState(arg.state, iJoyStick), id);
    638669
    639670    return true;
     
    646677  // ################################
    647678
    648   bool InputManager::initialise(const size_t windowHnd, const int windowWidth, const int windowHeight,
    649     const bool createKeyboard, const bool createMouse, const bool createJoySticks)
     679  bool InputManager::initialise(const size_t windowHnd, int windowWidth, int windowHeight,
     680    bool createKeyboard, bool createMouse, bool createJoySticks)
    650681  {
    651682    return _getSingleton()._initialise(windowHnd, windowWidth, windowHeight,
     
    686717  int InputManager::numberOfJoySticks()
    687718  {
    688     return _getSingleton().joySticks_.size();
     719    return _getSingleton().joySticksSize_;
     720  }
     721
     722  bool InputManager::isKeyDown(KeyCode::Enum key)
     723  {
     724    if (_getSingleton().keyboard_)
     725      return _getSingleton().keyboard_->isKeyDown((OIS::KeyCode)key);
     726    else
     727      return false;
     728  }
     729
     730  bool InputManager::isModifierDown(KeyboardModifier::Enum modifier)
     731  {
     732    if (_getSingleton().keyboard_)
     733      return isModifierDown(modifier);
     734    else
     735      return false;
     736  }
     737
     738  const MouseState InputManager::getMouseState()
     739  {
     740    if (_getSingleton().mouse_)
     741      return _getSingleton().mouse_->getMouseState();
     742    else
     743      return MouseState();
     744  }
     745
     746  const JoyStickState InputManager::getJoyStickState(unsigned int ID)
     747  {
     748    if (ID < _getSingleton().joySticksSize_)
     749      return JoyStickState(_getSingleton().joySticks_[ID]->getJoyStickState(), ID);
     750    else
     751      return JoyStickState();
    689752  }
    690753
     
    10621125    @return False if name or id was not found, true otherwise.
    10631126  */
    1064   bool InputManager::enableJoyStickHandler(const std::string& name, const int ID)
     1127  bool InputManager::enableJoyStickHandler(const std::string& name, unsigned int ID)
    10651128  {
    10661129    // get handler pointer from the map with all stored handlers
     
    10701133
    10711134    // check for existence of the ID
    1072     if ((unsigned int)ID >= _getSingleton().joySticks_.size())
    1073       return false;
    1074     OIS::JoyStick* joyStick = _getSingleton().joySticks_[ID];
     1135    if (ID >= _getSingleton().joySticksSize_)
     1136      return false;
    10751137
    10761138    // see whether the handler already is in the list
    1077     for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[joyStick].begin();
    1078           it != _getSingleton().activeJoyStickHandlers_[joyStick].end(); it++)
     1139    for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[ID].begin();
     1140          it != _getSingleton().activeJoyStickHandlers_[ID].end(); it++)
    10791141    {
    10801142      if ((*it) == (*handlerIt).second)
     
    10841146      }
    10851147    }
    1086     _getSingleton().activeJoyStickHandlers_[joyStick].push_back((*handlerIt).second);
     1148    _getSingleton().activeJoyStickHandlers_[ID].push_back((*handlerIt).second);
    10871149    _getSingleton().stateRequest_ = IS_CUSTOM;
    10881150    return true;
     
    10941156    @return False if name or id was not found, true otherwise.
    10951157  */
    1096   bool InputManager::disableJoyStickHandler(const std::string &name, int ID)
     1158  bool InputManager::disableJoyStickHandler(const std::string &name, unsigned int ID)
    10971159  {
    10981160    // get handler pointer from the map with all stored handlers
     
    11021164
    11031165    // check for existence of the ID
    1104     if ((unsigned int)ID >= _getSingleton().joySticks_.size())
    1105       return false;
    1106     OIS::JoyStick* joyStick = _getSingleton().joySticks_[ID];
     1166    if (ID >= _getSingleton().joySticksSize_)
     1167      return false;
    11071168
    11081169    // look for the handler in the list
    1109     for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[joyStick].begin();
    1110           it != _getSingleton().activeJoyStickHandlers_[joyStick].end(); it++)
     1170    for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[ID].begin();
     1171          it != _getSingleton().activeJoyStickHandlers_[ID].end(); it++)
    11111172    {
    11121173      if ((*it) == (*handlerIt).second)
    11131174      {
    1114         _getSingleton().activeJoyStickHandlers_[joyStick].erase(it);
     1175        _getSingleton().activeJoyStickHandlers_[ID].erase(it);
    11151176        _getSingleton().stateRequest_ = IS_CUSTOM;
    11161177        return true;
     
    11251186    @return False if key handler is not active or doesn't exist, true otherwise.
    11261187  */
    1127   bool InputManager::isJoyStickHandlerActive(const std::string& name, const int ID)
     1188  bool InputManager::isJoyStickHandlerActive(const std::string& name, unsigned int ID)
    11281189  {
    11291190    // get handler pointer from the map with all stored handlers
     
    11331194
    11341195    // check for existence of the ID
    1135     if ((unsigned int)ID >= _getSingleton().joySticks_.size())
    1136       return false;
    1137     OIS::JoyStick* joyStick = _getSingleton().joySticks_[ID];
     1196    if (ID >= _getSingleton().joySticksSize_)
     1197      return false;
    11381198
    11391199    // see whether the handler already is in the list
    1140     for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[joyStick].begin();
    1141           it != _getSingleton().activeJoyStickHandlers_[joyStick].end(); it++)
     1200    for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[ID].begin();
     1201          it != _getSingleton().activeJoyStickHandlers_[ID].end(); it++)
    11421202    {
    11431203      if ((*it) == (*handlerIt).second)
Note: See TracChangeset for help on using the changeset viewer.