mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 05:19:56 +00:00
Simplify & win11-build check fix
Without build check on Windows 10 it will appear as Windows 11, I forgot to keep build check, also the process can be simplified more to avoid extra functions.
This commit is contained in:
parent
b015225bf6
commit
e7d7d89066
@ -46,7 +46,7 @@ bool GetVersionFromKernel32(uint32_t &major, uint32_t &minor, uint32_t &build) {
|
||||
#endif
|
||||
}
|
||||
|
||||
bool DoesVersionMatchWindows(uint32_t major, uint32_t minor, uint32_t spMajor, uint32_t spMinor, bool greater) {
|
||||
bool DoesVersionMatchWindows(uint32_t major, uint32_t minor, uint32_t spMajor, uint32_t spMinor, uint32_t build, bool greater) {
|
||||
#if !PPSSPP_PLATFORM(UWP)
|
||||
if (spMajor == 0 && spMinor == 0) {
|
||||
// "Applications not manifested for Windows 10 will return the Windows 8 OS version value (6.2)."
|
||||
@ -55,7 +55,9 @@ bool DoesVersionMatchWindows(uint32_t major, uint32_t minor, uint32_t spMajor, u
|
||||
if (GetVersionFromKernel32(actualMajor, actualMinor, actualBuild)) {
|
||||
if (greater)
|
||||
return actualMajor > major || (major == actualMajor && actualMinor >= minor);
|
||||
return major == actualMajor && minor == actualMinor;
|
||||
|
||||
// To detect Windows 11 we must check build number
|
||||
return major == actualMajor && minor == actualMinor && actualBuild >= build;
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,25 +88,25 @@ bool DoesVersionMatchWindows(uint32_t major, uint32_t minor, uint32_t spMajor, u
|
||||
return VerifyVersionInfo(&osvi, typeMask, conditionMask) != FALSE;
|
||||
|
||||
#else
|
||||
if (greater) {
|
||||
if (greater)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool DoesVersionMatchWindows(WindowsReleaseInfo release) {
|
||||
return DoesVersionMatchWindows(release.major, release.minor, release.spMajor, release.spMinor, release.greater);
|
||||
}
|
||||
|
||||
bool IsVistaOrHigher() {
|
||||
// Vista is 6.0
|
||||
return DoesVersionMatchWindows(6, 0, 0, 0, true);
|
||||
return DoesVersionMatchWindows(6, 0, 0, 0, 0, true);
|
||||
}
|
||||
|
||||
bool IsWin7OrHigher() {
|
||||
// Win7 is 6.1
|
||||
return DoesVersionMatchWindows(6, 1, 0, 0, true);
|
||||
return DoesVersionMatchWindows(6, 1, 0, 0, 0, true);
|
||||
}
|
||||
|
||||
bool IsWin8OrHigher() {
|
||||
// Win8 is 6.2
|
||||
return DoesVersionMatchWindows(6, 2, 0, 0, 0, true);
|
||||
}
|
||||
|
||||
std::string GetWindowsVersion() {
|
||||
@ -126,8 +128,7 @@ std::string GetWindowsVersion() {
|
||||
// Start from higher to lower
|
||||
for (auto release = rbegin(windowsReleases); release != rend(windowsReleases); ++release) {
|
||||
WindowsReleaseInfo releaseInfo = release->second;
|
||||
bool buildMatch = DoesVersionMatchWindows(releaseInfo);
|
||||
if (buildMatch) {
|
||||
if (DoesVersionMatchWindows(releaseInfo.major, releaseInfo.minor, releaseInfo.spMajor, releaseInfo.spMinor, releaseInfo.build, releaseInfo.greater)) {
|
||||
std::string previewText = release->first;
|
||||
return previewText;
|
||||
}
|
||||
|
@ -6,7 +6,8 @@
|
||||
|
||||
bool IsVistaOrHigher();
|
||||
bool IsWin7OrHigher();
|
||||
bool DoesVersionMatchWindows(uint32_t major, uint32_t minor, uint32_t spMajor, uint32_t spMinor, bool acceptGreater);
|
||||
bool IsWin8OrHigher();
|
||||
bool DoesVersionMatchWindows(uint32_t major, uint32_t minor, uint32_t spMajor, uint32_t spMinor, uint32_t build, bool acceptGreater);
|
||||
bool GetVersionFromKernel32(uint32_t& major, uint32_t& minor, uint32_t& build);
|
||||
|
||||
std::string GetWindowsVersion();
|
||||
|
@ -423,7 +423,7 @@ static int DefaultGPUBackend() {
|
||||
|
||||
#if PPSSPP_PLATFORM(WINDOWS)
|
||||
// If no Vulkan, use Direct3D 11 on Windows 8+ (most importantly 10.)
|
||||
if (DoesVersionMatchWindows(6, 2, 0, 0, true)) {
|
||||
if (IsWin8OrHigher()) {
|
||||
return (int)GPUBackend::DIRECT3D11;
|
||||
}
|
||||
#elif PPSSPP_PLATFORM(ANDROID)
|
||||
@ -489,7 +489,7 @@ int Config::NextValidBackend() {
|
||||
}
|
||||
#endif
|
||||
#if PPSSPP_PLATFORM(WINDOWS)
|
||||
if (!failed.count(GPUBackend::DIRECT3D11) && DoesVersionMatchWindows(6, 1, 0, 0, true)) {
|
||||
if (!failed.count(GPUBackend::DIRECT3D11) && IsWin7OrHigher()) {
|
||||
return (int)GPUBackend::DIRECT3D11;
|
||||
}
|
||||
#endif
|
||||
@ -536,7 +536,7 @@ bool Config::IsBackendEnabled(GPUBackend backend) {
|
||||
if (backend != GPUBackend::OPENGL)
|
||||
return false;
|
||||
#elif PPSSPP_PLATFORM(WINDOWS)
|
||||
if (backend == GPUBackend::DIRECT3D11 && !DoesVersionMatchWindows(6, 0, 0, 0, true))
|
||||
if (backend == GPUBackend::DIRECT3D11 && !IsVistaOrHigher())
|
||||
return false;
|
||||
#else
|
||||
if (backend == GPUBackend::DIRECT3D11 || backend == GPUBackend::DIRECT3D9)
|
||||
|
@ -765,7 +765,7 @@ namespace MainWindow
|
||||
|
||||
switch (message) {
|
||||
case WM_CREATE:
|
||||
if (!DoesVersionMatchWindows(6, 0, 0, 0, true)) {
|
||||
if (!IsVistaOrHigher()) {
|
||||
// Remove the D3D11 choice on versions below XP
|
||||
RemoveMenu(GetMenu(hWnd), ID_OPTIONS_DIRECT3D11, MF_BYCOMMAND);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user