Move Windows version to OS namespace

This commit is contained in:
Hyper 2024-12-08 17:05:45 +00:00
parent 8db45bcf57
commit ad862adc83
9 changed files with 54 additions and 35 deletions

View file

@ -62,16 +62,22 @@ set(SWA_KERNEL_CXX_SOURCES
"kernel/xdm.cpp"
"kernel/heap.cpp"
"kernel/memory.cpp"
"kernel/platform.cpp"
"kernel/xam.cpp"
"kernel/io/file_system.cpp"
)
set(SWA_OS_CXX_SOURCES
"os/win32/process_win32.cpp"
"os/process.cpp"
"os/version.cpp"
)
if (WIN32)
list(APPEND SWA_OS_CXX_SOURCES
"os/win32/process_win32.cpp"
"os/win32/version_win32.cpp"
)
endif()
set(SWA_CPU_CXX_SOURCES
"cpu/guest_thread.cpp"
"cpu/code_cache.cpp"
@ -89,7 +95,7 @@ set(SWA_APU_CXX_SOURCES
"apu/audio.cpp"
)
if(SWA_XAUDIO2)
if (SWA_XAUDIO2)
list(APPEND SWA_APU_CXX_SOURCES "apu/driver/xaudio_driver.cpp")
else()
list(APPEND SWA_APU_CXX_SOURCES "apu/driver/miniaudio_driver.cpp")

View file

@ -1,11 +0,0 @@
#pragma once
struct PlatformVersion
{
public:
uint32_t Major{};
uint32_t Minor{};
uint32_t Build{};
};
extern PlatformVersion GetPlatformVersion();

View file

@ -1,5 +1,5 @@
#include "process.h"
#include "process_detail.h"
#include <os/process.h>
#include <os/process_detail.h>
std::filesystem::path os::process::GetExecutablePath()
{

View file

@ -0,0 +1,7 @@
#include <os/version.h>
#include <os/version_detail.h>
os::version::detail::OSVersion os::version::GetOSVersion()
{
return detail::GetOSVersion();
}

View file

@ -0,0 +1,8 @@
#pragma once
#include <os/version_detail.h>
namespace os::version
{
detail::OSVersion GetOSVersion();
}

View file

@ -0,0 +1,13 @@
#pragma once
namespace os::version::detail
{
struct OSVersion
{
uint32_t Major{};
uint32_t Minor{};
uint32_t Build{};
};
OSVersion GetOSVersion();
}

View file

@ -1,14 +1,11 @@
#include <kernel/platform.h>
#include <os/version_detail.h>
#if _WIN32
LIB_FUNCTION(LONG, "ntdll.dll", RtlGetVersion, PRTL_OSVERSIONINFOW);
#endif
PlatformVersion GetPlatformVersion()
os::version::detail::OSVersion os::version::detail::GetOSVersion()
{
auto result = PlatformVersion{};
auto result = os::version::detail::OSVersion{};
#if _WIN32
OSVERSIONINFOEXW osvi = { 0 };
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW);
@ -18,7 +15,6 @@ PlatformVersion GetPlatformVersion()
result.Major = osvi.dwMajorVersion;
result.Minor = osvi.dwMinorVersion;
result.Build = osvi.dwBuildNumber;
#endif
return result;
}

View file

@ -1,7 +1,7 @@
#include <cpu/guest_code.h>
#include <user/config.h>
#include <kernel/function.h>
#include <kernel/platform.h>
#include <os/version.h>
#include <patches/audio_patches.h>
#include <api/SWA.h>
@ -13,24 +13,24 @@ using namespace winrt;
using namespace winrt::Windows::Foundation;
using namespace winrt::Windows::Media::Control;
GlobalSystemMediaTransportControlsSessionManager m_sessionManager = nullptr;
static GlobalSystemMediaTransportControlsSessionManager g_sessionManager = nullptr;
GlobalSystemMediaTransportControlsSessionManager GetSessionManager()
static GlobalSystemMediaTransportControlsSessionManager GetSessionManager()
{
if (m_sessionManager)
return m_sessionManager;
if (g_sessionManager)
return g_sessionManager;
init_apartment();
return m_sessionManager = GlobalSystemMediaTransportControlsSessionManager::RequestAsync().get();
return g_sessionManager = GlobalSystemMediaTransportControlsSessionManager::RequestAsync().get();
}
GlobalSystemMediaTransportControlsSession GetCurrentSession()
static GlobalSystemMediaTransportControlsSession GetCurrentSession()
{
return GetSessionManager().GetCurrentSession();
}
bool IsExternalAudioPlaying()
static bool IsExternalAudioPlaying()
{
auto session = GetCurrentSession();
@ -43,7 +43,7 @@ bool IsExternalAudioPlaying()
int AudioPatches::m_isAttenuationSupported = -1;
#endif
be<float>* GetVolume(bool isMusic = true)
static be<float>* GetVolume(bool isMusic = true)
{
auto ppUnkClass = (be<uint32_t>*)g_memory.Translate(0x83362FFC);
@ -60,7 +60,7 @@ bool AudioPatches::CanAttenuate()
if (m_isAttenuationSupported >= 0)
return m_isAttenuationSupported;
auto version = GetPlatformVersion();
auto version = os::version::GetOSVersion();
m_isAttenuationSupported = version.Major >= 10 && version.Build >= 17763;

View file

@ -2,12 +2,12 @@
#include <res/images/game_icon.bmp.h>
#include <res/images/game_icon_night.bmp.h>
#include <os/version.h>
#include <ui/window_events.h>
#include <user/config.h>
#if _WIN32
#include <dwmapi.h>
#include <kernel/platform.h>
#pragma comment(lib, "dwmapi.lib")
#endif
@ -76,7 +76,7 @@ public:
static void SetDarkTitleBar(bool isEnabled)
{
#if _WIN32
auto version = GetPlatformVersion();
auto version = os::version::GetOSVersion();
if (version.Major < 10 || version.Build <= 17763)
return;