From 75898392b9192978bb38233b3916151dae20c382 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 17 Apr 2017 20:33:22 -0700 Subject: [PATCH] UI: Proxy devmenu keypress through an event. This prevents a mutex issue in #9626. --- UI/EmuScreen.cpp | 8 ++++++-- UI/EmuScreen.h | 2 ++ UI/GameSettingsScreen.cpp | 4 ++-- UI/GameSettingsScreen.h | 2 +- UI/MainScreen.cpp | 1 - 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 6ba78a0b4750..e05139d90446 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -122,6 +122,8 @@ EmuScreen::EmuScreen(const std::string &filename) frameStep_ = false; lastNumFlips = gpuStats.numFlips; startDumping = false; + + OnDevMenu.Handle(this, &EmuScreen::OnDevTools); } void EmuScreen::bootGame(const std::string &filename) { @@ -453,9 +455,11 @@ void EmuScreen::onVKeyDown(int virtualKeyCode) { break; case VIRTKEY_DEVMENU: - releaseButtons(); - screenManager()->push(new DevMenu()); + { + UI::EventParams e{}; + OnDevMenu.Trigger(e); break; + } case VIRTKEY_AXIS_X_MIN: case VIRTKEY_AXIS_X_MAX: diff --git a/UI/EmuScreen.h b/UI/EmuScreen.h index 6e10258572e5..74a24f93ee34 100644 --- a/UI/EmuScreen.h +++ b/UI/EmuScreen.h @@ -67,6 +67,8 @@ class EmuScreen : public UIScreen { void autoLoad(); void checkPowerDown(); + UI::Event OnDevMenu; + bool bootPending_; std::string gamePath_; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index afd08499ea7d..fe805bc123c4 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -519,7 +519,7 @@ void GameSettingsScreen::CreateViews() { // Combo key setup Choice *comboKey = controlsSettings->Add(new Choice(co->T("Combo Key Setup"))); - comboKey->OnClick.Handle(this, &GameSettingsScreen::OnCombo_key); + comboKey->OnClick.Handle(this, &GameSettingsScreen::OnComboKey); comboKey->SetEnabledPtr(&g_Config.bShowTouchControls); // On non iOS systems, offer to let the user see this button. @@ -1122,7 +1122,7 @@ UI::EventReturn GameSettingsScreen::OnChangeMacAddress(UI::EventParams &e) { return UI::EVENT_DONE; } -UI::EventReturn GameSettingsScreen::OnCombo_key(UI::EventParams &e) { +UI::EventReturn GameSettingsScreen::OnComboKey(UI::EventParams &e) { screenManager()->push(new Combo_keyScreen(&g_Config.iComboMode)); return UI::EVENT_DONE; } diff --git a/UI/GameSettingsScreen.h b/UI/GameSettingsScreen.h index 196dd043093a..ad2e1c56d1aa 100644 --- a/UI/GameSettingsScreen.h +++ b/UI/GameSettingsScreen.h @@ -66,7 +66,7 @@ class GameSettingsScreen : public UIDialogScreenWithGameBackground { UI::EventReturn OnReloadCheats(UI::EventParams &e); UI::EventReturn OnTiltTypeChange(UI::EventParams &e); UI::EventReturn OnTiltCustomize(UI::EventParams &e); - UI::EventReturn OnCombo_key(UI::EventParams &e); + UI::EventReturn OnComboKey(UI::EventParams &e); // Global settings handlers UI::EventReturn OnLanguage(UI::EventParams &e); diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 85f20e5c41cb..259ad59c6e34 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -1100,7 +1100,6 @@ UI::EventReturn MainScreen::OnGameSelectedInstant(UI::EventParams &e) { } UI::EventReturn MainScreen::OnGameSettings(UI::EventParams &e) { - // screenManager()->push(new SettingsScreen()); auto gameSettings = new GameSettingsScreen("", ""); gameSettings->OnRecentChanged.Handle(this, &MainScreen::OnRecentChange); screenManager()->push(gameSettings);