summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/yuzu/main.cpp19
-rw-r--r--src/yuzu/main.h3
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);
119#endif 119#endif
120 120
121#ifdef _WIN32 121#ifdef _WIN32
122#include <windows.h>
122extern "C" { 123extern "C" {
123// tells Nvidia and AMD drivers to use the dedicated GPU by default on laptops with switchable 124// tells Nvidia and AMD drivers to use the dedicated GPU by default on laptops with switchable
124// graphics 125// graphics
@@ -747,6 +748,18 @@ void GMainWindow::OnDisplayTitleBars(bool show) {
747 } 748 }
748} 749}
749 750
751void GMainWindow::PreventOSSleep() {
752#ifdef _WIN32
753 SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED);
754#endif
755}
756
757void GMainWindow::AllowOSSleep() {
758#ifdef _WIN32
759 SetThreadExecutionState(ES_CONTINUOUS);
760#endif
761}
762
750QStringList GMainWindow::GetUnsupportedGLExtensions() { 763QStringList GMainWindow::GetUnsupportedGLExtensions() {
751 QStringList unsupported_ext; 764 QStringList unsupported_ext;
752 765
@@ -966,6 +979,8 @@ void GMainWindow::BootGame(const QString& filename) {
966} 979}
967 980
968void GMainWindow::ShutdownGame() { 981void GMainWindow::ShutdownGame() {
982 AllowOSSleep();
983
969 discord_rpc->Pause(); 984 discord_rpc->Pause();
970 emu_thread->RequestStop(); 985 emu_thread->RequestStop();
971 986
@@ -1567,6 +1582,8 @@ void GMainWindow::OnMenuRecentFile() {
1567} 1582}
1568 1583
1569void GMainWindow::OnStartGame() { 1584void GMainWindow::OnStartGame() {
1585 PreventOSSleep();
1586
1570 emu_thread->SetRunning(true); 1587 emu_thread->SetRunning(true);
1571 1588
1572 qRegisterMetaType<Core::Frontend::SoftwareKeyboardParameters>( 1589 qRegisterMetaType<Core::Frontend::SoftwareKeyboardParameters>(
@@ -1598,6 +1615,8 @@ void GMainWindow::OnPauseGame() {
1598 ui.action_Pause->setEnabled(false); 1615 ui.action_Pause->setEnabled(false);
1599 ui.action_Stop->setEnabled(true); 1616 ui.action_Stop->setEnabled(true);
1600 ui.action_Capture_Screenshot->setEnabled(false); 1617 ui.action_Capture_Screenshot->setEnabled(false);
1618
1619 AllowOSSleep();
1601} 1620}
1602 1621
1603void GMainWindow::OnStopGame() { 1622void 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:
130 void ConnectWidgetEvents(); 130 void ConnectWidgetEvents();
131 void ConnectMenuEvents(); 131 void ConnectMenuEvents();
132 132
133 void PreventOSSleep();
134 void AllowOSSleep();
135
133 QStringList GetUnsupportedGLExtensions(); 136 QStringList GetUnsupportedGLExtensions();
134 bool LoadROM(const QString& filename); 137 bool LoadROM(const QString& filename);
135 void BootGame(const QString& filename); 138 void BootGame(const QString& filename);