Changeset 7284 for code/trunk/src/libraries/core/input
- Timestamp:
- Aug 31, 2010, 3:37:40 AM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/core/input/Button.cc
r6536 r7284 39 39 #include "util/StringUtils.h" 40 40 #include "util/Debug.h" 41 #include "core/ ConsoleCommand.h"42 #include "core/ CommandEvaluation.h"43 #include "core/ CommandExecutor.h"41 #include "core/command/ConsoleCommand.h" 42 #include "core/command/CommandEvaluation.h" 43 #include "core/command/CommandExecutor.h" 44 44 #include "core/ConfigFileManager.h" 45 45 … … 117 117 // separate the commands 118 118 SubString commandStrings(bindingString_, "|", SubString::WhiteSpaces, false, 119 '\\', false, '"', false, ' (', ')', false, '\0');119 '\\', false, '"', false, '{', '}', false, '\0'); 120 120 121 121 for (unsigned int iCommand = 0; iCommand < commandStrings.size(); iCommand++) … … 124 124 { 125 125 SubString tokens(commandStrings[iCommand], " ", SubString::WhiteSpaces, false, 126 '\\', false, '"', false, ' (', ')', false, '\0');126 '\\', false, '"', false, '{', '}', false, '\0'); 127 127 128 128 KeybindMode::Value mode = KeybindMode::None; … … 175 175 176 176 // evaluate the command 177 const CommandEvaluation&eval = CommandExecutor::evaluate(commandStr);178 if (!eval.isValid() )177 CommandEvaluation eval = CommandExecutor::evaluate(commandStr); 178 if (!eval.isValid() || eval.evaluateParams(true)) 179 179 { 180 180 parseError("Command evaluation of \"" + commandStr + "\"failed.", true); -
code/trunk/src/libraries/core/input/HalfAxis.cc
r5781 r7284 34 34 35 35 #include "HalfAxis.h" 36 #include "core/ CommandEvaluation.h"36 #include "core/command/CommandEvaluation.h" 37 37 38 38 namespace orxonox -
code/trunk/src/libraries/core/input/InputCommands.h
r6417 r7284 37 37 38 38 #include "InputPrereqs.h" 39 #include "core/ CommandEvaluation.h"39 #include "core/command/CommandEvaluation.h" 40 40 41 41 namespace orxonox -
code/trunk/src/libraries/core/input/InputManager.cc
r7266 r7284 47 47 #include "core/CoreIncludes.h" 48 48 #include "core/ConfigValueIncludes.h" 49 #include "core/ConsoleCommand.h"50 49 #include "core/CommandLineParser.h" 51 #include "core/Functor.h"52 50 #include "core/GraphicsManager.h" 51 #include "core/command/ConsoleCommand.h" 52 #include "core/command/Functor.h" 53 53 54 54 #include "InputBuffer.h" … … 61 61 { 62 62 SetCommandLineSwitch(keyboard_no_grab).information("Whether not to exclusively grab the keyboard"); 63 64 static const std::string __CC_InputManager_name = "InputManager"; 65 static const std::string __CC_calibrate_name = "calibrate"; 66 static const std::string __CC_reload_name = "reload"; 67 68 SetConsoleCommand(__CC_InputManager_name, __CC_calibrate_name, &InputManager::calibrate).addShortcut(); 69 SetConsoleCommand(__CC_InputManager_name, __CC_reload_name, &InputManager::reload ); 63 70 64 71 // Abuse of this source file for the InputHandler … … 118 125 this->updateActiveStates(); 119 126 120 // calibrate console command 121 this->getIdentifier()->addConsoleCommand(createConsoleCommand(createFunctor(&InputManager::calibrate, this), "calibrate"), true); 122 // reload console command 123 this->getIdentifier()->addConsoleCommand(createConsoleCommand(createFunctor(&InputManager::reload, this), "reload"), false); 127 ModifyConsoleCommand(__CC_InputManager_name, __CC_calibrate_name).setObject(this); 128 ModifyConsoleCommand(__CC_InputManager_name, __CC_reload_name).setObject(this); 124 129 125 130 CCOUT(4) << "Construction complete." << std::endl; … … 287 292 if (!(internalState_ & Bad)) 288 293 this->destroyDevices(); 294 295 // Reset console commands 296 ModifyConsoleCommand(__CC_InputManager_name, __CC_calibrate_name).setObject(0); 297 ModifyConsoleCommand(__CC_InputManager_name, __CC_reload_name).setObject(0); 289 298 290 299 CCOUT(3) << "Destruction complete." << std::endl; -
code/trunk/src/libraries/core/input/InputState.cc
r6746 r7284 28 28 29 29 #include "InputState.h" 30 #include "core/ Functor.h"30 #include "core/command/Functor.h" 31 31 32 32 namespace orxonox -
code/trunk/src/libraries/core/input/InputState.h
r6746 r7284 150 150 void left(); 151 151 //! Sets a functor to be called upon activation of the state 152 void setEnterFunctor( Functor*functor) { this->enterFunctor_ = functor; }152 void setEnterFunctor(const FunctorPtr& functor) { this->enterFunctor_ = functor; } 153 153 //! Sets a functor to be called upon deactivation of the state 154 void setLeaveFunctor( Functor*functor) { this->leaveFunctor_ = functor; }154 void setLeaveFunctor(const FunctorPtr& functor) { this->leaveFunctor_ = functor; } 155 155 156 156 private: … … 172 172 //! Handler to be used for all joy sticks (needs to be saved in case another joy stick gets attached) 173 173 InputHandler* joyStickHandlerAll_; 174 Functor *enterFunctor_; //!< Functor to be executed on enter175 Functor *leaveFunctor_; //!< Functor to be executed on leave174 FunctorPtr enterFunctor_; //!< Functor to be executed on enter 175 FunctorPtr leaveFunctor_; //!< Functor to be executed on leave 176 176 }; 177 177 -
code/trunk/src/libraries/core/input/KeyBinderManager.cc
r6417 r7284 31 31 #include "util/Debug.h" 32 32 #include "util/Exception.h" 33 #include "util/ScopedSingletonManager.h" 33 34 #include "core/ConfigValueIncludes.h" 34 #include "core/ConsoleCommand.h"35 35 #include "core/CoreIncludes.h" 36 #include "core/ScopedSingletonManager.h" 36 #include "core/LuaState.h" 37 #include "core/command/ConsoleCommand.h" 37 38 #include "InputManager.h" 38 39 #include "KeyDetector.h" … … 41 42 { 42 43 ManageScopedSingleton(KeyBinderManager, ScopeID::Graphics, false); 44 45 static const std::string __CC_keybind_name = "keybind"; 46 static const std::string __CC_tkeybind_name = "tkeybind"; 47 static const std::string __CC_unbind_name = "unbind"; 48 static const std::string __CC_tunbind_name = "tunbind"; 49 50 SetConsoleCommand(__CC_keybind_name, &KeyBinderManager::keybind).defaultValues("").argumentCompleter(0, autocompletion::command()); 51 SetConsoleCommand(__CC_tkeybind_name, &KeyBinderManager::tkeybind).defaultValues("").argumentCompleter(0, autocompletion::command()); 52 SetConsoleCommand(__CC_unbind_name, &KeyBinderManager::unbind).defaultValues(""); 53 SetConsoleCommand(__CC_tunbind_name, &KeyBinderManager::tunbind).defaultValues(""); 43 54 44 55 KeyBinderManager::KeyBinderManager() … … 51 62 52 63 // keybind console commands 53 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&KeyBinderManager::keybind, this), "keybind" )) 54 .defaultValues(""); 55 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&KeyBinderManager::tkeybind, this), "tkeybind")) 56 .defaultValues(""); 57 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&KeyBinderManager::unbind, this), "unbind")) 58 .defaultValues(""); 59 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&KeyBinderManager::tunbind, this), "tunbind")) 60 .defaultValues(""); 64 ModifyConsoleCommand(__CC_keybind_name ).setObject(this); 65 ModifyConsoleCommand(__CC_tkeybind_name).setObject(this); 66 ModifyConsoleCommand(__CC_unbind_name ).setObject(this); 67 ModifyConsoleCommand(__CC_tunbind_name ).setObject(this); 61 68 62 69 // Load default key binder … … 69 76 for (std::map<std::string, KeyBinder*>::const_iterator it = this->binders_.begin(); it != this->binders_.end(); ++it) 70 77 delete it->second; 78 79 // Reset console commands 80 ModifyConsoleCommand(__CC_keybind_name ).setObject(0); 81 ModifyConsoleCommand(__CC_tkeybind_name).setObject(0); 82 ModifyConsoleCommand(__CC_unbind_name ).setObject(0); 83 ModifyConsoleCommand(__CC_tunbind_name ).setObject(0); 71 84 } 72 85 … … 156 169 { 157 170 COUT(0) << "Press any button/key or move a mouse/joystick axis" << std::endl; 158 KeyDetector::getInstance().setCallback( shared_ptr<Functor>(createFunctor(&KeyBinderManager::keybindKeyPressed, this)));171 KeyDetector::getInstance().setCallback(createFunctor(&KeyBinderManager::keybindKeyPressed, this)); 159 172 InputManager::getInstance().enterState("detector"); 160 173 this->command_ = command; … … 187 200 // else: A key was probably pressed within the same tick, ignore it. 188 201 } 202 203 void KeyBinderManager::registerKeybindCallback(LuaFunctor* function) 204 { 205 this->callbackFunction_ = function; 206 } 189 207 } -
code/trunk/src/libraries/core/input/KeyBinderManager.h
r6417 r7284 99 99 void unbind(const std::string& binding); //tolua_export 100 100 void tunbind(const std::string& binding); 101 inline void registerKeybindCallback(Functor* function) { this->callbackFunction_.reset(function); } //tolua_export101 void registerKeybindCallback(LuaFunctor* function); //tolua_export 102 102 103 103 private: … … 114 114 115 115 // keybind command related 116 shared_ptr<Functor> callbackFunction_;//! Function to be called when key was pressed after "keybind" command116 SharedPtr<LuaFunctor> callbackFunction_; //! Function to be called when key was pressed after "keybind" command 117 117 bool bBinding_; //! Tells whether a key binding process is active 118 118 bool bTemporary_; //! Stores tkeybind/keybind value -
code/trunk/src/libraries/core/input/KeyDetector.cc
r6428 r7284 29 29 #include "KeyDetector.h" 30 30 31 #include " core/ConsoleCommand.h"31 #include "util/ScopedSingletonManager.h" 32 32 #include "core/CoreIncludes.h" 33 #include "core/ ScopedSingletonManager.h"33 #include "core/command/ConsoleCommand.h" 34 34 #include "Button.h" 35 35 #include "InputManager.h" … … 38 38 namespace orxonox 39 39 { 40 std::string KeyDetector::callbackCommand_s = "KeyDetectorKeyPressed";41 40 ManageScopedSingleton(KeyDetector, ScopeID::Graphics, false); 41 42 static const std::string __CC_KeyDetector_callback_name = "KeyDetectorKeyPressed"; 43 DeclareConsoleCommand(__CC_KeyDetector_callback_name, &prototype::void__string).hide(); 42 44 43 45 KeyDetector::KeyDetector() … … 46 48 RegisterObject(KeyDetector); 47 49 48 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&KeyDetector::callback, this), callbackCommand_s)); 50 ModifyConsoleCommand(__CC_KeyDetector_callback_name).setFunction(&KeyDetector::callback, this); 51 49 52 this->assignCommands(); 50 53 … … 59 62 inputState_->setHandler(NULL); 60 63 InputManager::getInstance().destroyState("detector"); 64 ModifyConsoleCommand(__CC_KeyDetector_callback_name).resetFunction(); 61 65 } 62 66 … … 65 69 // Assign every button/axis the same command, but with its name as argument 66 70 for (std::map<std::string, Button*>::const_iterator it = allButtons_.begin(); it != allButtons_.end(); ++it) 67 it->second->parse( callbackCommand_s+ ' ' + it->second->groupName_ + "." + it->second->name_);71 it->second->parse(__CC_KeyDetector_callback_name + ' ' + it->second->groupName_ + "." + it->second->name_); 68 72 } 69 73 -
code/trunk/src/libraries/core/input/KeyDetector.h
r6417 r7284 46 46 ~KeyDetector(); 47 47 48 void setCallback(const shared_ptr<Functor>& function) { this->callbackFunction_ = function; }48 void setCallback(const FunctorPtr& function) { this->callbackFunction_ = function; } 49 49 50 50 private: … … 55 55 void assignCommands(); 56 56 57 shared_ptr<Functor>callbackFunction_;57 FunctorPtr callbackFunction_; 58 58 InputState* inputState_; 59 static std::string callbackCommand_s;60 59 static KeyDetector* singletonPtr_s; 61 60 }; -
code/trunk/src/libraries/core/input/Mouse.cc
r5929 r7284 30 30 31 31 #include <ois/OISMouse.h> 32 #include "core/ConsoleCommand.h"33 32 #include "core/CoreIncludes.h" 33 #include "core/command/ConsoleCommand.h" 34 34 #include "InputState.h" 35 35 … … 41 41 namespace orxonox 42 42 { 43 #ifdef ORXONOX_PLATFORM_LINUX 44 static const std::string __CC_Mouse_name = "Mouse"; 45 static const std::string __CC_grab_name = "grab"; 46 static const std::string __CC_ungrab_name = "ungrab"; 47 48 SetConsoleCommand(__CC_Mouse_name, __CC_grab_name, &Mouse::grab); 49 SetConsoleCommand(__CC_Mouse_name, __CC_ungrab_name, &Mouse::ungrab); 50 #endif 51 43 52 Mouse::Mouse(unsigned int id, OIS::InputManager* oisInputManager) 44 53 : super(id, oisInputManager) … … 48 57 49 58 #ifdef ORXONOX_PLATFORM_LINUX 50 // Mouse grab console command 51 this->getIdentifier()->addConsoleCommand(createConsoleCommand(createFunctor(&Mouse::grab, this), "grab"), false); 52 // Mouse ungrab console command 53 this->getIdentifier()->addConsoleCommand(createConsoleCommand(createFunctor(&Mouse::ungrab, this), "ungrab"), false); 59 ModifyConsoleCommand(__CC_Mouse_name, __CC_grab_name).setObject(this); 60 ModifyConsoleCommand(__CC_Mouse_name, __CC_ungrab_name).setObject(this); 61 #endif 62 } 63 64 Mouse::~Mouse() 65 { 66 #ifdef ORXONOX_PLATFORM_LINUX 67 ModifyConsoleCommand(__CC_Mouse_name, __CC_grab_name).setObject(0); 68 ModifyConsoleCommand(__CC_Mouse_name, __CC_ungrab_name).setObject(0); 54 69 #endif 55 70 } -
code/trunk/src/libraries/core/input/Mouse.h
r5781 r7284 64 64 //! Only sets the clipping size. Initialising is done in the base class. 65 65 Mouse(unsigned int id, OIS::InputManager* oisInputManager); 66 ~Mouse() { }66 ~Mouse(); 67 67 68 68 #ifdef ORXONOX_PLATFORM_LINUX
Note: See TracChangeset
for help on using the changeset viewer.