all repos — mgba @ e0185740f7dd45ea804f94f229ec65bbff520ca6

mGBA Game Boy Advance Emulator

Qt: Handle saving input settings better
Jeffrey Pfau jeffrey@endrift.com
Tue, 21 Apr 2015 21:06:26 -0700
commit

e0185740f7dd45ea804f94f229ec65bbff520ca6

parent

6248e44e47a8156555f5b9873a24093643a8a12f

M CHANGESCHANGES

@@ -35,6 +35,7 @@ - Qt: Fix multiplayer windows opening as the wrong size

- 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:
M src/gba/input.csrc/gba/input.c

@@ -505,9 +505,12 @@ const char* GBAInputGetCustomValue(const struct Configuration* config, uint32_t type, const char* key, const char* profile) {

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 char* key, const char* value, const char* profile) {

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); }
M src/platform/qt/ConfigController.cppsrc/platform/qt/ConfigController.cpp

@@ -120,8 +120,6 @@ GBAConfigMap(&m_config, &m_opts);

} ConfigController::~ConfigController() { - write(); - GBAConfigDeinit(&m_config); GBAConfigFreeOpts(&m_opts); }
M src/platform/qt/InputController.cppsrc/platform/qt/InputController.cpp

@@ -108,13 +108,20 @@ recalibrateAxes();

#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(); }
M src/platform/qt/InputController.hsrc/platform/qt/InputController.h

@@ -36,9 +36,10 @@ InputController(int playerId = 0, QObject* parent = nullptr);

~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);
M src/platform/qt/Window.cppsrc/platform/qt/Window.cpp

@@ -197,6 +197,7 @@ m_inputController.setConfiguration(m_config);

} void Window::saveConfig() { + m_inputController.saveConfiguration(); m_config->write(); }

@@ -411,6 +412,7 @@

void Window::closeEvent(QCloseEvent* event) { emit shutdown(); m_config->setQtOption("windowPos", pos()); + saveConfig(); QMainWindow::closeEvent(event); }