Updated to use the new plugin
This commit is contained in:
parent
174a73d160
commit
509d6aab73
36 changed files with 788 additions and 753 deletions
|
@ -1,43 +0,0 @@
|
|||
// DataRefreshActor.h
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "HarmonyLinkClient.h"
|
||||
#include "DataRefreshActor.generated.h"
|
||||
|
||||
UCLASS()
|
||||
class HARMONYLINKUE_API ADataRefreshActor : public AActor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
// Sets default values for this actor's properties
|
||||
ADataRefreshActor();
|
||||
|
||||
protected:
|
||||
// Called when the game starts or when spawned
|
||||
virtual void BeginPlay() override;
|
||||
virtual void Destroyed() override;
|
||||
|
||||
FServerStatusCallback ServerStatusCallback;
|
||||
|
||||
// Function to refresh data
|
||||
UFUNCTION()
|
||||
void RefreshData();
|
||||
UFUNCTION()
|
||||
void OnServerStatusChecked(bool connected);
|
||||
|
||||
public:
|
||||
// Called every frame
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
private:
|
||||
// Timer interval for data refreshing (in seconds)
|
||||
UPROPERTY(EditAnywhere, Category = "Data Refresh")
|
||||
float RefreshInterval;
|
||||
|
||||
// Timer handle for data refreshing
|
||||
FTimerHandle RefreshTimerHandle;
|
||||
};
|
|
@ -1,283 +0,0 @@
|
|||
// Copyright Jordon Brooks © 2023
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "Runtime/Online/HTTP/Public/HttpModule.h"
|
||||
#include "Runtime/Online/HTTP/Public/Interfaces/IHttpRequest.h"
|
||||
#include "Engine/World.h"
|
||||
#include "Engine/WorldComposition.h"
|
||||
|
||||
#include "HarmonyLinkClient.generated.h"
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EDockModel : uint8
|
||||
{
|
||||
SteamDeckDock,
|
||||
JSAUX,
|
||||
Unknown,
|
||||
};
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FSDock
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="HarmonyLink")
|
||||
EDockModel Model = EDockModel::Unknown;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="HarmonyLink")
|
||||
FString Name = "";
|
||||
|
||||
void Print() const
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("Dock Model: %s"), *StaticEnum<EDockModel>()->GetNameStringByValue(static_cast<int64>(Model)));
|
||||
UE_LOG(LogTemp, Display, TEXT("Name: %s"), *Name);
|
||||
}
|
||||
};
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FDockInfo
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="HarmonyLink")
|
||||
FSDock DockModel;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="HarmonyLink")
|
||||
bool bIsDocked = false;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="HarmonyLink")
|
||||
bool bFallbackDetection = false;
|
||||
|
||||
void Print() const
|
||||
{
|
||||
DockModel.Print();
|
||||
UE_LOG(LogTemp, Display, TEXT("IsDocked: %s"), bIsDocked ? TEXT("true") : TEXT("false"));
|
||||
UE_LOG(LogTemp, Display, TEXT("FallbackDetection: %s"), bFallbackDetection ? TEXT("true") : TEXT("false"));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FOSInfo
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="HarmonyLink")
|
||||
FString OSType = "Unknown";
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="HarmonyLink")
|
||||
FString OSVersion = "";
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="HarmonyLink")
|
||||
FString OSEdition = "";
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="HarmonyLink")
|
||||
FString OSBits = "X64";
|
||||
|
||||
void Print() const
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("OS Type: %s"), *OSType);
|
||||
UE_LOG(LogTemp, Display, TEXT("OS Version: %s"), *OSVersion);
|
||||
UE_LOG(LogTemp, Display, TEXT("OS Edition: %s"), *OSEdition);
|
||||
UE_LOG(LogTemp, Display, TEXT("OS Bits: %s"), *OSBits);
|
||||
}
|
||||
};
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EChargingStatus : uint8
|
||||
{
|
||||
Charging,
|
||||
Battery,
|
||||
Unknown
|
||||
};
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FBatteryInfo
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="HarmonyLink")
|
||||
bool bHasBattery = false;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="HarmonyLink")
|
||||
int32 BatteryPercent = 0;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="HarmonyLink")
|
||||
EChargingStatus ChargingStatus = EChargingStatus::Unknown;
|
||||
|
||||
void Print() const
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("Has Battery: %s"), bHasBattery ? TEXT("true") : TEXT("false"));
|
||||
UE_LOG(LogTemp, Display, TEXT("Battery Percent: %d"), BatteryPercent);
|
||||
UE_LOG(LogTemp, Display, TEXT("Charging Status: %s"), *StaticEnum<EChargingStatus>()->GetNameStringByValue(static_cast<int64>(ChargingStatus)));
|
||||
}
|
||||
};
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FHarmonyLinkVersionData
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="HarmonyLink")
|
||||
FString BuildTimestamp;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="HarmonyLink")
|
||||
FString GitBranch;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="HarmonyLink")
|
||||
FString GitDescribe;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="HarmonyLink")
|
||||
FString GitCommitTimestamp;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="HarmonyLink")
|
||||
bool bDebug;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="HarmonyLink")
|
||||
FString Version;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="HarmonyLink")
|
||||
int32 VersionMajor;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="HarmonyLink")
|
||||
int32 VersionMinor;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="HarmonyLink")
|
||||
int32 VersionPatch;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="HarmonyLink")
|
||||
FString VersionPre;
|
||||
|
||||
void Print() const
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("Build Timestamp: %s"), *BuildTimestamp);
|
||||
UE_LOG(LogTemp, Display, TEXT("Git Branch: %s"), *GitBranch);
|
||||
UE_LOG(LogTemp, Display, TEXT("Git Describe: %s"), *GitDescribe);
|
||||
UE_LOG(LogTemp, Display, TEXT("Git Commit Timestamp: %s"), *GitCommitTimestamp);
|
||||
UE_LOG(LogTemp, Display, TEXT("Debug: %s"), bDebug ? TEXT("true") : TEXT("false"));
|
||||
UE_LOG(LogTemp, Display, TEXT("Version: %s"), *Version);
|
||||
UE_LOG(LogTemp, Display, TEXT("Version Major: %d"), VersionMajor);
|
||||
UE_LOG(LogTemp, Display, TEXT("Version Minor: %d"), VersionMinor);
|
||||
UE_LOG(LogTemp, Display, TEXT("Version Patch: %d"), VersionPatch);
|
||||
UE_LOG(LogTemp, Display, TEXT("Version Pre: %s"), *VersionPre);
|
||||
}
|
||||
};
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FAllInfo
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="HarmonyLink")
|
||||
FOSInfo OSInfo;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="HarmonyLink")
|
||||
FDockInfo DockInfo;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="HarmonyLink")
|
||||
FBatteryInfo BatteryInfo;
|
||||
|
||||
void Print() const
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("All Info:"));
|
||||
OSInfo.Print();
|
||||
DockInfo.Print();
|
||||
BatteryInfo.Print();
|
||||
}
|
||||
};
|
||||
|
||||
DECLARE_DYNAMIC_DELEGATE_OneParam(FDeviceInfoCallback, const FAllInfo&, DeviceInfo);
|
||||
DECLARE_DYNAMIC_DELEGATE_OneParam(FOSInfoCallback, const FOSInfo&, OSInfo);
|
||||
DECLARE_DYNAMIC_DELEGATE_OneParam(FBatteryInfoCallback, const FBatteryInfo&, BatteryInfo);
|
||||
DECLARE_DYNAMIC_DELEGATE_OneParam(FVersionInfoCallback, const FHarmonyLinkVersionData&, VersionInfo);
|
||||
DECLARE_DYNAMIC_DELEGATE_OneParam(FServerStatusCallback, const bool, connected);
|
||||
|
||||
|
||||
/*
|
||||
* Function library class.
|
||||
* Each function in it is expected to be static and represents blueprint node that can be called in any blueprint.
|
||||
*
|
||||
* When declaring function you can define metadata for the node. Key function specifiers will be BlueprintPure and BlueprintCallable.
|
||||
* BlueprintPure - means the function does not affect the owning object in any way and thus creates a node without Exec pins.
|
||||
* BlueprintCallable - makes a function which can be executed in Blueprints - Thus it has Exec pins.
|
||||
* DisplayName - full name of the node, shown when you mouse over the node and in the blueprint drop down menu.
|
||||
* Its lets you name the node using characters not allowed in C++ function names.
|
||||
* CompactNodeTitle - the word(s) that appear on the node.
|
||||
* Keywords - the list of keywords that helps you to find node when you search for it using Blueprint drop-down menu.
|
||||
* Good example is "Print String" node which you can find also by using keyword "log".
|
||||
* Category - the category your node will be under in the Blueprint drop-down menu.
|
||||
*
|
||||
* For more info on custom blueprint nodes visit documentation:
|
||||
* https://wiki.unrealengine.com/Custom_Blueprint_Node_Creation
|
||||
*/
|
||||
UCLASS()
|
||||
class HARMONYLINKUE_API UHarmonyLinkClient : public UBlueprintFunctionLibrary
|
||||
{
|
||||
GENERATED_UCLASS_BODY()
|
||||
|
||||
static bool Connected;
|
||||
|
||||
// Cached DeviceInfo variable
|
||||
static FAllInfo CachedAllInfo;
|
||||
|
||||
// Cached DeviceInfo variable
|
||||
static FHarmonyLinkVersionData CachedVersionData;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Harmony Link")
|
||||
static bool GetIsConnected()
|
||||
{ return Connected; }
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Harmony Link")
|
||||
static void PrintAllInfo()
|
||||
{ CachedAllInfo.Print(); }
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Harmony Link")
|
||||
static FAllInfo GetAllInfo()
|
||||
{ return CachedAllInfo; }
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Harmony Link")
|
||||
static FBatteryInfo GetBatteryInfo()
|
||||
{ return CachedAllInfo.BatteryInfo; }
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Harmony Link")
|
||||
static FDockInfo GetDockInfo()
|
||||
{ return CachedAllInfo.DockInfo; }
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Harmony Link")
|
||||
static FOSInfo GetOSInfo()
|
||||
{ return CachedAllInfo.OSInfo; }
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Harmony Link")
|
||||
static FHarmonyLinkVersionData GetVersionInfo()
|
||||
{ return CachedVersionData; }
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Harmony Link")
|
||||
static void CheckServerStatus(FServerStatusCallback Callback);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Harmony Link")
|
||||
static void RefreshOSInfo(FOSInfoCallback Callback);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Harmony Link")
|
||||
static void RefreshBatteryInfo(FBatteryInfoCallback Callback);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Harmony Link")
|
||||
static void RefreshAllInfo(FDeviceInfoCallback Callback);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Harmony Link")
|
||||
static void RefreshVersionInfo(FVersionInfoCallback Callback);
|
||||
|
||||
private:
|
||||
static void OnCheckServerStatusResponseReceived(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful, FServerStatusCallback Callback);
|
||||
static void OnOSInfoResponseReceived(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful, FOSInfoCallback Callback);
|
||||
static void OnBatteryInfoResponseReceived(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful, FBatteryInfoCallback Callback);
|
||||
static void OnDeviceInfoResponseReceived(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful, FDeviceInfoCallback Callback);
|
||||
static void OnVersionInfoResponseReceived(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful, FVersionInfoCallback Callback);
|
||||
};
|
|
@ -1,14 +0,0 @@
|
|||
// Copyright Jordon Brooks © 2023
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
class FHarmonyLinkUEModule : public IModuleInterface
|
||||
{
|
||||
public:
|
||||
|
||||
/** IModuleInterface implementation */
|
||||
virtual void StartupModule() override;
|
||||
virtual void ShutdownModule() override;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue