Changeset 5863 for code/branches/core5/src/libraries/core/input
- Timestamp:
- Oct 3, 2009, 5:33:31 PM (15 years ago)
- Location:
- code/branches/core5/src/libraries/core/input
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core5/src/libraries/core/input/CMakeLists.txt
r5738 r5863 9 9 JoyStickQuantityListener.cc 10 10 KeyBinder.cc 11 KeyBinderManager.cc 11 12 Keyboard.cc 12 13 KeyDetector.cc -
code/branches/core5/src/libraries/core/input/InputManager.cc
r5855 r5863 264 264 } 265 265 266 void InputManager::setKeyDetectorCallback(const std::string& command)267 {268 this->keyDetector_->setCallbackCommand(command);269 }270 271 266 // ############################################################ 272 267 // ##### Destruction ##### -
code/branches/core5/src/libraries/core/input/InputManager.h
r5738 r5863 161 161 // Various getters and setters 162 162 //------------------------------- 163 //! Sets the the name of the command used by the KeyDetector as callback.164 void setKeyDetectorCallback(const std::string& command);165 163 //! Returns the number of joy stick that have been created since the c'tor or last call to reload(). 166 164 unsigned int getJoyStickQuantity() const -
code/branches/core5/src/libraries/core/input/KeyBinder.cc
r5738 r5863 27 27 */ 28 28 29 /**30 @file31 @brief Implementation of the different input handlers.32 */33 34 29 #include "KeyBinder.h" 35 30 36 31 #include "util/Convert.h" 37 32 #include "util/Debug.h" 33 #include "util/Exception.h" 38 34 #include "core/ConfigValueIncludes.h" 39 35 #include "core/CoreIncludes.h" … … 48 44 Constructor that does as little as necessary. 49 45 */ 50 KeyBinder::KeyBinder( )46 KeyBinder::KeyBinder(const std::string& filename) 51 47 : deriveTime_(0.0f) 48 , filename_(filename) 52 49 { 53 50 mouseRelative_[0] = 0; … … 103 100 // set them here to use allHalfAxes_ 104 101 setConfigValues(); 102 103 // Load the bindings if filename was given 104 if (!this->filename_.empty()) 105 this->loadBindings(); 105 106 } 106 107 … … 240 241 @brief 241 242 Loads the key and button bindings. 242 @return 243 True if loading succeeded. 244 */ 245 void KeyBinder::loadBindings(const std::string& filename) 243 */ 244 void KeyBinder::loadBindings() 246 245 { 247 246 COUT(3) << "KeyBinder: Loading key bindings..." << std::endl; 248 247 249 if (filename.empty()) 250 return; 251 252 if (this->configFile_ == ConfigFileType::NoType) 253 { 254 // Get a new ConfigFileType from the ConfigFileManager 255 this->configFile_ = ConfigFileManager::getInstance().getNewConfigFileType(); 256 } 257 258 ConfigFileManager::getInstance().setFilename(this->configFile_, filename); 248 // Get a new ConfigFileType from the ConfigFileManager 249 this->configFile_ = ConfigFileManager::getInstance().getNewConfigFileType(); 250 251 ConfigFileManager::getInstance().setFilename(this->configFile_, this->filename_); 259 252 260 253 // Parse bindings and create the ConfigValueContainers if necessary 261 clearBindings();262 254 for (std::map<std::string, Button*>::const_iterator it = allButtons_.begin(); it != allButtons_.end(); ++it) 263 255 it->second->readConfigValue(this->configFile_); -
code/branches/core5/src/libraries/core/input/KeyBinder.h
r5738 r5863 26 26 * 27 27 */ 28 29 /**30 @file31 @brief32 Different definitions of input processing.33 */34 28 35 29 #ifndef _KeyBinder_H__ … … 53 47 /** 54 48 @brief 55 Handles mouse, keyboard and joy stick input while in the actual game mode. 56 Manages the key bindings. 49 Maps mouse, keyboard and joy stick input to command strings and executes them. 50 51 The bindings are stored in ini-files (like the one for configValues) in the config Path. 52 @remarks 53 You cannot change the filename because the KeyBinderManager maps these filenames to the 54 KeyBinders. If you need to load other bindings, just create a new one. 57 55 */ 58 56 class _CoreExport KeyBinder : public InputHandler, public JoyStickQuantityListener 59 57 { 60 58 public: 61 KeyBinder ( );59 KeyBinder (const std::string& filename); 62 60 virtual ~KeyBinder(); 63 61 64 void loadBindings(const std::string& filename);65 62 void clearBindings(); 66 63 bool setBinding(const std::string& binding, const std::string& name, bool bTemporary = false); 64 const std::string& getBindingsFilename() 65 { return this->filename_; } 67 66 void setConfigValues(); 68 67 void resetJoyStickAxes(); 69 68 70 69 protected: // functions 70 void loadBindings(); 71 void buttonThresholdChanged(); 72 void initialiseJoyStickBindings(); 73 void compilePointerLists(); 74 // from JoyStickQuantityListener interface 75 virtual void JoyStickQuantityChanged(const std::vector<JoyStick*>& joyStickList); 76 71 77 void allDevicesUpdated(float dt); 72 78 void mouseUpdated(float dt); … … 74 80 // internal 75 81 void tickHalfAxis(HalfAxis& halfAxis); 76 77 void buttonThresholdChanged();78 // from JoyStickQuantityListener interface79 virtual void JoyStickQuantityChanged(const std::vector<JoyStick*>& joyStickList);80 void initialiseJoyStickBindings();81 void compilePointerLists();82 82 83 83 void buttonPressed (const KeyEvent& evt); … … 144 144 float deriveTime_; 145 145 146 //! Name of the file used in this KeyBinder (constant!) 147 const std::string filename_; 146 148 //! Config file used. ConfigFileType::NoType in case of KeyDetector. Also indicates whether we've already loaded. 147 149 ConfigFileType configFile_; … … 171 173 }; 172 174 175 173 176 inline void KeyBinder::buttonPressed (const KeyEvent& evt) 174 177 { assert(!keys_[evt.getKeyCode()].name_.empty()); keys_[evt.getKeyCode()].execute(KeybindMode::OnPress); }
Note: See TracChangeset
for help on using the changeset viewer.