Files
ARMSX2/common/Windows/WinMisc.cpp
T

95 lines
2.2 KiB
C++
Raw Normal View History

2009-09-08 12:08:10 +00:00
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2021 PCSX2 Dev Team
*
2009-09-08 12:08:10 +00:00
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
2009-09-08 12:08:10 +00:00
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
2009-09-08 12:08:10 +00:00
* You should have received a copy of the GNU General Public License along with PCSX2.
* If not, see <http://www.gnu.org/licenses/>.
*/
2021-09-03 06:43:33 -04:00
#if defined(_WIN32)
2021-09-01 16:31:46 -04:00
#include "common/Pcsx2Defs.h"
#include "common/RedtapeWindows.h"
#include "common/Exceptions.h"
#include "common/StringUtil.h"
2022-04-18 23:35:14 +10:00
#include "common/General.h"
2022-10-02 23:05:05 +10:00
#include "common/WindowInfo.h"
#include "fmt/core.h"
2021-09-01 16:31:46 -04:00
2022-04-18 23:35:14 +10:00
#include <mmsystem.h>
#include <timeapi.h>
#include <VersionHelpers.h>
2021-09-03 01:23:59 -05:00
alignas(16) static LARGE_INTEGER lfreq;
void InitCPUTicks()
{
2021-07-06 18:53:34 -04:00
QueryPerformanceFrequency(&lfreq);
}
u64 GetTickFrequency()
{
2021-07-06 18:53:34 -04:00
return lfreq.QuadPart;
}
u64 GetCPUTicks()
{
2021-07-06 18:53:34 -04:00
LARGE_INTEGER count;
QueryPerformanceCounter(&count);
return count.QuadPart;
}
2009-07-11 08:31:38 +00:00
u64 GetPhysicalMemory()
{
2021-07-06 18:53:34 -04:00
MEMORYSTATUSEX status;
status.dwLength = sizeof(status);
GlobalMemoryStatusEx(&status);
return status.ullTotalPhys;
}
2021-07-06 15:25:17 -04:00
// Calculates the Windows OS Version and processor architecture, and returns it as a
// human-readable string. :)
std::string GetOSVersionString()
2009-07-11 08:31:38 +00:00
{
std::string retval;
2009-07-11 08:31:38 +00:00
2021-07-06 18:53:34 -04:00
SYSTEM_INFO si;
2021-07-06 15:25:17 -04:00
GetNativeSystemInfo(&si);
if (IsWindows10OrGreater())
{
retval = "Microsoft ";
retval += IsWindowsServer() ? "Windows Server 2016+" : "Windows 10+";
}
else
retval = "Unsupported Operating System!";
2021-07-06 18:53:34 -04:00
return retval;
2009-07-11 08:31:38 +00:00
}
2022-10-02 23:05:05 +10:00
bool WindowInfo::InhibitScreensaver(const WindowInfo& wi, bool inhibit)
{
2021-07-06 18:53:34 -04:00
EXECUTION_STATE flags = ES_CONTINUOUS;
2022-10-02 23:05:05 +10:00
if (inhibit)
2021-07-06 18:53:34 -04:00
flags |= ES_DISPLAY_REQUIRED;
SetThreadExecutionState(flags);
2022-10-02 23:05:05 +10:00
return true;
}
2022-04-18 23:35:14 +10:00
bool Common::PlaySoundAsync(const char* path)
{
const std::wstring wpath(StringUtil::UTF8StringToWideString(path));
return PlaySoundW(wpath.c_str(), NULL, SND_ASYNC | SND_NODEFAULT);
}
2021-09-03 06:43:33 -04:00
#endif