mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-27 07:20:49 +00:00
Move KeepScreenAwake to platform specific code.
This commit is contained in:
parent
b7b3e81e2f
commit
be708e3e02
@ -200,6 +200,8 @@ enum class SystemNotification {
|
|||||||
POLL_CONTROLLERS,
|
POLL_CONTROLLERS,
|
||||||
TOGGLE_DEBUG_CONSOLE, // TODO: Kinda weird, just ported forward.
|
TOGGLE_DEBUG_CONSOLE, // TODO: Kinda weird, just ported forward.
|
||||||
TEST_JAVA_EXCEPTION,
|
TEST_JAVA_EXCEPTION,
|
||||||
|
KEEP_SCREEN_AWAKE,
|
||||||
|
ACTIVITY,
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string System_GetProperty(SystemProperty prop);
|
std::string System_GetProperty(SystemProperty prop);
|
||||||
|
@ -48,10 +48,6 @@
|
|||||||
#include "Windows/InputDevice.h"
|
#include "Windows/InputDevice.h"
|
||||||
#endif
|
#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::condition_variable m_StepCond;
|
||||||
static std::mutex m_hStepMutex;
|
static std::mutex m_hStepMutex;
|
||||||
static std::condition_variable m_InactiveCond;
|
static std::condition_variable m_InactiveCond;
|
||||||
@ -63,8 +59,6 @@ static uint32_t steppingAddress = 0;
|
|||||||
static std::set<CoreLifecycleFunc> lifecycleFuncs;
|
static std::set<CoreLifecycleFunc> lifecycleFuncs;
|
||||||
static std::set<CoreStopRequestFunc> stopFuncs;
|
static std::set<CoreStopRequestFunc> stopFuncs;
|
||||||
static bool windowHidden = false;
|
static bool windowHidden = false;
|
||||||
static double lastActivity = 0.0;
|
|
||||||
static double lastKeepAwake = 0.0;
|
|
||||||
static GraphicsContext *graphicsContext;
|
static GraphicsContext *graphicsContext;
|
||||||
static bool powerSaving = false;
|
static bool powerSaving = false;
|
||||||
|
|
||||||
@ -84,10 +78,6 @@ bool Core_IsWindowHidden() {
|
|||||||
return windowHidden;
|
return windowHidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core_NotifyActivity() {
|
|
||||||
lastActivity = time_now_d();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Core_ListenLifecycle(CoreLifecycleFunc func) {
|
void Core_ListenLifecycle(CoreLifecycleFunc func) {
|
||||||
lifecycleFuncs.insert(func);
|
lifecycleFuncs.insert(func);
|
||||||
}
|
}
|
||||||
@ -217,12 +207,6 @@ void UpdateRunLoop() {
|
|||||||
NativeFrame(graphicsContext);
|
NativeFrame(graphicsContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeepScreenAwake() {
|
|
||||||
#if defined(_WIN32) && !PPSSPP_PLATFORM(UWP)
|
|
||||||
SetThreadExecutionState(ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void Core_RunLoop(GraphicsContext *ctx) {
|
void Core_RunLoop(GraphicsContext *ctx) {
|
||||||
float refreshRate = System_GetPropertyFloat(SYSPROP_DISPLAY_REFRESH_RATE);
|
float refreshRate = System_GetPropertyFloat(SYSPROP_DISPLAY_REFRESH_RATE);
|
||||||
|
|
||||||
@ -247,17 +231,6 @@ void Core_RunLoop(GraphicsContext *ctx) {
|
|||||||
UpdateRunLoop();
|
UpdateRunLoop();
|
||||||
if (!windowHidden && !Core_IsStepping()) {
|
if (!windowHidden && !Core_IsStepping()) {
|
||||||
ctx->SwapBuffers();
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,6 @@ bool UpdateScreenScale(int width, int height);
|
|||||||
// Don't run the core when minimized etc.
|
// Don't run the core when minimized etc.
|
||||||
void Core_NotifyWindowHidden(bool hidden);
|
void Core_NotifyWindowHidden(bool hidden);
|
||||||
bool Core_IsWindowHidden();
|
bool Core_IsWindowHidden();
|
||||||
void Core_NotifyActivity();
|
|
||||||
|
|
||||||
void Core_SetPowerSaving(bool mode);
|
void Core_SetPowerSaving(bool mode);
|
||||||
bool Core_GetPowerSaving();
|
bool Core_GetPowerSaving();
|
||||||
|
@ -564,7 +564,7 @@ void EmuScreen::sendMessage(const char *message, const char *value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EmuScreen::UnsyncTouch(const TouchInput &touch) {
|
void EmuScreen::UnsyncTouch(const TouchInput &touch) {
|
||||||
Core_NotifyActivity();
|
System_Notify(SystemNotification::ACTIVITY);
|
||||||
|
|
||||||
if (chatMenu_ && chatMenu_->GetVisibility() == UI::V_VISIBLE) {
|
if (chatMenu_ && chatMenu_->GetVisibility() == UI::V_VISIBLE) {
|
||||||
// Avoid pressing touch button behind the chat
|
// Avoid pressing touch button behind the chat
|
||||||
@ -830,7 +830,7 @@ void EmuScreen::onVKeyAnalog(int virtualKeyCode, float value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool EmuScreen::UnsyncKey(const KeyInput &key) {
|
bool EmuScreen::UnsyncKey(const KeyInput &key) {
|
||||||
Core_NotifyActivity();
|
System_Notify(SystemNotification::ACTIVITY);
|
||||||
|
|
||||||
if (UI::IsFocusMovementEnabled()) {
|
if (UI::IsFocusMovementEnabled()) {
|
||||||
if (UIScreen::UnsyncKey(key)) {
|
if (UIScreen::UnsyncKey(key)) {
|
||||||
@ -849,8 +849,7 @@ bool EmuScreen::UnsyncKey(const KeyInput &key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EmuScreen::UnsyncAxis(const AxisInput &axis) {
|
void EmuScreen::UnsyncAxis(const AxisInput &axis) {
|
||||||
Core_NotifyActivity();
|
System_Notify(SystemNotification::ACTIVITY);
|
||||||
|
|
||||||
return controlMapper_.Axis(axis);
|
return controlMapper_.Axis(axis);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1399,6 +1398,10 @@ void EmuScreen::render() {
|
|||||||
|
|
||||||
g_OSD.NudgeSidebar();
|
g_OSD.NudgeSidebar();
|
||||||
|
|
||||||
|
if (screenManager()->topScreen() == this) {
|
||||||
|
System_Notify(SystemNotification::KEEP_SCREEN_AWAKE);
|
||||||
|
}
|
||||||
|
|
||||||
if (invalid_) {
|
if (invalid_) {
|
||||||
// Loading, or after shutdown?
|
// Loading, or after shutdown?
|
||||||
if (loadingTextView_->GetVisibility() == UI::V_VISIBLE)
|
if (loadingTextView_->GetVisibility() == UI::V_VISIBLE)
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
#include "Common/Thread/ThreadUtil.h"
|
#include "Common/Thread/ThreadUtil.h"
|
||||||
#include "Common/Data/Encoding/Utf8.h"
|
#include "Common/Data/Encoding/Utf8.h"
|
||||||
#include "Common/Net/Resolve.h"
|
#include "Common/Net/Resolve.h"
|
||||||
|
#include "Common/TimeUtil.h"
|
||||||
#include "W32Util/DarkMode.h"
|
#include "W32Util/DarkMode.h"
|
||||||
#include "W32Util/ShellUtil.h"
|
#include "W32Util/ShellUtil.h"
|
||||||
|
|
||||||
@ -115,6 +116,12 @@ WindowsInputManager g_inputManager;
|
|||||||
|
|
||||||
int g_lastNumInstances = 0;
|
int g_lastNumInstances = 0;
|
||||||
|
|
||||||
|
static double g_lastActivity = 0.0;
|
||||||
|
static double g_lastKeepAwake = 0.0;
|
||||||
|
// 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;
|
||||||
|
|
||||||
void System_ShowFileInFolder(const char *path) {
|
void System_ShowFileInFolder(const char *path) {
|
||||||
// SHParseDisplayName can't handle relative paths, so normalize first.
|
// SHParseDisplayName can't handle relative paths, so normalize first.
|
||||||
std::string resolved = ReplaceAll(File::ResolvePath(path), "/", "\\");
|
std::string resolved = ReplaceAll(File::ResolvePath(path), "/", "\\");
|
||||||
@ -444,6 +451,29 @@ void System_Notify(SystemNotification notification) {
|
|||||||
case SystemNotification::TOGGLE_DEBUG_CONSOLE:
|
case SystemNotification::TOGGLE_DEBUG_CONSOLE:
|
||||||
MainWindow::ToggleDebugConsoleVisibility();
|
MainWindow::ToggleDebugConsoleVisibility();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SystemNotification::ACTIVITY:
|
||||||
|
g_lastActivity = time_now_d();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SystemNotification::KEEP_SCREEN_AWAKE:
|
||||||
|
{
|
||||||
|
// Keep the system awake for longer than normal for cutscenes and the like.
|
||||||
|
const double now = time_now_d();
|
||||||
|
if (now < g_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 - g_lastKeepAwake > 89.0 || now < g_lastKeepAwake) {
|
||||||
|
// Note that this needs to be called periodically.
|
||||||
|
// It's also possible to set ES_CONTINUOUS but let's not, for simplicity.
|
||||||
|
#if defined(_WIN32) && !PPSSPP_PLATFORM(UWP)
|
||||||
|
SetThreadExecutionState(ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED);
|
||||||
|
#endif
|
||||||
|
g_lastKeepAwake = now;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user