Successfully compiled and working on Win32 + tested on steam deck
This commit is contained in:
parent
47008fcefe
commit
e5cca6b23f
19 changed files with 311 additions and 186 deletions
|
@ -9,7 +9,7 @@
|
|||
* Enum representing different operating system platforms.
|
||||
*/
|
||||
UENUM(BlueprintType)
|
||||
enum class EDeviceEnum : uint8
|
||||
enum class EDevice : uint8
|
||||
{
|
||||
DESKTOP UMETA(DisplayName = "Desktop"),
|
||||
LAPTOP UMETA(DisplayName = "Laptop"),
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
UENUM(BlueprintType)
|
||||
enum class EProfile : uint8
|
||||
{
|
||||
NONE UMETA(DisplayName = "NONE"),
|
||||
NONE = 0 UMETA(DisplayName = "NONE"),
|
||||
BATTERY UMETA(DisplayName = "BATTERY"),
|
||||
CHARGING UMETA(DisplayName = "CHARGING"),
|
||||
DOCKED UMETA(DisplayName = "DOCKED"),
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
DECLARE_LOG_CATEGORY_EXTERN(LogHarmonyLink, Log, All);
|
||||
DECLARE_LOG_CATEGORY_EXTERN(LogHarmonyLink, All, All);
|
||||
|
||||
class FHarmonyLinkModule : public IModuleInterface
|
||||
{
|
||||
|
|
|
@ -21,31 +21,33 @@ class HARMONYLINK_API UHarmonyLinkLibrary : public UBlueprintFunctionLibrary
|
|||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UHarmonyLinkLibrary();
|
||||
|
||||
// Checks if the game is running under Wine.
|
||||
UFUNCTION(BlueprintCallable, Category="HarmonyLink")
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="HarmonyLink")
|
||||
static bool IsWine();
|
||||
|
||||
// Checks if the operating system is Linux.
|
||||
UFUNCTION(BlueprintCallable, Category="HarmonyLink")
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="HarmonyLink")
|
||||
static bool IsLinux();
|
||||
|
||||
// Checks if the game is running on a Steam Deck.
|
||||
UFUNCTION(BlueprintCallable, Category="HarmonyLink")
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="HarmonyLink")
|
||||
static bool IsSteamDeck();
|
||||
|
||||
// Retrieves information about the CPU of the current device.
|
||||
UFUNCTION(BlueprintCallable, Category="HarmonyLink")
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="HarmonyLink")
|
||||
static FCPUInfo GetCPUInfo();
|
||||
|
||||
// Retrieves information about the current device.
|
||||
UFUNCTION(BlueprintCallable, Category="HarmonyLink")
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="HarmonyLink")
|
||||
static FDevice GetDeviceInfo();
|
||||
|
||||
// Retrieves information about the operating system of the current device.
|
||||
UFUNCTION(BlueprintCallable, Category="HarmonyLink")
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="HarmonyLink")
|
||||
static FOSVerInfo GetOSInfo();
|
||||
|
||||
// Retrieves the current battery status of the device.
|
||||
UFUNCTION(BlueprintCallable, Category="HarmonyLink")
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="HarmonyLink")
|
||||
static FBattery GetBatteryStatus();
|
||||
};
|
||||
|
|
|
@ -120,7 +120,7 @@ public:
|
|||
* - Calls the `Init` function on the new instance to perform any necessary initialization.
|
||||
* - Returns the singleton instance.
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category="HarmonyLink Settings")
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="HarmonyLink Settings")
|
||||
static UHarmonyLinkGraphics* GetSettings();
|
||||
|
||||
/**
|
||||
|
@ -141,7 +141,7 @@ public:
|
|||
*
|
||||
* @note Uses UE_LOG for logging errors.
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="HarmonyLink Settings")
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, BlueprintPure, Category="HarmonyLink Settings")
|
||||
FSettingsProfile GetSettingProfile(const EProfile Profile);
|
||||
|
||||
/**
|
||||
|
@ -245,7 +245,7 @@ private:
|
|||
*
|
||||
* @note Uses UE_LOG for logging the creation process.
|
||||
*/
|
||||
void CreateDefaultConfigFile();
|
||||
void CreateDefaultConfigFile() const;
|
||||
|
||||
/**
|
||||
* @brief Retrieves the path to the configuration file.
|
||||
|
@ -278,7 +278,7 @@ private:
|
|||
*
|
||||
* @note Uses UE_LOG for logging errors and success messages.
|
||||
*/
|
||||
bool LoadSettingsFromConfig(const bool bLoadDefaults);
|
||||
bool LoadSettingsFromConfig(FConfigFile* ConfigFile) const;
|
||||
|
||||
/**
|
||||
* @brief Loads a specific section from the configuration file into a settings profile.
|
||||
|
@ -298,7 +298,7 @@ private:
|
|||
*
|
||||
* @note The function handles settings of types int, float, bool, and string.
|
||||
*/
|
||||
bool LoadSection(const FConfigFile& ConfigFile, const TPair<EProfile, FName> Profile);
|
||||
static bool LoadSection(FConfigFile* ConfigFile, const TPair<EProfile, FName> Profile);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -322,7 +322,7 @@ private:
|
|||
*
|
||||
* @note Uses UE_LOG for logging the save and flush operations.
|
||||
*/
|
||||
static void SaveSection(const FSettingsProfile& SettingsProfile, const bool bDefaultConfig, const bool bFlush = false);
|
||||
void SaveSection(const FSettingsProfile& SettingsProfile, const bool bDefaultConfig, const bool bFlush = false) const;
|
||||
|
||||
/**
|
||||
* @brief Loads the default settings into the profiles.
|
||||
|
@ -340,7 +340,7 @@ private:
|
|||
*
|
||||
* @note Uses UE_LOG for logging the start of the default settings loading process.
|
||||
*/
|
||||
void LoadDefaults();
|
||||
void LoadDefaults() const;
|
||||
|
||||
/**
|
||||
* @brief Applies the specified graphics profile internally.
|
||||
|
@ -451,6 +451,8 @@ private:
|
|||
*/
|
||||
void DebugPrintProfiles() const;
|
||||
|
||||
FConfigFile* GetConfig() const;
|
||||
|
||||
/**
|
||||
* @brief Prints debug information for a specific settings profile.
|
||||
*
|
||||
|
@ -468,10 +470,10 @@ private:
|
|||
static void PrintDebugSection(FSettingsProfile& SettingsProfile);
|
||||
|
||||
// Indicates whether automatic profile switching is enabled.
|
||||
bool _bAutomaticSwitch = false;
|
||||
static bool _bAutomaticSwitch;
|
||||
|
||||
// Stores the last recorded battery percentage.
|
||||
int32 _LastBatteryPercentage = 0;
|
||||
static int32 _LastBatteryPercentage;
|
||||
|
||||
// The rate at which to query HarmonyLinkLib for hardware info.
|
||||
static int32 _TickRate;
|
||||
|
@ -480,17 +482,15 @@ private:
|
|||
static FTimerHandle _TickTimerHandle;
|
||||
|
||||
// The currently active profile.
|
||||
EProfile _ActiveProfile = EProfile::NONE;
|
||||
static EProfile _ActiveProfile;
|
||||
|
||||
// Maps profile enums to their corresponding names.
|
||||
TMap<EProfile, FName> _ProfileNames = {
|
||||
{EProfile::BATTERY, "Battery"},
|
||||
{EProfile::CHARGING, "Charging"},
|
||||
{EProfile::DOCKED, "Docked"},
|
||||
};
|
||||
static TMap<EProfile, FName> _ProfileNames;
|
||||
|
||||
// Stores the settings profiles.
|
||||
TMap<EProfile, FSettingsProfile> _Profiles;
|
||||
static TMap<EProfile, FSettingsProfile> _Profiles;
|
||||
|
||||
static TSharedPtr<FConfigFile> _ConfigFile;
|
||||
|
||||
// The default settings for profiles.
|
||||
static TMap<FName, TMap<FName, FHLConfigValue>> _DefaultSettings;
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
// Copyright (C) 2024 Jordon Brooks
|
||||
#pragma once
|
||||
|
||||
#include <HarmonyLinkLib.h>
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
|
||||
#include "Structs/FBattery.h"
|
||||
|
||||
#include "Battery.generated.h"
|
||||
|
||||
/*
|
||||
|
|
|
@ -2,9 +2,10 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <HarmonyLinkLib.h>
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
|
||||
#include "Structs/FCPUInfo.h"
|
||||
|
||||
#include "CPUInfo.generated.h"
|
||||
|
||||
/*
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
#include "CoreMinimal.h"
|
||||
#include "Enums/DeviceEnum.h"
|
||||
#include "Enums/Platform.h"
|
||||
#include <Structs/FDevice.h>
|
||||
|
||||
#include "Structs/FDevice.h"
|
||||
|
||||
#include "Device.generated.h"
|
||||
|
||||
|
@ -25,7 +26,7 @@ struct FDevice
|
|||
|
||||
// The type of the device.
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="HarmonyLink")
|
||||
EDeviceEnum Device = EDeviceEnum::DESKTOP;
|
||||
EDevice Device = EDevice::DESKTOP;
|
||||
|
||||
// Constructor that initializes the struct with information from an external source.
|
||||
// @param oldDevice Pointer to an external FDevice structure to copy data from.
|
||||
|
@ -35,7 +36,7 @@ private:
|
|||
// Converts an external device enum to the internal EDeviceEnum type.
|
||||
// @param Device External device enum to convert.
|
||||
// @returns Converted EDeviceEnum value.
|
||||
static EDeviceEnum Convert(HarmonyLinkLib::EDevice Device);
|
||||
static EDevice Convert(HarmonyLinkLib::EDevice Device);
|
||||
|
||||
// Converts an external platform enum to the internal EPlatform type.
|
||||
// @param Platform External platform enum to convert.
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include <HarmonyLinkLib.h>
|
||||
|
||||
#include "Structs/FOSVerInfo.h"
|
||||
|
||||
#include "OSVerInfo.generated.h"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue