Changeset 2101 for code/branches/objecthierarchy/src/core/input
- Timestamp:
- Nov 2, 2008, 12:09:55 AM (16 years ago)
- Location:
- code/branches/objecthierarchy/src/core/input
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/core/input/Button.cc
r2001 r2101 82 82 } 83 83 84 void Button::readConfigValue( )84 void Button::readConfigValue(ConfigFileType configFile) 85 85 { 86 86 // create/get ConfigValueContainer 87 87 if (!configContainer_) 88 88 { 89 configContainer_ = new ConfigValueContainer( CFT_Keybindings, 0, groupName_, name_, "", name_);89 configContainer_ = new ConfigValueContainer(configFile, 0, groupName_, name_, "", name_); 90 90 configContainer_->callback(this, &Button::parse); 91 91 } -
code/branches/objecthierarchy/src/core/input/Button.h
r1887 r2101 41 41 #include <vector> 42 42 #include "InputCommands.h" 43 #include "core/ConfigFileManager.h" 43 44 44 45 namespace orxonox … … 52 53 virtual bool addParamCommand(ParamCommand* command) { return false; } 53 54 void parse(); 54 void readConfigValue( );55 void readConfigValue(ConfigFileType configFile); 55 56 bool execute(KeybindMode::Enum mode, float abs = 1.0f, float rel = 1.0f); 56 57 -
code/branches/objecthierarchy/src/core/input/InputManager.cc
r1887 r2101 395 395 if (!cont) 396 396 { 397 cont = new ConfigValueContainer(C FT_Settings, getIdentifier(), getIdentifier()->getName(), "CoeffPos", coeffPos);397 cont = new ConfigValueContainer(ConfigFileType::Settings, getIdentifier(), getIdentifier()->getName(), "CoeffPos", coeffPos); 398 398 getIdentifier()->addConfigValueContainer("CoeffPos", cont); 399 399 } … … 403 403 if (!cont) 404 404 { 405 cont = new ConfigValueContainer(C FT_Settings, getIdentifier(), getIdentifier()->getName(), "CoeffNeg", coeffNeg);405 cont = new ConfigValueContainer(ConfigFileType::Settings, getIdentifier(), getIdentifier()->getName(), "CoeffNeg", coeffNeg); 406 406 getIdentifier()->addConfigValueContainer("CoeffNeg", cont); 407 407 } … … 411 411 if (!cont) 412 412 { 413 cont = new ConfigValueContainer(C FT_Settings, getIdentifier(), getIdentifier()->getName(), "Zero", zero);413 cont = new ConfigValueContainer(ConfigFileType::Settings, getIdentifier(), getIdentifier()->getName(), "Zero", zero); 414 414 getIdentifier()->addConfigValueContainer("Zero", cont); 415 415 } -
code/branches/objecthierarchy/src/core/input/KeyBinder.cc
r2004 r2101 106 106 } 107 107 108 // Get a new ConfigFileType from the ConfigFileManager 109 this->configFile_ = ConfigFileManager::getInstance().getNewConfigFileType(); 110 108 111 // initialise joy sticks separatly to allow for reloading 109 112 numberOfJoySticks_ = InputManager::getInstance().numberOfJoySticks(); … … 133 136 void KeyBinder::setConfigValues() 134 137 { 135 SetConfigValue(defaultKeybindings_, "def_keybindings.ini")136 .description("Filename of default keybindings.");137 138 SetConfigValue(analogThreshold_, 0.05f) 138 139 .description("Threshold for analog axes until which the state is 0."); … … 173 174 174 175 // load the bindings if required 175 if ( !configFile_.empty())176 if (configFile_ != ConfigFileType::NoType) 176 177 { 177 178 for (unsigned int iDev = oldValue; iDev < numberOfJoySticks_; ++iDev) 178 179 { 179 180 for (unsigned int i = 0; i < JoyStickButtonCode::numberOfButtons; ++i) 180 joyStickButtons_[iDev][i].readConfigValue( );181 joyStickButtons_[iDev][i].readConfigValue(this->configFile_); 181 182 for (unsigned int i = 0; i < JoyStickAxisCode::numberOfAxes * 2; ++i) 182 joyStickAxes_[iDev][i].readConfigValue( );183 joyStickAxes_[iDev][i].readConfigValue(this->configFile_); 183 184 } 184 185 } … … 250 251 True if loading succeeded. 251 252 */ 252 void KeyBinder::loadBindings(const std::string& filename )253 void KeyBinder::loadBindings(const std::string& filename, const std::string& defaultFilename) 253 254 { 254 255 COUT(3) << "KeyBinder: Loading key bindings..." << std::endl; 255 256 256 configFile_ = filename; 257 if (configFile_.empty()) 257 if (filename.empty()) 258 258 return; 259 259 260 260 // get bindings from default file if filename doesn't exist. 261 261 std::ifstream infile; 262 infile.open( configFile_.c_str());262 infile.open(filename.c_str()); 263 263 if (!infile) 264 264 { 265 ConfigFileManager::getInstance().setFile (CFT_Keybindings, defaultKeybindings_);266 ConfigFileManager::getInstance().save (CFT_Keybindings, configFile_);265 ConfigFileManager::getInstance().setFilename(this->configFile_, defaultFilename); 266 ConfigFileManager::getInstance().saveAs(this->configFile_, filename); 267 267 } 268 268 else 269 269 infile.close(); 270 ConfigFileManager::getInstance().setFile (CFT_Keybindings, configFile_);270 ConfigFileManager::getInstance().setFilename(this->configFile_, filename); 271 271 272 272 // Parse bindings and create the ConfigValueContainers if necessary 273 273 clearBindings(); 274 274 for (std::map<std::string, Button*>::const_iterator it = allButtons_.begin(); it != allButtons_.end(); ++it) 275 it->second->readConfigValue( );275 it->second->readConfigValue(this->configFile_); 276 276 277 277 COUT(3) << "KeyBinder: Loading key bindings done." << std::endl; -
code/branches/objecthierarchy/src/core/input/KeyBinder.h
r2001 r2101 44 44 #include "InputCommands.h" 45 45 #include "JoyStickDeviceNumberListener.h" 46 #include "core/ConfigFileManager.h" 46 47 47 48 namespace orxonox … … 59 60 virtual ~KeyBinder(); 60 61 61 void loadBindings(const std::string& filename );62 void loadBindings(const std::string& filename, const std::string& defaultFilename); 62 63 void clearBindings(); 63 64 bool setBinding(const std::string& binding, const std::string& name, bool bTemporary = false); … … 142 143 float deriveTime_; 143 144 144 //! Config file used. ""in case of KeyDetector. Also indicates whether we've already loaded.145 std::stringconfigFile_;145 //! Config file used. ConfigFileType::NoType in case of KeyDetector. Also indicates whether we've already loaded. 146 ConfigFileType configFile_; 146 147 147 148 private: 148 149 //##### ConfigValues ##### 149 //! Filename of default keybindings.150 std::string defaultKeybindings_;151 150 //! Whether to filter small value analog input 152 151 bool bFilterAnalogNoise_;
Note: See TracChangeset
for help on using the changeset viewer.