Changeset 1022
- Timestamp:
- Apr 10, 2008, 5:12:02 PM (17 years ago)
- Location:
- code/branches/input
- Files:
-
- 2 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/input/src/orxonox/GraphicsEngine.cc
r969 r1022 76 76 void GraphicsEngine::setConfigValues() 77 77 { 78 SetConfigValue(dataPath_, dataPath_).description("relative path to media data");79 SetConfigValue(ogreLogfile_, "ogre.log").description("Logfile for messages from Ogre. Use to\"\" to suppress log file creation.");78 SetConfigValue(dataPath_, "../../media/").description("relative path to media data"); 79 SetConfigValue(ogreLogfile_, "ogre.log").description("Logfile for messages from Ogre. Use \"\" to suppress log file creation."); 80 80 SetConfigValue(ogreLogLevelTrivial_ , 5).description("relative path to media data"); 81 81 SetConfigValue(ogreLogLevelNormal_ , 4).description("relative path to media data"); … … 139 139 // temporary overwrite of dataPath, change ini file for permanent change 140 140 if( dataPath != "" ) 141 dataPath_ = dataPath ;141 dataPath_ = dataPath + "/"; 142 142 loadRessourceLocations(this->dataPath_); 143 143 if (!root_->restoreConfig() && !root_->showConfigDialog()) -
code/branches/input/src/orxonox/Orxonox.cc
r973 r1022 147 147 singletonRef_s = new Orxonox(); 148 148 return singletonRef_s; 149 //static Orxonox theOnlyInstance;150 //return &theOnlyInstance;151 149 } 152 150 … … 331 329 ogre_->getWindowWidth(), ogre_->getWindowHeight())) 332 330 abortImmediate(); 331 inputHandler_->setInputMode(IM_INGAME); 333 332 } 334 333 -
code/branches/input/src/orxonox/OrxonoxPlatform.h
r975 r1022 190 190 191 191 // Integer formats of fixed bit width 192 typedef unsigned int uint32; 192 // FIXME: consider 64 bit platforms! 193 /*typedef unsigned int uint32; 193 194 typedef unsigned short uint16; 194 typedef unsigned char uint8; 195 typedef unsigned char uint8;*/ 195 196 196 197 #ifdef ORXONOX_DOUBLE_PRECISION -
code/branches/input/src/orxonox/core/InputEventListener.cc
r971 r1022 22 22 * Reto Grieder 23 23 * Co-authors: 24 * Some guy writing the example code from Ogre24 * ... 25 25 * 26 26 */ -
code/branches/input/src/orxonox/core/InputEventListener.h
r973 r1022 46 46 class _CoreExport InputEventListener : virtual public OrxonoxClass 47 47 { 48 friend class Input Manager;48 friend class InputHandlerGame; 49 49 public: 50 50 InputEventListener(); -
code/branches/input/src/orxonox/core/InputHandler.cc
r973 r1022 31 31 */ 32 32 33 #include "Debug.h" 34 #include "util/Convert.h" 35 #include "InputEventListener.h" 36 #include "InputEvent.h" 33 37 #include "InputHandler.h" 34 38 … … 54 58 55 59 /** 60 @brief Loads the key bindings from the ini file. 61 Currently, this is just a simple test routine that fills the list with numbers. 62 */ 63 bool InputHandlerGame::loadBindings() 64 { 65 for (int i = 0; i < numberOfKeys_s; i++) 66 { 67 // simply write the key number (i) in the string 68 this->bindingsKeyPressed_[i] = ConvertValueAndReturn<int, std::string>(i); 69 this->bindingsKeyReleased_[i] = ConvertValueAndReturn<int, std::string>(i); 70 } 71 return true; 72 } 73 74 /** 56 75 @brief Event handler for the keyPressed Event. 57 76 @param e Event information … … 59 78 bool InputHandlerGame::keyPressed(const OIS::KeyEvent &e) 60 79 { 80 if (e.key == OIS::KC_ESCAPE) 81 { 82 InputEvent e = {1, true, 0, 0, 0}; 83 InputHandlerGame::callListeners(e); 84 } 85 else 86 { 87 // find the appropriate key binding 88 std::string cmdStr = bindingsKeyPressed_[int(e.key)]; 89 //COUT(3) << cmdStr << " pressed" << std::endl; 90 } 61 91 return true; 62 92 } … … 68 98 bool InputHandlerGame::keyReleased(const OIS::KeyEvent &e) 69 99 { 100 // find the appropriate key binding 101 std::string cmdStr = bindingsKeyReleased_[int(e.key)]; 102 //COUT(3) << cmdStr << " released" << std::endl; 70 103 return true; 71 104 } … … 100 133 } 101 134 135 /** 136 @brief Calls all the objects from classes that derive from InputEventListener. 137 @param evt The input event that occured. 138 */ 139 inline void InputHandlerGame::callListeners(orxonox::InputEvent &evt) 140 { 141 for (Iterator<InputEventListener> it = ObjectList<InputEventListener>::start(); it; ) 142 { 143 if (it->bActive_) 144 (it++)->eventOccured(evt); 145 else 146 it++; 147 } 148 } 149 150 102 151 // ############################### 103 152 // ### InputHandlerGUI ### … … 124 173 bool InputHandlerGUI::keyPressed(const OIS::KeyEvent &e) 125 174 { 175 //CEGUI::System::getSingleton().injectKeyDown( arg.key ); 176 //CEGUI::System::getSingleton().injectChar( arg.text ); 126 177 return true; 127 178 } … … 133 184 bool InputHandlerGUI::keyReleased(const OIS::KeyEvent &e) 134 185 { 186 //CEGUI::System::getSingleton().injectKeyUp( arg.key ); 135 187 return true; 136 188 } … … 142 194 bool InputHandlerGUI::mouseMoved(const OIS::MouseEvent &e) 143 195 { 196 //CEGUI::System::getSingleton().injectMouseMove( arg.state.X.rel, arg.state.Y.rel ); 144 197 return true; 145 198 } … … 152 205 bool InputHandlerGUI::mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id) 153 206 { 207 //CEGUI::System::getSingleton().injectMouseButtonDown(convertOISMouseButtonToCegui(id)); 154 208 return true; 155 209 } … … 162 216 bool InputHandlerGUI::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id) 163 217 { 218 //CEGUI::System::getSingleton().injectMouseButtonUp(convertOISMouseButtonToCegui(id)); 164 219 return true; 165 220 } -
code/branches/input/src/orxonox/core/InputHandler.h
r973 r1022 28 28 /** 29 29 @file 30 @brief Different implementations of input processing.30 @brief Different definitions of input processing. 31 31 */ 32 32 … … 34 34 #define _InputHandler_H__ 35 35 36 #include <string> 37 36 38 #include <OIS/OIS.h> 37 39 38 40 #include "CorePrereqs.h" 41 #include "InputEvent.h" 39 42 40 43 namespace orxonox 41 44 { 45 /** 46 @brief Captures mouse and keyboard input while in the actual game mode. 47 Manages the key bindings. 48 */ 49 class _CoreExport InputHandlerGame 50 : public OIS::KeyListener, public OIS::MouseListener 51 { 52 public: 53 InputHandlerGame (); 54 ~InputHandlerGame(); 55 56 bool loadBindings(); 57 58 private: 59 // input events 60 bool mousePressed (const OIS::MouseEvent &arg, OIS::MouseButtonID id); 61 bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id); 62 bool mouseMoved (const OIS::MouseEvent &arg); 63 bool keyPressed (const OIS::KeyEvent &arg); 64 bool keyReleased (const OIS::KeyEvent &arg); 65 66 // temporary hack 67 void callListeners(InputEvent &evt); 68 69 /** denotes the maximum number of different keys there are in OIS. 70 256 should be ok since the highest number in the enum is 237. */ 71 static const int numberOfKeys_s = 256; 72 //! Array of input events for every pressed key 73 std::string bindingsKeyPressed_[numberOfKeys_s]; 74 //! Array of input events for every released key 75 std::string bindingsKeyReleased_[numberOfKeys_s]; 76 77 /** denotes the maximum number of different buttons there are in OIS. 78 16 should be ok since the highest number in the enum is 7. */ 79 static const int numberOfButtons_s = 16; 80 //! Array of input events for every pressed key 81 std::string bindingsButtonPressed_[numberOfButtons_s]; 82 //! Array of input events for every released key 83 std::string bindingsButtonReleased_[numberOfButtons_s]; 84 85 }; 86 87 42 88 /** 43 89 @brief Captures mouse and keyboard input and distributes it to the … … 60 106 }; 61 107 62 63 /**64 @brief Captures mouse and keyboard input while in the actual game mode.65 Manages the key bindings.66 */67 class _CoreExport InputHandlerGame68 : public OIS::KeyListener, public OIS::MouseListener69 {70 public:71 InputHandlerGame ();72 ~InputHandlerGame();73 74 private:75 // input events76 bool mousePressed (const OIS::MouseEvent &arg, OIS::MouseButtonID id);77 bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id);78 bool mouseMoved (const OIS::MouseEvent &arg);79 bool keyPressed (const OIS::KeyEvent &arg);80 bool keyReleased (const OIS::KeyEvent &arg);81 };82 83 108 } 84 109 -
code/branches/input/src/orxonox/core/InputManager.cc
r973 r1022 35 35 #include "core/Debug.h" 36 36 #include "InputEventListener.h" 37 #include "InputHandler.h" 37 38 #include "InputManager.h" 38 39 … … 48 49 */ 49 50 InputManager::InputManager() : 50 mouse_(0), keyboard_(0), inputSystem_(0) 51 mouse_(0), keyboard_(0), inputSystem_(0), 52 currentMode_(IM_UNINIT), setMode_(IM_UNINIT), 53 handlerGUI_(0), handlerGame_(0), handlerBuffer_(0) 51 54 { 52 55 } … … 102 105 // create a keyboard. If none are available the exception is caught. 103 106 keyboard_ = static_cast<OIS::Keyboard*>(inputSystem_->createInputObject(OIS::OISKeyboard, true)); 104 keyboard_->setEventCallback(this);105 107 COUT(ORX_DEBUG) << "*** InputManager: Created OIS mouse" << std::endl; 106 108 107 109 // create a mouse. If none are available the exception is caught. 108 110 mouse_ = static_cast<OIS::Mouse*>(inputSystem_->createInputObject(OIS::OISMouse, true)); 109 mouse_->setEventCallback(this);110 111 COUT(ORX_DEBUG) << "*** InputManager: Created OIS keyboard" << std::endl; 111 112 … … 122 123 } 123 124 124 COUT(ORX_DEBUG) << "*** InputManager: Loading key bindings..." << std::endl; 125 // create the handlers 126 this->handlerGUI_ = new InputHandlerGUI(); 127 this->handlerGame_ = new InputHandlerGame(); 128 this->handlerGame_->loadBindings(); 129 130 /*COUT(ORX_DEBUG) << "*** InputManager: Loading key bindings..." << std::endl; 125 131 // load the key bindings 126 132 InputEvent empty = {0, false, 0, 0, 0}; … … 130 136 //assign 'abort' to the escape key 131 137 this->bindingsKeyPressed_[(int)OIS::KC_ESCAPE].id = 1; 132 COUT(ORX_DEBUG) << "*** InputManager: Loading done." << std::endl; 138 COUT(ORX_DEBUG) << "*** InputManager: Loading done." << std::endl;*/ 133 139 134 140 return true; … … 170 176 void InputManager::tick(float dt) 171 177 { 172 //this->mouse_->setEventCallback(this); 178 // reset the game if it has changed 179 if (this->currentMode_ != this->setMode_) 180 { 181 switch (this->setMode_) 182 { 183 case IM_GUI: 184 this->mouse_->setEventCallback(this->handlerGUI_); 185 this->keyboard_->setEventCallback(this->handlerGUI_); 186 break; 187 case IM_INGAME: 188 this->mouse_->setEventCallback(this->handlerGame_); 189 this->keyboard_->setEventCallback(this->handlerGame_); 190 break; 191 case IM_KEYBOARD: 192 this->mouse_->setEventCallback(this->handlerGame_); 193 this->keyboard_->setEventCallback(this->handlerBuffer_); 194 break; 195 case IM_UNINIT: 196 this->mouse_->setEventCallback(0); 197 this->keyboard_->setEventCallback(0); 198 break; 199 } 200 this->currentMode_ = this->setMode_; 201 } 202 173 203 // capture all the input. That calls the event handlers. 174 204 if (mouse_) … … 194 224 195 225 /** 196 @brief Calls all the objects from classes that derive from InputEventListener. 197 @param evt The input event that occured. 198 */ 199 inline void InputManager::callListeners(orxonox::InputEvent &evt) 200 { 201 for (Iterator<InputEventListener> it = ObjectList<InputEventListener>::start(); it; ) 202 { 203 if (it->bActive_) 204 (it++)->eventOccured(evt); 205 else 206 it++; 207 } 208 } 209 210 /** 211 @brief Event handler for the keyPressed Event. 212 @param e Event information 213 */ 214 bool InputManager::keyPressed(const OIS::KeyEvent &e) 215 { 216 callListeners(this->bindingsKeyPressed_[(int)e.key]); 217 return true; 218 } 219 220 /** 221 @brief Event handler for the keyReleased Event. 222 @param e Event information 223 */ 224 bool InputManager::keyReleased(const OIS::KeyEvent &e) 225 { 226 return true; 227 } 228 229 /** 230 @brief Event handler for the mouseMoved Event. 231 @param e Event information 232 */ 233 bool InputManager::mouseMoved(const OIS::MouseEvent &e) 234 { 235 return true; 236 } 237 238 /** 239 @brief Event handler for the mousePressed Event. 240 @param e Event information 241 @param id The ID of the mouse button 242 */ 243 bool InputManager::mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id) 244 { 245 COUT(1) << "asdf" << std::endl; 246 return true; 247 } 248 249 /** 250 @brief Event handler for the mouseReleased Event. 251 @param e Event information 252 @param id The ID of the mouse button 253 */ 254 bool InputManager::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id) 255 { 256 return true; 226 @brief Sets the input mode to either GUI, inGame or Buffer 227 @param mode The new input mode 228 @remark Only has an affect if the mode actually changes 229 */ 230 void InputManager::setInputMode(InputMode mode) 231 { 232 this->setMode_ = mode; 233 } 234 235 /** 236 @brief Returns the current input handling method 237 @return The current input mode. 238 */ 239 InputMode InputManager::getInputMode() 240 { 241 return this->currentMode_; 257 242 } 258 243 -
code/branches/input/src/orxonox/core/InputManager.h
r973 r1022 54 54 IM_KEYBOARD = 1, 55 55 IM_INGAME = 2, 56 IM_UNINIT = 3, 56 57 }; 57 58 … … 62 63 */ 63 64 class _CoreExport InputManager 64 : public Tickable , public OIS::KeyListener, public OIS::MouseListener65 : public Tickable 65 66 { 66 67 public: … … 69 70 void tick(float dt); 70 71 void setWindowExtents(int width, int height); 72 void setInputMode(InputMode mode); 73 InputMode getInputMode(); 71 74 72 75 // Temporary solutions. Will be removed soon! … … 84 87 ~InputManager(); 85 88 86 void callListeners(InputEvent &evt);87 88 // input events89 bool mousePressed (const OIS::MouseEvent &arg, OIS::MouseButtonID id);90 bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id);91 bool mouseMoved (const OIS::MouseEvent &arg);92 bool keyPressed (const OIS::KeyEvent &arg);93 bool keyReleased (const OIS::KeyEvent &arg);94 95 89 OIS::InputManager *inputSystem_; //!< OIS input manager 96 90 OIS::Keyboard *keyboard_; //!< OIS mouse 97 91 OIS::Mouse *mouse_; //!< OIS keyboard 98 92 99 /** denotes the maximum number of different keys there are in OIS. 100 256 should be ok since the highest number in the enum is 237. */ 101 static const int numberOfKeys_ = 256; 102 //! Array of input events for every pressed key 103 InputEvent bindingsKeyPressed_[numberOfKeys_]; 104 //! Array of input events for every released key 105 InputEvent bindingsKeyReleased_[numberOfKeys_]; 106 107 /** denotes the maximum number of different buttons there are in OIS. 108 16 should be ok since the highest number in the enum is 7. */ 109 static const int numberOfButtons_ = 16; 110 //! Array of input events for every pressed key 111 InputEvent bindingsButtonPressed_[numberOfButtons_]; 112 //! Array of input events for every released key 113 InputEvent bindingsButtonReleased_[numberOfButtons_]; 93 InputMode currentMode_; //!< Input mode currently used 94 InputMode setMode_; //!< Input mode that has been set lately 95 InputHandlerGUI *handlerGUI_; //!< Handles the input if in GUI mode 96 // FIXME: insert the InputBuffer once merged with core2 97 InputHandlerGUI *handlerBuffer_; //!< Handles the input if in Buffer mode 98 InputHandlerGame *handlerGame_; //!< Handles the input if in Game mode 114 99 115 100 //! Pointer to the instance of the singleton -
code/branches/input/src/orxonox/objects/Fighter.cc
r973 r1022 267 267 OIS::Mouse* mMouse = InputManager::getSingleton()->getMouse(); 268 268 269 mKeyboard->capture();270 mMouse->capture();269 //mKeyboard->capture(); 270 //mMouse->capture(); 271 271 272 272 if (leftButtonPressed_) -
code/branches/input/src/orxonox/objects/SpaceShip.cc
r973 r1022 417 417 void SpaceShip::tick(float dt) 418 418 { 419 if (!this->setMouseEventCallback_)419 if (InputManager::getSingleton()->getMouse()->getEventCallback() != this) 420 420 { 421 421 if (InputManager::getSingleton()->getMouse()) … … 448 448 OIS::Keyboard* mKeyboard = InputManager::getSingleton()->getKeyboard(); 449 449 OIS::Mouse* mMouse = InputManager::getSingleton()->getMouse(); 450 451 mKeyboard->capture();452 mMouse->capture();453 450 454 451 -
code/branches/input/visual_studio/base_properties_release.vsprops
r975 r1022 12 12 PreprocessorDefinitions="NDEBUG" 13 13 RuntimeLibrary="2" 14 DebugInformationFormat=" 0"14 DebugInformationFormat="3" 15 15 /> 16 16 <Tool -
code/branches/input/visual_studio/base_properties_release_sse.vsprops
r790 r1022 1 <?xml version="1.0" encoding="Windows-1252"?>2 <VisualStudioPropertySheet3 ProjectType="Visual C++"4 Version="8.00"5 Name="base_properties_release_sse"6 InheritedPropertySheets=".\base_properties_release.vsprops"7 >8 <Tool9 Name="VCCLCompilerTool"10 PreprocessorDefinitions="NDEBUG"11 EnableEnhancedInstructionSet="1"12 />13 <UserMacro14 Name="CS"15 Value="_sse"16 />17 <UserMacro18 Name="CSS"19 Value=""20 />21 </VisualStudioPropertySheet> -
code/branches/input/visual_studio/base_properties_release_sse2.vsprops
r790 r1022 1 <?xml version="1.0" encoding="Windows-1252"?>2 <VisualStudioPropertySheet3 ProjectType="Visual C++"4 Version="8.00"5 Name="base_properties_release_sse2"6 InheritedPropertySheets=".\base_properties_release.vsprops"7 >8 <Tool9 Name="VCCLCompilerTool"10 EnableEnhancedInstructionSet="2"11 />12 <UserMacro13 Name="CS"14 Value="_sse2"15 />16 <UserMacro17 Name="CSS"18 Value=""19 />20 </VisualStudioPropertySheet> -
code/branches/input/visual_studio/orxonox_vc8.sln
r975 r1022 56 56 EndProjectSection 57 57 EndProject 58 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tolua++", "vc8\tolua++.vcproj", "{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}" 59 ProjectSection(WebsiteProperties) = preProject 60 Debug.AspNetCompiler.Debug = "True" 61 Release.AspNetCompiler.Debug = "False" 62 EndProjectSection 63 EndProject 58 64 Global 59 65 GlobalSection(SolutionConfigurationPlatforms) = preSolution … … 83 89 {2240ECD7-2F48-4431-8E1B-25466A384CCC}.Release|Win32.Build.0 = Release|Win32 84 90 {F101C2F0-1CB9-4A57-827B-6C399A99B28F}.Debug|Win32.ActiveCfg = Debug|Win32 85 {F101C2F0-1CB9-4A57-827B-6C399A99B28F}.Debug|Win32.Build.0 = Debug|Win3286 91 {F101C2F0-1CB9-4A57-827B-6C399A99B28F}.Release|Win32.ActiveCfg = Release|Win32 87 {F101C2F0-1CB9-4A57-827B-6C399A99B28F}.Release|Win32.Build.0 = Release|Win32 92 {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}.Debug|Win32.ActiveCfg = Debug|Win32 93 {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}.Release|Win32.ActiveCfg = Release|Win32 88 94 EndGlobalSection 89 95 GlobalSection(SolutionProperties) = preSolution -
code/branches/input/visual_studio/vc8/orxonox.vcproj
r975 r1022 432 432 UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" 433 433 > 434 <File435 RelativePath="..\..\bin\media.cfg"436 >437 </File>438 <File439 RelativePath="..\..\bin\ogre.cfg"440 >441 </File>442 <File443 RelativePath="..\..\bin\ogre.cfg-init"444 >445 </File>446 <File447 RelativePath="..\..\bin\Ogre.log"448 >449 </File>450 <File451 RelativePath="..\..\bin\orxonox.bat"452 >453 </File>454 <File455 RelativePath="..\..\bin\orxonox.ini"456 >457 </File>458 <File459 RelativePath="..\..\bin\orxonox.log"460 >461 </File>462 <File463 RelativePath="..\..\bin\orxonox_d.bat"464 >465 </File>466 <File467 RelativePath="..\..\bin\plugins.cfg"468 >469 </File>470 <File471 RelativePath="..\..\bin\plugins.cfg-init"472 >473 </File>474 <File475 RelativePath="..\..\bin\plugins_d.cfg"476 >477 </File>478 <File479 RelativePath="..\..\bin\quake3settings.cfg"480 >481 </File>482 <File483 RelativePath="..\..\bin\resources.cfg"484 >485 </File>486 <File487 RelativePath="..\..\bin\run-script"488 >489 </File>490 <File491 RelativePath="..\..\bin\translation_default.lang"492 >493 </File>494 <File495 RelativePath="..\..\bin\translation_german.lang"496 >497 </File>498 434 </Filter> 499 435 </Files> -
code/branches/input/visual_studio/vc8/tixml.vcproj
r975 r1022 172 172 > 173 173 </File> 174 <File175 RelativePath="..\..\src\util\tinyxml\TinyXMLPrereqs.h"176 >177 </File>178 174 </Filter> 179 175 </Files>
Note: See TracChangeset
for help on using the changeset viewer.