Changeset 922 for code/branches/network/src
- Timestamp:
- Mar 25, 2008, 5:04:26 PM (17 years ago)
- Location:
- code/branches/network/src/orxonox
- Files:
-
- 3 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/orxonox/CMakeLists.txt
r919 r922 2 2 GraphicsEngine.cc 3 3 InputHandler.cc 4 InputEventListener.cc 4 5 Main.cc 5 6 Orxonox.cc -
code/branches/network/src/orxonox/InputHandler.cc
r921 r922 36 36 #include "core/CoreIncludes.h" 37 37 #include "Orxonox.h" 38 #include "InputEventListener.h" 38 39 #include "InputHandler.h" 39 40 40 41 namespace orxonox 41 42 { 42 //using namespace OIS;43 44 43 /** 45 44 @brief Constructor only resets the pointer values to 0. … … 47 46 InputHandler::InputHandler() 48 47 { 49 /*if (orxonox::Identifier::isCreatingHierarchy() && !this->getParents())50 this->createParents();51 this->setIdentifier(orxonox::ClassManager<InputHandler>::getIdentifier()->registerClass(this->getParents(), "InputHandler", true));52 if (orxonox::Identifier::isCreatingHierarchy() && this->getParents())53 this->getParents()->insert(this->getParents()->end(), this->getIdentifier());54 orxonox::ClassManager<InputHandler>::getIdentifier()->addObject(this);*/55 56 48 //RegisterObject(InputHandler); 57 58 49 this->mouse_ = 0; 59 50 this->keyboard_ = 0; 60 51 this->inputSystem_ = 0; 61 62 //this->setConfigValues();63 }64 65 void InputHandler::setConfigValues()66 {67 //SetConfigValue(codeFire_, 4).description("test value");68 69 ConfigValueContainer *containercodeFire_ = new ConfigValueContainer("asdfblah", "codeFire_", 4);70 containercodeFire_->getValue(&codeFire_).description("test");71 //containercodeFire_->72 52 } 73 53 … … 76 56 @return The pointer to the only instance of the InputHandler 77 57 */ 78 InputHandler *InputHandler::getSingleton()58 InputHandler *InputHandler::getSingleton() 79 59 { 80 60 static InputHandler theOnlyInstance; … … 83 63 84 64 /** 85 @brief Creates the OIS::InputMananger, the keyboard and the mouse 65 @brief Creates the OIS::InputMananger, the keyboard and the mouse and 66 assigns the key bindings. 86 67 @param windowHnd The window handle of the render window 87 68 @param windowWidth The width of the render window … … 120 101 } 121 102 } 103 104 // load the key bindings 105 InputEvent empty = {0, false, 0, 0, 0}; 106 for (int i = 0; i < this->numberOfKeys_; i++) 107 this->bindingsKeyPressed_[i] = empty; 108 109 //assign 'abort' to the escape key 110 this->bindingsKeyPressed_[(int)OIS::KC_ESCAPE].id = 1; 122 111 } 123 112 … … 130 119 // capture all the input. That calls the event handlers. 131 120 if (mouse_) 132 {133 121 mouse_->capture(); 134 }135 122 136 123 if (keyboard_) 137 {138 124 keyboard_->capture(); 139 }140 125 } 141 126 … … 155 140 156 141 /** 142 @brief Calls all the objects from classes that derive from InputEventListener. 143 @param evt The input event that occured. 144 */ 145 inline void InputHandler::callListeners(orxonox::InputEvent &evt) 146 { 147 for (Iterator<InputEventListener> it = ObjectList<InputEventListener>::start(); it; ) 148 { 149 if (it->bActive_) 150 (it++)->eventOccured(evt); 151 else 152 it++; 153 } 154 } 155 156 /** 157 157 @brief Event handler for the keyPressed Event. 158 158 @param e Event information … … 160 160 bool InputHandler::keyPressed(const OIS::KeyEvent &e) 161 161 { 162 if (e.key == OIS::KC_ESCAPE) 163 Orxonox::getSingleton()->abortRequest(); 162 callListeners(this->bindingsKeyPressed_[(int)e.key]); 164 163 return true; 165 164 } -
code/branches/network/src/orxonox/InputHandler.h
r921 r922 38 38 39 39 #include "OrxonoxPrereqs.h" 40 //#include "core/OrxonoxClass.h"41 40 #include "core/Tickable.h" 41 #include "InputEvent.h" 42 42 43 43 namespace orxonox 44 44 { 45 45 class _OrxonoxExport InputHandler 46 : public Tickable, 47 public OIS::KeyListener, public OIS::MouseListener 46 : public Tickable, public OIS::KeyListener, public OIS::MouseListener 48 47 { 48 //friend ClassIdentifier<InputHandler>; 49 49 public: 50 51 50 void initialise(size_t windowHnd, int windowWidth, int windowHeight); 52 51 void tick(float dt); … … 55 54 OIS::Mouse *getMouse() { return this->mouse_ ; } 56 55 OIS::Keyboard *getKeyboard() { return this->keyboard_; } 56 57 static InputHandler* getSingleton(); 58 59 private: 60 // don't mess with a Singleton 61 InputHandler (); 62 InputHandler (const InputHandler&) { } 63 ~InputHandler() { } 64 65 void callListeners(InputEvent &evt); 57 66 58 67 // input events … … 63 72 bool keyReleased (const OIS::KeyEvent &arg); 64 73 65 static InputHandler* getSingleton(); 74 OIS::InputManager *inputSystem_; //!< OIS input manager 75 OIS::Keyboard *keyboard_; //!< OIS mouse 76 OIS::Mouse *mouse_; //!< OIS keyboard 66 77 67 void setConfigValues(); 78 //! denotes the maximum number of different keys there are in OIS. 79 //! 256 should be ok since the highest number in the enum is 237. 80 static const int numberOfKeys_ = 256; 81 //! Array of input events for every pressed key 82 InputEvent bindingsKeyPressed_[numberOfKeys_]; 83 //! Array of input events for every released key 84 InputEvent bindingsKeyReleased_[numberOfKeys_]; 68 85 69 private: 70 // don't mess with a Singleton 71 InputHandler (); 72 InputHandler (const InputHandler&) { } 73 ~InputHandler() { } 74 75 OIS::InputManager *inputSystem_; 76 OIS::Keyboard *keyboard_; 77 OIS::Mouse *mouse_; 78 79 // Key bindings 80 int codeFire_; 81 OIS::KeyCode codeMoveForward_; 86 //! denotes the maximum number of different buttons there are in OIS. 87 //! 16 should be ok since the highest number in the enum is 7. 88 static const int numberOfButtons_ = 16; 89 //! Array of input events for every pressed key 90 InputEvent bindingsButtonPressed_[numberOfButtons_]; 91 //! Array of input events for every released key 92 InputEvent bindingsButtonReleased_[numberOfButtons_]; 82 93 83 94 }; -
code/branches/network/src/orxonox/Orxonox.cc
r919 r922 37 37 #include <OgreException.h> 38 38 #include <OgreRoot.h> 39 #include <OgreFrameListener.h>40 39 #include <OgreRenderWindow.h> 41 40 #include <OgreTextureManager.h> … … 373 372 } 374 373 375 374 /** 375 @brief Calls the InputHandler which sets up the input devices. 376 The render window width and height are used to set up the mouse movement. 377 */ 376 378 void Orxonox::setupInputSystem() 377 379 { … … 379 381 inputHandler_->initialise(ogre_->getWindowHandle(), 380 382 ogre_->getWindowWidth(), ogre_->getWindowHeight()); 381 382 /*size_t windowHnd = 0;383 std::ostringstream windowHndStr;384 OIS::ParamList pl;385 386 // fixes auto repeat problem387 #if defined OIS_LINUX_PLATFORM388 pl.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));389 #endif390 391 Ogre::RenderWindow *win = ogre_->getRoot()->getAutoCreatedWindow();392 win->getCustomAttribute("WINDOW", &windowHnd);393 windowHndStr << windowHnd;394 pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));395 inputManager_ = OIS::InputManager::createInputSystem(pl);396 397 try398 {399 keyboard_ = static_cast<OIS::Keyboard*>(inputManager_->createInputObject(OIS::OISKeyboard, false));400 mouse_ = static_cast<OIS::Mouse*>(inputManager_->createInputObject(OIS::OISMouse, true));401 }402 catch (const OIS::Exception &e)403 {404 throw new Ogre::Exception(42, e.eText, "OrxApplication::setupInputSystem");405 }*/406 383 } 407 384 … … 512 489 return (float)(times.back() - times.front()) / ((times.size()-1) * 1000); 513 490 } 491 492 void Orxonox::eventOccured(InputEvent &evt) 493 { 494 if (evt.id == 1) 495 this->abortRequest(); 496 } 514 497 } -
code/branches/network/src/orxonox/Orxonox.h
r919 r922 18 18 19 19 #include "GraphicsEngine.h" 20 #include "InputEventListener.h" 20 21 21 22 … … 30 31 }; 31 32 32 class _OrxonoxExport Orxonox 33 class _OrxonoxExport Orxonox : public InputEventListener 33 34 { 34 35 public: … … 68 69 float calculateEventTime(unsigned long, std::deque<unsigned long>&); 69 70 71 void eventOccured(InputEvent &evt); 72 70 73 private: 71 74 GraphicsEngine* ogre_; //!< our dearest graphics engine <3 -
code/branches/network/src/orxonox/OrxonoxPrereqs.h
r919 r922 68 68 class Camera; 69 69 class GraphicsEngine; 70 struct InputEvent; 71 class InputEventListener; 70 72 class InputHandler; 71 73 class Mesh; -
code/branches/network/src/orxonox/OrxonoxStableHeaders.h
r918 r922 46 46 #endif 47 47 //#include <Ogre.h> 48 //#include <OgreBillboardSet.h> 49 //#include <OgreCamera.h> 50 //#include <OgreConfigFile.h> 48 #include <OgreBillboardSet.h> 49 #include <OgreCamera.h> 50 #include <OgreColourValue.h> 51 #include <OgreConfigFile.h> 51 52 #include <OgreEntity.h> 52 53 #include <OgreException.h> 53 //#include <OgreFrameListener.h>54 #include <OgreFrameListener.h> 54 55 #include <OgreLight.h> 55 //#include <OgreOverlay.h> 56 //#include <OgreOverlayElement.h> 57 //#include <OgreOverlayManager.h> 56 #include <OgreMath.h> 57 #include <OgreMatrix3.h> 58 #include <OgreOverlay.h> 59 #include <OgreOverlayElement.h> 60 #include <OgreOverlayManager.h> 58 61 #include <OgreParticleEmitter.h> 59 62 #include <OgreParticleSystem.h> 60 63 #include <OgrePlatform.h> 61 64 #include <OgrePrerequisites.h> 62 //#include <OgreRenderWindow.h> 63 //#include <OgreRoot.h> 65 #include <OgreQuaternion.h> 66 #include <OgreResourceGroupManager.h> 67 #include <OgreRenderWindow.h> 68 #include <OgreRoot.h> 64 69 #include <OgreSceneManager.h> 65 70 #include <OgreSceneNode.h> 66 71 #include <OgreStringConverter.h> 67 //#include <OgreTextureManager.h> 68 //#include <OgreViewport.h> 72 #include <OgreTextureManager.h> 73 #include <OgreTimer.h> 74 #include <OgreVector2.h> 75 #include <OgreVector3.h> 76 #include <OgreVector3.h> 77 #include <OgreViewport.h> 78 #include <OgreWindowEventUtilities.h> 69 79 70 80 #include <OIS/OIS.h>
Note: See TracChangeset
for help on using the changeset viewer.