mirror of https://github.com/mgba-emu/mgba.git
Qt: Only set default controller bindings if loading fails (fixes #799)
This commit is contained in:
parent
feb22a2bda
commit
b1ff578201
1
CHANGES
1
CHANGES
|
@ -32,6 +32,7 @@ Misc:
|
||||||
- Core: Suspend runloop when a core crashes
|
- Core: Suspend runloop when a core crashes
|
||||||
- Qt: Rearrange menus some
|
- Qt: Rearrange menus some
|
||||||
- Qt: Clean up cheats dialog
|
- 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
|
- Util: Improve speed of UPS patch loading
|
||||||
|
|
||||||
0.9.1: (2021-04-18)
|
0.9.1: (2021-04-18)
|
||||||
|
|
|
@ -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 mInputUnbindHat(struct mInputMap*, uint32_t type, int id);
|
||||||
void mInputUnbindAllHats(struct mInputMap*, uint32_t type);
|
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*);
|
void mInputMapSave(const struct mInputMap*, uint32_t type, struct Configuration*);
|
||||||
|
|
||||||
bool mInputProfileLoad(struct mInputMap*, uint32_t type, const struct Configuration*, const char* profile);
|
bool mInputProfileLoad(struct mInputMap*, uint32_t type, const struct Configuration*, const char* profile);
|
||||||
|
|
|
@ -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];
|
char sectionName[SECTION_NAME_MAX];
|
||||||
_makeSectionName(map->info->platformName, sectionName, SECTION_NAME_MAX, type);
|
_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) {
|
void mInputMapSave(const struct mInputMap* map, uint32_t type, struct Configuration* config) {
|
||||||
|
|
|
@ -44,7 +44,6 @@ InputController::InputController(int playerId, QWidget* topLevel, QObject* paren
|
||||||
}
|
}
|
||||||
++s_sdlInited;
|
++s_sdlInited;
|
||||||
m_sdlPlayer.bindings = &m_inputMap;
|
m_sdlPlayer.bindings = &m_inputMap;
|
||||||
mSDLInitBindingsGBA(&m_inputMap);
|
|
||||||
updateJoysticks();
|
updateJoysticks();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -163,23 +162,28 @@ void InputController::setConfiguration(ConfigController* config) {
|
||||||
if (!m_playerAttached) {
|
if (!m_playerAttached) {
|
||||||
m_playerAttached = mSDLAttachPlayer(&s_sdlEvents, &m_sdlPlayer);
|
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));
|
loadProfile(SDL_BINDING_BUTTON, profileForType(SDL_BINDING_BUTTON));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputController::loadConfiguration(uint32_t type) {
|
bool InputController::loadConfiguration(uint32_t type) {
|
||||||
mInputMapLoad(&m_inputMap, type, m_config->input());
|
if (!mInputMapLoad(&m_inputMap, type, m_config->input())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
#ifdef BUILD_SDL
|
#ifdef BUILD_SDL
|
||||||
if (m_playerAttached) {
|
if (m_playerAttached) {
|
||||||
mSDLPlayerLoadConfig(&m_sdlPlayer, m_config->input());
|
mSDLPlayerLoadConfig(&m_sdlPlayer, m_config->input());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputController::loadProfile(uint32_t type, const QString& profile) {
|
bool InputController::loadProfile(uint32_t type, const QString& profile) {
|
||||||
if (profile.isEmpty()) {
|
if (profile.isEmpty()) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
bool loaded = mInputProfileLoad(&m_inputMap, type, m_config->input(), profile.toUtf8().constData());
|
bool loaded = mInputProfileLoad(&m_inputMap, type, m_config->input(), profile.toUtf8().constData());
|
||||||
recalibrateAxes();
|
recalibrateAxes();
|
||||||
|
@ -187,9 +191,11 @@ void InputController::loadProfile(uint32_t type, const QString& profile) {
|
||||||
const InputProfile* ip = InputProfile::findProfile(profile);
|
const InputProfile* ip = InputProfile::findProfile(profile);
|
||||||
if (ip) {
|
if (ip) {
|
||||||
ip->apply(this);
|
ip->apply(this);
|
||||||
|
loaded = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
emit profileLoaded(profile);
|
emit profileLoaded(profile);
|
||||||
|
return loaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputController::saveConfiguration() {
|
void InputController::saveConfiguration() {
|
||||||
|
|
|
@ -56,8 +56,8 @@ public:
|
||||||
|
|
||||||
void setConfiguration(ConfigController* config);
|
void setConfiguration(ConfigController* config);
|
||||||
void saveConfiguration();
|
void saveConfiguration();
|
||||||
void loadConfiguration(uint32_t type);
|
bool loadConfiguration(uint32_t type);
|
||||||
void loadProfile(uint32_t type, const QString& profile);
|
bool loadProfile(uint32_t type, const QString& profile);
|
||||||
void saveConfiguration(uint32_t type);
|
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);
|
||||||
|
|
Loading…
Reference in New Issue