Changeset 3291 for code/branches/core4/src/core/input
- Timestamp:
- Jul 14, 2009, 11:50:47 AM (15 years ago)
- Location:
- code/branches/core4/src/core/input
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core4/src/core/input/InputManager.cc
r3288 r3291 82 82 // ########## ########## 83 83 // ############################################################ 84 InputManager::InputManager(size_t windowHnd , unsigned int windowWidth, unsigned int windowHeight)84 InputManager::InputManager(size_t windowHnd) 85 85 : internalState_(Bad) 86 86 , oisInputManager_(0) … … 100 100 this->setConfigValues(); 101 101 102 this->loadDevices(windowHnd , windowWidth, windowHeight);102 this->loadDevices(windowHnd); 103 103 104 104 // Lowest priority empty InputState … … 157 157 The height of the render window 158 158 */ 159 void InputManager::loadDevices(size_t windowHnd , unsigned int windowWidth, unsigned int windowHeight)159 void InputManager::loadDevices(size_t windowHnd) 160 160 { 161 161 CCOUT(3) << "Loading input devices..." << std::endl; … … 216 216 217 217 // TODO: Remove the two parameters 218 this->loadMouse( windowWidth, windowHeight);218 this->loadMouse(); 219 219 this->loadJoySticks(); 220 220 … … 226 226 227 227 //! Creates a new orxonox::Mouse 228 void InputManager::loadMouse( unsigned int windowWidth, unsigned int windowHeight)228 void InputManager::loadMouse() 229 229 { 230 230 if (oisInputManager_->getNumberOfDevices(OIS::OISMouse) > 0) … … 232 232 try 233 233 { 234 devices_[InputDeviceEnumerator::Mouse] = new Mouse(InputDeviceEnumerator::Mouse, oisInputManager_ , windowWidth, windowHeight);234 devices_[InputDeviceEnumerator::Mouse] = new Mouse(InputDeviceEnumerator::Mouse, oisInputManager_); 235 235 } 236 236 catch (const OIS::Exception& ex) … … 368 368 CCOUT(3) << "Reloading ..." << std::endl; 369 369 370 // Save mouse clipping size371 int clippingWidth = 800;372 int clippingHeight = 600;373 if (devices_[InputDeviceEnumerator::Mouse])374 {375 int clippingWidth = static_cast<Mouse*>(devices_[InputDeviceEnumerator::Mouse])->getClippingWidth();376 int clippingHeight = static_cast<Mouse*>(devices_[InputDeviceEnumerator::Mouse])->getClippingHeight();377 }378 379 370 this->destroyDevices(); 380 this->loadDevices(windowHnd_ , clippingWidth, clippingHeight);371 this->loadDevices(windowHnd_); 381 372 382 373 internalState_ &= ~Bad; … … 563 554 } 564 555 556 //! Gets called by WindowEventListener upon focus change --> clear buffers 557 void InputManager::windowFocusChanged() 558 { 559 this->clearBuffers(); 560 } 561 565 562 // ############################################################ 566 563 // ##### Iput States ##### -
code/branches/core4/src/core/input/InputManager.h
r3286 r3291 37 37 #include <vector> 38 38 39 #include "core/ OrxonoxClass.h"39 #include "core/WindowEventListener.h" 40 40 #include "InputState.h" 41 41 … … 62 62 If the OIS::InputManager or the Keyboard fail, an exception is thrown. 63 63 */ 64 class _CoreExport InputManager : public OrxonoxClass64 class _CoreExport InputManager : public WindowEventListener 65 65 { 66 66 public: … … 82 82 the constructor fails with an std::exception. 83 83 */ 84 InputManager(size_t windowHnd , unsigned int windowWidth, unsigned int windowHeight);84 InputManager(size_t windowHnd); 85 85 //! Destroys all devices AND all input states! 86 86 ~InputManager(); … … 176 176 177 177 // Intenal methods 178 void loadDevices(size_t windowHnd , unsigned int windowWidth, unsigned int windowHeight);179 void loadMouse( unsigned int windowWidth, unsigned int windowHeight);178 void loadDevices(size_t windowHnd); 179 void loadMouse(); 180 180 void loadJoySticks(); 181 181 void destroyDevices(); … … 186 186 void destroyStateInternal(InputState* state); 187 187 void updateActiveStates(); 188 189 // From WindowEventListener 190 void windowFocusChanged(); 188 191 189 192 private: // variables -
code/branches/core4/src/core/input/JoyStickQuantityListener.h
r3288 r3291 44 44 { 45 45 friend InputManager; 46 p ublic:46 protected: 47 47 JoyStickQuantityListener(); 48 48 virtual ~JoyStickQuantityListener() { } -
code/branches/core4/src/core/input/Mouse.cc
r3286 r3291 30 30 31 31 #include <ois/OISMouse.h> 32 #include "core/ConsoleCommand.h" 33 #include "core/CoreIncludes.h" 32 34 #include "InputState.h" 33 #include "core/ConsoleCommand.h"34 35 35 // HACK (include this as last, X11 seems to define some macros...)36 36 #ifdef ORXONOX_PLATFORM_LINUX 37 # include <ois/linux/LinuxMouse.h> 37 // include this as last, X11 seems to define some macros... 38 #include <ois/linux/LinuxMouse.h> 38 39 #endif 39 40 40 41 namespace orxonox 41 42 { 42 Mouse::Mouse(unsigned int id, OIS::InputManager* oisInputManager , unsigned int windowWidth, unsigned int windowHeight)43 Mouse::Mouse(unsigned int id, OIS::InputManager* oisInputManager) 43 44 : super(id, oisInputManager) 44 45 { 45 this->setMouseClipping(windowWidth, windowHeight); 46 // HACK: 47 instancePointer_s = this; 48 } 46 RegisterRootObject(Mouse); 47 this->windowResized(this->getWindowHeight(), this->getWindowHeight()); 49 48 50 void Mouse::setMouseClipping(unsigned int width, unsigned int height) 51 {52 oisDevice_->getMouseState().width = width;53 oisDevice_->getMouseState().height = height;54 }55 56 unsigned int Mouse::getClippingWidth() const57 {58 return oisDevice_->getMouseState().width;59 }60 61 unsigned int Mouse::getClippingHeight() const62 {63 return oisDevice_->getMouseState().height; 49 #ifdef ORXONOX_PLATFORM_LINUX 50 { 51 // Mouse grab console command 52 FunctorMember<Mouse>* functor = createFunctor(&Mouse::grab); 53 functor->setObject(this); 54 this->getIdentifier()->addConsoleCommand(createConsoleCommand(functor, "grab"), false); 55 } 56 { 57 // Mouse ungrab console command 58 FunctorMember<Mouse>* functor = createFunctor(&Mouse::ungrab); 59 functor->setObject(this); 60 this->getIdentifier()->addConsoleCommand(createConsoleCommand(functor, "ungrab"), false); 61 } 62 #endif 64 63 } 65 64 … … 87 86 } 88 87 89 // ############################################################ 90 // ##### ugly hacks ##### 91 // ########## ########## 92 // ############################################################ 93 94 // HACK: 95 SetConsoleCommand(Mouse, setMouseClipping_s, false); 96 #ifdef ORXONOX_PLATFORM_LINUX 97 SetConsoleCommand(Mouse, grabMouse, true); 98 SetConsoleCommand(Mouse, ungrabMouse, true); 99 #endif 100 Mouse* Mouse::instancePointer_s = NULL; 88 void Mouse::windowResized(unsigned int newWidth, unsigned int newHeight) 89 { 90 oisDevice_->getMouseState().width = newWidth; 91 oisDevice_->getMouseState().height = newHeight; 92 } 101 93 102 94 #ifdef ORXONOX_PLATFORM_LINUX -
code/branches/core4/src/core/input/Mouse.h
r3286 r3291 31 31 32 32 #include "InputPrereqs.h" 33 33 34 #include "InputDevice.h" 35 #include "core/WindowEventListener.h" 34 36 35 37 namespace orxonox … … 53 55 : public InputDeviceTemplated<MouseTraits> 54 56 , public OIS::MouseListener 57 , public WindowEventListener 55 58 { 56 59 friend class InputDeviceTemplated<MouseTraits>; … … 60 63 public: 61 64 //! Only sets the clipping size. Initialising is done in the base class. 62 Mouse(unsigned int id, OIS::InputManager* oisInputManager , unsigned int windowWidth, unsigned int windowHeight);65 Mouse(unsigned int id, OIS::InputManager* oisInputManager); 63 66 ~Mouse() { } 64 67 65 /**66 @brief67 Adjusts the mouse window metrics.68 69 This method has to be called every time the size of the window changes.70 */71 void setMouseClipping(unsigned int width, unsigned int height);72 // Returns the width of the mouse window73 unsigned int getClippingWidth() const;74 // Returns the height of the mouse window75 unsigned int getClippingHeight() const;76 77 // HACK!78 static void setMouseClipping_s(unsigned int width, unsigned int height)79 { instancePointer_s->setMouseClipping(width, height); }80 void setConfigValues() { }81 68 #ifdef ORXONOX_PLATFORM_LINUX 82 // HACK!83 69 // TODO: Make this a feature rather than a hack 84 staticvoid grabMouse();85 staticvoid ungrabMouse();70 void grabMouse(); 71 void ungrabMouse(); 86 72 #endif 87 73 … … 103 89 bool mouseMoved(const OIS::MouseEvent &arg); 104 90 91 void windowResized(unsigned int newWidth, unsigned int newHeight); 92 105 93 // Returns the class name as string 106 94 static std::string getClassNameImpl() { return "Mouse"; } 107 108 // HACK:109 static Mouse* instancePointer_s;110 95 }; 111 96 }
Note: See TracChangeset
for help on using the changeset viewer.