mirror of https://github.com/mgba-emu/mgba.git
Qt: Handle saving input settings better
This commit is contained in:
parent
6248e44e47
commit
e0185740f7
1
CHANGES
1
CHANGES
|
@ -35,6 +35,7 @@ Bugfixes:
|
||||||
- Qt: Fix controllers sometimes not loading the right profile
|
- Qt: Fix controllers sometimes not loading the right profile
|
||||||
Misc:
|
Misc:
|
||||||
- Qt: Show multiplayer numbers in window title
|
- Qt: Show multiplayer numbers in window title
|
||||||
|
- Qt: Handle saving input settings better
|
||||||
|
|
||||||
0.2.0: (2015-04-03)
|
0.2.0: (2015-04-03)
|
||||||
Features:
|
Features:
|
||||||
|
|
|
@ -505,9 +505,12 @@ const char* GBAInputGetCustomValue(const struct Configuration* config, uint32_t
|
||||||
char sectionName[SECTION_NAME_MAX];
|
char sectionName[SECTION_NAME_MAX];
|
||||||
if (profile) {
|
if (profile) {
|
||||||
snprintf(sectionName, SECTION_NAME_MAX, "input-profile.%s", profile);
|
snprintf(sectionName, SECTION_NAME_MAX, "input-profile.%s", profile);
|
||||||
} else {
|
const char* value = ConfigurationGetValue(config, sectionName, key);
|
||||||
_makeSectionName(sectionName, SECTION_NAME_MAX, type);
|
if (value) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
_makeSectionName(sectionName, SECTION_NAME_MAX, type);
|
||||||
return ConfigurationGetValue(config, sectionName, key);
|
return ConfigurationGetValue(config, sectionName, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -515,8 +518,8 @@ void GBAInputSetCustomValue(struct Configuration* config, uint32_t type, const c
|
||||||
char sectionName[SECTION_NAME_MAX];
|
char sectionName[SECTION_NAME_MAX];
|
||||||
if (profile) {
|
if (profile) {
|
||||||
snprintf(sectionName, SECTION_NAME_MAX, "input-profile.%s", profile);
|
snprintf(sectionName, SECTION_NAME_MAX, "input-profile.%s", profile);
|
||||||
} else {
|
ConfigurationSetValue(config, sectionName, key, value);
|
||||||
_makeSectionName(sectionName, SECTION_NAME_MAX, type);
|
|
||||||
}
|
}
|
||||||
|
_makeSectionName(sectionName, SECTION_NAME_MAX, type);
|
||||||
ConfigurationSetValue(config, sectionName, key, value);
|
ConfigurationSetValue(config, sectionName, key, value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,8 +120,6 @@ ConfigController::ConfigController(QObject* parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigController::~ConfigController() {
|
ConfigController::~ConfigController() {
|
||||||
write();
|
|
||||||
|
|
||||||
GBAConfigDeinit(&m_config);
|
GBAConfigDeinit(&m_config);
|
||||||
GBAConfigFreeOpts(&m_opts);
|
GBAConfigFreeOpts(&m_opts);
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,13 +108,20 @@ void InputController::loadProfile(uint32_t type, const QString& profile) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputController::saveConfiguration(uint32_t type) {
|
void InputController::saveConfiguration() {
|
||||||
GBAInputMapSave(&m_inputMap, type, m_config->input());
|
saveConfiguration(KEYBOARD);
|
||||||
#ifdef BUILD_SDL
|
#ifdef BUILD_SDL
|
||||||
|
saveConfiguration(SDL_BINDING_BUTTON);
|
||||||
|
saveProfile(SDL_BINDING_BUTTON, profileForType(SDL_BINDING_BUTTON));
|
||||||
if (m_playerAttached) {
|
if (m_playerAttached) {
|
||||||
GBASDLPlayerSaveConfig(&m_sdlPlayer, m_config->input());
|
GBASDLPlayerSaveConfig(&m_sdlPlayer, m_config->input());
|
||||||
}
|
}
|
||||||
|
m_config->write();
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void InputController::saveConfiguration(uint32_t type) {
|
||||||
|
GBAInputMapSave(&m_inputMap, type, m_config->input());
|
||||||
m_config->write();
|
m_config->write();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,9 +36,10 @@ public:
|
||||||
~InputController();
|
~InputController();
|
||||||
|
|
||||||
void setConfiguration(ConfigController* config);
|
void setConfiguration(ConfigController* config);
|
||||||
|
void saveConfiguration();
|
||||||
void loadConfiguration(uint32_t type);
|
void loadConfiguration(uint32_t type);
|
||||||
void loadProfile(uint32_t type, const QString& profile);
|
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);
|
void saveProfile(uint32_t type, const QString& profile);
|
||||||
const char* profileForType(uint32_t type);
|
const char* profileForType(uint32_t type);
|
||||||
|
|
||||||
|
|
|
@ -197,6 +197,7 @@ void Window::loadConfig() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::saveConfig() {
|
void Window::saveConfig() {
|
||||||
|
m_inputController.saveConfiguration();
|
||||||
m_config->write();
|
m_config->write();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -411,6 +412,7 @@ void Window::resizeEvent(QResizeEvent*) {
|
||||||
void Window::closeEvent(QCloseEvent* event) {
|
void Window::closeEvent(QCloseEvent* event) {
|
||||||
emit shutdown();
|
emit shutdown();
|
||||||
m_config->setQtOption("windowPos", pos());
|
m_config->setQtOption("windowPos", pos());
|
||||||
|
saveConfig();
|
||||||
QMainWindow::closeEvent(event);
|
QMainWindow::closeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue