Updated to use the new plugin

This commit is contained in:
Jordon Brooks 2024-01-07 23:46:48 +00:00
parent 174a73d160
commit 509d6aab73
No known key found for this signature in database
GPG key ID: 83964894E5D98D57
36 changed files with 788 additions and 753 deletions

View file

@ -0,0 +1,59 @@
// Copyright Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
using System.IO;
public class HarmonyLink : ModuleRules
{
public HarmonyLink(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
PublicIncludePaths.AddRange(
new string[] {
// ... add public include paths required here ...
}
);
PrivateIncludePaths.AddRange(
new string[] {
// ... add other private include paths required here ...
"ThirdParty/HarmonyLinkLib/include"
}
);
PublicDependencyModuleNames.AddRange(
new string[]
{
"Core",
"CoreUObject",
"Engine",
"Projects"
// ... add other public dependencies that you statically link with here ...
}
);
PrivateDependencyModuleNames.AddRange(
new string[]
{
// ... add private dependencies that you statically link with here ...
}
);
DynamicallyLoadedModuleNames.AddRange(
new string[]
{
// ... add any modules that your module loads dynamically here ...
}
);
PublicAdditionalLibraries.Add(Path.Combine(PluginDirectory, "Source/ThirdParty/HarmonyLinkLib/bin/Win64/HarmonyLinkLib.lib"));
RuntimeDependencies.Add("$(BinaryOutputDir)/HarmonyLinkLib.dll", Path.Combine(PluginDirectory, "Source/ThirdParty/HarmonyLinkLib/bin/Win64/HarmonyLinkLib.dll"));
}
}

View file

@ -0,0 +1,18 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#include "HarmonyLink.h"
#include "Modules/ModuleManager.h"
#define LOCTEXT_NAMESPACE "FHarmonyLinkModule"
void FHarmonyLinkModule::StartupModule()
{
}
void FHarmonyLinkModule::ShutdownModule()
{
}
#undef LOCTEXT_NAMESPACE
IMPLEMENT_MODULE(FHarmonyLinkModule, HarmonyLink)

View file

@ -0,0 +1,53 @@
// Copyright (C) 2023 Jordon Brooks
#include "HarmonyLinkLibrary.h"
#include <HarmonyLinkLib.h>
bool UHarmonyLinkLibrary::IsWine()
{
static bool IsWine_ = HarmonyLinkLib::get_is_wine();
return IsWine_;
}
bool UHarmonyLinkLibrary::IsLinux()
{
static bool IsLinux_ =
#if PLATFORM_WINDOWS
IsWine();
#elif PLATFORM_LINUX
true;
#else
false;
#endif
return IsLinux_;
}
bool UHarmonyLinkLibrary::IsSteamDeck()
{
static bool IsSteamDeck_ = GetDeviceInfo().Device == EDevice::STEAM_DECK;
return IsSteamDeck_;
}
FCPUInfo UHarmonyLinkLibrary::GetCPUInfo()
{
static FCPUInfo CPUInfo(HarmonyLinkLib::get_cpu_info());
return CPUInfo;
}
FDevice UHarmonyLinkLibrary::GetDeviceInfo()
{
return FDevice();
}
FOSVerInfo UHarmonyLinkLibrary::GetOSInfo()
{
return FOSVerInfo();
}
FBattery UHarmonyLinkLibrary::GetBatteryStatus()
{
return FBattery(HarmonyLinkLib::get_battery_status());
}

View file

@ -0,0 +1,21 @@
// Copyright (C) 2023 Jordon Brooks
#include "Structs/Battery.h"
#include <Structs/FBattery.h>
FBattery::FBattery(HarmonyLinkLib::FBattery* battery)
{
if (battery)
{
HasBattery = battery->has_battery;
IsACConnected = battery->is_connected_to_ac;
BatteryPercent = battery->battery_percent;
battery->free();
}
else
{
UE_LOG(LogTemp, Error, TEXT("Failed to convert FBattery."))
}
}

View file

@ -0,0 +1,25 @@
// Copyright (C) 2023 Jordon Brooks
#include "Structs/CPUInfo.h"
FCPUInfo::FCPUInfo(HarmonyLinkLib::FCPUInfo* cpu_info)
{
if (cpu_info)
{
VendorID = cpu_info->VendorID.c_str();
ModelName = cpu_info->Model_Name.c_str();
PhysicalCores = cpu_info->Physical_Cores;
LogicalCores = cpu_info->Logical_Cores;
for (const HarmonyLinkLib::FString& Flag : cpu_info->Flags)
{
Flags.Add(Flag.c_str());
}
cpu_info->free();
}
else
{
UE_LOG(LogTemp, Error, TEXT("Failed to convert FCPUInfo."))
}
}

View file

@ -0,0 +1,17 @@
#pragma once
#include "CoreMinimal.h"
#include "Device.generated.h"
/**
*
*/
UENUM(BlueprintType)
enum class EDevice : uint8
{
DESKTOP UMETA(DisplayName = "Desktop"),
LAPTOP UMETA(DisplayName = "Laptop"),
HANDHELD UMETA(DisplayName = "Handheld"),
STEAM_DECK UMETA(DisplayName = "Steam Deck")
};

