Native Linux compile working and works on steam deck
This commit is contained in:
parent
e5cca6b23f
commit
6ba25c1b0d
8 changed files with 137 additions and 52 deletions
|
@ -5,6 +5,21 @@
|
|||
|
||||
#include "HarmonyLinkLib.h"
|
||||
|
||||
bool UHarmonyLinkLibrary::bIsWineCached = false;
|
||||
bool UHarmonyLinkLibrary::bIsLinuxCached = false;
|
||||
bool UHarmonyLinkLibrary::bIsSteamDeckCached = false;
|
||||
bool UHarmonyLinkLibrary::bCPUInfoCached = false;
|
||||
bool UHarmonyLinkLibrary::bDeviceInfoCached = false;
|
||||
bool UHarmonyLinkLibrary::bOSInfoCached = false;
|
||||
|
||||
bool UHarmonyLinkLibrary::bIsWine = false;
|
||||
bool UHarmonyLinkLibrary::bIsLinux = false;
|
||||
bool UHarmonyLinkLibrary::bIsSteamDeck = false;
|
||||
|
||||
FCPUInfo UHarmonyLinkLibrary::CachedCPUInfo = FCPUInfo();
|
||||
FDevice UHarmonyLinkLibrary::CachedDeviceInfo = FDevice();
|
||||
FOSVerInfo UHarmonyLinkLibrary::CachedOSInfo = FOSVerInfo();
|
||||
|
||||
UHarmonyLinkLibrary::UHarmonyLinkLibrary()
|
||||
{
|
||||
if (!HarmonyLinkLib::HL_Init())
|
||||
|
@ -16,34 +31,65 @@ UHarmonyLinkLibrary::UHarmonyLinkLibrary()
|
|||
UE_LOG(LogHarmonyLink, Log, TEXT("HarmonyLinkLib Initialised!"));
|
||||
}
|
||||
|
||||
bool UHarmonyLinkLibrary::IsWine()
|
||||
bool UHarmonyLinkLibrary::IsWine(bool bForce)
|
||||
{
|
||||
return HarmonyLinkLib::get_is_wine();
|
||||
if (!bIsWineCached || bForce)
|
||||
{
|
||||
bIsWine = HarmonyLinkLib::get_is_wine();
|
||||
bIsWineCached = true;
|
||||
}
|
||||
return bIsWine;
|
||||
}
|
||||
|
||||
bool UHarmonyLinkLibrary::IsLinux()
|
||||
bool UHarmonyLinkLibrary::IsLinux(bool bForce)
|
||||
{
|
||||
return HarmonyLinkLib::get_is_linux();
|
||||
if (!bIsLinuxCached || bForce)
|
||||
{
|
||||
bIsLinux = HarmonyLinkLib::get_is_linux();
|
||||
bIsLinuxCached = true;
|
||||
}
|
||||
return bIsLinux;
|
||||
}
|
||||
|
||||
bool UHarmonyLinkLibrary::IsSteamDeck()
|
||||
bool UHarmonyLinkLibrary::IsSteamDeck(bool bForce)
|
||||
{
|
||||
return GetDeviceInfo().Device == EDevice::STEAM_DECK;
|
||||
if (!bIsSteamDeckCached || bForce)
|
||||
{
|
||||
bIsSteamDeck = GetDeviceInfo().Device == EDevice::STEAM_DECK;
|
||||
bIsSteamDeckCached = true;
|
||||
}
|
||||
return bIsSteamDeck;
|
||||
}
|
||||
|
||||
FCPUInfo UHarmonyLinkLibrary::GetCPUInfo()
|
||||
FCPUInfo UHarmonyLinkLibrary::GetCPUInfo(bool bForce)
|
||||
{
|
||||
return FCPUInfo(HarmonyLinkLib::get_cpu_info());
|
||||
if (!bCPUInfoCached || bForce)
|
||||
{
|
||||
CachedCPUInfo = FCPUInfo(HarmonyLinkLib::get_cpu_info());
|
||||
bCPUInfoCached = true;
|
||||
}
|
||||
|
||||
return CachedCPUInfo;
|
||||
}
|
||||
|
||||
FDevice UHarmonyLinkLibrary::GetDeviceInfo()
|
||||
FDevice UHarmonyLinkLibrary::GetDeviceInfo(bool bForce)
|
||||
{
|
||||
return FDevice(HarmonyLinkLib::get_device_info());
|
||||
if (!bDeviceInfoCached || bForce)
|
||||
{
|
||||
CachedDeviceInfo = FDevice(HarmonyLinkLib::get_device_info());
|
||||
bDeviceInfoCached = true;
|
||||
}
|
||||
return CachedDeviceInfo;
|
||||
}
|
||||
|
||||
FOSVerInfo UHarmonyLinkLibrary::GetOSInfo()
|
||||
FOSVerInfo UHarmonyLinkLibrary::GetOSInfo(bool bForce)
|
||||
{
|
||||
return FOSVerInfo(HarmonyLinkLib::get_os_version());
|
||||
if (!bOSInfoCached || bForce)
|
||||
{
|
||||
CachedOSInfo = FOSVerInfo(HarmonyLinkLib::get_os_version());
|
||||
bOSInfoCached = true;
|
||||
}
|
||||
return CachedOSInfo;
|
||||
}
|
||||
|
||||
FBattery UHarmonyLinkLibrary::GetBatteryStatus()
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "HarmonyLinkLibrary.h"
|
||||
#include "GameFramework/GameUserSettings.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
#include "HarmonyLinkLib.h"
|
||||
|
||||
UHarmonyLinkGraphics* UHarmonyLinkGraphics::_INSTANCE = nullptr;
|
||||
int32 UHarmonyLinkGraphics::_TickRate = 1;
|
||||
|
@ -72,8 +73,8 @@ UHarmonyLinkGraphics::UHarmonyLinkGraphics()
|
|||
|
||||
AddToRoot();
|
||||
|
||||
FWorldDelegates::OnPostWorldInitialization.AddUObject(this, &UHarmonyLinkGraphics::OnPostWorldInitialization);
|
||||
FWorldDelegates::OnPreWorldFinishDestroy.AddUObject(this, &UHarmonyLinkGraphics::OnWorldEnd);
|
||||
FWorldDelegates::OnPostWorldInitialization.AddStatic(&UHarmonyLinkGraphics::OnPostWorldInitialization);
|
||||
FWorldDelegates::OnPreWorldFinishDestroy.AddStatic(&UHarmonyLinkGraphics::OnWorldEnd);
|
||||
|
||||
Init();
|
||||
}
|
||||
|
@ -82,6 +83,7 @@ UHarmonyLinkGraphics::~UHarmonyLinkGraphics()
|
|||
{
|
||||
UE_LOG(LogHarmonyLink, Verbose, TEXT("~UHarmonyLinkGraphics called."));
|
||||
FWorldDelegates::OnPostWorldInitialization.RemoveAll(this);
|
||||
FWorldDelegates::OnPreWorldFinishDestroy.RemoveAll(this);
|
||||
}
|
||||
|
||||
void UHarmonyLinkGraphics::LoadConfig(const bool bForceReload)
|
||||
|
@ -352,13 +354,27 @@ void UHarmonyLinkGraphics::DestroySettings()
|
|||
void UHarmonyLinkGraphics::Init()
|
||||
{
|
||||
UE_LOG(LogHarmonyLink, Log, TEXT("Init called."));
|
||||
|
||||
if (!HarmonyLinkLib::HL_Init())
|
||||
{
|
||||
UE_LOG(LogHarmonyLink, Fatal, TEXT("Failed to initialise HarmonyLinkLib!"));
|
||||
return;
|
||||
}
|
||||
|
||||
LoadConfig();
|
||||
|
||||
const FBattery BatteryStatus = UHarmonyLinkLibrary::GetBatteryStatus();
|
||||
|
||||
|
||||
if (BatteryStatus.HasBattery)
|
||||
{
|
||||
ApplyProfileInternal(EProfile::BATTERY);
|
||||
if (BatteryStatus.IsACConnected)
|
||||
{
|
||||
ApplyProfileInternal(EProfile::BATTERY);
|
||||
}
|
||||
else
|
||||
{
|
||||
ApplyProfileInternal(EProfile::CHARGING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -584,7 +600,7 @@ void UHarmonyLinkGraphics::OnPostWorldInitialization(UWorld* World, UWorld::Init
|
|||
|
||||
if (World->IsGameWorld())
|
||||
{
|
||||
if (IsValid(_INSTANCE))
|
||||
if (IsValid(GetSettings()))
|
||||
{
|
||||
FTimerManager* TimerManager = &World->GetTimerManager();
|
||||
if (!TimerManager)
|
||||
|
@ -598,7 +614,7 @@ void UHarmonyLinkGraphics::OnPostWorldInitialization(UWorld* World, UWorld::Init
|
|||
|
||||
World->GetTimerManager().SetTimer(_TickTimerHandle, [TimerManager]
|
||||
{
|
||||
if (!_INSTANCE)
|
||||
if (!GetSettings())
|
||||
{
|
||||
UE_LOG(LogHarmonyLink, Error, TEXT("'This' is destroyed, Clearing timer."))
|
||||
if (TimerManager)
|
||||
|
@ -607,7 +623,7 @@ void UHarmonyLinkGraphics::OnPostWorldInitialization(UWorld* World, UWorld::Init
|
|||
}
|
||||
return;
|
||||
}
|
||||
_INSTANCE->Tick();
|
||||
GetSettings()->Tick();
|
||||
}, _TickRate, true);
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue