Changeset 922 for code/branches/network/src/orxonox/InputHandler.cc
- Timestamp:
- Mar 25, 2008, 5:04:26 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.