mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-13 22:08:34 +00:00
Check OS version before going down screensaver path
This commit is contained in:
parent
f86097aefb
commit
6d4212ca06
@ -13,6 +13,8 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <retro_miscellaneous.h>
|
||||
|
||||
#include "../../general.h"
|
||||
#include "../../verbosity.h"
|
||||
#include "win32_common.h"
|
||||
@ -386,32 +388,42 @@ bool win32_suppress_screensaver(void *data, bool enable)
|
||||
#ifdef _XBOX
|
||||
return false;
|
||||
#else
|
||||
typedef HANDLE (WINAPI * PowerCreateRequestPtr)(REASON_CONTEXT *context);
|
||||
typedef BOOL (WINAPI * PowerSetRequestPtr)(HANDLE PowerRequest, POWER_REQUEST_TYPE RequestType);
|
||||
HMODULE kernel32 = GetModuleHandleW(L"kernel32.dll");
|
||||
PowerCreateRequestPtr powerCreateRequest =
|
||||
(PowerCreateRequestPtr)GetProcAddress(kernel32, "PowerCreateRequest");
|
||||
PowerSetRequestPtr powerSetRequest =
|
||||
(PowerSetRequestPtr)GetProcAddress(kernel32, "PowerSetRequest");
|
||||
|
||||
if(enable)
|
||||
{
|
||||
if(powerCreateRequest && powerSetRequest)
|
||||
int major, minor;
|
||||
char tmp[PATH_MAX_LENGTH];
|
||||
|
||||
frontend->get_os(tmp, sizeof(tmp), &major, &minor);
|
||||
|
||||
if (major >= 6 && minor >= 1)
|
||||
{
|
||||
/* Windows 7, 8, 10 codepath */
|
||||
POWER_REQUEST_CONTEXT RequestContext;
|
||||
HANDLE Request;
|
||||
typedef HANDLE (WINAPI * PowerCreateRequestPtr)(REASON_CONTEXT *context);
|
||||
typedef BOOL (WINAPI * PowerSetRequestPtr)(HANDLE PowerRequest,
|
||||
POWER_REQUEST_TYPE RequestType);
|
||||
HMODULE kernel32 = GetModuleHandleW(L"kernel32.dll");
|
||||
PowerCreateRequestPtr powerCreateRequest =
|
||||
(PowerCreateRequestPtr)GetProcAddress(kernel32, "PowerCreateRequest");
|
||||
PowerSetRequestPtr powerSetRequest =
|
||||
(PowerSetRequestPtr)GetProcAddress(kernel32, "PowerSetRequest");
|
||||
|
||||
RequestContext.Version = POWER_REQUEST_CONTEXT_VERSION;
|
||||
RequestContext.Flags = POWER_REQUEST_CONTEXT_SIMPLE_STRING;
|
||||
RequestContext.Reason.SimpleReasonString = (LPWSTR)L"RetroArch running";
|
||||
if(powerCreateRequest && powerSetRequest)
|
||||
{
|
||||
POWER_REQUEST_CONTEXT RequestContext;
|
||||
HANDLE Request;
|
||||
|
||||
Request = powerCreateRequest(&RequestContext);
|
||||
RequestContext.Version = POWER_REQUEST_CONTEXT_VERSION;
|
||||
RequestContext.Flags = POWER_REQUEST_CONTEXT_SIMPLE_STRING;
|
||||
RequestContext.Reason.SimpleReasonString = (LPWSTR)L"RetroArch running";
|
||||
|
||||
powerSetRequest( Request, PowerRequestDisplayRequired);
|
||||
return true;
|
||||
Request = powerCreateRequest(&RequestContext);
|
||||
|
||||
powerSetRequest( Request, PowerRequestDisplayRequired);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
/* XP / Vista codepath */
|
||||
SetThreadExecutionState(ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED);
|
||||
|
Loading…
Reference in New Issue
Block a user