diff --git a/CHANGES b/CHANGES index cfdff2aba..3feb26d4f 100644 --- a/CHANGES +++ b/CHANGES @@ -35,6 +35,7 @@ Bugfixes: - Qt: Fix controllers sometimes not loading the right profile Misc: - Qt: Show multiplayer numbers in window title + - Qt: Handle saving input settings better 0.2.0: (2015-04-03) Features: diff --git a/src/gba/input.c b/src/gba/input.c index 439a11d36..97b5c9103 100644 --- a/src/gba/input.c +++ b/src/gba/input.c @@ -505,9 +505,12 @@ const char* GBAInputGetCustomValue(const struct Configuration* config, uint32_t char sectionName[SECTION_NAME_MAX]; if (profile) { snprintf(sectionName, SECTION_NAME_MAX, "input-profile.%s", profile); - } else { - _makeSectionName(sectionName, SECTION_NAME_MAX, type); + const char* value = ConfigurationGetValue(config, sectionName, key); + if (value) { + return value; + } } + _makeSectionName(sectionName, SECTION_NAME_MAX, type); return ConfigurationGetValue(config, sectionName, key); } @@ -515,8 +518,8 @@ void GBAInputSetCustomValue(struct Configuration* config, uint32_t type, const c char sectionName[SECTION_NAME_MAX]; if (profile) { snprintf(sectionName, SECTION_NAME_MAX, "input-profile.%s", profile); - } else { - _makeSectionName(sectionName, SECTION_NAME_MAX, type); + ConfigurationSetValue(config, sectionName, key, value); } + _makeSectionName(sectionName, SECTION_NAME_MAX, type); ConfigurationSetValue(config, sectionName, key, value); } diff --git a/src/platform/qt/ConfigController.cpp b/src/platform/qt/ConfigController.cpp index 9857727d8..ff6fd9664 100644 --- a/src/platform/qt/ConfigController.cpp +++ b/src/platform/qt/ConfigController.cpp @@ -120,8 +120,6 @@ ConfigController::ConfigController(QObject* parent) } ConfigController::~ConfigController() { - write(); - GBAConfigDeinit(&m_config); GBAConfigFreeOpts(&m_opts); } diff --git a/src/platform/qt/InputController.cpp b/src/platform/qt/InputController.cpp index 9dfb58daf..e72e7f2b9 100644 --- a/src/platform/qt/InputController.cpp +++ b/src/platform/qt/InputController.cpp @@ -108,13 +108,20 @@ void InputController::loadProfile(uint32_t type, const QString& profile) { #endif } -void InputController::saveConfiguration(uint32_t type) { - GBAInputMapSave(&m_inputMap, type, m_config->input()); +void InputController::saveConfiguration() { + saveConfiguration(KEYBOARD); #ifdef BUILD_SDL + saveConfiguration(SDL_BINDING_BUTTON); + saveProfile(SDL_BINDING_BUTTON, profileForType(SDL_BINDING_BUTTON)); if (m_playerAttached) { GBASDLPlayerSaveConfig(&m_sdlPlayer, m_config->input()); } + m_config->write(); #endif +} + +void InputController::saveConfiguration(uint32_t type) { + GBAInputMapSave(&m_inputMap, type, m_config->input()); m_config->write(); } diff --git a/src/platform/qt/InputController.h b/src/platform/qt/InputController.h index b4a73bab1..175445e3e 100644 --- a/src/platform/qt/InputController.h +++ b/src/platform/qt/InputController.h @@ -36,9 +36,10 @@ public: ~InputController(); void setConfiguration(ConfigController* config); + void saveConfiguration(); void loadConfiguration(uint32_t type); void loadProfile(uint32_t type, const QString& profile); - void saveConfiguration(uint32_t type = KEYBOARD); + void saveConfiguration(uint32_t type); void saveProfile(uint32_t type, const QString& profile); const char* profileForType(uint32_t type); diff --git a/src/platform/qt/Window.cpp b/src/platform/qt/Window.cpp index 6984fb7e2..df434575a 100644 --- a/src/platform/qt/Window.cpp +++ b/src/platform/qt/Window.cpp @@ -197,6 +197,7 @@ void Window::loadConfig() { } void Window::saveConfig() { + m_inputController.saveConfiguration(); m_config->write(); } @@ -411,6 +412,7 @@ void Window::resizeEvent(QResizeEvent*) { void Window::closeEvent(QCloseEvent* event) { emit shutdown(); m_config->setQtOption("windowPos", pos()); + saveConfig(); QMainWindow::closeEvent(event); }