Qt: Only set default controller bindings if loading fails (fixes #799)

This commit is contained in:
Vicki Pfau 2021-06-20 00:34:45 -07:00
parent feb22a2bda
commit b1ff578201
5 changed files with 18 additions and 11 deletions

View File

@ -32,6 +32,7 @@ Misc:
- Core: Suspend runloop when a core crashes
- Qt: Rearrange menus some
- Qt: Clean up cheats dialog
- Qt: Only set default controller bindings if loading fails (fixes mgba.io/i/799)
- Util: Improve speed of UPS patch loading
0.9.1: (2021-04-18)

View File

@ -70,7 +70,7 @@ bool mInputQueryHat(const struct mInputMap*, uint32_t type, int id, struct mInpu
void mInputUnbindHat(struct mInputMap*, uint32_t type, int id);
void mInputUnbindAllHats(struct mInputMap*, uint32_t type);
void mInputMapLoad(struct mInputMap*, uint32_t type, const struct Configuration*);
bool mInputMapLoad(struct mInputMap*, uint32_t type, const struct Configuration*);
void mInputMapSave(const struct mInputMap*, uint32_t type, struct Configuration*);
bool mInputProfileLoad(struct mInputMap*, uint32_t type, const struct Configuration*, const char* profile);

View File

@ -578,10 +578,10 @@ void mInputUnbindAllHats(struct mInputMap* map, uint32_t type) {
}
}
void mInputMapLoad(struct mInputMap* map, uint32_t type, const struct Configuration* config) {
bool mInputMapLoad(struct mInputMap* map, uint32_t type, const struct Configuration* config) {
char sectionName[SECTION_NAME_MAX];
_makeSectionName(map->info->platformName, sectionName, SECTION_NAME_MAX, type);
_loadAll(map, type, sectionName, config);
return _loadAll(map, type, sectionName, config);
}
void mInputMapSave(const struct mInputMap* map, uint32_t type, struct Configuration* config) {

View File

@ -44,7 +44,6 @@ InputController::InputController(int playerId, QWidget* topLevel, QObject* paren
}
++s_sdlInited;
m_sdlPlayer.bindings = &m_inputMap;
mSDLInitBindingsGBA(&m_inputMap);
updateJoysticks();
#endif
@ -163,23 +162,28 @@ void InputController::setConfiguration(ConfigController* config) {
if (!m_playerAttached) {
m_playerAttached = mSDLAttachPlayer(&s_sdlEvents, &m_sdlPlayer);
}
loadConfiguration(SDL_BINDING_BUTTON);
if (!loadConfiguration(SDL_BINDING_BUTTON)) {
mSDLInitBindingsGBA(&m_inputMap);
}
loadProfile(SDL_BINDING_BUTTON, profileForType(SDL_BINDING_BUTTON));
#endif
}
void InputController::loadConfiguration(uint32_t type) {
mInputMapLoad(&m_inputMap, type, m_config->input());
bool InputController::loadConfiguration(uint32_t type) {
if (!mInputMapLoad(&m_inputMap, type, m_config->input())) {
return false;
}
#ifdef BUILD_SDL
if (m_playerAttached) {
mSDLPlayerLoadConfig(&m_sdlPlayer, m_config->input());
}
#endif
return true;
}
void InputController::loadProfile(uint32_t type, const QString& profile) {
bool InputController::loadProfile(uint32_t type, const QString& profile) {
if (profile.isEmpty()) {
return;
return false;
}
bool loaded = mInputProfileLoad(&m_inputMap, type, m_config->input(), profile.toUtf8().constData());
recalibrateAxes();
@ -187,9 +191,11 @@ void InputController::loadProfile(uint32_t type, const QString& profile) {
const InputProfile* ip = InputProfile::findProfile(profile);
if (ip) {
ip->apply(this);
loaded = true;
}
}
emit profileLoaded(profile);
return loaded;
}
void InputController::saveConfiguration() {

View File

@ -56,8 +56,8 @@ public:
void setConfiguration(ConfigController* config);
void saveConfiguration();
void loadConfiguration(uint32_t type);
void loadProfile(uint32_t type, const QString& profile);
bool loadConfiguration(uint32_t type);
bool loadProfile(uint32_t type, const QString& profile);
void saveConfiguration(uint32_t type);
void saveProfile(uint32_t type, const QString& profile);
const char* profileForType(uint32_t type);