View file

@ -0,0 +1,16 @@
#pragma once
#include "CoreMinimal.h"
#include "Platform.generated.h"
/**
*
*/
UENUM(BlueprintType)
enum class EPlatform : uint8
{
WINDOWS UMETA(DisplayName = "Windows"),
LINUX UMETA(DisplayName = "Linux"),
MAC UMETA(DisplayName = "Mac"),
UNIX UMETA(DisplayName = "Unix")
};

View file

@ -0,0 +1,14 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Modules/ModuleManager.h"
class FHarmonyLinkModule : public IModuleInterface
{
public:
/** IModuleInterface implementation */
virtual void StartupModule() override;
virtual void ShutdownModule() override;
};

View file

@ -0,0 +1,41 @@
// Copyright (C) 2023 Jordon Brooks
#pragma once
#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "Structs/Battery.h"
#include "Structs/CPUInfo.h"
#include "Structs/FDevice.h"
#include "Structs/OSVerInfo.h"
#include "HarmonyLinkLibrary.generated.h"
/**
*
*/
UCLASS()
class HARMONYLINK_API UHarmonyLinkLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
UFUNCTION(BlueprintCallable, Category="HarmonyLink")
static bool IsWine();
UFUNCTION(BlueprintCallable, Category="HarmonyLink")
static bool IsLinux();
UFUNCTION(BlueprintCallable, Category="HarmonyLink")
static bool IsSteamDeck();
UFUNCTION(BlueprintCallable, Category="HarmonyLink")
static FCPUInfo GetCPUInfo();
UFUNCTION(BlueprintCallable, Category="HarmonyLink")
static FDevice GetDeviceInfo();
UFUNCTION(BlueprintCallable, Category="HarmonyLink")
static FOSVerInfo GetOSInfo();
UFUNCTION(BlueprintCallable, Category="HarmonyLink")
static FBattery GetBatteryStatus();
};

View file

@ -0,0 +1,29 @@
// Copyright (C) 2023 Jordon Brooks
#pragma once
#include <HarmonyLinkLib.h>
#include "CoreMinimal.h"
#include "Battery.generated.h"
/**
*
*/
USTRUCT(BlueprintType)
struct FBattery
{
GENERATED_BODY()
FBattery() {}
UPROPERTY(BlueprintReadWrite, EditAnywhere)
bool HasBattery = false;
UPROPERTY(BlueprintReadWrite, EditAnywhere)
bool IsACConnected = false;
UPROPERTY(BlueprintReadWrite, EditAnywhere)
int32 BatteryPercent = 0;
FBattery(HarmonyLinkLib::FBattery* battery);
};

View file

@ -0,0 +1,36 @@
// Copyright (C) 2023 Jordon Brooks
#pragma once
#include <HarmonyLinkLib.h>
#include "CoreMinimal.h"
#include "CPUInfo.generated.h"
/**
*
*/
USTRUCT(BlueprintType)
struct FCPUInfo
{
GENERATED_BODY()
FCPUInfo() {}
UPROPERTY(BlueprintReadWrite, EditAnywhere)
FString VendorID;
UPROPERTY(BlueprintReadWrite, EditAnywhere)
FString ModelName;
UPROPERTY(BlueprintReadWrite, EditAnywhere)
int32 PhysicalCores = 0;
UPROPERTY(BlueprintReadWrite, EditAnywhere)
int32 LogicalCores = 0;
UPROPERTY(BlueprintReadWrite, EditAnywhere)
TSet<FString> Flags;
FCPUInfo(HarmonyLinkLib::FCPUInfo* cpu_info);
};

View file

@ -0,0 +1,22 @@
#pragma once
#include "CoreMinimal.h"
#include "Enums/Device.h"
#include "Enums/Platform.h"
#include "FDevice.generated.h"
/**
*
*/
USTRUCT(BlueprintType)
struct FDevice
{
GENERATED_BODY()
UPROPERTY(BlueprintReadWrite, EditAnywhere)
EPlatform Platform = EPlatform::WINDOWS;
UPROPERTY(BlueprintReadWrite, EditAnywhere)
EDevice Device = EDevice::DESKTOP;
};

View file

@ -0,0 +1,36 @@
// Copyright (C) 2023 Jordon Brooks
#pragma once
#include "CoreMinimal.h"
#include "OSVerInfo.generated.h"
/**
*
*/
USTRUCT(BlueprintType)
struct FOSVerInfo
{
GENERATED_BODY()
UPROPERTY(BlueprintReadWrite, EditAnywhere)
FString Name;
UPROPERTY(BlueprintReadWrite, EditAnywhere)
int32 Version = 0;
UPROPERTY(BlueprintReadWrite, EditAnywhere)
FString ID;
UPROPERTY(BlueprintReadWrite, EditAnywhere)
FString VersionID;
UPROPERTY(BlueprintReadWrite, EditAnywhere)
FString VersionCodename;
UPROPERTY(BlueprintReadWrite, EditAnywhere)
FString PrettyName;
UPROPERTY(BlueprintReadWrite, EditAnywhere)
FString VariantID;
};