Common: Implement screensaver prevention on macOS

This commit is contained in:
TellowKrinkle 2022-05-27 23:50:43 -05:00 committed by tellowkrinkle
parent 9680e7460c
commit fc06963c56
1 changed files with 11 additions and 1 deletions

View File

@ -20,6 +20,7 @@
#include <sys/types.h>
#include <sys/sysctl.h>
#include <mach/mach_time.h>
#include <IOKit/pwr_mgt/IOPMLib.h>
#include "common/Pcsx2Types.h"
#include "common/General.h"
@ -93,8 +94,17 @@ std::string GetOSVersionString()
return type + " " + release + " " + arch;
}
static IOPMAssertionID s_pm_assertion;
void ScreensaverAllow(bool allow)
{
// no-op
if (s_pm_assertion)
{
IOPMAssertionRelease(s_pm_assertion);
s_pm_assertion = 0;
}
if (!allow)
IOPMAssertionCreateWithName(kIOPMAssertionTypePreventUserIdleDisplaySleep, kIOPMAssertionLevelOn, CFSTR("Playing a game"), &s_pm_assertion);
}
#endif