- Timestamp:
- May 26, 2008, 12:00:20 AM (16 years ago)
- Location:
- code/branches/network
- Files:
-
- 4 edited
- 1 moved
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 ###### -
code/branches/network/src/core/InputManager.h
r1413 r1426 85 85 IS_GUI, //!< All OIS input events are passed to CEGUI. 86 86 IS_CONSOLE, //!< Keyboard input is redirected to the InputBuffer. 87 IS_DETECTION, //!< All the input goes to the KeyDetector 87 IS_DETECT, //!< All the input additionally goes to the KeyDetector 88 IS_NODETECT, //!< remove KeyDetector 88 89 IS_CUSTOM //!< Any possible configuration. 89 90 }; … … 115 116 116 117 static void storeKeyStroke(const std::string& name); 117 static const std::string& getLastKeyStroke();118 static void keyBind(const std::string& command); 118 119 119 120 static bool addKeyHandler (KeyHandler* handler, const std::string& name); … … 189 190 InputState stateRequest_; 190 191 unsigned int keyboardModifiers_; 191 std::string lastStroke_;192 InputState savedState_; 192 193 193 194 //! Keeps track of the joy stick POV states … … 209 210 std::vector<std::vector<int> > joyStickButtonsDown_; 210 211 212 static std::string bindingCommmandString_s; 211 213 }; 212 214 -
code/branches/network/src/core/KeyBinder.cc
r1422 r1426 900 900 button.nCommands_[KeybindMode::OnPress] = 1; 901 901 } 902 902 903 } -
code/branches/network/src/core/KeyBinder.h
r1420 r1426 232 232 void loadBindings(); 233 233 void setConfigValues(); 234 234 235 protected: 235 236 void readTrigger(Button& button);
Note: See TracChangeset
for help on using the changeset viewer.