Changeset 8051 for code/branches/tutorial/src/libraries/core
- Timestamp:
- Mar 9, 2011, 11:27:05 AM (14 years ago)
- Location:
- code/branches/tutorial
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/tutorial
- Property svn:mergeinfo changed
/code/branches/usability merged: 8018-8041
- Property svn:mergeinfo changed
-
code/branches/tutorial/src/libraries/core/CMakeLists.txt
r7966 r8051 80 80 Game.h 81 81 GameMode.h 82 GraphicsManager.h 82 83 GUIManager.h 83 84 Loader.h -
code/branches/tutorial/src/libraries/core/Core.cc
r7872 r8051 208 208 #ifdef ORXONOX_RELEASE 209 209 const unsigned int defaultLevelLogFile = 3; 210 SetConfigValue(bDevMode_, false) 211 .description("Developer mode. If not set, hides some things from the user to not confuse him."); 210 212 #else 211 213 const unsigned int defaultLevelLogFile = 4; 214 SetConfigValue(bDevMode_, true) 215 .description("Developer mode. If not set, hides some things from the user to not confuse him."); 212 216 #endif 213 217 SetConfigValueExternal(softDebugLevelLogFile_, "OutputHandler", "softDebugLevelLogFile", defaultLevelLogFile) -
code/branches/tutorial/src/libraries/core/Core.h
r7870 r8051 91 91 { return this->ogreConfigTimestamp_; } 92 92 93 inline bool inDevMode(void) const 94 { return this->bDevMode_; } 95 93 96 private: 94 97 Core(const Core&); //!< Don't use (undefined symbol) … … 130 133 long long lastLevelTimestamp_; ///< Timestamp when the last level was started 131 134 long long ogreConfigTimestamp_; ///< Timestamp wehen the ogre config level was modified 135 bool bDevMode_; //!< Developers bit. If set to false, some options are not available as to not confuse the normal user. 132 136 133 137 static Core* singletonPtr_s; -
code/branches/tutorial/src/libraries/core/GUIManager.cc
r7994 r8051 103 103 /*static*/ const std::string GUIManager::defaultScheme_ = "TaharezGreen"; 104 104 105 static const std::string __CC_navigateGUI_name = "navigateGUI"; 106 105 107 SetConsoleCommand("showGUI", &GUIManager::showGUI).defaultValue(1, false).defaultValue(2, false); 106 108 SetConsoleCommand("hideGUI", &GUIManager::hideGUI); 109 SetConsoleCommand("toggleGUI", &GUIManager::toggleGUI).defaultValue(1, false).defaultValue(2, false); 110 SetConsoleCommand(__CC_navigateGUI_name, &GUIManager::navigateGUI).deactivate(); 111 112 //! Strings that specify modes for the GUI navigation. 113 /*static*/ const std::string GUIManager::NAVIGATE_UP = "up"; 114 /*static*/ const std::string GUIManager::NAVIGATE_DOWN = "down"; 115 /*static*/ const std::string GUIManager::NAVIGATE_LEFT = "left"; 116 /*static*/ const std::string GUIManager::NAVIGATE_RIGHT = "right"; 117 /*static*/ const std::string GUIManager::NAVIGATE_ENTER = "enter"; 107 118 108 119 /** … … 282 293 { 283 294 GUIManager::getInstance().executeCode("hideMenuSheet(\"" + name + "\")"); 295 } 296 297 /** 298 @brief 299 Toggles specified GUI. 300 If the GUI with the input name is already shown and on the top, it is hidden, else it is shown. 301 */ 302 /*static*/ void GUIManager::toggleGUI(const std::string& name, bool bHidePrevious, bool bNoInput) 303 { 304 GUIManager::getInstance().executeCode("getGUIFirstActive(\"" + name + "\", " + multi_cast<std::string>(bHidePrevious) + ", " + multi_cast<std::string>(bNoInput) + ")"); 305 } 306 307 /** 308 @brief 309 Helper method to toggle a specified GUI. 310 Is called by lua. 311 */ 312 void GUIManager::toggleGUIHelper(const std::string& name, bool bHidePrevious, bool bNoInput, bool show) 313 { 314 if(show) 315 GUIManager::showGUI(name, bHidePrevious, bNoInput); 316 else 317 GUIManager::hideGUI(name); 284 318 } 285 319 … … 340 374 this->rootWindow_->setProperty("Alpha", "1.0"); 341 375 this->rootWindow_->setProperty("Image", image); 376 } 377 378 /** 379 @brief 380 Method to navigate the GUI, by specifying the mode of navigation. 381 @param mode 382 The mode of navigation, at this point can be either 'up', 'down', 'left', 'right' or 'enter'. 383 */ 384 /*static*/ void GUIManager::navigateGUI(const std::string& mode) 385 { 386 if(mode == NAVIGATE_UP) 387 GUIManager::getInstance().executeCode("navigateGUI(\"" + NAVIGATE_UP + "\")"); 388 else if(mode == NAVIGATE_DOWN) 389 GUIManager::getInstance().executeCode("navigateGUI(\"" + NAVIGATE_DOWN + "\")"); 390 else if(mode == NAVIGATE_LEFT) 391 GUIManager::getInstance().executeCode("navigateGUI(\"" + NAVIGATE_LEFT + "\")"); 392 else if(mode == NAVIGATE_RIGHT) 393 GUIManager::getInstance().executeCode("navigateGUI(\"" + NAVIGATE_RIGHT + "\")"); 394 else if(mode == NAVIGATE_ENTER) 395 GUIManager::getInstance().executeCode("navigateGUI(\"" + NAVIGATE_ENTER + "\")"); 396 } 397 398 /** 399 @brief 400 Is called by lua to change whether there are any GUIs active at the moment. 401 @param active 402 Whether GUIs are active. 403 */ 404 void GUIManager::guisActiveChanged(bool active) 405 { 406 if(this->GUIsActive_ == active) 407 return; 408 this->GUIsActive_ = active; 409 if(this->GUIsActive_) 410 ModifyConsoleCommand(__CC_navigateGUI_name).activate(); 411 else 412 ModifyConsoleCommand(__CC_navigateGUI_name).deactivate(); 342 413 } 343 414 -
code/branches/tutorial/src/libraries/core/GUIManager.h
r7874 r8051 49 49 #include "util/Singleton.h" 50 50 #include "input/InputHandler.h" 51 #include "Core.h" 51 52 #include "OrxonoxClass.h" 52 53 #include "WindowEventListener.h" … … 88 89 void showGUIExtra(const std::string& name, const std::string& ptr, bool bHidePrevious = false, bool bNoInput = false); 89 90 static void hideGUI(const std::string& name); 91 static void toggleGUI(const std::string& name, bool bHidePrevious = false, bool bNoInput = false); 92 void toggleGUIHelper(const std::string& name, bool bHidePrevious, bool bNoInput, bool show); // tolua_export 90 93 void keyESC(); 91 94 void setBackgroundImage(const std::string& imageSet, const std::string imageName); // tolua_export 92 95 void setBackgroundImage(const std::string& image); 96 97 static void navigateGUI(const std::string& mode); 98 void guisActiveChanged(bool active); // tolua_export 99 100 /** 101 @brief Helper method to get the developer's mode without having to export Core.h. 102 @see Core::inDevMode 103 */ 104 static bool inDevMode(void) { return Core::getInstance().inDevMode(); } // tolua_export 93 105 94 106 //! Creates a new InputState to be used with a GUI Sheet … … 122 134 template <typename FunctionType> 123 135 bool protectedCall(FunctionType function); 136 137 static const std::string NAVIGATE_UP; 138 static const std::string NAVIGATE_DOWN; 139 static const std::string NAVIGATE_LEFT; 140 static const std::string NAVIGATE_RIGHT; 141 static const std::string NAVIGATE_ENTER; 142 143 bool GUIsActive_; //!< Whether there are any GUIs active at a given moment. 124 144 125 145 // keyHandler functions -
code/branches/tutorial/src/libraries/core/Game.cc
r7993 r8051 61 61 static void printFPS() 62 62 { COUT(0) << Game::getInstance().getAvgFPS() << std::endl; } 63 SetConsoleCommand(" printFPS", &printFPS);63 SetConsoleCommand("Stats", "printFPS", &printFPS); 64 64 static void printTickTime() 65 65 { COUT(0) << Game::getInstance().getAvgTickTime() << std::endl; } 66 SetConsoleCommand(" printTickTime", &printTickTime);66 SetConsoleCommand("Stats", "printTickTime", &printTickTime); 67 67 68 68 std::map<std::string, GameStateInfo> Game::gameStateDeclarations_s; -
code/branches/tutorial/src/libraries/core/GraphicsManager.cc
r8008 r8051 480 480 } 481 481 482 unsigned int GraphicsManager::getWindowWidth() const 483 { 484 return this->renderWindow_->getWidth(); 485 } 486 487 unsigned int GraphicsManager::getWindowHeight() const 488 { 489 return this->renderWindow_->getHeight(); 490 } 491 482 492 bool GraphicsManager::hasVSyncEnabled() const 483 493 { 484 494 Ogre::ConfigOptionMap& options = ogreRoot_->getRenderSystem()->getConfigOptions(); 485 if (options.find("VSync") != options.end()) 486 return (options["VSync"].currentValue == "Yes"); 495 Ogre::ConfigOptionMap::iterator it = options.find("VSync"); 496 if (it != options.end()) 497 return (it->second.currentValue == "Yes"); 487 498 else 488 499 return false; 489 500 } 490 501 502 std::string GraphicsManager::getFSAAMode() const 503 { 504 Ogre::ConfigOptionMap& options = ogreRoot_->getRenderSystem()->getConfigOptions(); 505 Ogre::ConfigOptionMap::iterator it = options.find("FSAA"); 506 if (it != options.end()) 507 return it->second.currentValue; 508 else 509 return ""; 510 } 511 491 512 std::string GraphicsManager::setScreenResolution(unsigned int width, unsigned int height, bool fullscreen) 492 513 { 493 this->ogreRoot_->getRenderSystem()->setConfigOption("Video Mode", multi_cast<std::string>(width) + " x " + multi_cast<std::string>(height) + " @ " + multi_cast<std::string>(this->getRenderWindow()->getColourDepth()) + "-bit colour"); 514 // workaround to detect if the colour depth should be written to the config file 515 bool bWriteColourDepth = false; 516 Ogre::ConfigOptionMap& options = ogreRoot_->getRenderSystem()->getConfigOptions(); 517 Ogre::ConfigOptionMap::iterator it = options.find("Video Mode"); 518 if (it != options.end()) 519 bWriteColourDepth = (it->second.currentValue.find('@') != std::string::npos); 520 521 if (bWriteColourDepth) 522 { 523 this->ogreRoot_->getRenderSystem()->setConfigOption("Video Mode", multi_cast<std::string>(width) 524 + " x " + multi_cast<std::string>(height) 525 + " @ " + multi_cast<std::string>(this->getRenderWindow()->getColourDepth()) + "-bit colour"); 526 } 527 else 528 { 529 this->ogreRoot_->getRenderSystem()->setConfigOption("Video Mode", multi_cast<std::string>(width) 530 + " x " + multi_cast<std::string>(height)); 531 } 532 494 533 this->ogreRoot_->getRenderSystem()->setConfigOption("Full Screen", fullscreen ? "Yes" : "No"); 495 534 -
code/branches/tutorial/src/libraries/core/GraphicsManager.h
r7995 r8051 54 54 #include "OrxonoxClass.h" 55 55 56 // tolua_begin 56 57 namespace orxonox 57 58 { … … 60 61 Graphics engine manager class 61 62 */ 62 class _CoreExport GraphicsManager : public Singleton<GraphicsManager>, public OrxonoxClass, public Ogre::LogListener 63 { 63 class _CoreExport GraphicsManager 64 // tolua_end 65 : public Singleton<GraphicsManager>, public OrxonoxClass, public Ogre::LogListener 66 { // tolua_export 64 67 friend class Singleton<GraphicsManager>; 65 68 public: … … 74 77 Ogre::RenderWindow* getRenderWindow() { return this->renderWindow_; } 75 78 size_t getRenderWindowHandle(); 79 80 // tolua_begin 81 static GraphicsManager& getInstance() { return Singleton<GraphicsManager>::getInstance(); } // tolua_export 82 76 83 bool isFullScreen() const; 84 unsigned int getWindowWidth() const; 85 unsigned int getWindowHeight() const; 86 77 87 bool hasVSyncEnabled() const; 88 std::string getFSAAMode() const; 89 // tolua_end 78 90 79 91 void upgradeToGraphics(); … … 127 139 128 140 static GraphicsManager* singletonPtr_s; //!< Pointer to the Singleton 141 // tolua_begin 129 142 }; 130 143 } 144 // tolua_end 131 145 132 146 #endif /* _GraphicsManager_H__ */ -
code/branches/tutorial/src/libraries/core/command/CommandEvaluation.h
r7401 r8051 70 70 71 71 @remarks execCommand_ and hintCommand_ can be different in this case: There are multiple 72 commands avaliable, let's say "tcl" , "tclexecute", and "tclquery". The user enters73 "tcl", which is already a valid command. Now execCommand_ points to the "tcl"-command,74 but hintCommand_ still points to the autocompletion command of CommandExecutor, because75 the auto-completion list must still return the three possible commands, "tcl tclexecute tclquery"76 because the user may want to execute "tclquery" and needs auto-completion.72 commands avaliable, let's say "tcl" and "TclThreadManager". The user enters "tcl", which 73 is already a valid command. Now execCommand_ points to the "tcl"-command, but hintCommand_ 74 still points to the autocompletion command of CommandExecutor, because the auto-completion 75 list must still return the two possible commands, "tcl TclThreadManager" because the user 76 may want to write "TclThreadManager ..." and needs auto-completion. 77 77 78 78 @see See @ref CommandExecutorExample "this description" for an example. -
code/branches/tutorial/src/libraries/core/command/ConsoleCommandCompilation.cc
r7401 r8051 46 46 namespace orxonox 47 47 { 48 SetConsoleCommand("source", source).argumentCompleter(0, autocompletion::files()); 48 // SetConsoleCommand("source", source).argumentCompleter(0, autocompletion::files()); // disabled because we use the implementation in Tcl 49 49 SetConsoleCommand("echo", echo); 50 SetConsoleCommand("puts", puts); 51 52 SetConsoleCommand("read", read).argumentCompleter(0, autocompletion::files()); 53 SetConsoleCommand("append", append).argumentCompleter(0, autocompletion::files()); 54 SetConsoleCommand("write", write).argumentCompleter(0, autocompletion::files()); 50 // SetConsoleCommand("puts", puts); // disabled because we use the implementation in Tcl 51 52 // SetConsoleCommand("read", read).argumentCompleter(0, autocompletion::files()); // disabled because we use the implementation in Tcl 53 // SetConsoleCommand("append", append).argumentCompleter(0, autocompletion::files()); // disabled because we use the implementation in Tcl 54 // SetConsoleCommand("write", write).argumentCompleter(0, autocompletion::files()); // disabled because we use the implementation in Tcl 55 55 56 56 SetConsoleCommand("calculate", calculate); -
code/branches/tutorial/src/libraries/core/command/Shell.cc
r7401 r8051 46 46 { 47 47 SetConsoleCommand("log", OutputHandler::log ); 48 SetConsoleCommand("error", OutputHandler::error ) ;49 SetConsoleCommand("warning", OutputHandler::warning) ;50 SetConsoleCommand("info", OutputHandler::info ) ;51 SetConsoleCommand("debug", OutputHandler::debug ) ;48 SetConsoleCommand("error", OutputHandler::error ).hide(); 49 SetConsoleCommand("warning", OutputHandler::warning).hide(); 50 SetConsoleCommand("info", OutputHandler::info ).hide(); 51 SetConsoleCommand("debug", OutputHandler::debug ).hide(); 52 52 53 53 unsigned int Shell::cacheSize_s; -
code/branches/tutorial/src/libraries/core/command/TclBind.cc
r7401 r8051 45 45 { 46 46 SetConsoleCommand("tcl", &TclBind::tcl); 47 SetConsoleCommand("bgerror", &TclBind::bgerror) ;47 SetConsoleCommand("bgerror", &TclBind::bgerror).hide(); 48 48 49 49 TclBind* TclBind::singletonPtr_s = 0; … … 91 91 92 92 this->interpreter_->def("::orxonox::query", TclBind::tcl_query, Tcl::variadic()); 93 this->interpreter_->def("::orxonox::execute", TclBind::tcl_execute, Tcl::variadic()); 93 94 this->interpreter_->def("::orxonox::crossquery", TclThreadManager::tcl_crossquery, Tcl::variadic()); 94 this->interpreter_->def("execute", TclBind::tcl_execute, Tcl::variadic());95 95 this->interpreter_->def("::orxonox::crossexecute", TclThreadManager::tcl_crossexecute, Tcl::variadic()); 96 96 97 97 try 98 98 { 99 this->interpreter_->eval("proc query {args} { ::orxonox::query $args }"); 99 this->interpreter_->def("query", TclBind::tcl_query, Tcl::variadic()); 100 this->interpreter_->def("execute", TclBind::tcl_execute, Tcl::variadic()); 100 101 this->interpreter_->eval("proc crossquery {id args} { ::orxonox::crossquery 0 $id $args }"); 101 this->interpreter_->eval("proc crossexecute {id args} { ::orxonox::cross query0 $id $args }");102 this->interpreter_->eval("proc crossexecute {id args} { ::orxonox::crossexecute 0 $id $args }"); 102 103 this->interpreter_->eval("proc running {} { return 1 }"); 103 104 this->interpreter_->eval("set id 0"); … … 154 155 { 155 156 COUT(4) << "Tcl_query: " << args.get() << std::endl; 156 157 return TclBind::tcl_helper(args, true); 158 } 159 160 /** 161 @brief Callback: Used to send an Orxonox-command from Tcl to the CommandExecutor. 162 */ 163 void TclBind::tcl_execute(Tcl::object const &args) 164 { 165 COUT(4) << "Tcl_execute: " << args.get() << std::endl; 166 TclBind::tcl_helper(args, false); 167 } 168 169 /** 170 @brief Helper function, used by tcl_query() and tcl_execute(). 171 */ 172 std::string TclBind::tcl_helper(Tcl::object const &args, bool bQuery) 173 { 157 174 const std::string& command = stripEnclosingBraces(args.get()); 158 175 159 176 int error; 177 std::string result; 178 160 179 CommandEvaluation evaluation = CommandExecutor::evaluate(command); 161 const std::string& result = evaluation.query(&error); 180 181 if (bQuery) 182 result = evaluation.query(&error).getString(); 183 else 184 error = evaluation.execute(); 185 162 186 switch (error) 163 187 { … … 175 199 176 200 /** 177 @brief Callback: Used to send an Orxonox-command from Tcl to the CommandExecutor.178 */179 void TclBind::tcl_execute(Tcl::object const &args)180 {181 COUT(4) << "Tcl_execute: " << args.get() << std::endl;182 const std::string& command = stripEnclosingBraces(args.get());183 184 if (CommandExecutor::execute(command, false))185 {186 COUT(1) << "Error: Can't execute command \"" << command << "\"!" << std::endl;187 }188 }189 190 /**191 201 @brief Console command, executes Tcl code. Can be used to bind Tcl-commands to a key, because native 192 202 Tcl-commands can not be evaluated and are thus not supported by the key-binder. … … 198 208 try 199 209 { 200 const std::string& output = TclBind::getInstance().interpreter_->eval("uplevel #0 " + tclcode); 201 if (!output.empty()) 202 { 203 COUT(0) << "tcl> " << output << std::endl; 204 } 205 return output; 210 return TclBind::getInstance().interpreter_->eval("uplevel #0 " + tclcode); 206 211 } 207 212 catch (Tcl::tcl_error const &e) 208 { COUT(1) << " tcl> Error: " << e.what() << std::endl; }213 { COUT(1) << "Tcl error: " << e.what() << std::endl; } 209 214 } 210 215 -
code/branches/tutorial/src/libraries/core/command/TclBind.h
r7401 r8051 126 126 TclBind(const TclBind& other); ///< Copy-constructor, not implemented 127 127 128 static std::string tcl_helper(Tcl::object const &args, bool bQuery); 129 128 130 Tcl::interpreter* interpreter_; ///< The wrapped Tcl interpreter 129 131 std::string tclDataPath_; ///< The path to the directory that contains the Orxonox-specific Tcl-files -
code/branches/tutorial/src/libraries/core/command/TclThreadManager.cc
r7401 r8051 55 55 const float TCLTHREADMANAGER_MAX_CPU_USAGE = 0.50f; 56 56 57 SetConsoleCommand("tclexecute", &TclThreadManager::execute).argumentCompleter(0, autocompletion::tclthreads());58 SetConsoleCommand("tclquery", &TclThreadManager::query ).argumentCompleter(0, autocompletion::tclthreads());59 57 SetConsoleCommand("TclThreadManager", "create", &TclThreadManager::create); 60 58 SetConsoleCommand("TclThreadManager", "destroy", &TclThreadManager::destroy).argumentCompleter(0, autocompletion::tclthreads()); -
code/branches/tutorial/src/libraries/core/input/InputManager.cc
r7874 r8051 641 641 state->destroy(); 642 642 } 643 644 bool InputManager::setMouseExclusive(const std::string& name, TriBool::Value value) 645 { 646 if (name == "empty") 647 { 648 COUT(2) << "InputManager: Changing the empty state is not allowed!" << std::endl; 649 return false; 650 } 651 std::map<std::string, InputState*>::iterator it = statesByName_.find(name); 652 if (it != statesByName_.end()) 653 { 654 it->second->setMouseExclusive(value); 655 return true; 656 } 657 return false; 658 } 643 659 } -
code/branches/tutorial/src/libraries/core/input/InputManager.h
r7874 r8051 163 163 */ 164 164 bool destroyState(const std::string& name); // tolua_export 165 /** 166 @brief 167 Changes the mouse mode of an input state. 168 @return 169 True if the call was successful, fals if the name was not found 170 */ 171 bool setMouseExclusive(const std::string& name, TriBool::Value value); // tolua_export 165 172 166 173 //------------------------------- -
code/branches/tutorial/src/libraries/core/input/Keyboard.cc
r6422 r8051 36 36 { 37 37 // update modifiers 38 if (arg.key == OIS::KC_RMENU || arg.key == OIS::KC_LMENU) 39 modifiers_ |= KeyboardModifier::Alt; // alt key 40 if (arg.key == OIS::KC_RCONTROL || arg.key == OIS::KC_LCONTROL) 41 modifiers_ |= KeyboardModifier::Ctrl; // ctrl key 42 if (arg.key == OIS::KC_RSHIFT || arg.key == OIS::KC_LSHIFT) 43 modifiers_ |= KeyboardModifier::Shift; // shift key 38 switch (arg.key) 39 { 40 case OIS::KC_RMENU: 41 case OIS::KC_LMENU: 42 modifiers_ |= KeyboardModifier::Alt; // alt key 43 break; 44 case OIS::KC_RCONTROL: 45 case OIS::KC_LCONTROL: 46 modifiers_ |= KeyboardModifier::Ctrl; // ctrl key 47 break; 48 case OIS::KC_RSHIFT: 49 case OIS::KC_LSHIFT: 50 modifiers_ |= KeyboardModifier::Shift; // shift key 51 break; 52 case OIS::KC_TAB: 53 // Do not distribute the alt+tab event (messes with the operating system) 54 if ((modifiers_ & KeyboardModifier::Alt) != 0) 55 return true; 56 default:; 57 } 44 58 45 // Do not distribute the alt+tab event (messes with the operating system) 46 if ((modifiers_ & KeyboardModifier::Alt) != 0 && arg.key == OIS::KC_TAB) 47 return true; 48 49 KeyEvent evt(arg); 59 KeyEvent evt(static_cast<KeyCode::ByEnum>(arg.key), Keyboard::getKeyText(arg), 0); 50 60 super::buttonPressed(evt); 51 61 return true; … … 56 66 { 57 67 // update modifiers 58 if (arg.key == OIS::KC_RMENU || arg.key == OIS::KC_LMENU) 59 modifiers_ &= ~KeyboardModifier::Alt; // alt key 60 if (arg.key == OIS::KC_RCONTROL || arg.key == OIS::KC_LCONTROL) 61 modifiers_ &= ~KeyboardModifier::Ctrl; // ctrl key 62 if (arg.key == OIS::KC_RSHIFT || arg.key == OIS::KC_LSHIFT) 63 modifiers_ &= ~KeyboardModifier::Shift; // shift key 68 switch (arg.key) 69 { 70 case OIS::KC_RMENU: 71 case OIS::KC_LMENU: 72 modifiers_ &= ~KeyboardModifier::Alt; // alt key 73 break; 74 case OIS::KC_RCONTROL: 75 case OIS::KC_LCONTROL: 76 modifiers_ &= ~KeyboardModifier::Ctrl; // ctrl key 77 break; 78 case OIS::KC_RSHIFT: 79 case OIS::KC_LSHIFT: 80 modifiers_ &= ~KeyboardModifier::Shift; // shift key 81 break; 82 default:; 83 } 64 84 65 KeyEvent evt( arg);85 KeyEvent evt(static_cast<KeyCode::ByEnum>(arg.key), Keyboard::getKeyText(arg), 0); 66 86 super::buttonReleased(evt); 67 87 return true; 68 88 } 89 90 /// A map which returns the corresponding chars for some key codes 91 unsigned int Keyboard::getKeyText(const OIS::KeyEvent& arg) 92 { 93 switch (arg.key) 94 { 95 case OIS::KC_NUMPAD0: return static_cast<unsigned int>('0'); 96 case OIS::KC_NUMPAD1: return static_cast<unsigned int>('1'); 97 case OIS::KC_NUMPAD2: return static_cast<unsigned int>('2'); 98 case OIS::KC_NUMPAD3: return static_cast<unsigned int>('3'); 99 case OIS::KC_NUMPAD4: return static_cast<unsigned int>('4'); 100 case OIS::KC_NUMPAD5: return static_cast<unsigned int>('5'); 101 case OIS::KC_NUMPAD6: return static_cast<unsigned int>('6'); 102 case OIS::KC_NUMPAD7: return static_cast<unsigned int>('7'); 103 case OIS::KC_NUMPAD8: return static_cast<unsigned int>('8'); 104 case OIS::KC_NUMPAD9: return static_cast<unsigned int>('9'); 105 case OIS::KC_DECIMAL: return static_cast<unsigned int>('.'); 106 case OIS::KC_DIVIDE: return static_cast<unsigned int>('/'); 107 case OIS::KC_NUMPADENTER: return static_cast<unsigned int>('\n'); 108 default: return arg.text; 109 } 110 } 69 111 } -
code/branches/tutorial/src/libraries/core/input/Keyboard.h
r7809 r8051 83 83 static std::string getClassNameImpl() { return "Keyboard"; } 84 84 85 static unsigned int getKeyText(const OIS::KeyEvent& arg); 86 85 87 //! Bit mask representing keyboard modifiers 86 88 int modifiers_;
Note: See TracChangeset
for help on using the changeset viewer.