Changeset 1193
- Timestamp:
- Apr 27, 2008, 1:50:28 PM (17 years ago)
- Location:
- code/branches/input
- Files:
-
- 5 deleted
- 7 edited
- 1 copied
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
code/branches/input/src/core/Debug.h
r1089 r1193 264 264 /// CCOUT: Prints output with std::cout and adds the classname /// 265 265 ///////////////////////////////////////////////////////////////////// 266 #define CCOUTORX_NONE CCOUT0 267 #define CCOUTORX_ERROR CCOUT1 268 #define CCOUTORX_WARNING CCOUT2 269 #define CCOUTORX_INFO CCOUT3 270 #define CCOUTORX_DEBUG CCOUT4 271 #define CCOUTORX_vDEBUG CCOUT5 266 272 267 273 #define CCOUT_EXEC(x) \ -
code/branches/input/src/core/InputBuffer.h
r1066 r1193 35 35 #include <list> 36 36 37 #ifdef WIN3238 37 #include <OIS/OISKeyboard.h> 39 #else40 #include <OISKeyboard.h>41 #endif42 38 43 39 namespace orxonox -
code/branches/input/src/core/InputManager.cc
r1182 r1193 28 28 29 29 /** 30 @file31 @brief Implementation of a little Input handler that distributes everything32 coming from OIS.30 @file 31 @brief Implementation of the InputManager that captures all the input from OIS 32 and redirects it to listeners if necessary. 33 33 */ 34 34 … … 42 42 namespace orxonox 43 43 { 44 /** 45 @brief Constructor only resets the pointer values to 0. 44 // ############################### 45 // ### Internal Methods ### 46 // ############################### 47 48 /** 49 @brief Constructor only sets member fields to initial zero values 50 and registers the class in the class hierarchy. 46 51 */ 47 52 InputManager::InputManager() : … … 49 54 state_(IS_UNINIT), stateRequest_(IS_UNINIT) 50 55 { 56 // overwrite every key binding with "" 57 _clearBindings(); 58 _setNumberOfJoysticks(0); 59 51 60 RegisterObject(InputManager); 52 61 } … … 63 72 64 73 /** 65 @brief Destructor only called at the end of the program 74 @brief Destructor only called at the end of the program, after main. 66 75 */ 67 76 InputManager::~InputManager() … … 71 80 72 81 /** 73 @brief Creates the OIS::InputMananger, the keyboard andthe mouse and74 assigns the key bindings.82 @brief Creates the OIS::InputMananger, the keyboard, the mouse and 83 the joysticks and assigns the key bindings. 75 84 @param windowHnd The window handle of the render window 76 85 @param windowWidth The width of the render window 77 86 @param windowHeight The height of the render window 78 87 */ 79 bool InputManager::_initialise(size_t windowHnd, int windowWidth, int windowHeight) 80 { 81 if (!inputSystem_) 82 { 83 // Setup basic variables 88 bool InputManager::_initialise(size_t windowHnd, int windowWidth, int windowHeight, 89 bool createKeyboard, bool createMouse, bool createJoySticks) 90 { 91 if (state_ == IS_UNINIT) 92 { 93 CCOUT(ORX_DEBUG) << "Initialising OIS components..." << std::endl; 94 84 95 OIS::ParamList paramList; 85 96 std::ostringstream windowHndStr; … … 95 106 try 96 107 { 97 // Create inputsystem98 108 inputSystem_ = OIS::InputManager::createInputSystem(paramList); 99 COUT(ORX_DEBUG) << "*** InputManager: Created OIS input system" << std::endl; 100 101 // create a keyboard. If none are available the exception is caught. 102 keyboard_ = static_cast<OIS::Keyboard*>(inputSystem_->createInputObject(OIS::OISKeyboard, true)); 103 COUT(ORX_DEBUG) << "*** InputManager: Created OIS mouse" << std::endl; 104 105 //TODO: check for already pressed keys 106 107 // create a mouse. If none are available the exception is caught. 108 mouse_ = static_cast<OIS::Mouse*>(inputSystem_->createInputObject(OIS::OISMouse, true)); 109 COUT(ORX_DEBUG) << "*** InputManager: Created OIS keyboard" << std::endl; 110 111 // Set mouse region 112 setWindowExtents(windowWidth, windowHeight); 113 114 this->state_ = IS_NONE; 109 CCOUT(ORX_DEBUG) << "Created OIS input system" << std::endl; 115 110 } 116 111 catch (OIS::Exception ex) 117 112 { 118 // something went wrong with the initialisation119 COUT(ORX_ERROR) << "Error: Failed creating an input system/keyboard/mouse. Message: \"" << ex.eText << "\"" << std::endl;113 CCOUT(ORX_ERROR) << "Error: Failed creating an OIS input system." 114 << "OIS message: \"" << ex.eText << "\"" << std::endl; 120 115 inputSystem_ = 0; 121 116 return false; 122 117 } 123 } 124 125 keyboard_->setEventCallback(this); 126 mouse_->setEventCallback(this); 127 118 119 if (createKeyboard) 120 _initialiseKeyboard(); 121 122 if (createMouse) 123 _initialiseMouse(); 124 125 if (createJoySticks) 126 _initialiseJoySticks(); 127 128 // Set mouse/joystick region 129 setWindowExtents(windowWidth, windowHeight); 130 131 this->state_ = IS_NONE; 132 CCOUT(ORX_DEBUG) << "Initialising OIS components done." << std::endl; 133 } 134 else 135 { 136 CCOUT(ORX_WARNING) << "Warning: OIS compoments already initialised, skipping" << std::endl; 137 } 138 139 // InputManager holds the input buffer --> create one and add it. 128 140 addKeyListener(new InputBuffer(), "buffer"); 129 141 130 _loadBindings(); 131 132 COUT(ORX_DEBUG) << "*** InputManager: Loading done." << std::endl; 133 134 return true; 135 } 136 137 void InputManager::_loadBindings() 138 { 139 for (int i = 0; i < numberOfKeys_s; i++) 140 { 141 // simply write the key number (i) in the string 142 this->bindingsKeyPress_[i] = ""; 143 this->bindingsKeyRelease_[i] = ""; 144 } 142 // Read all the key bindings and assign them 143 if (!_loadBindings()) 144 return false; 145 146 CCOUT(ORX_DEBUG) << "Initialising complete." << std::endl; 147 return true; 148 } 149 150 /** 151 @brief Creates a keyboard and sets the event handler. 152 */ 153 void InputManager::_initialiseKeyboard() 154 { 155 try 156 { 157 #if (OIS_VERSION >> 8) == 0x0100 158 if (inputSystem_->numKeyboards() > 0) 159 #elif (OIS_VERSION >> 8) == 0x0102 160 if (inputSystem_->getNumberOfDevices(OIS::OISKeyboard) > 0) 161 #endif 162 { 163 keyboard_ = (OIS::Keyboard*)inputSystem_->createInputObject(OIS::OISKeyboard, true); 164 // register our listener in OIS. 165 keyboard_->setEventCallback(this); 166 // note: OIS will not detect keys that have already been down when the keyboard was created. 167 CCOUT(ORX_DEBUG) << "Created OIS keyboard" << std::endl; 168 } 169 else 170 CCOUT(ORX_WARNING) << "Warning: No keyboard found!" << std::endl; 171 } 172 catch (OIS::Exception ex) 173 { 174 CCOUT(ORX_WARNING) << "Warning: Failed to create an OIS keyboard\n" 175 << "OIS error message: \"" << ex.eText << "\"" << std::endl; 176 keyboard_ = 0; 177 } 178 } 179 180 /** 181 @brief Creates a mouse and sets the event handler. 182 */ 183 void InputManager::_initialiseMouse() 184 { 185 try 186 { 187 #if (OIS_VERSION >> 8) == 0x0100 188 if (inputSystem_->numMice() > 0) 189 #elif (OIS_VERSION >> 8) == 0x0102 190 if (inputSystem_->getNumberOfDevices(OIS::OISMouse) > 0) 191 #endif 192 { 193 mouse_ = static_cast<OIS::Mouse*>(inputSystem_->createInputObject(OIS::OISMouse, true)); 194 // register our listener in OIS. 195 mouse_->setEventCallback(this); 196 CCOUT(ORX_DEBUG) << "Created OIS keyboard" << std::endl; 197 } 198 else 199 CCOUT(ORX_WARNING) << "Warning: No mouse found!" << std::endl; 200 } 201 catch (OIS::Exception ex) 202 { 203 CCOUT(ORX_WARNING) << "Warning: Failed to create an OIS mouse\n" 204 << "OIS error message: \"" << ex.eText << "\"" << std::endl; 205 mouse_ = 0; 206 } 207 } 208 209 /** 210 @brief Creates all joy sticks and sets the event handler. 211 */ 212 void InputManager::_initialiseJoySticks() 213 { 214 #if (OIS_VERSION >> 8) == 0x0100 215 if (inputSystem_->numJoySticks() > 0) 216 { 217 _setNumberOfJoysticks(inputSystem_->numJoySticks()); 218 #elif (OIS_VERSION >> 8) == 0x0102 219 if (inputSystem_->getNumberOfDevices(OIS::OISJoyStick) > 0) 220 { 221 _setNumberOfJoysticks(inputSystem_->getNumberOfDevices(OIS::OISJoyStick)); 222 #endif 223 for (std::vector<OIS::JoyStick*>::iterator it = joySticks_.begin(); it != joySticks_.end(); it++) 224 { 225 try 226 { 227 *it = static_cast<OIS::JoyStick*>(inputSystem_->createInputObject(OIS::OISJoyStick, true)); 228 // register our listener in OIS. 229 (*it)->setEventCallback(this); 230 CCOUT(ORX_DEBUG) << "Created OIS joy stick with ID " << (*it)->getID() << std::endl; 231 } 232 catch (OIS::Exception ex) 233 { 234 CCOUT(ORX_WARNING) << "Warning: Failed to create OIS joy stick with ID" << (*it)->getID() << "\n" 235 << "OIS error message: \"" << ex.eText << "\"" << std::endl; 236 (*it) = 0; 237 } 238 } 239 } 240 else 241 CCOUT(ORX_WARNING) << "Warning: Joy stick support requested, but no joy stick was found" << std::endl; 242 } 243 244 /** 245 @brief Resizes all lists related to joy sticks and sets joy stick bindings to "". 246 @param size Number of joy sticks available. 247 */ 248 void InputManager::_setNumberOfJoysticks(int size) 249 { 250 this->bindingsJoyStickButtonHold_ .resize(size); 251 this->bindingsJoyStickButtonPress_ .resize(size); 252 this->bindingsJoyStickButtonRelease_.resize(size); 253 this->bJoyStickButtonBindingsActive_.resize(size); 254 this->joyStickButtonsDown_ .resize(size); 255 this->joySticks_ .resize(size); 256 for (int j = 0; j < size; j++) 257 { 258 bindingsJoyStickButtonPress_ [j].resize(numberOfJoyStickButtons_s); 259 bindingsJoyStickButtonRelease_[j].resize(numberOfJoyStickButtons_s); 260 bindingsJoyStickButtonHold_ [j].resize(numberOfJoyStickButtons_s); 261 for (int i = 0; i < numberOfJoyStickButtons_s; i++) 262 { 263 this->bindingsJoyStickButtonPress_ [j][i] = ""; 264 this->bindingsJoyStickButtonRelease_[j][i] = ""; 265 this->bindingsJoyStickButtonHold_ [j][i] = ""; 266 } 267 } 268 } 269 270 /** 271 @brief Loads the key and button bindings. 272 */ 273 bool InputManager::_loadBindings() 274 { 275 CCOUT(ORX_DEBUG) << "Loading key bindings..." << std::endl; 276 277 // clear all the bindings at first. 278 _clearBindings(); 279 280 // TODO: Insert the code to load the bindings from file. 145 281 this->bindingsKeyPress_[OIS::KC_NUMPADENTER] = "activateConsole"; 146 282 this->bindingsKeyPress_[OIS::KC_ESCAPE] = "exit"; 147 283 this->bindingsKeyHold_[OIS::KC_U] = "exec disco.txt"; 148 } 149 150 /** 151 @brief Destroys all the created input devices and handlers. 284 285 CCOUT(ORX_DEBUG) << "Loading key bindings done." << std::endl; 286 return true; 287 } 288 289 /** 290 @brief Overwrites all bindings with "" 291 */ 292 void InputManager::_clearBindings() 293 { 294 for (int i = 0; i < numberOfKeys_s; i++) 295 { 296 this->bindingsKeyPress_ [i] = ""; 297 this->bindingsKeyRelease_[i] = ""; 298 this->bindingsKeyHold_ [i] = ""; 299 } 300 for (int i = 0; i < numberOfMouseButtons_s; i++) 301 { 302 this->bindingsMouseButtonPress_ [i] = ""; 303 this->bindingsMouseButtonRelease_[i] = ""; 304 this->bindingsMouseButtonHold_ [i] = ""; 305 } 306 for (unsigned int j = 0; j < joySticks_.size(); j++) 307 { 308 for (int i = 0; i < numberOfJoyStickButtons_s; i++) 309 { 310 this->bindingsJoyStickButtonPress_ [j][i] = ""; 311 this->bindingsJoyStickButtonRelease_[j][i] = ""; 312 this->bindingsJoyStickButtonHold_ [j][i] = ""; 313 } 314 } 315 } 316 317 /** 318 @brief Destroys all the created input devices and sets the InputManager to construction state. 152 319 */ 153 320 void InputManager::_destroy() 154 321 { 155 COUT(ORX_DEBUG) << "*** InputManager: Destroying ..." << std::endl; 156 if (mouse_) 157 inputSystem_->destroyInputObject(mouse_); 158 if (keyboard_) 159 inputSystem_->destroyInputObject(keyboard_); 160 if (inputSystem_) 161 OIS::InputManager::destroyInputSystem(inputSystem_); 162 163 mouse_ = 0; 164 keyboard_ = 0; 165 inputSystem_ = 0; 166 167 OIS::KeyListener* buffer = keyListeners_["buffer"]; 168 if (buffer) 169 { 170 this->removeKeyListener("buffer"); 171 delete buffer; 172 buffer = 0; 173 } 174 175 COUT(ORX_DEBUG) << "*** InputManager: Destroying done." << std::endl; 176 } 322 CCOUT(ORX_DEBUG) << "Destroying ..." << std::endl; 323 324 if (state_ != IS_UNINIT) 325 { 326 this->listenersKeyActive_.clear(); 327 this->listenersMouseActive_.clear(); 328 this->listenersJoySticksActive_.clear(); 329 this->listenersKey_.clear(); 330 this->listenersMouse_.clear(); 331 this->listenersJoySticks_.clear(); 332 333 this->keysDown_.clear(); 334 this->mouseButtonsDown_.clear(); 335 336 _clearBindings(); 337 338 if (keyboard_) 339 inputSystem_->destroyInputObject(keyboard_); 340 keyboard_ = 0; 341 342 if (mouse_) 343 inputSystem_->destroyInputObject(mouse_); 344 mouse_ = 0; 345 346 if (joySticks_.size() > 0) 347 { 348 for (unsigned int i = 0; i < joySticks_.size(); i++) 349 { 350 if (joySticks_[i] != 0) 351 inputSystem_->destroyInputObject(joySticks_[i]); 352 } 353 _setNumberOfJoysticks(0); 354 } 355 356 if (inputSystem_) 357 OIS::InputManager::destroyInputSystem(inputSystem_); 358 inputSystem_ = 0; 359 360 if (listenersKey_.find("buffer") != listenersKey_.end()) 361 delete listenersKey_["buffer"]; 362 363 this->state_ = IS_UNINIT; 364 } 365 else 366 CCOUT(ORX_WARNING) << "Warning: Cannot be destroyed, since not initialised." << std::endl; 367 368 CCOUT(ORX_DEBUG) << "Destroying done." << std::endl; 369 } 370 371 372 // ############################### 373 // ### Public Member Methods ### 374 // ############################### 177 375 178 376 /** … … 188 386 if (state_ != stateRequest_) 189 387 { 190 if (stateRequest_ != IS_CUSTOM)191 _setDefaultState();192 193 388 switch (stateRequest_) 194 389 { 195 390 case IS_NORMAL: 391 this->listenersKeyActive_.clear(); 392 this->listenersMouseActive_.clear(); 393 this->listenersJoySticksActive_.clear(); 394 this->bKeyBindingsActive_ = true; 395 this->bMouseButtonBindingsActive_ = true; 396 //this->bJoySticksButtonBindingsActive_ = true; 196 397 break; 398 197 399 case IS_GUI: 198 // FIXME: do stuff400 // FIXME: do stuff 199 401 break; 402 200 403 case IS_CONSOLE: 201 if (this->keyListeners_.find("buffer") != this->keyListeners_.end()) 202 this->activeKeyListeners_.push_back(this->keyListeners_["buffer"]); 203 this->bDefaultKeyInput = false; 404 this->listenersKeyActive_.clear(); 405 this->listenersMouseActive_.clear(); 406 //this->listenersJoyStickActive_.clear(); 407 this->bKeyBindingsActive_ = false; 408 this->bMouseButtonBindingsActive_ = true; 409 //this->bJoyStickButtonBindingsActive_ = true; 410 if (listenersKey_.find("buffer") != listenersKey_.end()) 411 listenersKeyActive_.push_back(listenersKey_["buffer"]); 412 else 413 { 414 // someone fiddled with the InputBuffer 415 CCOUT(2) << "Error: Cannot redirect input to console, InputBuffer instance missing." << std::endl; 416 this->bKeyBindingsActive_ = true; 417 } 204 418 break; 419 420 case IS_NONE: 421 this->listenersKeyActive_.clear(); 422 this->listenersMouseActive_.clear(); 423 //this->listenersJoyStickActive_.clear(); 424 this->bKeyBindingsActive_ = false; 425 this->bMouseButtonBindingsActive_ = false; 426 //this->bJoyStickButtonBindingsActive_ = false; 427 break; 428 205 429 case IS_CUSTOM: 206 430 // don't do anything … … 210 434 } 211 435 212 // capture all the input. That calls the event handlers.436 // Capture all the input. This calls the event handlers in InputManager. 213 437 if (mouse_) 214 438 mouse_->capture(); … … 217 441 } 218 442 219 void InputManager::_setDefaultState()220 { 221 this-> activeJoyStickListeners_.clear();222 this-> activeKeyListeners_.clear();223 this-> activeMouseListeners_.clear();224 this->b DefaultKeyInput= true;225 this->b DefaultMouseInput= true;226 this->b DefaultJoyStickInput= true;227 } 443 /*void InputManager::_setDefaultState() 444 { 445 this->listenersKeyActive_.clear(); 446 this->listenersMouseActive_.clear(); 447 this->listenersJoyStickActive_.clear(); 448 this->bKeyBindingsActive_ = true; 449 this->bMouseButtonBindingsActive_ = true; 450 this->bJoyStickButtonBindingsActive_ = true; 451 }*/ 228 452 229 453 … … 236 460 this->keysDown_.push_back(e.key); 237 461 238 if (this->b DefaultKeyInput)462 if (this->bKeyBindingsActive_) 239 463 { 240 464 // find the appropriate key binding … … 248 472 else 249 473 { 250 for (std::list<OIS::KeyListener*>::const_iterator it = activeKeyListeners_.begin(); it != activeKeyListeners_.end(); it++)474 for (std::list<OIS::KeyListener*>::const_iterator it = listenersKeyActive_.begin(); it != listenersKeyActive_.end(); it++) 251 475 (*it)->keyPressed(e); 252 476 } … … 270 494 } 271 495 272 if (this->b DefaultKeyInput)496 if (this->bKeyBindingsActive_) 273 497 { 274 498 // find the appropriate key binding … … 282 506 else 283 507 { 284 for (std::list<OIS::KeyListener*>::const_iterator it = activeKeyListeners_.begin(); it != activeKeyListeners_.end(); it++)508 for (std::list<OIS::KeyListener*>::const_iterator it = listenersKeyActive_.begin(); it != listenersKeyActive_.end(); it++) 285 509 (*it)->keyReleased(e); 286 510 } … … 343 567 344 568 569 // ################################ 570 // ### Static Interface Methods ### 571 // ################################ 345 572 346 573 /** … … 352 579 void InputManager::setWindowExtents(int width, int height) 353 580 { 354 // Set mouse region (if window resizes, we should alter this to reflect as well) 355 const OIS::MouseState &mouseState = _getSingleton().mouse_->getMouseState(); 356 mouseState.width = width; 357 mouseState.height = height; 581 if (_getSingleton().mouse_) 582 { 583 // Set mouse region (if window resizes, we should alter this to reflect as well) 584 const OIS::MouseState &mouseState = _getSingleton().mouse_->getMouseState(); 585 mouseState.width = width; 586 mouseState.height = height; 587 } 358 588 } 359 589 … … 382 612 } 383 613 384 bool InputManager::initialise(size_t windowHnd, int windowWidth, int windowHeight) 385 { 386 return _getSingleton()._initialise(windowHnd, windowWidth, windowHeight); 614 bool InputManager::initialise(size_t windowHnd, int windowWidth, int windowHeight, 615 bool createKeyboard, bool createMouse, bool createJoySticks) 616 { 617 return _getSingleton()._initialise(windowHnd, windowWidth, windowHeight, 618 createKeyboard, createMouse, createJoySticks); 387 619 } 388 620 389 621 bool InputManager::addKeyListener(OIS::KeyListener *listener, const std::string& name) 390 622 { 391 if (_getSingleton(). keyListeners_.find(name) == _getSingleton().keyListeners_.end())392 { 393 _getSingleton(). keyListeners_[name] = listener;623 if (_getSingleton().listenersKey_.find(name) == _getSingleton().listenersKey_.end()) 624 { 625 _getSingleton().listenersKey_[name] = listener; 394 626 return true; 395 627 } … … 400 632 bool InputManager::removeKeyListener(const std::string &name) 401 633 { 402 std::map<std::string, OIS::KeyListener*>::iterator it = _getSingleton(). keyListeners_.find(name);403 if (it != _getSingleton(). keyListeners_.end())404 { 405 _getSingleton(). keyListeners_.erase(it);634 std::map<std::string, OIS::KeyListener*>::iterator it = _getSingleton().listenersKey_.find(name); 635 if (it != _getSingleton().listenersKey_.end()) 636 { 637 _getSingleton().listenersKey_.erase(it); 406 638 return true; 407 639 } … … 412 644 OIS::KeyListener* InputManager::getKeyListener(const std::string& name) 413 645 { 414 std::map<std::string, OIS::KeyListener*>::iterator it = _getSingleton(). keyListeners_.find(name);415 if (it != _getSingleton(). keyListeners_.end())646 std::map<std::string, OIS::KeyListener*>::iterator it = _getSingleton().listenersKey_.find(name); 647 if (it != _getSingleton().listenersKey_.end()) 416 648 { 417 649 return (*it).second; -
code/branches/input/src/core/InputManager.h
r1182 r1193 56 56 public OIS::MouseListener, public OIS::KeyListener, public OIS::JoyStickListener 57 57 { 58 public: 58 public: // enumerations 59 59 /** 60 @brief Designates the way input is handled currently. 61 IM_GUI: All the OIS input events are passed to CEGUI 62 IM_BUFFER: Only keyboard input is captured and passed to the InputBuffer 63 IM_NORMAL: Normal game mode. Key bindings and mouse are active. 60 @brief Designates the way input is handled and redirected. 64 61 */ 65 62 enum InputState 66 63 { 67 IS_UNINIT, 68 IS_NONE, 69 IS_NORMAL, 70 IS_GUI, 71 IS_CONSOLE, 72 IS_CUSTOM 64 IS_UNINIT, //!< InputManager has not yet been initialised. 65 IS_NONE, //!< Input is discarded. 66 IS_NORMAL, //!< Normal play state. Key and button bindings are active. 67 IS_GUI, //!< All OIS input events are passed to CEGUI. 68 IS_CONSOLE, //!< Keyboard input is redirected to the InputBuffer. 69 IS_CUSTOM //!< Any possible configuration. 73 70 }; 74 71 75 public: 76 void tick(float dt); 77 78 static bool initialise(size_t windowHnd, int windowWidth, int windowHeight); 72 public: // functions 73 // METHODS OF THE STATIC INTERFACE 74 75 static bool initialise(size_t windowHnd, int windowWidth, int windowHeight, 76 bool createKeyboard = true, bool createMouse = true, bool createJoySticks = false); 79 77 static void destroy(); 80 78 81 79 static void setWindowExtents(int width, int height); 80 82 81 static void setInputState(const InputState state); 83 82 static InputState getInputState(); 83 static void setKeyBindingState (bool bActive); 84 static void setMouseButtonBindingState (bool bActive); 85 static void setJoyStickButtonBindingState(bool bActive); 84 86 85 87 static bool addKeyListener(OIS::KeyListener* listener, const std::string& name); 86 //static bool removeKeyListener(OIS::KeyListener* listener);87 static bool removeKeyListener(const std::string& name);88 static bool enableKeyListener(const std::string& name);89 static bool disableKeyListener(const std::string& name);88 static bool removeKeyListener (const std::string& name); 89 static bool enableKeyListener (const std::string& name); 90 static bool disableKeyListener (const std::string& name); 91 static bool isKeyListenerActive(const std::string& name); 90 92 static OIS::KeyListener* getKeyListener(const std::string& name); 91 static bool isKeyListenerActive(const std::string& name);92 93 93 94 static bool addMouseListener(OIS::MouseListener* listener, const std::string& name); 94 //static bool removeMouseListener(OIS::MouseListener* listener);95 static bool removeMouseListener(const std::string& name);96 static bool enableMouseListener(const std::string& name);97 static bool disableMouseListener(const std::string& name);95 static bool removeMouseListener (const std::string& name); 96 static bool enableMouseListener (const std::string& name); 97 static bool disableMouseListener (const std::string& name); 98 static bool isMouseListenerActive(const std::string& name); 98 99 static OIS::MouseListener* getMouseListener(const std::string& name); 99 static bool isMouseListenerActive(const std::string& name);100 100 101 101 static bool addJoyStickListener(OIS::JoyStickListener* listener, const std::string& name); 102 //static bool removeJoyStickListener(OIS::JoyStickListener* listener);103 static bool removeJoyStickListener(const std::string& name);104 static bool enableJoyStickListener(const std::string& name);105 static bool disableJoyStickListener(const std::string& name);102 static bool removeJoyStickListener (const std::string& name); 103 static bool enableJoyStickListener (const std::string& name); 104 static bool disableJoyStickListener (const std::string& name); 105 static bool isJoyStickListenerActive(const std::string& name); 106 106 static OIS::JoyStickListener* getJoyStickListener(const std::string& name); 107 static bool isJoyStickListenerActive(const std::string& name);108 107 109 108 // Temporary solutions. Will be removed soon! … … 111 110 static OIS::Keyboard* getKeyboard() { return _getSingleton().keyboard_; } 112 111 113 private: 112 private: // functions 114 113 // don't mess with a Singleton 115 114 InputManager (); … … 117 116 ~InputManager(); 118 117 119 bool _initialise(size_t windowHnd, int windowWidth, int windowHeight); 118 // Intenal methods 119 bool _initialise(size_t, int, int, bool, bool, bool); 120 void _initialiseKeyboard(); 121 void _initialiseMouse(); 122 void _initialiseJoySticks(); 120 123 void _destroy(); 121 void _setDefaultState(); 122 void _loadBindings(); 124 //void _setDefaultState(); 125 bool _loadBindings(); 126 void _clearBindings(); 127 void _setNumberOfJoysticks(int size); 128 129 void tick(float dt); 123 130 124 131 // input events … … 137 144 static InputManager* _getSingletonPtr() { return &_getSingleton(); } 138 145 139 private: 146 private: // variables 140 147 OIS::InputManager* inputSystem_; //!< OIS input manager 141 148 OIS::Keyboard* keyboard_; //!< OIS mouse 142 149 OIS::Mouse* mouse_; //!< OIS keyboard 150 std::vector<OIS::JoyStick*> joySticks_; //!< OIS joy sticks 143 151 144 152 InputState state_; 145 153 InputState stateRequest_; 146 154 147 std::list<OIS::KeyCode> keysDown_; 148 149 bool bDefaultKeyInput; 150 bool bDefaultMouseInput; 151 bool bDefaultJoyStickInput; 152 153 std::map<std::string, OIS::KeyListener*> keyListeners_; 154 std::list<OIS::KeyListener*> activeKeyListeners_; 155 std::map<std::string, OIS::MouseListener*> mouseListeners_; 156 std::list<OIS::MouseListener*> activeMouseListeners_; 157 std::map<std::string, OIS::JoyStickListener*> joystickListeners_; 158 std::list<OIS::JoyStickListener*> activeJoyStickListeners_; 155 bool bKeyBindingsActive_; 156 bool bMouseButtonBindingsActive_; 157 std::vector<bool> bJoyStickButtonBindingsActive_; 158 159 std::map<std::string, OIS::KeyListener*> listenersKey_; 160 std::map<std::string, OIS::MouseListener*> listenersMouse_; 161 std::map<std::string, OIS::JoyStickListener*> listenersJoySticks_; 162 163 std::list<OIS::KeyListener*> listenersKeyActive_; 164 std::list<OIS::MouseListener*> listenersMouseActive_; 165 std::list<OIS::JoyStickListener*> listenersJoySticksActive_; 166 167 std::list<OIS::KeyCode> keysDown_; 168 std::list<OIS::MouseButtonID> mouseButtonsDown_; 169 std::vector< std::list<int> > joyStickButtonsDown_; 159 170 160 171 161 172 /** denotes the maximum number of different keys there are in OIS. 162 256 should be ok since the highest number in the enum is 237. */173 256 should be ok since the highest number in the OIS enum is 237. */ 163 174 static const int numberOfKeys_s = 256; 164 175 //! Array of input events for every pressed key … … 170 181 171 182 /** denotes the maximum number of different buttons there are in OIS. 172 16 should be ok since the highest number in the enum is 7. */183 16 should be ok since the highest number in the OIS enum is 7. */ 173 184 static const int numberOfMouseButtons_s = 16; 174 185 //! Array of input events for every pressed mouse button … … 182 193 32 should be ok. */ 183 194 static const int numberOfJoyStickButtons_s = 32; 184 //! Array of input events for every pressed joystick button 185 std::string bindingsJoyStickButtonPress_ [numberOfJoyStickButtons_s]; 186 //! Array of input events for every released joystick button 187 std::string bindingsJoyStickButtonRelease_[numberOfJoyStickButtons_s]; 188 //! Array of input events for every held joystick button 189 std::string bindingsJoyStickButtonHold_ [numberOfJoyStickButtons_s]; 195 std::vector< std::vector< std::string > > bindingsJoyStickButtonPress_; 196 std::vector< std::vector< std::string > > bindingsJoyStickButtonRelease_; 197 std::vector< std::vector< std::string > > bindingsJoyStickButtonHold_; 190 198 191 199 }; -
code/branches/input/visual_studio/core_properties.vsprops
r1084 r1193 12 12 <Tool 13 13 Name="VCLinkerTool" 14 AdditionalDependencies="OgreMain$(CSS).lib OIS$(CS).lib lua51$(CS).lib"14 AdditionalDependencies="OgreMain$(CSS).lib ois-1.2.0$(CS).lib lua-5.1$(CS).lib" 15 15 /> 16 16 </VisualStudioPropertySheet> -
code/branches/input/visual_studio/orxonox_properties.vsprops
r1084 r1193 14 14 <Tool 15 15 Name="VCLinkerTool" 16 AdditionalDependencies="OgreMain$(CSS).lib OIS$(CS).lib"16 AdditionalDependencies="OgreMain$(CSS).lib ois-1.2.0$(CS).lib" 17 17 OutputFile="$(OutDir)$(ProjectName)$(CS).exe" 18 18 IgnoreDefaultLibraryNames="" -
code/branches/input/visual_studio/orxonox_vc8.sln
r1064 r1193 57 57 EndProjectSection 58 58 EndProject 59 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tolua ++", "vc8\tolua++.vcproj", "{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}"59 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tolua", "vc8\tolua.vcproj", "{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}" 60 60 ProjectSection(WebsiteProperties) = preProject 61 61 Debug.AspNetCompiler.Debug = "True" … … 102 102 {2240ECD7-2F48-4431-8E1B-25466A384CCC}.static_libs_release|Win32.ActiveCfg = Release|Win32 103 103 {F101C2F0-1CB9-4A57-827B-6C399A99B28F}.Debug|Win32.ActiveCfg = Debug|Win32 104 {F101C2F0-1CB9-4A57-827B-6C399A99B28F}.Debug|Win32.Build.0 = Debug|Win32 104 105 {F101C2F0-1CB9-4A57-827B-6C399A99B28F}.Release|Win32.ActiveCfg = Release|Win32 106 {F101C2F0-1CB9-4A57-827B-6C399A99B28F}.Release|Win32.Build.0 = Release|Win32 105 107 {F101C2F0-1CB9-4A57-827B-6C399A99B28F}.static_libs_debug|Win32.ActiveCfg = Debug|Win32 106 108 {F101C2F0-1CB9-4A57-827B-6C399A99B28F}.static_libs_debug|Win32.Build.0 = Debug|Win32 … … 108 110 {F101C2F0-1CB9-4A57-827B-6C399A99B28F}.static_libs_release|Win32.Build.0 = Release|Win32 109 111 {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}.Debug|Win32.ActiveCfg = Debug|Win32 112 {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}.Debug|Win32.Build.0 = Debug|Win32 110 113 {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}.Release|Win32.ActiveCfg = Release|Win32 114 {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}.Release|Win32.Build.0 = Release|Win32 111 115 {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}.static_libs_debug|Win32.ActiveCfg = Debug|Win32 112 116 {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}.static_libs_debug|Win32.Build.0 = Debug|Win32 -
code/branches/input/visual_studio/tolua_properties.vsprops
r1158 r1193 3 3 ProjectType="Visual C++" 4 4 Version="8.00" 5 Name="tolua ++_properties"5 Name="tolua_properties" 6 6 InheritedPropertySheets=".\directory_properties.vsprops" 7 7 > 8 <Tool 9 Name="VCCLCompilerTool" 10 DisableSpecificWarnings="4996" 11 /> 8 12 </VisualStudioPropertySheet> -
code/branches/input/visual_studio/vc8/tolua.vcproj
r1158 r1193 3 3 ProjectType="Visual C++" 4 4 Version="8.00" 5 Name="tolua ++"5 Name="tolua" 6 6 ProjectGUID="{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}" 7 7 RootNamespace="FICN" … … 19 19 Name="Debug|Win32" 20 20 ConfigurationType="4" 21 InheritedPropertySheets="$(SolutionDir)base_properties_debug.vsprops;..\tolua ++_properties.vsprops"21 InheritedPropertySheets="$(SolutionDir)base_properties_debug.vsprops;..\tolua_properties.vsprops" 22 22 CharacterSet="1" 23 23 > … … 71 71 Name="Release|Win32" 72 72 ConfigurationType="4" 73 InheritedPropertySheets="$(SolutionDir)base_properties_release.vsprops;..\tolua ++_properties.vsprops"73 InheritedPropertySheets="$(SolutionDir)base_properties_release.vsprops;..\tolua_properties.vsprops" 74 74 CharacterSet="1" 75 75 WholeProgramOptimization="1"
Note: See TracChangeset
for help on using the changeset viewer.