- Timestamp:
- Dec 25, 2009, 1:18:03 PM (15 years ago)
- Location:
- code/branches/pickup2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickup2
- Property svn:mergeinfo changed
-
code/branches/pickup2/src/libraries/core/input/KeyBinderManager.cc
r5929 r6412 40 40 namespace orxonox 41 41 { 42 KeyBinderManager* KeyBinderManager::singletonPtr_s = 0;43 42 ManageScopedSingleton(KeyBinderManager, ScopeID::Graphics, false); 44 43 … … 48 47 , bBinding_(false) 49 48 { 50 this->callbackFunction_ = createFunctor(&KeyBinderManager::callback, this);51 52 49 RegisterObject(KeyBinderManager); 53 50 this->setConfigValues(); … … 57 54 .defaultValues(""); 58 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")) 59 60 .defaultValues(""); 60 61 … … 68 69 for (std::map<std::string, KeyBinder*>::const_iterator it = this->binders_.begin(); it != this->binders_.end(); ++it) 69 70 delete it->second; 70 delete this->callbackFunction_;71 71 } 72 72 … … 91 91 else 92 92 this->bDefaultFileLoaded_ = false; 93 } 94 95 inline void KeyBinderManager::unbind(const std::string& binding) 96 { 97 this->currentBinder_->setBinding("", binding, false); 98 } 99 100 inline void KeyBinderManager::tunbind(const std::string& binding) 101 { 102 this->currentBinder_->setBinding("", binding, true); 93 103 } 94 104 … … 146 156 { 147 157 COUT(0) << "Press any button/key or move a mouse/joystick axis" << std::endl; 148 KeyDetector::getInstance().setCallback( callbackFunction_);158 KeyDetector::getInstance().setCallback(shared_ptr<Functor>(createFunctor(&KeyBinderManager::keybindKeyPressed, this))); 149 159 InputManager::getInstance().enterState("detector"); 150 160 this->command_ = command; … … 156 166 157 167 // Gets called by the KeyDetector (registered with a Functor) 158 void KeyBinderManager:: callback(const std::string& keyName)168 void KeyBinderManager::keybindKeyPressed(const std::string& keyName) 159 169 { 160 170 if (this->bBinding_) 161 171 { 162 COUT(0) << "Binding string \"" << command_ << "\" on key '" << keyName << "'" << std::endl; 163 this->currentBinder_->setBinding(command_, keyName, bTemporary_); 172 if (keyName == "Keys.KeyEscape") 173 { 174 COUT(0) << "Keybinding aborted." << std::endl; 175 } 176 else 177 { 178 COUT(0) << "Binding string \"" << command_ << "\" on key '" << keyName << "'" << std::endl; 179 this->currentBinder_->setBinding(command_, keyName, bTemporary_); 180 } 164 181 InputManager::getInstance().leaveState("detector"); 182 // inform whatever was calling the command 183 if (this->callbackFunction_) 184 (*this->callbackFunction_)(); 165 185 this->bBinding_ = false; 166 186 }
Note: See TracChangeset
for help on using the changeset viewer.