mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-11-26 02:54:17 +01:00
Log Windows version + Fix logging crash on Linux
This commit is contained in:
parent
890df997cb
commit
892ae13680
@ -484,26 +484,53 @@ namespace CafeSystem
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if BOOST_OS_WINDOWS
|
||||||
|
std::string GetWindowsNamedVersion(uint32& buildNumber)
|
||||||
|
{
|
||||||
|
static char productName[256];
|
||||||
|
HKEY hKey;
|
||||||
|
DWORD dwType = REG_SZ;
|
||||||
|
DWORD dwSize = sizeof(productName);
|
||||||
|
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
if (RegQueryValueExA(hKey, "ProductName", NULL, &dwType, (LPBYTE)productName, &dwSize) != ERROR_SUCCESS)
|
||||||
|
strcpy(productName, "Windows");
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
}
|
||||||
|
OSVERSIONINFO osvi;
|
||||||
|
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
|
||||||
|
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||||
|
GetVersionEx(&osvi);
|
||||||
|
buildNumber = osvi.dwBuildNumber;
|
||||||
|
return std::string(productName);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void logPlatformInfo()
|
void logPlatformInfo()
|
||||||
{
|
{
|
||||||
|
std::string buffer;
|
||||||
const char* platform = NULL;
|
const char* platform = NULL;
|
||||||
#if BOOST_OS_WINDOWS
|
#if BOOST_OS_WINDOWS
|
||||||
platform = "Windows";
|
uint32 buildNumber;
|
||||||
|
std::string windowsVersionName = GetWindowsNamedVersion(buildNumber);
|
||||||
|
buffer = fmt::format("{} (Build {})", windowsVersionName, buildNumber);
|
||||||
|
platform = buffer.c_str();
|
||||||
#elif BOOST_OS_LINUX
|
#elif BOOST_OS_LINUX
|
||||||
if (getenv ("APPIMAGE"))
|
if (getenv ("APPIMAGE"))
|
||||||
platform = "Linux (AppImage)";
|
platform = "Linux (AppImage)";
|
||||||
else if (getenv ("SNAP"))
|
else if (getenv ("SNAP"))
|
||||||
platform = "Linux (Snap)";
|
platform = "Linux (Snap)";
|
||||||
else if (platform = getenv ("container"))
|
else if (platform = getenv ("container"))
|
||||||
|
{
|
||||||
if (strcmp (platform, "flatpak") == 0)
|
if (strcmp (platform, "flatpak") == 0)
|
||||||
platform = "Linux (Flatpak)";
|
platform = "Linux (Flatpak)";
|
||||||
|
}
|
||||||
else
|
else
|
||||||
platform = "Linux";
|
platform = "Linux";
|
||||||
#elif BOOST_OS_MACOS
|
#elif BOOST_OS_MACOS
|
||||||
platform = "MacOS";
|
platform = "MacOS";
|
||||||
#endif
|
#endif
|
||||||
cemuLog_log(LogType::Force, "Platform: {}", platform);
|
cemuLog_log(LogType::Force, "Platform: {}", platform);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize all subsystems which are persistent and don't depend on a game running
|
// initialize all subsystems which are persistent and don't depend on a game running
|
||||||
|
Loading…
Reference in New Issue
Block a user