Changeset 3327 for code/trunk/src/core/input/Mouse.cc
- Timestamp:
- Jul 19, 2009, 5:31:02 PM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/core4 merged: 3269,3271-3275,3278,3285,3290-3294,3310
- Property svn:mergeinfo changed
-
code/trunk/src/core/input/Mouse.cc
r3276 r3327 30 30 31 31 #include <ois/OISMouse.h> 32 #include <boost/foreach.hpp> 32 #include "core/ConsoleCommand.h" 33 #include "core/CoreIncludes.h" 33 34 #include "InputState.h" 34 #include "core/ConsoleCommand.h"35 35 36 // HACK (include this as last, X11 seems to define some macros...)37 36 #ifdef ORXONOX_PLATFORM_LINUX 38 # include <ois/linux/LinuxMouse.h> 37 // include this as last, X11 seems to define some macros... 38 #include <ois/linux/LinuxMouse.h> 39 39 #endif 40 40 41 41 namespace orxonox 42 42 { 43 Mouse::Mouse(unsigned int id, unsigned int windowWidth, unsigned int windowHeight)44 : super(id )43 Mouse::Mouse(unsigned int id, OIS::InputManager* oisInputManager) 44 : super(id, oisInputManager) 45 45 { 46 this->setMouseClipping(windowWidth, windowHeight); 47 // HACK: 48 instancePointer_s = this; 49 } 46 RegisterRootObject(Mouse); 47 this->windowResized(this->getWindowWidth(), this->getWindowHeight()); 50 48 51 void Mouse::setMouseClipping(unsigned int width, unsigned int height) 52 {53 oisDevice_->getMouseState().width = width;54 oisDevice_->getMouseState().height = height;55 }56 57 unsigned int Mouse::getClippingWidth() const58 {59 return oisDevice_->getMouseState().width;60 }61 62 unsigned int Mouse::getClippingHeight() const63 {64 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 65 63 } 66 64 … … 74 72 IntVector2 rel(e.state.X.rel, e.state.Y.rel); 75 73 IntVector2 clippingSize(e.state.width, e.state.height); 76 BOOST_FOREACH(InputState* state, inputStates_)77 state->mouseMoved(abs, rel, clippingSize);74 for (unsigned int i = 0; i < inputStates_.size(); ++i) 75 inputStates_[i]->mouseMoved(abs, rel, clippingSize); 78 76 } 79 77 … … 81 79 if (e.state.Z.rel != 0) 82 80 { 83 BOOST_FOREACH(InputState* state, inputStates_)84 state->mouseScrolled(e.state.Z.abs, e.state.Z.rel);81 for (unsigned int i = 0; i < inputStates_.size(); ++i) 82 inputStates_[i]->mouseScrolled(e.state.Z.abs, e.state.Z.rel); 85 83 } 86 84 … … 88 86 } 89 87 90 // ############################################################ 91 // ##### ugly hacks ##### 92 // ########## ########## 93 // ############################################################ 94 95 // HACK: 96 SetConsoleCommand(Mouse, setMouseClipping_s, false); 97 #ifdef ORXONOX_PLATFORM_LINUX 98 SetConsoleCommand(Mouse, grabMouse, true); 99 SetConsoleCommand(Mouse, ungrabMouse, true); 100 #endif 101 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 } 102 93 103 94 #ifdef ORXONOX_PLATFORM_LINUX 104 void Mouse::grab Mouse()95 void Mouse::grab() 105 96 { 106 OIS::LinuxMouse* linuxMouse = dynamic_cast<OIS::LinuxMouse*>( instancePointer_s->oisDevice_);97 OIS::LinuxMouse* linuxMouse = dynamic_cast<OIS::LinuxMouse*>(oisDevice_); 107 98 assert(linuxMouse); 108 99 linuxMouse->grab(true); 109 100 } 110 101 111 void Mouse::ungrab Mouse()102 void Mouse::ungrab() 112 103 { 113 OIS::LinuxMouse* linuxMouse = dynamic_cast<OIS::LinuxMouse*>( instancePointer_s->oisDevice_);104 OIS::LinuxMouse* linuxMouse = dynamic_cast<OIS::LinuxMouse*>(oisDevice_); 114 105 assert(linuxMouse); 115 106 linuxMouse->grab(false);
Note: See TracChangeset
for help on using the changeset viewer.