Changeset 1426 for code/branches/network/src/core/InputManager.cc
- Timestamp:
- May 26, 2008, 12:00:20 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/core/InputManager.cc
r1422 r1426 38 38 #include "InputBuffer.h" 39 39 #include "KeyBinder.h" 40 #include "CommandExecutor.h" 41 #include "ConsoleCommand.h" 40 42 41 43 namespace orxonox 42 44 { 45 ConsoleCommandShortcut(InputManager, keyBind, AccessLevel::User); 46 ConsoleCommandShortcut(InputManager, storeKeyStroke, AccessLevel::Offline); 47 43 48 // ############################### 44 49 // ### Internal Methods ### … … 54 59 joySticksSize_(0), 55 60 keyBinder_(0), buffer_(0), keyDetector_(0), 56 state_(IS_UNINIT), stateRequest_(IS_UNINIT), 61 state_(IS_UNINIT), stateRequest_(IS_UNINIT), savedState_(IS_UNINIT), 57 62 keyboardModifiers_(0) 58 63 { … … 405 410 if (stateRequest_ != IS_CUSTOM) 406 411 { 407 activeKeyHandlers_.clear(); 408 activeMouseHandlers_.clear(); 409 for (unsigned int i = 0; i < joySticksSize_; i++) 410 activeJoyStickHandlers_[i].clear(); 412 if (stateRequest_ != IS_NODETECT && stateRequest_ != IS_DETECT) 413 { 414 activeKeyHandlers_.clear(); 415 activeMouseHandlers_.clear(); 416 for (unsigned int i = 0; i < joySticksSize_; i++) 417 activeJoyStickHandlers_[i].clear(); 418 } 411 419 412 420 switch (stateRequest_) … … 429 437 break; 430 438 431 case IS_DETECTION: 432 if (mouse_) 433 mouse_->capture(); 434 if (keyboard_) 435 keyboard_->capture(); 436 for (unsigned int i = 0; i < joySticksSize_; i++) 437 joySticks_[i]->capture(); 438 439 lastStroke_ = ""; 439 case IS_DETECT: 440 savedState_ = state_; 440 441 enableKeyHandler("keydetector"); 441 442 enableMouseHandler("keydetector"); … … 443 444 break; 444 445 446 case IS_NODETECT: 447 disableKeyHandler("keydetector"); 448 disableMouseHandler("keydetector"); 449 disableJoyStickHandler("keydetector", 0); 450 break; 451 445 452 default: 446 453 break; 447 454 } 448 state_ = stateRequest_; 455 456 if (stateRequest_ == IS_NODETECT) 457 state_ = savedState_; 458 else 459 state_ = stateRequest_; 449 460 } 450 461 } … … 767 778 // ################################ 768 779 780 std::string InputManager::bindingCommmandString_s = ""; 781 769 782 bool InputManager::initialise(const size_t windowHnd, int windowWidth, int windowHeight, 770 783 bool createKeyboard, bool createMouse, bool createJoySticks) … … 901 914 void InputManager::storeKeyStroke(const std::string& name) 902 915 { 903 if (_getSingleton().lastStroke_ == "") 904 _getSingleton().lastStroke_ = name; 905 } 906 907 const std::string& InputManager::getLastKeyStroke() 908 { 909 return _getSingleton().lastStroke_; 910 } 911 916 setInputState(IS_NODETECT); 917 COUT(3) << "Binding string \"" << bindingCommmandString_s << "\" on key '" << name << "'" << std::endl; 918 CommandExecutor::execute("set KeyBinder " + name + " " + bindingCommmandString_s, false); 919 } 920 921 void InputManager::keyBind(const std::string& command) 922 { 923 bindingCommmandString_s = command; 924 setInputState(IS_DETECT); 925 } 912 926 913 927 // ###### KeyHandler ######
Note: See TracChangeset
for help on using the changeset viewer.