mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 05:40:04 +00:00 
			
		
		
		
	Merge pull request #4914 from vitor-k/windows-coffee
Fix to Windows sleep issues
This commit is contained in:
		
						commit
						8c2a33553a
					
				
					 2 changed files with 24 additions and 0 deletions
				
			
		|  | @ -18,6 +18,9 @@ | ||||||
| #ifdef __APPLE__ | #ifdef __APPLE__ | ||||||
| #include <unistd.h> // for chdir
 | #include <unistd.h> // for chdir
 | ||||||
| #endif | #endif | ||||||
|  | #ifdef _WIN32 | ||||||
|  | #include <windows.h> | ||||||
|  | #endif | ||||||
| #include "citra_qt/aboutdialog.h" | #include "citra_qt/aboutdialog.h" | ||||||
| #include "citra_qt/applets/mii_selector.h" | #include "citra_qt/applets/mii_selector.h" | ||||||
| #include "citra_qt/applets/swkbd.h" | #include "citra_qt/applets/swkbd.h" | ||||||
|  | @ -709,6 +712,18 @@ void GMainWindow::OnOpenUpdater() { | ||||||
|     updater->LaunchUI(); |     updater->LaunchUI(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | void GMainWindow::PreventOSSleep() { | ||||||
|  | #ifdef _WIN32 | ||||||
|  |     SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED); | ||||||
|  | #endif | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void GMainWindow::AllowOSSleep() { | ||||||
|  | #ifdef _WIN32 | ||||||
|  |     SetThreadExecutionState(ES_CONTINUOUS); | ||||||
|  | #endif | ||||||
|  | } | ||||||
|  | 
 | ||||||
| bool GMainWindow::LoadROM(const QString& filename) { | bool GMainWindow::LoadROM(const QString& filename) { | ||||||
|     // Shutdown previous session if the emu thread is still active...
 |     // Shutdown previous session if the emu thread is still active...
 | ||||||
|     if (emu_thread != nullptr) |     if (emu_thread != nullptr) | ||||||
|  | @ -899,6 +914,8 @@ void GMainWindow::ShutdownGame() { | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     AllowOSSleep(); | ||||||
|  | 
 | ||||||
|     discord_rpc->Pause(); |     discord_rpc->Pause(); | ||||||
|     OnStopRecordingPlayback(); |     OnStopRecordingPlayback(); | ||||||
|     emu_thread->RequestStop(); |     emu_thread->RequestStop(); | ||||||
|  | @ -1216,6 +1233,8 @@ void GMainWindow::OnStartGame() { | ||||||
|         movie_record_path.clear(); |         movie_record_path.clear(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     PreventOSSleep(); | ||||||
|  | 
 | ||||||
|     emu_thread->SetRunning(true); |     emu_thread->SetRunning(true); | ||||||
|     qRegisterMetaType<Core::System::ResultStatus>("Core::System::ResultStatus"); |     qRegisterMetaType<Core::System::ResultStatus>("Core::System::ResultStatus"); | ||||||
|     qRegisterMetaType<std::string>("std::string"); |     qRegisterMetaType<std::string>("std::string"); | ||||||
|  | @ -1243,6 +1262,8 @@ void GMainWindow::OnPauseGame() { | ||||||
|     ui.action_Pause->setEnabled(false); |     ui.action_Pause->setEnabled(false); | ||||||
|     ui.action_Stop->setEnabled(true); |     ui.action_Stop->setEnabled(true); | ||||||
|     ui.action_Capture_Screenshot->setEnabled(false); |     ui.action_Capture_Screenshot->setEnabled(false); | ||||||
|  | 
 | ||||||
|  |     AllowOSSleep(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void GMainWindow::OnStopGame() { | void GMainWindow::OnStopGame() { | ||||||
|  |  | ||||||
|  | @ -104,6 +104,9 @@ private: | ||||||
|     void ConnectWidgetEvents(); |     void ConnectWidgetEvents(); | ||||||
|     void ConnectMenuEvents(); |     void ConnectMenuEvents(); | ||||||
| 
 | 
 | ||||||
|  |     void PreventOSSleep(); | ||||||
|  |     void AllowOSSleep(); | ||||||
|  | 
 | ||||||
|     bool LoadROM(const QString& filename); |     bool LoadROM(const QString& filename); | ||||||
|     void BootGame(const QString& filename); |     void BootGame(const QString& filename); | ||||||
|     void ShutdownGame(); |     void ShutdownGame(); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue