Disable screensaver/etc when a game is running
This commit is contained in:
parent
18cc668fd3
commit
531e8c4cfe
5 changed files with 47 additions and 2 deletions
|
@ -11,6 +11,7 @@
|
|||
#include "EmulationSettings.h"
|
||||
#include "../Utilities/Timer.h"
|
||||
#include "../Utilities/FolderUtilities.h"
|
||||
#include "../Utilities/PlatformUtilities.h"
|
||||
#include "HdPpu.h"
|
||||
#include "NsfPpu.h"
|
||||
#include "SoundMixer.h"
|
||||
|
@ -268,6 +269,8 @@ void Console::Run()
|
|||
targetTime = GetFrameDelay();
|
||||
|
||||
VideoDecoder::GetInstance()->StartThread();
|
||||
|
||||
PlatformUtilities::DisableScreensaver();
|
||||
|
||||
while(true) {
|
||||
try {
|
||||
|
@ -307,13 +310,15 @@ void Console::Run()
|
|||
|
||||
//Prevent audio from looping endlessly while game is paused
|
||||
SoundMixer::StopAudio();
|
||||
|
||||
|
||||
PlatformUtilities::EnableScreensaver();
|
||||
while(paused) {
|
||||
//Sleep until emulation is resumed
|
||||
std::this_thread::sleep_for(std::chrono::duration<int, std::milli>(100));
|
||||
paused = EmulationSettings::IsPaused();
|
||||
}
|
||||
_runLock.Acquire();
|
||||
PlatformUtilities::DisableScreensaver();
|
||||
_runLock.Acquire();
|
||||
MessageManager::SendNotification(ConsoleNotificationType::GameResumed);
|
||||
}
|
||||
|
||||
|
@ -341,6 +346,7 @@ void Console::Run()
|
|||
SoundMixer::StopAudio();
|
||||
Movie::Stop();
|
||||
SoundMixer::StopRecording();
|
||||
PlatformUtilities::EnableScreensaver();
|
||||
|
||||
VideoDecoder::GetInstance()->StopThread();
|
||||
|
||||
|
|
22
Utilities/PlatformUtilities.cpp
Normal file
22
Utilities/PlatformUtilities.cpp
Normal file
|
@ -0,0 +1,22 @@
|
|||
#include "stdafx.h"
|
||||
#include "PlatformUtilities.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
void PlatformUtilities::DisableScreensaver()
|
||||
{
|
||||
//Prevent screensaver/etc from starting while using the emulator
|
||||
//DirectInput devices apparently do not always count as user input
|
||||
#ifdef WIN32
|
||||
SetThreadExecutionState(ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED | ES_CONTINUOUS);
|
||||
#endif // WIN32
|
||||
}
|
||||
|
||||
void PlatformUtilities::EnableScreensaver()
|
||||
{
|
||||
#ifdef WIN32
|
||||
SetThreadExecutionState(ES_CONTINUOUS);
|
||||
#endif // WIN32
|
||||
}
|
9
Utilities/PlatformUtilities.h
Normal file
9
Utilities/PlatformUtilities.h
Normal file
|
@ -0,0 +1,9 @@
|
|||
#pragma once
|
||||
#include "stdafx.h"
|
||||
|
||||
class PlatformUtilities
|
||||
{
|
||||
public:
|
||||
static void DisableScreensaver();
|
||||
static void EnableScreensaver();
|
||||
};
|
|
@ -336,6 +336,7 @@
|
|||
<ClInclude Include="nes_ntsc.h" />
|
||||
<ClInclude Include="nes_ntsc_config.h" />
|
||||
<ClInclude Include="nes_ntsc_impl.h" />
|
||||
<ClInclude Include="PlatformUtilities.h" />
|
||||
<ClInclude Include="PNGHelper.h" />
|
||||
<ClInclude Include="Scale2x\scale2x.h" />
|
||||
<ClInclude Include="Scale2x\scale3x.h" />
|
||||
|
@ -369,6 +370,7 @@
|
|||
<ClCompile Include="md5.cpp" />
|
||||
<ClCompile Include="miniz.cpp" />
|
||||
<ClCompile Include="nes_ntsc.cpp" />
|
||||
<ClCompile Include="PlatformUtilities.cpp" />
|
||||
<ClCompile Include="PNGHelper.cpp" />
|
||||
<ClCompile Include="AutoResetEvent.cpp" />
|
||||
<ClCompile Include="Scale2x\scale2x.cpp" />
|
||||
|
|
|
@ -116,6 +116,9 @@
|
|||
<ClInclude Include="ArchiveReader.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="PlatformUtilities.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
|
@ -208,5 +211,8 @@
|
|||
<ClCompile Include="ArchiveReader.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="PlatformUtilities.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
Loading…
Add table
Reference in a new issue