Move KeepScreenAwake to platform specific code.

This commit is contained in:
Henrik Rydgård committed 2023-08-10 16:12:12 +02:00
1 parent b7b3e81e2f
commit be708e3e02
5 files changed
+39 -32

No files matched your search

-27
View File
@@ -48,10 +48,6 @@
#include "Windows/InputDevice.h"
#endif
// Time until we stop considering the core active without user input.
// Should this be configurable? 2 hours currently.
static const double ACTIVITY_IDLE_TIMEOUT = 2.0 * 3600.0;
static std::condition_variable m_StepCond;
static std::mutex m_hStepMutex;
static std::condition_variable m_InactiveCond;
@@ -63,8 +59,6 @@ static uint32_t steppingAddress = 0;
static std::set<CoreLifecycleFunc> lifecycleFuncs;
static std::set<CoreStopRequestFunc> stopFuncs;
static bool windowHidden = false;
static double lastActivity = 0.0;
static double lastKeepAwake = 0.0;
static GraphicsContext *graphicsContext;
static bool powerSaving = false;
@@ -84,10 +78,6 @@ bool Core_IsWindowHidden() {
return windowHidden;
}
void Core_NotifyActivity() {
lastActivity = time_now_d();
}
void Core_ListenLifecycle(CoreLifecycleFunc func) {
lifecycleFuncs.insert(func);
}
@@ -217,12 +207,6 @@ void UpdateRunLoop() {
NativeFrame(graphicsContext);
}
void KeepScreenAwake() {
#if defined(_WIN32) && !PPSSPP_PLATFORM(UWP)
SetThreadExecutionState(ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED);
#endif
}
void Core_RunLoop(GraphicsContext *ctx) {
float refreshRate = System_GetPropertyFloat(SYSPROP_DISPLAY_REFRESH_RATE);
@@ -247,17 +231,6 @@ void Core_RunLoop(GraphicsContext *ctx) {
UpdateRunLoop();
if (!windowHidden && !Core_IsStepping()) {
ctx->SwapBuffers();
// Keep the system awake for longer than normal for cutscenes and the like.
const double now = time_now_d();
if (now < lastActivity + ACTIVITY_IDLE_TIMEOUT) {
// Only resetting it ever prime number seconds in case the call is expensive.
// Using a prime number to ensure there's no interaction with other periodic events.
if (now - lastKeepAwake > 89.0 || now < lastKeepAwake) {
KeepScreenAwake();
lastKeepAwake = now;
}
}
}
}
}