Fix a couple of keymap load/save/default bugs

This commit is contained in:
Henrik Rydgard 2013-08-20 16:06:43 +02:00
parent 35894f9f77
commit 6b48dda12f
2 changed files with 9 additions and 8 deletions

View File

@ -622,6 +622,7 @@ void SetAxisMapping(int btn, int deviceId, int axisId, int direction, bool repla
// Note that it's easy to add other defaults if desired.
void RestoreDefault() {
g_controllerMap.clear();
#if defined(_WIN32)
SetDefaultKeyMap(DEFAULT_MAPPING_KEYBOARD, true);
SetDefaultKeyMap(DEFAULT_MAPPING_X360, false);
@ -635,6 +636,8 @@ void RestoreDefault() {
SetDefaultKeyMap(DEFAULT_MAPPING_OUYA, true);
} else if (name == "Sony Ericsson:R800i" || name == "Sony Ericsson:zeus") {
SetDefaultKeyMap(DEFAULT_MAPPING_XPERIA_PLAY, true);
} else {
SetDefaultKeyMap(DEFAULT_MAPPING_PAD, true);
}
#else
SetDefaultKeyMap(DEFAULT_MAPPING_KEYBOARD, true);

View File

@ -203,16 +203,16 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename)
IniFile controllerIniFile;
if (!controllerIniFile.Load(controllerIniFilename)) {
ERROR_LOG(LOADER, "Failed to read %s. Setting controller config to default.", controllerIniFilename);
KeyMap::RestoreDefault();
} else {
// Continue anyway to initialize the config. It will just restore the defaults.
KeyMap::LoadFromIni(controllerIniFile);
}
// Continue anyway to initialize the config. It will just restore the defaults.
KeyMap::LoadFromIni(controllerIniFile);
CleanRecent();
}
void Config::Save()
{
void Config::Save() {
if (iniFilename_.size() && g_Config.bSaveSettings) {
CleanRecent();
IniFile iniFile;
@ -336,10 +336,8 @@ void Config::Save()
IniFile controllerIniFile;
if (!controllerIniFile.Load(controllerIniFilename_.c_str())) {
ERROR_LOG(LOADER, "Error saving config - can't read ini %s", controllerIniFilename_.c_str());
} else {
KeyMap::SaveToIni(controllerIniFile);
}
KeyMap::SaveToIni(controllerIniFile);
if (!controllerIniFile.Save(controllerIniFilename_.c_str())) {
ERROR_LOG(LOADER, "Error saving config - can't write ini %s", controllerIniFilename_.c_str());
return;