mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
OS Version preview
This commit is contained in:
parent
2694104531
commit
b235d4b218
7 changed files with 104 additions and 18 deletions
|
@ -93,7 +93,7 @@ bool DoesVersionMatchWindows(uint32_t major, uint32_t minor, uint32_t spMajor, u
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DoesVersionMatchWindows(WindowsReleaseInfo release) {
|
bool DoesVersionMatchWindows(WindowsReleaseInfo release, uint64_t version, uint32_t& outMajor, uint32_t& outMinor, uint32_t& outBuild) {
|
||||||
if (release.spMajor == 0 && release.spMinor == 0) {
|
if (release.spMajor == 0 && release.spMinor == 0) {
|
||||||
// Compare Info
|
// Compare Info
|
||||||
uint32_t major = release.major;
|
uint32_t major = release.major;
|
||||||
|
@ -101,25 +101,29 @@ bool DoesVersionMatchWindows(WindowsReleaseInfo release) {
|
||||||
uint32_t build = release.build;
|
uint32_t build = release.build;
|
||||||
bool greater = release.greater;
|
bool greater = release.greater;
|
||||||
|
|
||||||
OSVERSIONINFOEX osvi;
|
// System Info
|
||||||
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
|
uint32_t osMajor = 0, osMinor = 0, osBuild = 0, osRevision = 0;
|
||||||
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
|
|
||||||
GetVersionEx((LPOSVERSIONINFO)&osvi);
|
|
||||||
|
|
||||||
// OS Info
|
if (version > 0) {
|
||||||
uint32_t osMajor = osvi.dwMajorVersion;
|
// Extract the major, minor, build, and revision numbers
|
||||||
uint32_t osMinor = osvi.dwMinorVersion;
|
// UWP take this path
|
||||||
uint32_t osBuild = osvi.dwBuildNumber;
|
osMajor = static_cast<uint32_t>((version & 0xFFFF000000000000L) >> 48);
|
||||||
|
osMinor = static_cast<uint32_t>((version & 0x0000FFFF00000000L) >> 32);
|
||||||
#if !PPSSPP_PLATFORM(UWP)
|
osBuild = static_cast<uint32_t>((version & 0x00000000FFFF0000L) >> 16);
|
||||||
// "Applications not manifested for Windows 10 will return the Windows 8 OS version value (6.2)."
|
osRevision = static_cast<uint32_t>((version & 0x000000000000FFFFL));
|
||||||
// Try to use kernel32.dll instead, for Windows 10+.
|
}
|
||||||
GetVersionFromKernel32(osMajor, osMinor, osBuild);
|
else {
|
||||||
#endif
|
// "Applications not manifested for Windows 10 will return the Windows 8 OS version value (6.2)."
|
||||||
|
// Try to use kernel32.dll instead, for Windows 10+.
|
||||||
|
GetVersionFromKernel32(osMajor, osMinor, osBuild);
|
||||||
|
}
|
||||||
|
|
||||||
if (major == osMajor) {
|
if (major == osMajor) {
|
||||||
// To detect Windows 11 we must check build number
|
// To detect Windows 11 we must check build number
|
||||||
if (osMinor >= minor && osBuild >= build) {
|
if (osMinor >= minor && osBuild >= build) {
|
||||||
|
outMajor = osMajor;
|
||||||
|
outMinor = osMinor;
|
||||||
|
outBuild = osBuild;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,6 +146,20 @@ bool IsWin7OrHigher() {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetWindowsVersion() {
|
std::string GetWindowsVersion() {
|
||||||
|
uint32_t outMajor = 0, outMinor = 0, outBuild = 0; // Dummy
|
||||||
|
return GetWindowsVersion(0, outMajor, outMinor, outBuild);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string GetWindowsVersion(uint64_t versionInfo) {
|
||||||
|
uint32_t outMajor = 0, outMinor = 0, outBuild = 0; // Dummy
|
||||||
|
return GetWindowsVersion(versionInfo, outMajor, outMinor, outBuild);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string GetWindowsVersion(uint32_t& outMajor, uint32_t& outMinor, uint32_t& outBuild) {
|
||||||
|
return GetWindowsVersion(0, outMajor, outMinor, outBuild);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string GetWindowsVersion(uint64_t versionInfo, uint32_t& outMajor, uint32_t& outMinor, uint32_t& outBuild) {
|
||||||
std::vector<std::pair<std::string, WindowsReleaseInfo>> windowsReleases = {
|
std::vector<std::pair<std::string, WindowsReleaseInfo>> windowsReleases = {
|
||||||
/* { "Preview text", { major, minor, spMajor, spMinor, build, greater } }, */
|
/* { "Preview text", { major, minor, spMajor, spMinor, build, greater } }, */
|
||||||
{ "Microsoft Windows XP, Service Pack 2", { 5, 1, 2, 0 } },
|
{ "Microsoft Windows XP, Service Pack 2", { 5, 1, 2, 0 } },
|
||||||
|
@ -160,7 +178,7 @@ std::string GetWindowsVersion() {
|
||||||
// Start from higher to lower
|
// Start from higher to lower
|
||||||
for (auto release = rbegin(windowsReleases); release != rend(windowsReleases); ++release) {
|
for (auto release = rbegin(windowsReleases); release != rend(windowsReleases); ++release) {
|
||||||
WindowsReleaseInfo releaseInfo = release->second;
|
WindowsReleaseInfo releaseInfo = release->second;
|
||||||
bool buildMatch = DoesVersionMatchWindows(releaseInfo);
|
bool buildMatch = DoesVersionMatchWindows(releaseInfo, versionInfo, outMajor, outMinor, outBuild);
|
||||||
if (buildMatch) {
|
if (buildMatch) {
|
||||||
std::string previewText = release->first;
|
std::string previewText = release->first;
|
||||||
return previewText;
|
return previewText;
|
||||||
|
|
|
@ -7,7 +7,16 @@
|
||||||
bool IsVistaOrHigher();
|
bool IsVistaOrHigher();
|
||||||
bool IsWin7OrHigher();
|
bool IsWin7OrHigher();
|
||||||
bool DoesVersionMatchWindows(uint32_t major, uint32_t minor, uint32_t spMajor, uint32_t spMinor, bool acceptGreater);
|
bool DoesVersionMatchWindows(uint32_t major, uint32_t minor, uint32_t spMajor, uint32_t spMinor, bool acceptGreater);
|
||||||
|
|
||||||
std::string GetWindowsVersion();
|
std::string GetWindowsVersion();
|
||||||
|
|
||||||
|
// Platforms like UWP has their own API,
|
||||||
|
// so we use versionInfo to pass version info from outside
|
||||||
|
// on Win32 it will use kernel (normal behavior) when versionInfo is 0
|
||||||
|
std::string GetWindowsVersion(uint64_t versionInfo);
|
||||||
|
std::string GetWindowsVersion(uint32_t& outMajor, uint32_t& outMinor, uint32_t& outBuild);
|
||||||
|
std::string GetWindowsVersion(uint64_t versionInfo, uint32_t& outMajor, uint32_t& outMinor, uint32_t& outBuild);
|
||||||
|
|
||||||
std::string GetWindowsSystemArchitecture();
|
std::string GetWindowsSystemArchitecture();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -489,6 +489,11 @@ void SystemInfoScreen::CreateTabs() {
|
||||||
systemInfo->Add(new InfoItem(si->T("System Name", "Name"), System_GetProperty(SYSPROP_NAME)));
|
systemInfo->Add(new InfoItem(si->T("System Name", "Name"), System_GetProperty(SYSPROP_NAME)));
|
||||||
#if PPSSPP_PLATFORM(ANDROID)
|
#if PPSSPP_PLATFORM(ANDROID)
|
||||||
systemInfo->Add(new InfoItem(si->T("System Version"), StringFromInt(System_GetPropertyInt(SYSPROP_SYSTEMVERSION))));
|
systemInfo->Add(new InfoItem(si->T("System Version"), StringFromInt(System_GetPropertyInt(SYSPROP_SYSTEMVERSION))));
|
||||||
|
#elif PPSSPP_PLATFORM(WINDOWS)
|
||||||
|
std::string sysVersion = System_GetProperty(SYSPROP_SYSTEMVERSION);
|
||||||
|
if (!sysVersion.empty()) {
|
||||||
|
systemInfo->Add(new InfoItem(si->T("OS Build"), sysVersion));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
systemInfo->Add(new InfoItem(si->T("Lang/Region"), System_GetProperty(SYSPROP_LANGREGION)));
|
systemInfo->Add(new InfoItem(si->T("Lang/Region"), System_GetProperty(SYSPROP_LANGREGION)));
|
||||||
std::string board = System_GetProperty(SYSPROP_BOARDNAME);
|
std::string board = System_GetProperty(SYSPROP_BOARDNAME);
|
||||||
|
|
|
@ -314,7 +314,21 @@ std::string System_GetProperty(SystemProperty prop) {
|
||||||
static bool hasCheckedGPUDriverVersion = false;
|
static bool hasCheckedGPUDriverVersion = false;
|
||||||
switch (prop) {
|
switch (prop) {
|
||||||
case SYSPROP_NAME:
|
case SYSPROP_NAME:
|
||||||
return GetWindowsVersion();
|
{
|
||||||
|
uint64_t versionInfo = GetWindowsVersionInfo();
|
||||||
|
std::string osName;
|
||||||
|
if (IsXBox()) {
|
||||||
|
osName = "Xbox OS";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
osName = GetWindowsVersion(versionInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
osName += " " + GetWindowsSystemArchitecture();
|
||||||
|
return osName;
|
||||||
|
}
|
||||||
|
case SYSPROP_SYSTEMVERSION:
|
||||||
|
return GetWindowsVersionInfoPreview();
|
||||||
case SYSPROP_LANGREGION:
|
case SYSPROP_LANGREGION:
|
||||||
return GetLangRegion();
|
return GetLangRegion();
|
||||||
case SYSPROP_CLIPBOARD_TEXT:
|
case SYSPROP_CLIPBOARD_TEXT:
|
||||||
|
|
|
@ -238,4 +238,26 @@ bool IsMobile() {
|
||||||
auto deviceInfo = Windows::System::Profile::AnalyticsInfo::VersionInfo;
|
auto deviceInfo = Windows::System::Profile::AnalyticsInfo::VersionInfo;
|
||||||
return deviceInfo->DeviceFamily == "Windows.Mobile";
|
return deviceInfo->DeviceFamily == "Windows.Mobile";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t GetWindowsVersionInfo() {
|
||||||
|
Platform::String^ deviceFamilyVersion = Windows::System::Profile::AnalyticsInfo::VersionInfo->DeviceFamilyVersion;
|
||||||
|
return std::stoull(deviceFamilyVersion->Data());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ParseVersionInfo(uint64_t version, uint32_t& major, uint32_t& minor, uint32_t& build, uint32_t& revision) {
|
||||||
|
major = static_cast<uint32_t>((version & 0xFFFF000000000000L) >> 48);
|
||||||
|
minor = static_cast<uint32_t>((version & 0x0000FFFF00000000L) >> 32);
|
||||||
|
build = static_cast<uint32_t>((version & 0x00000000FFFF0000L) >> 16);
|
||||||
|
revision = static_cast<uint32_t>(version & 0x000000000000FFFFL);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string GetWindowsVersionInfoPreview() {
|
||||||
|
uint64_t version = GetWindowsVersionInfo();
|
||||||
|
uint32_t major = 0, minor = 0, build = 0, revision = 0;
|
||||||
|
ParseVersionInfo(version, major, minor, build, revision);
|
||||||
|
|
||||||
|
char buffer[50];
|
||||||
|
sprintf_s(buffer, sizeof(buffer), "%u.%u.%u", major, minor, build);
|
||||||
|
return std::string(buffer);
|
||||||
|
}
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
|
@ -47,3 +47,10 @@ bool IsCtrlOnHold();
|
||||||
std::string GetLangRegion();
|
std::string GetLangRegion();
|
||||||
bool IsXBox();
|
bool IsXBox();
|
||||||
bool IsMobile();
|
bool IsMobile();
|
||||||
|
|
||||||
|
// Get windows version info
|
||||||
|
uint64_t GetWindowsVersionInfo();
|
||||||
|
// Parse data from GetWindowsVersionInfo to major, minor, build, revision
|
||||||
|
void ParseVersionInfo(uint64_t version, uint32_t& major, uint32_t& minor, uint32_t& build, uint32_t& revision);
|
||||||
|
// Get formatted windows version as string (for preview)
|
||||||
|
std::string GetWindowsVersionInfoPreview();
|
||||||
|
|
|
@ -106,6 +106,7 @@ CVFPUDlg *vfpudlg = nullptr;
|
||||||
|
|
||||||
static std::string langRegion;
|
static std::string langRegion;
|
||||||
static std::string osName;
|
static std::string osName;
|
||||||
|
static std::string osVersion;
|
||||||
static std::string gpuDriverVersion;
|
static std::string gpuDriverVersion;
|
||||||
|
|
||||||
static std::string restartArgs;
|
static std::string restartArgs;
|
||||||
|
@ -203,6 +204,8 @@ std::string System_GetProperty(SystemProperty prop) {
|
||||||
switch (prop) {
|
switch (prop) {
|
||||||
case SYSPROP_NAME:
|
case SYSPROP_NAME:
|
||||||
return osName;
|
return osName;
|
||||||
|
case SYSPROP_SYSTEMVERSION:
|
||||||
|
return osVersion;
|
||||||
case SYSPROP_LANGREGION:
|
case SYSPROP_LANGREGION:
|
||||||
return langRegion;
|
return langRegion;
|
||||||
case SYSPROP_CLIPBOARD_TEXT:
|
case SYSPROP_CLIPBOARD_TEXT:
|
||||||
|
@ -903,7 +906,15 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
|
||||||
g_VFS.Register("", new DirectoryReader(exePath));
|
g_VFS.Register("", new DirectoryReader(exePath));
|
||||||
|
|
||||||
langRegion = GetDefaultLangRegion();
|
langRegion = GetDefaultLangRegion();
|
||||||
osName = GetWindowsVersion() + " " + GetWindowsSystemArchitecture();
|
|
||||||
|
uint32_t outMajor = 0, outMinor = 0, outBuild = 0;
|
||||||
|
osName = GetWindowsVersion(outMajor, outMinor, outBuild) + " " + GetWindowsSystemArchitecture();
|
||||||
|
if (outMajor > 0) {
|
||||||
|
// Builds with (service pack) don't show OS Version for now
|
||||||
|
char buffer[50];
|
||||||
|
sprintf_s(buffer, sizeof(buffer), "%u.%u.%u", outMajor, outMinor, outBuild);
|
||||||
|
osVersion = std::string(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
std::string configFilename = "";
|
std::string configFilename = "";
|
||||||
const std::wstring configOption = L"--config=";
|
const std::wstring configOption = L"--config=";
|
||||||
|
|
Loading…
Add table
Reference in a new issue