From fa77010f23069ff374a5abc8267500ca25b3908e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ed=C3=AAnis=20Freindorfer=20Azevedo?= Date: Fri, 28 Jun 2019 23:02:10 -0300 Subject: [PATCH] Fix pause toggle keybinding when unmuting. We use the same event for both keybinding and `Emulation` > `Pause` actions. The issue here is that the menu item is checkable, meaning that you toggle its value and then run the handler. The handler checks the value of the menu item `Emulation` > `Pause`, and toggle the game pause accordingly. Such thing does not happen when using the keybinding. Hence, it did not toggle the pause as expected. - Related to #454. --- src/wx/cmdevents.cpp | 15 ++++++++++++++- src/wx/wxvbam.cpp | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/wx/cmdevents.cpp b/src/wx/cmdevents.cpp index cbcf73af..d14328ae 100644 --- a/src/wx/cmdevents.cpp +++ b/src/wx/cmdevents.cpp @@ -1353,7 +1353,20 @@ EVT_HANDLER(wxID_EXIT, "Exit") // Emulation menu EVT_HANDLER(Pause, "Pause (toggle)") { - GetMenuOptionBool("Pause", paused); + bool menuPress; + GetMenuOptionBool("Pause", menuPress); + + if (paused == menuPress) + { + // used accelerator + paused = !paused; + SetMenuOption("Pause", paused ? 1 : 0); + } + else + { + // used menu item + paused = menuPress; + } if (paused) panel->Pause(); diff --git a/src/wx/wxvbam.cpp b/src/wx/wxvbam.cpp index 94cc059b..34ea1fb2 100644 --- a/src/wx/wxvbam.cpp +++ b/src/wx/wxvbam.cpp @@ -818,7 +818,7 @@ void MainFrame::OnSize(wxSizeEvent& event) int MainFrame::FilterEvent(wxEvent& event) { - if (!IsPaused() && event.GetEventType() == wxEVT_KEY_DOWN) + if (event.GetEventType() == wxEVT_KEY_DOWN) { wxKeyEvent& ke = (wxKeyEvent&)event; int keyCode = ke.GetKeyCode();