From 4b5373b25b1d0788fc5beb2cde59b6f246abae57 Mon Sep 17 00:00:00 2001 From: Rukai Date: Fri, 9 Feb 2018 22:54:35 +1100 Subject: [PATCH] Remove hardcoded esc hotkey, make pause/stop hotkey actually toggle rather than just pausing, fix frame advance hotkey --- Source/Core/Core/Core.cpp | 2 +- Source/Core/DolphinQt2/HotkeyScheduler.cpp | 17 +++++++++-------- Source/Core/DolphinQt2/HotkeyScheduler.h | 2 +- Source/Core/DolphinQt2/MainWindow.cpp | 20 +++++++++++++++----- Source/Core/DolphinQt2/MainWindow.h | 1 + 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index 4c8433e7dd..1c7bdac8c9 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -629,7 +629,7 @@ State GetState() if (s_hardware_initialized) { - if (CPU::IsStepping()) + if (CPU::IsStepping() || s_frame_step) return State::Paused; return State::Running; diff --git a/Source/Core/DolphinQt2/HotkeyScheduler.cpp b/Source/Core/DolphinQt2/HotkeyScheduler.cpp index ad0114b96c..c70736968b 100644 --- a/Source/Core/DolphinQt2/HotkeyScheduler.cpp +++ b/Source/Core/DolphinQt2/HotkeyScheduler.cpp @@ -89,14 +89,16 @@ static void HandleFrameskipHotkeys() if (frame_step_delay_count < frame_step_delay && frame_step_hold) frame_step_delay_count++; - // TODO GUI Update (Depends on an unimplemented feature) - // if ((frame_step_count == 0 || frame_step_count == FRAME_STEP_DELAY) && !frame_step_hold) + if ((frame_step_count == 0 || frame_step_count == FRAME_STEP_DELAY) && !frame_step_hold) + { + Core::DoFrameStep(); + frame_step_hold = true; + } if (frame_step_count < FRAME_STEP_DELAY) { - ++frame_step_count; - if (frame_step_hold) - frame_step_hold = false; + frame_step_count++; + frame_step_hold = false; } if (frame_step_count == FRAME_STEP_DELAY && frame_step_hold && @@ -108,8 +110,7 @@ static void HandleFrameskipHotkeys() return; } - - if (frame_step_count > 0) + else if (frame_step_count > 0) { // Reset frame advance frame_step_count = 0; @@ -143,7 +144,7 @@ void HotkeyScheduler::Run() // Pause and Unpause if (IsHotkey(HK_PLAY_PAUSE)) - emit PauseHotkey(); + emit TogglePauseHotkey(); // Stop if (IsHotkey(HK_STOP)) diff --git a/Source/Core/DolphinQt2/HotkeyScheduler.h b/Source/Core/DolphinQt2/HotkeyScheduler.h index 7aee962eec..8a32d672f7 100644 --- a/Source/Core/DolphinQt2/HotkeyScheduler.h +++ b/Source/Core/DolphinQt2/HotkeyScheduler.h @@ -23,7 +23,7 @@ signals: void ExitHotkey(); void FullScreenHotkey(); void StopHotkey(); - void PauseHotkey(); + void TogglePauseHotkey(); void ScreenShotHotkey(); void SetStateSlotHotkey(int slot); void StateLoadSlotHotkey(); diff --git a/Source/Core/DolphinQt2/MainWindow.cpp b/Source/Core/DolphinQt2/MainWindow.cpp index e0876e50f1..8b5e23bc6f 100644 --- a/Source/Core/DolphinQt2/MainWindow.cpp +++ b/Source/Core/DolphinQt2/MainWindow.cpp @@ -271,7 +271,7 @@ void MainWindow::ConnectMenuBar() void MainWindow::ConnectHotkeys() { connect(m_hotkey_scheduler, &HotkeyScheduler::ExitHotkey, this, &MainWindow::close); - connect(m_hotkey_scheduler, &HotkeyScheduler::PauseHotkey, this, &MainWindow::Pause); + connect(m_hotkey_scheduler, &HotkeyScheduler::TogglePauseHotkey, this, &MainWindow::TogglePause); connect(m_hotkey_scheduler, &HotkeyScheduler::StopHotkey, this, &MainWindow::RequestStop); connect(m_hotkey_scheduler, &HotkeyScheduler::ScreenShotHotkey, this, &MainWindow::ScreenShot); connect(m_hotkey_scheduler, &HotkeyScheduler::FullScreenHotkey, this, &MainWindow::FullScreen); @@ -322,7 +322,6 @@ void MainWindow::ConnectRenderWidget() { m_rendering_to_main = false; m_render_widget->hide(); - connect(m_render_widget, &RenderWidget::EscapePressed, this, &MainWindow::RequestStop); connect(m_render_widget, &RenderWidget::Closed, this, &MainWindow::ForceStop); } @@ -397,6 +396,18 @@ void MainWindow::Pause() EnableScreenSaver(true); } +void MainWindow::TogglePause() +{ + if (Core::GetState() == Core::State::Paused) + { + Play(); + } + else + { + Pause(); + } +} + void MainWindow::OnStopComplete() { m_stop_requested = false; @@ -577,8 +588,8 @@ void MainWindow::HideRenderWidget() } // The following code works around a driver bug that would lead to Dolphin crashing when changing - // graphics backends (e.g. OpenGL to Vulkan). To avoid this the render widget is (safely) recreated - disconnect(m_render_widget, &RenderWidget::EscapePressed, this, &MainWindow::RequestStop); + // graphics backends (e.g. OpenGL to Vulkan). To avoid this the render widget is (safely) + // recreated disconnect(m_render_widget, &RenderWidget::Closed, this, &MainWindow::ForceStop); m_render_widget->hide(); @@ -588,7 +599,6 @@ void MainWindow::HideRenderWidget() m_render_widget = new RenderWidget; m_render_widget->installEventFilter(this); - connect(m_render_widget, &RenderWidget::EscapePressed, this, &MainWindow::RequestStop); connect(m_render_widget, &RenderWidget::Closed, this, &MainWindow::ForceStop); } diff --git a/Source/Core/DolphinQt2/MainWindow.h b/Source/Core/DolphinQt2/MainWindow.h index 92aac61a17..9a586027f5 100644 --- a/Source/Core/DolphinQt2/MainWindow.h +++ b/Source/Core/DolphinQt2/MainWindow.h @@ -53,6 +53,7 @@ private: void Open(); void Play(const std::optional& savestate_path = {}); void Pause(); + void TogglePause(); // May ask for confirmation. Returns whether or not it actually stopped. bool RequestStop();