Changeset 1272 for code/branches/merge/src/core/InputManager.cc
- Timestamp:
- May 14, 2008, 11:44:17 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/merge/src/core/InputManager.cc
r1268 r1272 30 30 @file 31 31 @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. 33 33 */ 34 34 … … 52 52 InputManager::InputManager() : 53 53 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) 55 57 { 56 58 RegisterObject(InputManager); 57 58 this->joySticks_.reserve(5);59 //this->activeJoyStickHandlers_.reserve(10);60 this->activeKeyHandlers_.reserve(10);61 this->activeMouseHandlers_.reserve(10);62 59 } 63 60 … … 87 84 @param windowHeight The height of the render window 88 85 */ 89 bool InputManager::_initialise(const size_t windowHnd, const int windowWidth, constint windowHeight,90 const bool createKeyboard, const bool createMouse, constbool createJoySticks)86 bool InputManager::_initialise(const size_t windowHnd, int windowWidth, int windowHeight, 87 bool createKeyboard, bool createMouse, bool createJoySticks) 91 88 { 92 89 if (state_ == IS_UNINIT) … … 146 143 addKeyHandler(binder, "keybinder"); 147 144 addMouseHandler(binder, "keybinder"); 145 addJoyStickHandler(binder, "keybinder"); 148 146 149 147 // Read all the key bindings and assign them … … 235 233 bool InputManager::_initialiseJoySticks() 236 234 { 237 if (joySticks _.size()> 0)235 if (joySticksSize_ > 0) 238 236 { 239 237 CCOUT(2) << "Warning: Joy sticks already initialised, skipping." << std::endl; … … 266 264 return false; 267 265 } 266 joySticksSize_ = joySticks_.size(); 267 activeJoyStickHandlers_.resize(joySticksSize_); 268 joyStickButtonsDown_.resize(joySticksSize_); 268 269 return success; 269 270 } … … 337 338 void InputManager::_destroyJoySticks() 338 339 { 339 if (joySticks _.size()> 0)340 if (joySticksSize_ > 0) 340 341 { 341 342 // 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++) 343 344 if (joySticks_[i] != 0) 344 345 inputSystem_->destroyInputObject(joySticks_[i]); 345 346 346 347 joySticks_.clear(); 348 joySticksSize_ = 0; 347 349 activeJoyStickHandlers_.clear(); 348 350 joyStickButtonsDown_.clear(); … … 373 375 activeKeyHandlers_.clear(); 374 376 activeMouseHandlers_.clear(); 375 activeJoyStickHandlers_.clear(); 377 for (unsigned int i = 0; i < joySticksSize_; i++) 378 activeJoyStickHandlers_[i].clear(); 376 379 377 380 switch (stateRequest_) … … 383 386 activeMouseHandlers_.push_back(mouseHandlers_["keybinder"]); 384 387 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"]); 388 390 break; 389 391 … … 394 396 case IS_CONSOLE: 395 397 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"]); 399 401 400 402 activeKeyHandlers_.push_back(keyHandlers_["buffer"]); … … 413 415 if (keyboard_) 414 416 keyboard_->capture(); 417 for (unsigned int i = 0; i < joySticksSize_; i++) 418 joySticks_[i]->capture(); 415 419 416 420 417 421 // 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_)); 425 425 426 426 // 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]); 434 430 435 431 // 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 } 450 438 451 439 // ###### Key Events ###### … … 458 446 { 459 447 // 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 469 461 470 462 for (unsigned int i = 0; i < activeKeyHandlers_.size(); i++) 471 activeKeyHandlers_[i]->keyPressed( e);463 activeKeyHandlers_[i]->keyPressed(KeyEvent(e, keyboardModifiers_)); 472 464 473 465 return true; … … 481 473 { 482 474 // 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); 488 480 break; 489 481 } 490 482 } 491 483 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 492 492 for (unsigned int i = 0; i < activeKeyHandlers_.size(); i++) 493 activeKeyHandlers_[i]->keyReleased( e);493 activeKeyHandlers_[i]->keyReleased(KeyEvent(e, keyboardModifiers_)); 494 494 495 495 return true; … … 505 505 bool InputManager::mouseMoved(const OIS::MouseEvent &e) 506 506 { 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 } 509 520 510 521 return true; … … 519 530 { 520 531 // 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); 530 537 531 538 for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++) 532 activeMouseHandlers_[i]->mouse Pressed(e,id);539 activeMouseHandlers_[i]->mouseButtonPressed(e.state, (MouseButton::Enum)id); 533 540 534 541 return true; … … 543 550 { 544 551 // 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); 550 557 break; 551 558 } … … 553 560 554 561 for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++) 555 activeMouseHandlers_[i]->mouse Released(e,id);562 activeMouseHandlers_[i]->mouseButtonReleased(e.state, (MouseButton::Enum)id); 556 563 557 564 return true; … … 563 570 bool InputManager::buttonPressed(const OIS::JoyStickEvent &arg, int button) 564 571 { 572 // use the device to identify which one called the method 565 573 OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device; 574 unsigned int iJoyStick = 0; 575 while (joySticks_[iJoyStick] != joyStick) 576 iJoyStick++; 566 577 567 578 // 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); 574 607 break; 575 608 } 576 609 } 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 587 620 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 608 634 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 617 648 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 626 662 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); 638 669 639 670 return true; … … 646 677 // ################################ 647 678 648 bool InputManager::initialise(const size_t windowHnd, const int windowWidth, constint windowHeight,649 const bool createKeyboard, const bool createMouse, constbool createJoySticks)679 bool InputManager::initialise(const size_t windowHnd, int windowWidth, int windowHeight, 680 bool createKeyboard, bool createMouse, bool createJoySticks) 650 681 { 651 682 return _getSingleton()._initialise(windowHnd, windowWidth, windowHeight, … … 686 717 int InputManager::numberOfJoySticks() 687 718 { 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(); 689 752 } 690 753 … … 1062 1125 @return False if name or id was not found, true otherwise. 1063 1126 */ 1064 bool InputManager::enableJoyStickHandler(const std::string& name, constint ID)1127 bool InputManager::enableJoyStickHandler(const std::string& name, unsigned int ID) 1065 1128 { 1066 1129 // get handler pointer from the map with all stored handlers … … 1070 1133 1071 1134 // 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; 1075 1137 1076 1138 // 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++) 1079 1141 { 1080 1142 if ((*it) == (*handlerIt).second) … … 1084 1146 } 1085 1147 } 1086 _getSingleton().activeJoyStickHandlers_[ joyStick].push_back((*handlerIt).second);1148 _getSingleton().activeJoyStickHandlers_[ID].push_back((*handlerIt).second); 1087 1149 _getSingleton().stateRequest_ = IS_CUSTOM; 1088 1150 return true; … … 1094 1156 @return False if name or id was not found, true otherwise. 1095 1157 */ 1096 bool InputManager::disableJoyStickHandler(const std::string &name, int ID)1158 bool InputManager::disableJoyStickHandler(const std::string &name, unsigned int ID) 1097 1159 { 1098 1160 // get handler pointer from the map with all stored handlers … … 1102 1164 1103 1165 // 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; 1107 1168 1108 1169 // 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++) 1111 1172 { 1112 1173 if ((*it) == (*handlerIt).second) 1113 1174 { 1114 _getSingleton().activeJoyStickHandlers_[ joyStick].erase(it);1175 _getSingleton().activeJoyStickHandlers_[ID].erase(it); 1115 1176 _getSingleton().stateRequest_ = IS_CUSTOM; 1116 1177 return true; … … 1125 1186 @return False if key handler is not active or doesn't exist, true otherwise. 1126 1187 */ 1127 bool InputManager::isJoyStickHandlerActive(const std::string& name, constint ID)1188 bool InputManager::isJoyStickHandlerActive(const std::string& name, unsigned int ID) 1128 1189 { 1129 1190 // get handler pointer from the map with all stored handlers … … 1133 1194 1134 1195 // 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; 1138 1198 1139 1199 // 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++) 1142 1202 { 1143 1203 if ((*it) == (*handlerIt).second)
Note: See TracChangeset
for help on using the changeset viewer.