diff options
author | bunnei <bunneidev@gmail.com> | 2019-09-04 04:32:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-04 04:32:09 +0200 |
commit | 86b39e06778e2c270a400a63891c51d8731b0eed (patch) | |
tree | 68d2a41e27021b9180df875929a4e9c1f97a9a3f | |
parent | Merge pull request #2832 from FearlessTobi/im-an-idiot (diff) | |
parent | Fix to Windows sleep issues (diff) | |
download | yuzu-86b39e06778e2c270a400a63891c51d8731b0eed.tar yuzu-86b39e06778e2c270a400a63891c51d8731b0eed.tar.gz yuzu-86b39e06778e2c270a400a63891c51d8731b0eed.tar.bz2 yuzu-86b39e06778e2c270a400a63891c51d8731b0eed.tar.lz yuzu-86b39e06778e2c270a400a63891c51d8731b0eed.tar.xz yuzu-86b39e06778e2c270a400a63891c51d8731b0eed.tar.zst yuzu-86b39e06778e2c270a400a63891c51d8731b0eed.zip |
-rw-r--r-- | src/yuzu/main.cpp | 19 | ||||
-rw-r--r-- | src/yuzu/main.h | 3 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index a7c656fdb..ac57229d5 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -119,6 +119,7 @@ Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin); #endif #ifdef _WIN32 +#include <windows.h> extern "C" { // tells Nvidia and AMD drivers to use the dedicated GPU by default on laptops with switchable // graphics @@ -747,6 +748,18 @@ void GMainWindow::OnDisplayTitleBars(bool show) { } } +void GMainWindow::PreventOSSleep() { +#ifdef _WIN32 + SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED); +#endif +} + +void GMainWindow::AllowOSSleep() { +#ifdef _WIN32 + SetThreadExecutionState(ES_CONTINUOUS); +#endif +} + QStringList GMainWindow::GetUnsupportedGLExtensions() { QStringList unsupported_ext; @@ -966,6 +979,8 @@ void GMainWindow::BootGame(const QString& filename) { } void GMainWindow::ShutdownGame() { + AllowOSSleep(); + discord_rpc->Pause(); emu_thread->RequestStop(); @@ -1567,6 +1582,8 @@ void GMainWindow::OnMenuRecentFile() { } void GMainWindow::OnStartGame() { + PreventOSSleep(); + emu_thread->SetRunning(true); qRegisterMetaType<Core::Frontend::SoftwareKeyboardParameters>( @@ -1598,6 +1615,8 @@ void GMainWindow::OnPauseGame() { ui.action_Pause->setEnabled(false); ui.action_Stop->setEnabled(true); ui.action_Capture_Screenshot->setEnabled(false); + + AllowOSSleep(); } void GMainWindow::OnStopGame() { diff --git a/src/yuzu/main.h b/src/yuzu/main.h index 1137bbc7a..501608ddc 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h @@ -130,6 +130,9 @@ private: void ConnectWidgetEvents(); void ConnectMenuEvents(); + void PreventOSSleep(); + void AllowOSSleep(); + QStringList GetUnsupportedGLExtensions(); bool LoadROM(const QString& filename); void BootGame(const QString& filename); |