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"
|
#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()
|
UHarmonyLinkLibrary::UHarmonyLinkLibrary()
|
||||||
{
|
{
|
||||||
if (!HarmonyLinkLib::HL_Init())
|
if (!HarmonyLinkLib::HL_Init())
|
||||||
|
@ -16,34 +31,65 @@ UHarmonyLinkLibrary::UHarmonyLinkLibrary()
|
||||||
UE_LOG(LogHarmonyLink, Log, TEXT("HarmonyLinkLib Initialised!"));
|
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()
|
FBattery UHarmonyLinkLibrary::GetBatteryStatus()
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "HarmonyLinkLibrary.h"
|
#include "HarmonyLinkLibrary.h"
|
||||||
#include "GameFramework/GameUserSettings.h"
|
#include "GameFramework/GameUserSettings.h"
|
||||||
#include "Kismet/GameplayStatics.h"
|
#include "Kismet/GameplayStatics.h"
|
||||||
|
#include "HarmonyLinkLib.h"
|
||||||
|
|
||||||
UHarmonyLinkGraphics* UHarmonyLinkGraphics::_INSTANCE = nullptr;
|
UHarmonyLinkGraphics* UHarmonyLinkGraphics::_INSTANCE = nullptr;
|
||||||
int32 UHarmonyLinkGraphics::_TickRate = 1;
|
int32 UHarmonyLinkGraphics::_TickRate = 1;
|
||||||
|
@ -72,8 +73,8 @@ UHarmonyLinkGraphics::UHarmonyLinkGraphics()
|
||||||
|
|
||||||
AddToRoot();
|
AddToRoot();
|
||||||
|
|
||||||
FWorldDelegates::OnPostWorldInitialization.AddUObject(this, &UHarmonyLinkGraphics::OnPostWorldInitialization);
|
FWorldDelegates::OnPostWorldInitialization.AddStatic(&UHarmonyLinkGraphics::OnPostWorldInitialization);
|
||||||
FWorldDelegates::OnPreWorldFinishDestroy.AddUObject(this, &UHarmonyLinkGraphics::OnWorldEnd);
|
FWorldDelegates::OnPreWorldFinishDestroy.AddStatic(&UHarmonyLinkGraphics::OnWorldEnd);
|
||||||
|
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
@ -82,6 +83,7 @@ UHarmonyLinkGraphics::~UHarmonyLinkGraphics()
|
||||||
{
|
{
|
||||||
UE_LOG(LogHarmonyLink, Verbose, TEXT("~UHarmonyLinkGraphics called."));
|
UE_LOG(LogHarmonyLink, Verbose, TEXT("~UHarmonyLinkGraphics called."));
|
||||||
FWorldDelegates::OnPostWorldInitialization.RemoveAll(this);
|
FWorldDelegates::OnPostWorldInitialization.RemoveAll(this);
|
||||||
|
FWorldDelegates::OnPreWorldFinishDestroy.RemoveAll(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UHarmonyLinkGraphics::LoadConfig(const bool bForceReload)
|
void UHarmonyLinkGraphics::LoadConfig(const bool bForceReload)
|
||||||
|
@ -352,13 +354,27 @@ void UHarmonyLinkGraphics::DestroySettings()
|
||||||
void UHarmonyLinkGraphics::Init()
|
void UHarmonyLinkGraphics::Init()
|
||||||
{
|
{
|
||||||
UE_LOG(LogHarmonyLink, Log, TEXT("Init called."));
|
UE_LOG(LogHarmonyLink, Log, TEXT("Init called."));
|
||||||
|
|
||||||
|
if (!HarmonyLinkLib::HL_Init())
|
||||||
|
{
|
||||||
|
UE_LOG(LogHarmonyLink, Fatal, TEXT("Failed to initialise HarmonyLinkLib!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
LoadConfig();
|
LoadConfig();
|
||||||
|
|
||||||
const FBattery BatteryStatus = UHarmonyLinkLibrary::GetBatteryStatus();
|
const FBattery BatteryStatus = UHarmonyLinkLibrary::GetBatteryStatus();
|
||||||
|
|
||||||
if (BatteryStatus.HasBattery)
|
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 (World->IsGameWorld())
|
||||||
{
|
{
|
||||||
if (IsValid(_INSTANCE))
|
if (IsValid(GetSettings()))
|
||||||
{
|
{
|
||||||
FTimerManager* TimerManager = &World->GetTimerManager();
|
FTimerManager* TimerManager = &World->GetTimerManager();
|
||||||
if (!TimerManager)
|
if (!TimerManager)
|
||||||
|
@ -598,7 +614,7 @@ void UHarmonyLinkGraphics::OnPostWorldInitialization(UWorld* World, UWorld::Init
|
||||||
|
|
||||||
World->GetTimerManager().SetTimer(_TickTimerHandle, [TimerManager]
|
World->GetTimerManager().SetTimer(_TickTimerHandle, [TimerManager]
|
||||||
{
|
{
|
||||||
if (!_INSTANCE)
|
if (!GetSettings())
|
||||||
{
|
{
|
||||||
UE_LOG(LogHarmonyLink, Error, TEXT("'This' is destroyed, Clearing timer."))
|
UE_LOG(LogHarmonyLink, Error, TEXT("'This' is destroyed, Clearing timer."))
|
||||||
if (TimerManager)
|
if (TimerManager)
|
||||||
|
@ -607,7 +623,7 @@ void UHarmonyLinkGraphics::OnPostWorldInitialization(UWorld* World, UWorld::Init
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_INSTANCE->Tick();
|
GetSettings()->Tick();
|
||||||
}, _TickRate, true);
|
}, _TickRate, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -25,29 +25,45 @@ public:
|
||||||
|
|
||||||
// Checks if the game is running under Wine.
|
// Checks if the game is running under Wine.
|
||||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="HarmonyLink")
|
UFUNCTION(BlueprintCallable, BlueprintPure, Category="HarmonyLink")
|
||||||
static bool IsWine();
|
static bool IsWine(bool bForce = false);
|
||||||
|
|
||||||
// Checks if the operating system is Linux.
|
// Checks if the operating system is Linux.
|
||||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="HarmonyLink")
|
UFUNCTION(BlueprintCallable, BlueprintPure, Category="HarmonyLink")
|
||||||
static bool IsLinux();
|
static bool IsLinux(bool bForce = false);
|
||||||
|
|
||||||
// Checks if the game is running on a Steam Deck.
|
// Checks if the game is running on a Steam Deck.
|
||||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="HarmonyLink")
|
UFUNCTION(BlueprintCallable, BlueprintPure, Category="HarmonyLink")
|
||||||
static bool IsSteamDeck();
|
static bool IsSteamDeck(bool bForce = false);
|
||||||
|
|
||||||
// Retrieves information about the CPU of the current device.
|
// Retrieves information about the CPU of the current device.
|
||||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="HarmonyLink")
|
UFUNCTION(BlueprintCallable, BlueprintPure, Category="HarmonyLink")
|
||||||
static FCPUInfo GetCPUInfo();
|
static FCPUInfo GetCPUInfo(bool bForce = false);
|
||||||
|
|
||||||
// Retrieves information about the current device.
|
// Retrieves information about the current device.
|
||||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="HarmonyLink")
|
UFUNCTION(BlueprintCallable, BlueprintPure, Category="HarmonyLink")
|
||||||
static FDevice GetDeviceInfo();
|
static FDevice GetDeviceInfo(bool bForce = false);
|
||||||
|
|
||||||
// Retrieves information about the operating system of the current device.
|
// Retrieves information about the operating system of the current device.
|
||||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="HarmonyLink")
|
UFUNCTION(BlueprintCallable, BlueprintPure, Category="HarmonyLink")
|
||||||
static FOSVerInfo GetOSInfo();
|
static FOSVerInfo GetOSInfo(bool bForce = false);
|
||||||
|
|
||||||
// Retrieves the current battery status of the device.
|
// Retrieves the current battery status of the device.
|
||||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="HarmonyLink")
|
UFUNCTION(BlueprintCallable, BlueprintPure, Category="HarmonyLink")
|
||||||
static FBattery GetBatteryStatus();
|
static FBattery GetBatteryStatus();
|
||||||
|
|
||||||
|
private:
|
||||||
|
static bool bIsWineCached;
|
||||||
|
static bool bIsWine;
|
||||||
|
static bool bIsLinuxCached;
|
||||||
|
static bool bIsLinux;
|
||||||
|
static bool bIsSteamDeckCached;
|
||||||
|
static bool bIsSteamDeck;
|
||||||
|
|
||||||
|
static bool bCPUInfoCached;
|
||||||
|
static bool bDeviceInfoCached;
|
||||||
|
static bool bOSInfoCached;
|
||||||
|
|
||||||
|
static FCPUInfo CachedCPUInfo;
|
||||||
|
static FDevice CachedDeviceInfo;
|
||||||
|
static FOSVerInfo CachedOSInfo;
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include "Enums/Profile.h"
|
#include "Enums/Profile.h"
|
||||||
#include "Structs/SettingsProfile.h"
|
#include "Structs/SettingsProfile.h"
|
||||||
|
|
||||||
#include "UObject/Object.h"
|
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||||
#include "HarmonyLinkGraphics.generated.h"
|
#include "HarmonyLinkGraphics.generated.h"
|
||||||
|
|
||||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnProfileChanged, EProfile, Profile);
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnProfileChanged, EProfile, Profile);
|
||||||
|
@ -17,7 +17,7 @@ DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnBatteryLevelChanged, int32, Batte
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
UCLASS(Blueprintable, config="HarmonyLink")
|
UCLASS(Blueprintable, config="HarmonyLink")
|
||||||
class HARMONYLINK_API UHarmonyLinkGraphics : public UObject
|
class HARMONYLINK_API UHarmonyLinkGraphics : public UBlueprintFunctionLibrary
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
@ -390,7 +390,7 @@ private:
|
||||||
*
|
*
|
||||||
* @note Uses UE_LOG for logging errors and informational messages.
|
* @note Uses UE_LOG for logging errors and informational messages.
|
||||||
*/
|
*/
|
||||||
void OnPostWorldInitialization(UWorld* World, UWorld::InitializationValues IVS);
|
static void OnPostWorldInitialization(UWorld* World, UWorld::InitializationValues IVS);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Handles actions to be performed when the world ends.
|
* @brief Handles actions to be performed when the world ends.
|
||||||
|
@ -406,7 +406,7 @@ private:
|
||||||
*
|
*
|
||||||
* @note Uses UE_LOG for logging errors and informational messages.
|
* @note Uses UE_LOG for logging errors and informational messages.
|
||||||
*/
|
*/
|
||||||
void OnWorldEnd(UWorld* World);
|
static void OnWorldEnd(UWorld* World);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Resets the singleton instance of the UHarmonyLinkGraphics settings.
|
* @brief Resets the singleton instance of the UHarmonyLinkGraphics settings.
|
||||||
|
|
|
@ -43,26 +43,30 @@ public class HarmonyLinkLib : ModuleRules
|
||||||
}
|
}
|
||||||
else if (Target.Platform == UnrealTargetPlatform.Linux)
|
else if (Target.Platform == UnrealTargetPlatform.Linux)
|
||||||
{
|
{
|
||||||
PublicDefinitions.Add("HARMONYLINKLIB_SHARED=1");
|
PublicDefinitions.Add("HARMONYLINKLIB_STATIC=1");
|
||||||
//Console.WriteLine("Building Linux");
|
//Console.WriteLine("Building Linux");
|
||||||
PublicDefinitions.Add("BUILD_LINUX=1");
|
PublicDefinitions.Add("BUILD_LINUX=1");
|
||||||
string libPath = Path.Combine(ModuleDirectory, "bin", platformString, "libHarmonyLinkLibShared.so");
|
string dllPath = Path.Combine(ModuleDirectory, "lib", platformString, "libHarmonyLinkLibStatic_clang++.a");
|
||||||
//Console.WriteLine("Library Path: " + libPath);
|
//string dllTargetPath = "$(TargetOutputDir)/libHarmonyLinkLibShared.so";
|
||||||
PublicAdditionalLibraries.Add(libPath);
|
//Console.WriteLine("Library Path: " + libPath);
|
||||||
|
PublicAdditionalLibraries.Add(dllPath);
|
||||||
|
|
||||||
// Add the C++ standard library explicitly
|
// Ensure the proper linking of standard C++ libraries
|
||||||
//string toolchainLibPath = "E:/UnrealToolChains/v22_clang-16.0.6-centos7/x86_64-unknown-linux-gnu/lib";
|
//PublicSystemLibraries.Add("stdc++");
|
||||||
//PublicSystemLibraryPaths.Add(toolchainLibPath);
|
//PublicSystemLibraries.Add("c++abi");
|
||||||
RuntimeDependencies.Add(libPath);
|
//PublicSystemLibraries.Add("m"); // Math library
|
||||||
}
|
//PublicSystemLibraries.Add("pthread"); // POSIX threads library
|
||||||
// I shall include this if anyone wishes to provide Mac binaries of HarmonyLink but these are not included by default as I don't own one.
|
|
||||||
else if (Target.Platform == UnrealTargetPlatform.Mac)
|
// Add the C++ standard library explicitly if needed
|
||||||
{
|
PublicSystemLibraries.Add("c++");
|
||||||
PublicDefinitions.Add("HARMONYLINKLIB_SHARED=1");
|
|
||||||
PublicDefinitions.Add("BUILD_MACOS=1");
|
// Ensure linking with libc and other necessary libraries
|
||||||
string dynlibPath = Path.Combine(ModuleDirectory, "lib", platformString, "libHarmonyLinkLibStatic.a");
|
//PublicSystemLibraries.Add("dl"); // Dynamic linking loader
|
||||||
//Console.WriteLine("Dynamic Library Path: " + dynlibPath);
|
//PublicSystemLibraries.Add("rt"); // Real-time library
|
||||||
RuntimeDependencies.Add(dynlibPath);
|
|
||||||
}
|
// Add any other libraries that might be needed
|
||||||
|
//PublicSystemLibraries.Add("gcc_s"); // GCC support library
|
||||||
|
//PublicSystemLibraries.Add("gcc"); // GCC compiler support library
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
BIN
Source/ThirdParty/HarmonyLinkLib/bin/Linux/libHarmonyLinkLibShared.so
(Stored with Git LFS)
vendored
BIN
Source/ThirdParty/HarmonyLinkLib/bin/Linux/libHarmonyLinkLibShared.so
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
Source/ThirdParty/HarmonyLinkLib/lib/Linux/libHarmonyLinkLibStatic_clang++.a
(Stored with Git LFS)
vendored
Normal file
BIN
Source/ThirdParty/HarmonyLinkLib/lib/Linux/libHarmonyLinkLibStatic_clang++.a
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
BIN
Source/ThirdParty/HarmonyLinkLib/lib/Win64/HarmonyLinkLibStatic.lib
(Stored with Git LFS)
vendored
BIN
Source/ThirdParty/HarmonyLinkLib/lib/Win64/HarmonyLinkLibStatic.lib
(Stored with Git LFS)
vendored
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue