- Timestamp:
- Nov 2, 2008, 12:09:55 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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;
Note: See TracChangeset
for help on using the changeset viewer.