Changeset 5929 for code/trunk/src/libraries/core/input/InputManager.cc
- Timestamp:
- Oct 12, 2009, 8:20:07 PM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/core5 (added) merged: 5768-5769,5772,5775-5780,5783-5785,5791-5792,5795-5807,5809-5814,5816-5832,5836-5839,5842-5853,5855-5899,5904-5922,5924-5928
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/core/input/InputManager.cc
r5781 r5929 41 41 #include <boost/foreach.hpp> 42 42 43 #include "util/Clock.h" 43 44 #include "util/Convert.h" 44 45 #include "util/Exception.h" 45 46 #include "util/ScopeGuard.h" 46 #include "core/Clock.h"47 47 #include "core/CoreIncludes.h" 48 48 #include "core/ConfigValueIncludes.h" … … 53 53 54 54 #include "InputBuffer.h" 55 #include "KeyDetector.h"56 55 #include "JoyStick.h" 57 56 #include "JoyStickQuantityListener.h" … … 88 87 , oisInputManager_(0) 89 88 , devices_(2) 90 , bExclusiveMouse_(false)89 , mouseMode_(MouseMode::Nonexclusive) 91 90 , emptyState_(0) 92 , keyDetector_(0)93 91 , calibratorCallbackHandler_(0) 94 92 { … … 99 97 this->setConfigValues(); 100 98 99 if (GraphicsManager::getInstance().isFullScreen()) 100 mouseMode_ = MouseMode::Exclusive; 101 101 this->loadDevices(); 102 102 … … 105 105 emptyState_->setHandler(&InputHandler::EMPTY); 106 106 activeStates_[emptyState_->getPriority()] = emptyState_; 107 108 // KeyDetector to evaluate a pressed key's name109 InputState* detector = createInputState("detector", false, false, InputStatePriority::Detector);110 // Create a callback to avoid buttonHeld events after the key has been detected111 FunctorMember<InputManager>* bufferFunctor = createFunctor(&InputManager::clearBuffers);112 bufferFunctor->setObject(this);113 detector->setLeaveFunctor(bufferFunctor);114 keyDetector_ = new KeyDetector();115 detector->setHandler(keyDetector_);116 107 117 108 // Joy stick calibration helper callback … … 124 115 this->updateActiveStates(); 125 116 126 { 127 // calibrate console command 128 FunctorMember<InputManager>* functor = createFunctor(&InputManager::calibrate); 129 functor->setObject(this); 130 this->getIdentifier()->addConsoleCommand(createConsoleCommand(functor, "calibrate"), true); 131 } 132 { 133 // reload console command 134 FunctorMember<InputManager>* functor = createFunctor(&InputManager::reload); 135 functor->setObject(this); 136 this->getIdentifier()->addConsoleCommand(createConsoleCommand(functor, "reload"), false); 137 } 117 // calibrate console command 118 this->getIdentifier()->addConsoleCommand(createConsoleCommand(createFunctor(&InputManager::calibrate, this), "calibrate"), true); 119 // reload console command 120 this->getIdentifier()->addConsoleCommand(createConsoleCommand(createFunctor(&InputManager::reload, this), "reload"), false); 138 121 139 122 CCOUT(4) << "Construction complete." << std::endl; … … 172 155 paramList.insert(std::make_pair("w32_keyboard", "DISCL_FOREGROUND")); 173 156 paramList.insert(std::make_pair("w32_mouse", "DISCL_FOREGROUND")); 174 if ( bExclusiveMouse_|| GraphicsManager::getInstance().isFullScreen())157 if (mouseMode_ == MouseMode::Exclusive || GraphicsManager::getInstance().isFullScreen()) 175 158 { 176 159 // Disable Windows key plus special keys (like play, stop, next, etc.) … … 185 168 paramList.insert(std::make_pair("XAutoRepeatOn", "true")); 186 169 187 if ( bExclusiveMouse_|| GraphicsManager::getInstance().isFullScreen())170 if (mouseMode_ == MouseMode::Exclusive || GraphicsManager::getInstance().isFullScreen()) 188 171 { 189 172 if (CommandLine::getValue("keyboard_no_grab").getBool()) … … 274 257 } 275 258 276 void InputManager::setKeyDetectorCallback(const std::string& command)277 {278 this->keyDetector_->setCallbackCommand(command);279 }280 281 259 // ############################################################ 282 260 // ##### Destruction ##### … … 289 267 290 268 // Destroy calibrator helper handler and state 291 delete keyDetector_;292 269 this->destroyState("calibrator"); 293 270 // Destroy KeyDetector and state 294 delete calibratorCallbackHandler_; 295 this->destroyState("detector"); 271 calibratorCallbackHandler_->destroy(); 296 272 // destroy the empty InputState 297 273 this->destroyStateInternal(this->emptyState_); … … 528 504 529 505 // Check whether we have to change the mouse mode 506 MouseMode::Value requestedMode = MouseMode::Dontcare; 530 507 std::vector<InputState*>& mouseStates = devices_[InputDeviceEnumerator::Mouse]->getStateListRef(); 531 if (mouseStates.empty() && bExclusiveMouse_ || 532 !mouseStates.empty() && mouseStates.front()->getIsExclusiveMouse() != bExclusiveMouse_) 533 { 534 bExclusiveMouse_ = !bExclusiveMouse_; 508 if (mouseStates.empty()) 509 requestedMode = MouseMode::Nonexclusive; 510 else 511 requestedMode = mouseStates.front()->getMouseMode(); 512 if (requestedMode != MouseMode::Dontcare && mouseMode_ != requestedMode) 513 { 514 mouseMode_ = requestedMode; 535 515 if (!GraphicsManager::getInstance().isFullScreen()) 536 516 this->reloadInternal(); … … 722 702 } 723 703 statesByName_.erase(state->getName()); 724 delete state;704 state->destroy(); 725 705 } 726 706 }
Note: See TracChangeset
for help on using the changeset viewer.