Changeset 1118 for code/branches/input/src/core
- Timestamp:
- Apr 20, 2008, 4:31:03 PM (17 years ago)
- Location:
- code/branches/input/src/core
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/input/src/core/InputHandler.cc
r1112 r1118 74 74 this->bindingsKeyPress_[OIS::KC_NUMPADENTER] = "setInputMode " + getConvertedValue<int, std::string>(IM_KEYBOARD); 75 75 this->bindingsKeyPress_[OIS::KC_ESCAPE] = "exit"; 76 this->bindingsKeyHold_[OIS::KC_U] = "exec disco.txt"; 76 77 return true; 77 78 } … … 83 84 bool InputHandlerGame::keyPressed(const OIS::KeyEvent &e) 84 85 { 86 this->keysDown_.push_back(e.key); 85 87 // find the appropriate key binding 86 88 std::string cmdStr = bindingsKeyPress_[int(e.key)]; … … 99 101 bool InputHandlerGame::keyReleased(const OIS::KeyEvent &e) 100 102 { 103 // remove the key from the keysDown_ list 104 for (std::list<OIS::KeyCode>::iterator it = keysDown_.begin(); it != keysDown_.end(); it++) 105 { 106 if (*it == e.key) 107 { 108 keysDown_.erase(it); 109 break; 110 } 111 } 112 101 113 // find the appropriate key binding 102 114 std::string cmdStr = bindingsKeyRelease_[int(e.key)]; … … 136 148 { 137 149 return true; 150 } 151 152 /** 153 @brief Tick method to do additional calculations. 154 @param dt Delta time. 155 */ 156 void InputHandlerGame::tick(float dt) 157 { 158 // iterate through all the pressed keys 159 for (std::list<OIS::KeyCode>::iterator it = keysDown_.begin(); it != keysDown_.end(); it++) 160 { 161 // find the appropriate key binding 162 std::string cmdStr = bindingsKeyHold_[*it]; 163 if (cmdStr != "") 164 { 165 CommandExecutor::execute(cmdStr); 166 COUT(3) << "Executing command: " << cmdStr << std::endl; 167 } 168 } 138 169 } 139 170 … … 225 256 } 226 257 258 /** 259 @brief Tick method to do additional calculations. 260 @param dt Delta time. 261 */ 262 void InputHandlerGUI::tick(float dt) 263 { 264 265 } 266 227 267 } -
code/branches/input/src/core/InputHandler.h
r1112 r1118 38 38 39 39 #include <string> 40 #include <list> 40 41 #include <OIS/OIS.h> 41 42 … … 48 49 enum KeybindSetting 49 50 { 50 none,51 onPress,52 onRelease,53 continuous,51 None, 52 OnPress, 53 OnRelease, 54 Continuous, 54 55 }; 55 56 } … … 58 59 : public OIS::KeyListener, public OIS::MouseListener 59 60 { 61 virtual void tick(float dt) = 0; 60 62 }; 61 63 … … 80 82 bool keyReleased (const OIS::KeyEvent &arg); 81 83 84 void tick(float dt); 85 82 86 // temporary hack 83 87 void callListeners(InputEvent &evt); 88 89 //! Stores all the keys that are down 90 std::list<OIS::KeyCode> keysDown_; 84 91 85 92 /** denotes the maximum number of different keys there are in OIS. … … 114 121 ~InputHandlerGUI(); 115 122 123 void tick(float dt); 124 116 125 private: 117 126 // input events -
code/branches/input/src/core/InputManager.cc
r1112 r1118 207 207 if (mouse_) 208 208 mouse_->capture(); 209 210 209 if (keyboard_) 211 210 keyboard_->capture(); 211 212 // Give the listeners the chance to do additional calculations 212 213 } 213 214
Note: See TracChangeset
for help on using the changeset viewer.