Changeset 1112 for code/branches/input
- Timestamp:
- Apr 19, 2008, 10:31:52 PM (17 years ago)
- Location:
- code/branches/input
- Files:
-
- 1 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/input/src/core/InputHandler.cc
r1066 r1112 38 38 #include "InputEvent.h" 39 39 #include "InputManager.h" 40 #include "core/CommandExecutor.h" 40 41 41 42 namespace orxonox … … 68 69 { 69 70 // simply write the key number (i) in the string 70 this->bindingsKeyPressed_[i] = getConvertedValue<int, std::string>(i); 71 this->bindingsKeyReleased_[i] = getConvertedValue<int, std::string>(i); 72 } 71 this->bindingsKeyPress_[i] = ""; 72 this->bindingsKeyRelease_[i] = ""; 73 } 74 this->bindingsKeyPress_[OIS::KC_NUMPADENTER] = "setInputMode " + getConvertedValue<int, std::string>(IM_KEYBOARD); 75 this->bindingsKeyPress_[OIS::KC_ESCAPE] = "exit"; 73 76 return true; 74 77 } … … 80 83 bool InputHandlerGame::keyPressed(const OIS::KeyEvent &e) 81 84 { 82 if (e.key == OIS::KC_ESCAPE) 83 { 84 InputEvent e = {1, true, 0, 0, 0}; 85 InputHandlerGame::callListeners(e); 86 } 87 else if (e.key == OIS::KC_NUMPADENTER) 88 { 89 InputManager::getSingleton().setInputMode(IM_KEYBOARD); 90 } 91 else 92 { 93 // find the appropriate key binding 94 std::string cmdStr = bindingsKeyPressed_[int(e.key)]; 95 //COUT(3) << cmdStr << " pressed" << std::endl; 85 // find the appropriate key binding 86 std::string cmdStr = bindingsKeyPress_[int(e.key)]; 87 if (cmdStr != "") 88 { 89 CommandExecutor::execute(cmdStr); 90 COUT(3) << "Executing command: " << cmdStr << std::endl; 96 91 } 97 92 return true; … … 105 100 { 106 101 // find the appropriate key binding 107 std::string cmdStr = bindingsKeyReleased_[int(e.key)]; 108 //COUT(3) << cmdStr << " released" << std::endl; 102 std::string cmdStr = bindingsKeyRelease_[int(e.key)]; 103 if (cmdStr != "") 104 { 105 CommandExecutor::execute(cmdStr); 106 COUT(3) << "Executing command: " << cmdStr << std::endl; 107 } 109 108 return true; 110 109 } -
code/branches/input/src/core/InputHandler.h
r1062 r1112 44 44 namespace orxonox 45 45 { 46 namespace KeybindSetting 47 { 48 enum KeybindSetting 49 { 50 none, 51 onPress, 52 onRelease, 53 continuous, 54 }; 55 } 56 57 class _CoreExport BaseInputHandler 58 : public OIS::KeyListener, public OIS::MouseListener 59 { 60 }; 61 46 62 /** 47 63 @brief Captures mouse and keyboard input while in the actual game mode. 48 64 Manages the key bindings. 49 65 */ 50 class _CoreExport InputHandlerGame 51 : public OIS::KeyListener, public OIS::MouseListener 66 class _CoreExport InputHandlerGame : public BaseInputHandler 52 67 { 53 68 public: … … 72 87 static const int numberOfKeys_s = 256; 73 88 //! Array of input events for every pressed key 74 std::string bindingsKeyPress ed_[numberOfKeys_s];89 std::string bindingsKeyPress_[numberOfKeys_s]; 75 90 //! Array of input events for every released key 76 std::string bindingsKeyReleased_[numberOfKeys_s]; 91 std::string bindingsKeyRelease_[numberOfKeys_s]; 92 //! Array of input events for every holding key 93 std::string bindingsKeyHold_[numberOfKeys_s]; 77 94 78 95 /** denotes the maximum number of different buttons there are in OIS. … … 91 108 GUI. 92 109 */ 93 class _CoreExport InputHandlerGUI 94 : public OIS::KeyListener, public OIS::MouseListener 110 class _CoreExport InputHandlerGUI : public BaseInputHandler 95 111 { 96 112 public: -
code/branches/input/src/core/InputManager.cc
r1089 r1112 93 93 paramList.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str())); 94 94 95 #if defined OIS_LINUX_PLATFORM96 paramList.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));97 #endif95 //#if defined OIS_LINUX_PLATFORM 96 // paramList.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true"))); 97 //#endif 98 98 99 99 try -
code/branches/input/src/orxonox/Orxonox.cc
r1092 r1112 54 54 //#include "util/Sleep.h" 55 55 #include "util/ArgReader.h" 56 #include "util/FloatParser.h" 56 57 57 58 // core … … 123 124 InputBuffer* ib_; 124 125 }; 126 127 class Calculator 128 { 129 public: 130 static void calculate(std::string calculation) 131 { 132 char** useless = 0; 133 double result = 0.0; 134 bool success = parse_float((char* const)calculation.c_str(), useless, &result); 135 if (success) 136 { 137 if (result == 42.0) 138 std::cout << "Greetings from the restaurant at the end of the universe." << std::endl; 139 std::cout << "Result is: " << result << std::endl; 140 } 141 else 142 std::cout << "Cannot calculate expression: Parse error" << std::endl; 143 } 144 }; 145 ConsoleCommandShortcut(Calculator, calculate, AccessLevel::None); 125 146 126 147 /** … … 410 431 return; 411 432 } 433 Ogre::Root& ogreRoot = Ogre::Root::getSingleton(); 434 412 435 413 436 // Contains the times of recently fired events … … 429 452 { 430 453 // Pump messages in all registered RenderWindows 454 // This calls the WindowEventListener objects. 431 455 Ogre::WindowEventUtilities::messagePump(); 432 456 … … 452 476 // don't forget to call _fireFrameStarted in ogre to make sure 453 477 // everything goes smoothly 454 Ogre::Root::getSingleton()._fireFrameStarted(evt);478 ogreRoot._fireFrameStarted(evt); 455 479 456 480 // server still renders at the moment 457 481 //if (mode_ != SERVER) 458 Ogre::Root::getSingleton()._updateAllRenderTargets(); // only render in non-server mode482 ogreRoot._updateAllRenderTargets(); // only render in non-server mode 459 483 460 484 // get current time … … 466 490 467 491 // again, just to be sure ogre works fine 468 Ogre::Root::getSingleton()._fireFrameEnded(evt);492 ogreRoot._fireFrameEnded(evt); 469 493 } 470 494 } -
code/branches/input/src/util/String.cc
r1064 r1112 274 274 if (str.size() == 0) 275 275 return str; 276 else if (str.size() == 1) 277 { 278 //TODO: decide whether we need the commented code 279 /*if (str[0] != '\\') 280 return ""; 281 else*/ 282 return str; 283 } 276 284 277 285 std::string output = ""; -
code/branches/input/visual_studio/vc8/core.vcproj
r1084 r1112 258 258 RelativePath="..\..\src\core\tolua\tolua_bind.cc" 259 259 > 260 <FileConfiguration261 Name="Debug|Win32"262 >263 <Tool264 Name="VCCLCompilerTool"265 />266 </FileConfiguration>267 260 </File> 268 261 </Filter> -
code/branches/input/visual_studio/vc8/util.vcproj
r1064 r1112 157 157 </File> 158 158 <File 159 RelativePath="..\..\src\util\FloatParser.cpp" 160 > 161 </File> 162 <File 159 163 RelativePath="..\..\src\util\Math.cc" 160 164 > … … 199 203 </File> 200 204 <File 205 RelativePath="..\..\src\util\FloatParser.h" 206 > 207 </File> 208 <File 201 209 RelativePath="..\..\src\util\Math.h" 202 210 >
Note: See TracChangeset
for help on using the changeset viewer.