Qt: Handle saving input settings better

This commit is contained in:
Jeffrey Pfau 2015-04-21 21:06:26 -07:00
parent 6248e44e47
commit e0185740f7
6 changed files with 21 additions and 9 deletions

View File

@ -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:

View File

@ -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);
}

View File

@ -120,8 +120,6 @@ ConfigController::ConfigController(QObject* parent)
}
ConfigController::~ConfigController() {
write();
GBAConfigDeinit(&m_config);
GBAConfigFreeOpts(&m_opts);
}

View File

@ -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();
}

View File

@ -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);

View File

@ -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);
}