bump the senseglove unreal engine plugin to v2.6.0

This commit is contained in:
Mamadou Babaei
2025-06-04 04:21:52 +02:00
parent a35f8e2cef
commit d0f86efc53
182 changed files with 777 additions and 821 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
{
"FileVersion": 3,
"Version": 1,
"VersionName": "2.4.2",
"VersionName": "2.6.0",
"FriendlyName": "SenseGlove",
"Description": "Integrating the SenseGlove haptic controller into Unreal Engine",
"Category": "Virtual Reality",
@@ -35,6 +35,7 @@
#include "SenseGlove/Animation/SGVirtualHandAnimInstanceProxy.h"
#include "Animation/AnimInstance.h"
#include "Animation/Skeleton.h"
#include "BoneContainer.h"
#include "BoneControllers/AnimNode_ModifyBone.h"
@@ -137,7 +137,7 @@ void USGAndroidPermissions::OnPermissionsGranted(const TArray<FString>& Permissi
return;
}
for (int32 i = 0; i < Permissions.Num(); i++)
for (int32 i = 0; i < Permissions.Num(); ++i)
{
if (GrantResults[i])
{
@@ -54,7 +54,7 @@
int32 FSGConnectJNI::Initialize()
{
int32 Result = -999999;
int32 Result = -1000;
#if PLATFORM_ANDROID
static constexpr char SGCONNECT_JAVA_CLASS_NAME[] = "com.senseglove.sgconnect.SGConnect";
@@ -66,7 +66,7 @@ int32 FSGConnectJNI::Initialize()
if (!Env)
{
SGLOG_ERROR("FSGCoreJNI: failed to get the Android JNI environmnet!");
return -1999999;
return -1001;
}
FSGIC_JNIEnv_Ptr InEnvContainer{Env};
@@ -77,7 +77,7 @@ int32 FSGConnectJNI::Initialize()
if (Env->IsSameObject(Class, nullptr))
{
SGLOG_ERROR("FSGCoreJNI: failed to get the Android Java class!");
return -2999999;
return -1002;
}
Class = (jclass)Env->NewGlobalRef(Class);
FSGIC_jclass InClassContainer{Class};
@@ -89,7 +89,7 @@ int32 FSGConnectJNI::Initialize()
if (!InitMethodID)
{
SGLOG_ERROR("FSGCoreJNI: failed to get the Android JNI method 'Init'!");
return -3999999;
return -1003;
}
FSGIC_jmethodID InInitMethodIDContainer{InitMethodID};
@@ -100,7 +100,7 @@ int32 FSGConnectJNI::Initialize()
if (!DisposeMethodID)
{
SGLOG_ERROR("FSGCoreJNI: failed to get the Android JNI method 'Dispose'!");
return -4999999;
return -1004;
}
FSGIC_jmethodID InDisposeMethodIDContainer{DisposeMethodID};
@@ -111,7 +111,7 @@ int32 FSGConnectJNI::Initialize()
if (!GetLibraryVersionMethodID)
{
SGLOG_ERROR("FSGCoreJNI: failed to get the Android JNI method 'GetLibraryVersion'!");
return -5999999;
return -1005;
}
FSGIC_jmethodID InGetLibraryVersionMethodIDContainer{GetLibraryVersionMethodID};
@@ -54,7 +54,7 @@
int32 FSGCoreJNI::Initialize()
{
int32 Result = -999999;
int32 Result = -1000;
#if PLATFORM_ANDROID
static constexpr char SGCONNECT_JAVA_CLASS_NAME[] = "com.senseglove.sgconnect.SGConnect";
@@ -66,7 +66,7 @@ int32 FSGCoreJNI::Initialize()
if (!Env)
{
SGLOG_ERROR("FSGCoreJNI: failed to get the Android JNI environmnet!");
return -1999999;
return -1001;
}
FSGIC_JNIEnv_Ptr InEnvContainer{Env};
@@ -77,7 +77,7 @@ int32 FSGCoreJNI::Initialize()
if (Env->IsSameObject(Class, nullptr))
{
SGLOG_ERROR("FSGCoreJNI: failed to get the Android Java class!");
return -2999999;
return -1002;
}
Class = (jclass)Env->NewGlobalRef(Class);
FSGIC_jclass InClassContainer{Class};
@@ -89,7 +89,7 @@ int32 FSGCoreJNI::Initialize()
if (!ActiveDevicesMethodID)
{
SGLOG_ERROR("FSGCoreJNI: failed to get the Android JNI method 'ActiveDevices'!");
return -3999999;
return -1003;
}
FSGIC_jmethodID InActiveDevicesMethodIDContainer{ActiveDevicesMethodID};
@@ -100,7 +100,7 @@ int32 FSGCoreJNI::Initialize()
if (!GetDeviceStringMethodID)
{
SGLOG_ERROR("FSGCoreJNI: failed to get the Android JNI method 'GetDeviceString'!");
return -4999999;
return -1004;
}
FSGIC_jmethodID InGetDeviceStringMethodIDContainer{GetDeviceStringMethodID};
@@ -111,7 +111,7 @@ int32 FSGCoreJNI::Initialize()
if (!GetSensorStringMethodID)
{
SGLOG_ERROR("FSGCoreJNI: failed to get the Android JNI method 'GetSensorString'!");
return -5999999;
return -1005;
}
FSGIC_jmethodID InGetSensorStringMethodIDContainer{GetSensorStringMethodID};
@@ -122,7 +122,7 @@ int32 FSGCoreJNI::Initialize()
if (!WriteHapticsMethodID)
{
SGLOG_ERROR("FSGCoreJNI: failed to get the Android JNI method 'WriteHaptics'!");
return -6999999;
return -1006;
}
FSGIC_jmethodID InWriteHapticsMethodIDContainer{WriteHapticsMethodID};
@@ -36,6 +36,7 @@
#include "SGBackend/SGBackend.h"
#include "Engine/Engine.h"
#include "Templates/Atomic.h"
#if PLATFORM_ANDROID
#include "SGConnect/SGConnect.h"
@@ -47,6 +48,12 @@
struct USGBackend::FImpl
{
/************************
* Member variables
************************/
TAtomic<bool> bInitialized;
/************************
* Owner object
************************/
@@ -64,8 +71,8 @@ struct USGBackend::FImpl
* Default copy constructor & copy assignment operator
************************/
FImpl(const FImpl& Rhs) = default;
FImpl& operator=(const FImpl& Rhs) = default;
FImpl(const FImpl& Rhs) = delete;
FImpl& operator=(const FImpl& Rhs) = delete;
};
USGBackend* USGBackend::GetInstance()
@@ -82,7 +89,11 @@ USGBackend* USGBackend::GetInstance()
USGBackend::USGBackend()
: Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}, PimplDeleter))
{
bBackendInitialized = false;
}
bool USGBackend::IsBackendInitialized() const
{
return Pimpl->bInitialized;
}
bool USGBackend::InitializeBackend()
@@ -93,6 +104,18 @@ bool USGBackend::InitializeBackend()
const int32 Result = FSGConnect::Init();
switch (Result)
{
case -103:
SGLOG_ERROR("Android JNI-specific Error: Invalid Java method ID!");
return false;
case -102:
SGLOG_ERROR("Android JNI-specific Error: Invalid Java class!");
return false;
case -101:
SGLOG_ERROR("Android JNI-specific Error: Invalid Java environment!");
return false;
case -100:
SGLOG_ERROR("Android JNI-specific Error: Generic Error! Note: you should never see this!");
return false;
case -3:
SGLOG_ERROR("An Unexpected error occurred. Please try again.");
return false;
@@ -118,7 +141,7 @@ bool USGBackend::InitializeBackend()
FSGDeviceList::Dispose();
FSGDeviceList::Reinitialize();
bBackendInitialized = true;
Pimpl->bInitialized = true;
return true;
}
@@ -136,6 +159,18 @@ bool USGBackend::UninitializeBackend()
const int32 Result = FSGConnect::Dispose();
switch (Result)
{
case -103:
SGLOG_ERROR("Android JNI-specific Error: Invalid Java method ID!");
return false;
case -102:
SGLOG_ERROR("Android JNI-specific Error: Invalid Java class!");
return false;
case -101:
SGLOG_ERROR("Android JNI-specific Error: Invalid Java environment!");
return false;
case -100:
SGLOG_ERROR("Android JNI-specific Error: Generic Error! Note: you should never see this!");
return false;
case -3:
SGLOG_ERROR("An Unexpected error occurred. Please try again.");
return false;
@@ -157,7 +192,7 @@ bool USGBackend::UninitializeBackend()
}
#endif /* PLATFORM_ANDROID */
bBackendInitialized = false;
Pimpl->bInitialized = false;
return true;
}
@@ -205,13 +240,14 @@ void USGBackend::Deinitialize()
SGLOG_ERROR("Failed to uninitialize the bridge to the SenseGlove Backend!")
}
(void)Pimpl.Release();
(void) Pimpl.Release();
SGLOG("The SenseGlove Backend singleton has been successfully de-initialized!");
}
USGBackend::FImpl::FImpl(USGBackend* InOwner)
: Owner(InOwner)
: bInitialized(false),
Owner(InOwner)
{
}
@@ -49,10 +49,6 @@ class SENSEGLOVEBACKEND_API USGBackend : public UEngineSubsystem
{
GENERATED_BODY()
private:
UPROPERTY(Transient)
bool bBackendInitialized;
public:
static USGBackend* GetInstance();
@@ -71,10 +67,7 @@ private:
USGBackend();
public:
FORCEINLINE bool IsBackendInitialized() const
{
return bBackendInitialized;
}
bool IsBackendInitialized() const;
bool InitializeBackend();
bool UninitializeBackend();
@@ -34,7 +34,6 @@
using System;
using System.IO;
using UnrealBuildTool;
public class SenseGloveBuildHacks : ModuleRules
@@ -55,23 +54,18 @@ public class SenseGloveBuildHacks : ModuleRules
}
);
PublicDependencyModuleNames.AddRange(
new string[]
{
"SGConnectThirdPartyHeaders",
}
);
PrivateDependencyModuleNames.AddRange(
new string[]
{
"SenseGloveLog",
}
);
AddConnectHeaders();
}
private void AddConnectHeaders()
{
string PluginRootDirectory = Path.GetFullPath(Path.Combine(ModuleDirectory, "..", ".."));
string SourceDirectory = Path.GetFullPath(Path.Combine(PluginRootDirectory, "Source"));
string ThirdPartyDirectory = Path.GetFullPath(Path.Combine(SourceDirectory, "ThirdParty"));
string IncludePath = Path.GetFullPath(Path.Combine(ThirdPartyDirectory, "include"));
PrivateIncludePaths.Add(IncludePath);
}
}
@@ -34,9 +34,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using UnrealBuildTool;
public class SenseGloveConnectImpl : ModuleRules
@@ -57,6 +54,15 @@ public class SenseGloveConnectImpl : ModuleRules
}
);
PrivateDependencyModuleNames.AddRange(
new string[]
{
"SGBleThirdPartyLibs",
"SGConnectThirdPartyLibs",
"SGSerialThirdPartyLibs",
}
);
PrivateDependencyModuleNames.AddRange(
new string[]
{
@@ -74,258 +80,7 @@ public class SenseGloveConnectImpl : ModuleRules
}
);
AddConnectLibrary(Target);
AddSerialLibrary(Target);
PublicDefinitions.Add("SENSEGLOVE_BUILDING_CONNECT_IMPL_MODULE");
PublicDefinitions.Add("SENSEGLOVE_UNREAL_ENGINE_PLUGIN");
}
private void AddConnectLibrary(ReadOnlyTargetRules Target)
{
string PluginRootDirectory = Path.GetFullPath(Path.Combine(ModuleDirectory, "..", ".."));
string SourceDirectory = Path.GetFullPath(Path.Combine(PluginRootDirectory, "Source"));
string ThirdPartyDirectory = Path.GetFullPath(Path.Combine(SourceDirectory, "ThirdParty"));
string LibraryPath = Path.GetFullPath(Path.Combine(ThirdPartyDirectory, "lib"));
string LibraryPathAnroidArm64 = "";
string LibraryPathAnroidx64 = "";
string LibraryName = "sgconnect";
bool bIsAndroid = Target.IsInPlatformGroup(UnrealPlatformGroup.Android);
bool bIsLinux = Target.Platform == UnrealTargetPlatform.Linux;
bool bIsLinuxArm64 = Target.Platform == UnrealTargetPlatform.LinuxArm64;
bool bIsWin64 = Target.IsInPlatformGroup(UnrealPlatformGroup.Windows) &&
Target.WindowsPlatform.Architecture == UnrealArch.X64;
bool bIsDebugBuild = (Target.Configuration == UnrealTargetConfiguration.Debug);
if (bIsAndroid)
{
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "android"));
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "r25b"));
LibraryPathAnroidArm64 = Path.GetFullPath(Path.Combine(LibraryPath, "arm64"));
LibraryPathAnroidx64 = Path.GetFullPath(Path.Combine(LibraryPath, "x64"));
LibraryName = string.Format("lib{0}.a", LibraryName);
}
else if (bIsLinux)
{
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "linux"));
LibraryName = string.Format("lib{0}.a", LibraryName);
#if UE_5_5_OR_LATER
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v23"));
#elif UE_5_3_OR_LATER
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v22"));
#elif UE_5_2_OR_LATER
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v21"));
#else
Debug.Assert(false, "Unsupported engine version or compiler!");
#endif
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "x86-64"));
}
else if (bIsLinuxArm64)
{
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "linux"));
LibraryName = string.Format("lib{0}.a", LibraryName);
#if UE_5_5_OR_LATER
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v23"));
#elif UE_5_3_OR_LATER
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v22"));
#elif UE_5_2_OR_LATER
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v21"));
#else
Debug.Assert(false, "Unsupported engine version or compiler!");
#endif
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "aarch64"));
}
else if (bIsWin64)
{
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "win64"));
switch (Target.WindowsPlatform.Compiler)
{
case WindowsCompiler.VisualStudio2022:
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "msvc143"));
break;
#if ! UE_5_4_OR_LATER
case WindowsCompiler.VisualStudio2019:
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "msvc142"));
break;
#endif
default:
Debug.Assert(false, "Unsupported engine version or compiler!");
break;
}
LibraryName = string.Format("{0}.lib", LibraryName);
}
else
{
Debug.Assert(false, "Unsupported platform!");
}
string IncludePath = Path.GetFullPath(Path.Combine(ThirdPartyDirectory, "include"));
PrivateIncludePaths.Add(IncludePath);
if (bIsAndroid)
{
if (bIsDebugBuild)
{
LibraryPathAnroidArm64 = Path.GetFullPath(Path.Combine(LibraryPathAnroidArm64, "debug"));
LibraryPathAnroidx64 = Path.GetFullPath(Path.Combine(LibraryPathAnroidx64, "debug"));
}
else
{
LibraryPathAnroidArm64 = Path.GetFullPath(Path.Combine(LibraryPathAnroidArm64, "release"));
LibraryPathAnroidx64 = Path.GetFullPath(Path.Combine(LibraryPathAnroidx64, "release"));
}
LibraryPathAnroidArm64 = Path.GetFullPath(Path.Combine(LibraryPathAnroidArm64, LibraryName));
LibraryPathAnroidx64 = Path.GetFullPath(Path.Combine(LibraryPathAnroidx64, LibraryName));
PublicAdditionalLibraries.Add(LibraryPathAnroidArm64);
PublicAdditionalLibraries.Add(LibraryPathAnroidx64);
}
else
{
if (bIsDebugBuild)
{
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "debug"));
}
else
{
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "release"));
}
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, LibraryName));
PublicAdditionalLibraries.Add(LibraryPath);
}
}
private void AddSerialLibrary(ReadOnlyTargetRules Target)
{
string PluginRootDirectory = Path.GetFullPath(Path.Combine(ModuleDirectory, "..", ".."));
string SourceDirectory = Path.GetFullPath(Path.Combine(PluginRootDirectory, "Source"));
string ThirdPartyDirectory = Path.GetFullPath(Path.Combine(SourceDirectory, "ThirdParty"));
string LibraryPath = Path.GetFullPath(Path.Combine(ThirdPartyDirectory, "lib"));
string LibraryPathAnroidArm64 = "";
string LibraryPathAnroidx64 = "";
string LibraryName = "serial";
bool bIsAndroid = Target.IsInPlatformGroup(UnrealPlatformGroup.Android);
bool bIsLinux = Target.Platform == UnrealTargetPlatform.Linux;
bool bIsLinuxArm64 = Target.Platform == UnrealTargetPlatform.LinuxArm64;
bool bIsWin64 = Target.IsInPlatformGroup(UnrealPlatformGroup.Windows) &&
Target.WindowsPlatform.Architecture == UnrealArch.X64;
bool bIsDebugBuild = (Target.Configuration == UnrealTargetConfiguration.Debug);
if (bIsAndroid)
{
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "android"));
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "r25b"));
LibraryPathAnroidArm64 = Path.GetFullPath(Path.Combine(LibraryPath, "arm64"));
LibraryPathAnroidx64 = Path.GetFullPath(Path.Combine(LibraryPath, "x64"));
LibraryName = string.Format("lib{0}.a", LibraryName);
}
else if (bIsLinux)
{
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "linux"));
LibraryName = string.Format("lib{0}.a", LibraryName);
#if UE_5_5_OR_LATER
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v23"));
#elif UE_5_3_OR_LATER
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v22"));
#elif UE_5_2_OR_LATER
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v21"));
#else
Debug.Assert(false, "Unsupported engine version or compiler!");
#endif
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "x86-64"));
}
else if (bIsLinuxArm64)
{
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "linux"));
LibraryName = string.Format("lib{0}.a", LibraryName);
#if UE_5_5_OR_LATER
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v23"));
#elif UE_5_3_OR_LATER
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v22"));
#elif UE_5_2_OR_LATER
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v21"));
#else
Debug.Assert(false, "Unsupported engine version or compiler!");
#endif
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "aarch64"));
}
else if (bIsWin64)
{
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "win64"));
switch (Target.WindowsPlatform.Compiler)
{
case WindowsCompiler.VisualStudio2022:
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "msvc143"));
break;
#if ! UE_5_4_OR_LATER
case WindowsCompiler.VisualStudio2019:
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "msvc142"));
break;
#endif
default:
Debug.Assert(false, "Unsupported engine version or compiler!");
break;
}
LibraryName = string.Format("{0}.lib", LibraryName);
}
else
{
Debug.Assert(false, "Unsupported platform!");
}
string IncludePath = Path.GetFullPath(Path.Combine(ThirdPartyDirectory, "include"));
PrivateIncludePaths.Add(IncludePath);
if (bIsAndroid)
{
if (bIsDebugBuild)
{
LibraryPathAnroidArm64 = Path.GetFullPath(Path.Combine(LibraryPathAnroidArm64, "debug"));
LibraryPathAnroidx64 = Path.GetFullPath(Path.Combine(LibraryPathAnroidx64, "debug"));
}
else
{
LibraryPathAnroidArm64 = Path.GetFullPath(Path.Combine(LibraryPathAnroidArm64, "release"));
LibraryPathAnroidx64 = Path.GetFullPath(Path.Combine(LibraryPathAnroidx64, "release"));
}
LibraryPathAnroidArm64 = Path.GetFullPath(Path.Combine(LibraryPathAnroidArm64, LibraryName));
LibraryPathAnroidx64 = Path.GetFullPath(Path.Combine(LibraryPathAnroidx64, LibraryName));
PublicAdditionalLibraries.Add(LibraryPathAnroidArm64);
PublicAdditionalLibraries.Add(LibraryPathAnroidx64);
}
else
{
if (bIsDebugBuild)
{
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "debug"));
}
else
{
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "release"));
}
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, LibraryName));
PublicAdditionalLibraries.Add(LibraryPath);
}
}
}
@@ -34,9 +34,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using UnrealBuildTool;
public class SenseGloveCoreImpl : ModuleRules
@@ -57,6 +54,13 @@ public class SenseGloveCoreImpl : ModuleRules
}
);
PrivateDependencyModuleNames.AddRange(
new string[]
{
"SGCoreThirdPartyLibs",
}
);
PrivateDependencyModuleNames.AddRange(
new string[]
{
@@ -74,133 +78,7 @@ public class SenseGloveCoreImpl : ModuleRules
}
);
AddCoreLibrary(Target);
PublicDefinitions.Add("SENSEGLOVE_BUILDING_CORE_IMPL_MODULE");
PublicDefinitions.Add("SENSEGLOVE_UNREAL_ENGINE_PLUGIN");
}
private void AddCoreLibrary(ReadOnlyTargetRules Target)
{
string PluginRootDirectory = Path.GetFullPath(Path.Combine(ModuleDirectory, "..", ".."));
string SourceDirectory = Path.GetFullPath(Path.Combine(PluginRootDirectory, "Source"));
string ThirdPartyDirectory = Path.GetFullPath(Path.Combine(SourceDirectory, "ThirdParty"));
string LibraryPath = Path.GetFullPath(Path.Combine(ThirdPartyDirectory, "lib"));
string LibraryPathAnroidArm64 = "";
string LibraryPathAnroidx64 = "";
string LibraryName = "sgcore";
bool bIsAndroid = Target.IsInPlatformGroup(UnrealPlatformGroup.Android);
bool bIsLinux = Target.Platform == UnrealTargetPlatform.Linux;
bool bIsLinuxArm64 = Target.Platform == UnrealTargetPlatform.LinuxArm64;
bool bIsWin64 = Target.IsInPlatformGroup(UnrealPlatformGroup.Windows) &&
Target.WindowsPlatform.Architecture == UnrealArch.X64;
bool bIsDebugBuild = (Target.Configuration == UnrealTargetConfiguration.Debug);
if (bIsAndroid)
{
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "android"));
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "r25b"));
LibraryPathAnroidArm64 = Path.GetFullPath(Path.Combine(LibraryPath, "arm64"));
LibraryPathAnroidx64 = Path.GetFullPath(Path.Combine(LibraryPath, "x64"));
LibraryName = string.Format("lib{0}.a", LibraryName);
}
else if (bIsLinux)
{
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "linux"));
LibraryName = string.Format("lib{0}.a", LibraryName);
#if UE_5_5_OR_LATER
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v23"));
#elif UE_5_3_OR_LATER
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v22"));
#elif UE_5_2_OR_LATER
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v21"));
#else
Debug.Assert(false, "Unsupported engine version or compiler!");
#endif
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "x86-64"));
}
else if (bIsLinuxArm64)
{
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "linux"));
LibraryName = string.Format("lib{0}.a", LibraryName);
#if UE_5_5_OR_LATER
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v23"));
#elif UE_5_3_OR_LATER
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v22"));
#elif UE_5_2_OR_LATER
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v21"));
#else
Debug.Assert(false, "Unsupported engine version or compiler!");
#endif
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "aarch64"));
}
else if (bIsWin64)
{
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "win64"));
switch (Target.WindowsPlatform.Compiler)
{
case WindowsCompiler.VisualStudio2022:
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "msvc143"));
break;
#if ! UE_5_4_OR_LATER
case WindowsCompiler.VisualStudio2019:
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "msvc142"));
break;
#endif
default:
Debug.Assert(false, "Unsupported engine version or compiler!");
break;
}
LibraryName = string.Format("{0}.lib", LibraryName);
}
else
{
Debug.Assert(false, "Unsupported platform!");
}
string IncludePath = Path.GetFullPath(Path.Combine(ThirdPartyDirectory, "include"));
PrivateIncludePaths.Add(IncludePath);
if (bIsAndroid)
{
if (bIsDebugBuild)
{
LibraryPathAnroidArm64 = Path.GetFullPath(Path.Combine(LibraryPathAnroidArm64, "debug"));
LibraryPathAnroidx64 = Path.GetFullPath(Path.Combine(LibraryPathAnroidx64, "debug"));
}
else
{
LibraryPathAnroidArm64 = Path.GetFullPath(Path.Combine(LibraryPathAnroidArm64, "release"));
LibraryPathAnroidx64 = Path.GetFullPath(Path.Combine(LibraryPathAnroidx64, "release"));
}
LibraryPathAnroidArm64 = Path.GetFullPath(Path.Combine(LibraryPathAnroidArm64, LibraryName));
LibraryPathAnroidx64 = Path.GetFullPath(Path.Combine(LibraryPathAnroidx64, LibraryName));
PublicAdditionalLibraries.Add(LibraryPathAnroidArm64);
PublicAdditionalLibraries.Add(LibraryPathAnroidx64);
}
else
{
if (bIsDebugBuild)
{
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "debug"));
}
else
{
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "release"));
}
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, LibraryName));
PublicAdditionalLibraries.Add(LibraryPath);
}
}
}
@@ -34,15 +34,20 @@
#include "SGLog/SGLog.h"
#include "Containers/Map.h"
#include "Logging/LogMacros.h"
#include "Templates/Atomic.h"
DEFINE_LOG_CATEGORY(LogEditor)
DEFINE_LOG_CATEGORY(LogGeneric)
struct FSGLogCore::FStaticImpl
{
public:
/************************
* Type definitions
************************/
struct VerbosityMapper
{
FString Tag;
@@ -51,33 +56,56 @@ public:
VerbosityMapper(const FString& InTag, const FColor& InColor);
};
public:
/************************
* Member variables
************************/
TMap<FSGLogCore::EVerbosity, VerbosityMapper> VerbosityMap;
bool bInitialized;
TAtomic<bool> bInitialized;
/************************
* Constructor / Destructor
************************/
public:
FStaticImpl();
~FStaticImpl();
};
struct FSGLogCore::FImpl
{
public:
/************************
* Member variables
************************/
FSGLogCore::EVerbosity Verbosity;
FSGLogCore::ECategory Category;
FString File;
FString Function;
FString Line;
/************************
* Constructor / Destructor
************************/
FImpl();
~FImpl();
/************************
* Default copy constructor & copy assignment operator
************************/
FImpl(const FImpl& Rhs) = default;
FImpl& operator=(const FImpl& Rhs) = default;
};
FSGLogCore::FStaticImplDeleter FSGLogCore::SPimplDeleter;
std::unique_ptr<FSGLogCore::FStaticImpl, FSGLogCore::FStaticImplDeleter> FSGLogCore::SPimpl =
std::unique_ptr<FSGLogCore::FStaticImpl, FSGLogCore::FStaticImplDeleter>(
new FSGLogCore::FStaticImpl{}, FSGLogCore::SPimplDeleter);
TUniquePtr<FSGLogCore::FStaticImpl, FSGLogCore::FStaticImplDeleter> FSGLogCore::SPimpl{
new FStaticImpl{}, FStaticImplDeleter()
};
FSGLogCore::FSGLogCore(const EVerbosity& Verbosity, const ECategory& Category, const std::string& File,
const std::string& Function, const int32 Line)
: Pimpl(std::unique_ptr<FImpl, FImplDeleter>(new FImpl{}, PimplDeleter)),
const std::string& Function, const int32 Line)
: Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{}, PimplDeleter)),
bAnyEntries(false)
{
#if defined ( SENSEGLOVE_LOGGING )
@@ -85,12 +113,14 @@ FSGLogCore::FSGLogCore(const EVerbosity& Verbosity, const ECategory& Category, c
{
SPimpl->VerbosityMap.Add(FSGLogCore::EVerbosity::Fatal,
FStaticImpl::VerbosityMapper(TEXT("FATAL"), FColor::White));
SPimpl->VerbosityMap.Add(FSGLogCore::EVerbosity::Error, FStaticImpl::VerbosityMapper(TEXT("ERROR"), FColor::Red));
SPimpl->VerbosityMap.Add(FSGLogCore::EVerbosity::Error,
FStaticImpl::VerbosityMapper(TEXT("ERROR"), FColor::Red));
SPimpl->VerbosityMap.Add(FSGLogCore::EVerbosity::Warning,
FStaticImpl::VerbosityMapper(TEXT("WARNING"), FColor::Yellow));
SPimpl->VerbosityMap.Add(FSGLogCore::EVerbosity::Display,
FStaticImpl::VerbosityMapper(TEXT("DISPLAY"), FColor::Green));
SPimpl->VerbosityMap.Add(FSGLogCore::EVerbosity::Log, FStaticImpl::VerbosityMapper(TEXT("LOG"), FColor::Silver));
SPimpl->VerbosityMap.Add(FSGLogCore::EVerbosity::Log,
FStaticImpl::VerbosityMapper(TEXT("LOG"), FColor::Silver));
SPimpl->VerbosityMap.Add(FSGLogCore::EVerbosity::Verbose,
FStaticImpl::VerbosityMapper(TEXT("VERBOSE"), FColor::Purple));
SPimpl->VerbosityMap.Add(FSGLogCore::EVerbosity::VeryVerbose,
@@ -127,46 +157,46 @@ FSGLogCore::~FSGLogCore()
switch (Verbosity)
{
case EVerbosity::Display:
{
UE_LOG(LogGeneric, Display, TEXT("%s"), Message.GetCharArray().GetData());
}
break;
{
UE_LOG(LogGeneric, Display, TEXT("%s"), Message.GetCharArray().GetData());
}
break;
case EVerbosity::Error:
{
UE_LOG(LogGeneric, Error, TEXT("%s"), Message.GetCharArray().GetData());
}
break;
{
UE_LOG(LogGeneric, Error, TEXT("%s"), Message.GetCharArray().GetData());
}
break;
case EVerbosity::Fatal:
{
UE_LOG(LogGeneric, Fatal, TEXT("%s"), Message.GetCharArray().GetData());
}
break;
{
UE_LOG(LogGeneric, Fatal, TEXT("%s"), Message.GetCharArray().GetData());
}
break;
case EVerbosity::Log:
{
UE_LOG(LogGeneric, Log, TEXT("%s"), Message.GetCharArray().GetData());
}
break;
{
UE_LOG(LogGeneric, Log, TEXT("%s"), Message.GetCharArray().GetData());
}
break;
case EVerbosity::Verbose:
{
UE_LOG(LogGeneric, Verbose, TEXT("%s"), Message.GetCharArray().GetData());
}
break;
{
UE_LOG(LogGeneric, Verbose, TEXT("%s"), Message.GetCharArray().GetData());
}
break;
case EVerbosity::VeryVerbose:
{
UE_LOG(LogGeneric, VeryVerbose, TEXT("%s"), Message.GetCharArray().GetData());
}
break;
{
UE_LOG(LogGeneric, VeryVerbose, TEXT("%s"), Message.GetCharArray().GetData());
}
break;
case EVerbosity::Warning:
{
UE_LOG(LogGeneric, Warning, TEXT("%s"), Message.GetCharArray().GetData());
}
break;
{
UE_LOG(LogGeneric, Warning, TEXT("%s"), Message.GetCharArray().GetData());
}
break;
}
}
@@ -176,46 +206,46 @@ FSGLogCore::~FSGLogCore()
switch (Verbosity)
{
case EVerbosity::Display:
{
UE_LOG(LogEditor, Display, TEXT("%s"), Message.GetCharArray().GetData());
}
break;
{
UE_LOG(LogEditor, Display, TEXT("%s"), Message.GetCharArray().GetData());
}
break;
case EVerbosity::Error:
{
UE_LOG(LogEditor, Error, TEXT("%s"), Message.GetCharArray().GetData());
}
break;
{
UE_LOG(LogEditor, Error, TEXT("%s"), Message.GetCharArray().GetData());
}
break;
case EVerbosity::Fatal:
{
UE_LOG(LogEditor, Fatal, TEXT("%s"), Message.GetCharArray().GetData());
}
break;
{
UE_LOG(LogEditor, Fatal, TEXT("%s"), Message.GetCharArray().GetData());
}
break;
case EVerbosity::Log:
{
UE_LOG(LogEditor, Log, TEXT("%s"), Message.GetCharArray().GetData());
}
break;
{
UE_LOG(LogEditor, Log, TEXT("%s"), Message.GetCharArray().GetData());
}
break;
case EVerbosity::Verbose:
{
UE_LOG(LogEditor, Verbose, TEXT("%s"), Message.GetCharArray().GetData());
}
break;
{
UE_LOG(LogEditor, Verbose, TEXT("%s"), Message.GetCharArray().GetData());
}
break;
case EVerbosity::VeryVerbose:
{
UE_LOG(LogEditor, VeryVerbose, TEXT("%s"), Message.GetCharArray().GetData());
}
break;
{
UE_LOG(LogEditor, VeryVerbose, TEXT("%s"), Message.GetCharArray().GetData());
}
break;
case EVerbosity::Warning:
{
UE_LOG(LogEditor, Warning, TEXT("%s"), Message.GetCharArray().GetData());
}
break;
{
UE_LOG(LogEditor, Warning, TEXT("%s"), Message.GetCharArray().GetData());
}
break;
}
}
#endif /* defined ( SENSEGLOVE_LOGGING ) */
@@ -226,8 +256,10 @@ FSGLogCore::FStaticImpl::FStaticImpl()
{
}
FSGLogCore::FStaticImpl::~FStaticImpl() = default;
FSGLogCore::FStaticImpl::VerbosityMapper::VerbosityMapper(const FString& InTag,
const FColor& InColor)
const FColor& InColor)
: Tag(InTag),
Color(InColor)
{
@@ -238,7 +270,15 @@ void FSGLogCore::FStaticImplDeleter::operator()(const FSGLogCore::FStaticImpl* P
delete Pointer;
}
FSGLogCore::FImpl::FImpl()
: Verbosity(EVerbosity::Verbose),
Category(ECategory::Generic)
{
}
FSGLogCore::FImpl::~FImpl() = default;
void FSGLogCore::FImplDeleter::operator()(const FSGLogCore::FImpl* Pointer) const
{
delete Pointer;
}
}
@@ -35,10 +35,9 @@
#pragma once
#include <memory>
#include <string>
#include <cstddef>
#include <cstdio>
#include <string>
#include "Containers/StringConv.h"
#include "Containers/UnrealString.h"
@@ -47,6 +46,7 @@
#include "Math/Rotator.h"
#include "Math/Transform.h"
#include "Math/Vector.h"
#include "Templates/SharedPointer.h"
#include "Templates/UnrealTemplate.h"
DECLARE_LOG_CATEGORY_EXTERN(LogEditor, All, All);
@@ -96,7 +96,7 @@ struct TFSGLogString<const bool>
{
static void Format(const bool Value, FString& OutString)
{
OutString = FString::Printf(TEXT("%s"), (Value ? TEXT("True") : TEXT("False")));
OutString = Value ? TEXT("True") : TEXT("False");
}
};
@@ -105,7 +105,7 @@ struct TFSGLogString<bool>
{
static void Format(const bool Value, FString& OutString)
{
OutString = FString::Printf(TEXT("%s"), (Value ? TEXT("True") : TEXT("False")));
OutString = Value ? TEXT("True") : TEXT("False");
}
};
@@ -114,7 +114,7 @@ struct TFSGLogString<const char[L]>
{
static void Format(const char* Value, FString& OutString)
{
OutString = FString(StringCast<WIDECHAR>(Value).Get());
OutString = FString(UTF8_TO_TCHAR(Value));
}
};
@@ -123,7 +123,7 @@ struct TFSGLogString<char[L]>
{
static void Format(const char* Value, FString& OutString)
{
OutString = FString(StringCast<WIDECHAR>(Value).Get());
OutString = FString(UTF8_TO_TCHAR(Value));
}
};
@@ -132,7 +132,7 @@ struct TFSGLogString<const char*>
{
static void Format(const char* Value, FString& OutString)
{
OutString = FString(StringCast<WIDECHAR>(Value).Get());
OutString = FString(UTF8_TO_TCHAR(Value));
}
};
@@ -141,48 +141,52 @@ struct TFSGLogString<char*>
{
static void Format(const char* Value, FString& OutString)
{
OutString = FString(StringCast<WIDECHAR>(Value).Get());
OutString = FString(UTF8_TO_TCHAR(Value));
}
};
#if ! PLATFORM_ANDROID && PLATFORM_LINUX
template< std::size_t L>
template<std::size_t L>
struct TFSGLogString<const char16_t[L]>
{
static void Format(const char16_t* Value, FString& OutString)
{
OutString = FString(StringCast<WIDECHAR>(Value).Get());
OutString = FString(StringCast<TCHAR>(Value).Get());
}
};
#endif /* ! PLATFORM_ANDROID && PLATFORM_LINUX */
template< std::size_t L>
#if ! PLATFORM_ANDROID && PLATFORM_LINUX
template<std::size_t L>
struct TFSGLogString<char16_t[L]>
{
static void Format(const char16_t* Value, FString& OutString)
{
OutString = FString(StringCast<WIDECHAR>(Value).Get());
OutString = FString(StringCast<TCHAR>(Value).Get());
}
};
#endif /* ! PLATFORM_ANDROID && PLATFORM_LINUX */
template <>
#if ! PLATFORM_ANDROID && PLATFORM_LINUX
template<>
struct TFSGLogString<const char16_t*>
{
static void Format(const char16_t* Value, FString& OutString)
{
OutString = FString(StringCast<WIDECHAR>(Value).Get());
OutString = FString(StringCast<TCHAR>(Value).Get());
}
};
#endif /* ! PLATFORM_ANDROID && PLATFORM_LINUX */
template <>
#if ! PLATFORM_ANDROID && PLATFORM_LINUX
template<>
struct TFSGLogString<char16_t*>
{
static void Format(const char16_t* Value, FString& OutString)
{
OutString = FString(StringCast<WIDECHAR>(Value).Get());
OutString = FString(StringCast<TCHAR>(Value).Get());
}
};
#endif /* ! PLATFORM_ANDROID && PLATFORM_LINUX */
template<>
@@ -190,12 +194,7 @@ struct TFSGLogString<const double>
{
static void Format(const double Value, FString& OutString)
{
char Buffer[100];
std::snprintf(Buffer, sizeof(Buffer), "%f", Value);
std::string String(Buffer);
OutString = FString(StringCast<WIDECHAR>(String.c_str()).Get());
OutString = LexToString(Value);
}
};
@@ -204,12 +203,7 @@ struct TFSGLogString<double>
{
static void Format(const double Value, FString& OutString)
{
char Buffer[100];
std::snprintf(Buffer, sizeof(Buffer), "%f", Value);
std::string String(Buffer);
OutString = FString(StringCast<WIDECHAR>(String.c_str()).Get());
OutString = LexToString(Value);
}
};
@@ -218,7 +212,7 @@ struct TFSGLogString<const float>
{
static void Format(const float Value, FString& OutString)
{
OutString = FString::SanitizeFloat(StaticCast<double>(Value), 1);
OutString = LexToString(Value);
}
};
@@ -227,7 +221,7 @@ struct TFSGLogString<float>
{
static void Format(const float Value, FString& OutString)
{
OutString = FString::SanitizeFloat(StaticCast<double>(Value), 1);
OutString = LexToString(Value);
}
};
@@ -236,7 +230,7 @@ struct TFSGLogString<const FName>
{
static void Format(const FName& Value, FString& OutString)
{
OutString = FString::Printf(TEXT("%s"), Value.ToString().GetCharArray().GetData());
OutString = Value.ToString();
}
};
@@ -245,7 +239,7 @@ struct TFSGLogString<FName>
{
static void Format(const FName& Value, FString& OutString)
{
OutString = FString::Printf(TEXT("%s"), Value.ToString().GetCharArray().GetData());
OutString = Value.ToString();
}
};
@@ -254,7 +248,7 @@ struct TFSGLogString<const FQuat>
{
static void Format(const FQuat& Value, FString& OutString)
{
OutString = FString::Printf(TEXT("%s"), Value.ToString().GetCharArray().GetData());
OutString = Value.ToString();
}
};
@@ -263,7 +257,7 @@ struct TFSGLogString<FQuat>
{
static void Format(const FQuat& Value, FString& OutString)
{
OutString = FString::Printf(TEXT("%s"), Value.ToString().GetCharArray().GetData());
OutString = Value.ToString();
}
};
@@ -272,7 +266,7 @@ struct TFSGLogString<const FRotator>
{
static void Format(const FRotator& Value, FString& OutString)
{
OutString = FString::Printf(TEXT("%s"), Value.ToString().GetCharArray().GetData());
OutString = Value.ToString();
}
};
@@ -281,7 +275,7 @@ struct TFSGLogString<FRotator>
{
static void Format(const FRotator& Value, FString& OutString)
{
OutString = FString::Printf(TEXT("%s"), Value.ToString().GetCharArray().GetData());
OutString = Value.ToString();
}
};
@@ -308,7 +302,7 @@ struct TFSGLogString<const FTransform>
{
static void Format(const FTransform& Value, FString& OutString)
{
OutString = FString::Printf(TEXT("%s"), Value.ToString().GetCharArray().GetData());
OutString = Value.ToString();
}
};
@@ -317,7 +311,7 @@ struct TFSGLogString<FTransform>
{
static void Format(const FTransform& Value, FString& OutString)
{
OutString = FString::Printf(TEXT("%s"), Value.ToString().GetCharArray().GetData());
OutString = Value.ToString();
}
};
@@ -326,7 +320,7 @@ struct TFSGLogString<const FVector>
{
static void Format(const FVector& Value, FString& OutString)
{
OutString = FString::Printf(TEXT("%s"), Value.ToString().GetCharArray().GetData());
OutString = Value.ToString();
}
};
@@ -335,7 +329,7 @@ struct TFSGLogString<FVector>
{
static void Format(const FVector& Value, FString& OutString)
{
OutString = FString::Printf(TEXT("%s"), Value.ToString().GetCharArray().GetData());
OutString = Value.ToString();
}
};
@@ -344,7 +338,7 @@ struct TFSGLogString<const int8>
{
static void Format(const int8 Value, FString& OutString)
{
OutString = FString::Printf(TEXT("%d"), Value);
OutString = LexToString(Value);
}
};
@@ -353,7 +347,7 @@ struct TFSGLogString<int8>
{
static void Format(const int8 Value, FString& OutString)
{
OutString = FString::Printf(TEXT("%d"), Value);
OutString = LexToString(Value);
}
};
@@ -362,7 +356,7 @@ struct TFSGLogString<const int16>
{
static void Format(const int16 Value, FString& OutString)
{
OutString = FString::Printf(TEXT("%d"), Value);
OutString = LexToString(Value);
}
};
@@ -371,7 +365,7 @@ struct TFSGLogString<int16>
{
static void Format(const int16 Value, FString& OutString)
{
OutString = FString::Printf(TEXT("%d"), Value);
OutString = LexToString(Value);
}
};
@@ -380,7 +374,7 @@ struct TFSGLogString<const int32>
{
static void Format(const int32 Value, FString& OutString)
{
OutString = FString::FromInt(Value);
OutString = LexToString(Value);
}
};
@@ -389,7 +383,7 @@ struct TFSGLogString<int32>
{
static void Format(const int32 Value, FString& OutString)
{
OutString = FString::FromInt(Value);
OutString = LexToString(Value);
}
};
@@ -398,7 +392,7 @@ struct TFSGLogString<const int64>
{
static void Format(const int64 Value, FString& OutString)
{
OutString = FString::Printf(TEXT("%d"), Value);
OutString = LexToString(Value);
}
};
@@ -407,7 +401,7 @@ struct TFSGLogString<int64>
{
static void Format(const int64 Value, FString& OutString)
{
OutString = FString::Printf(TEXT("%d"), Value);
OutString = LexToString(Value);
}
};
@@ -416,12 +410,9 @@ struct TFSGLogString<const long double>
{
static void Format(const long double Value, FString& OutString)
{
char Buffer[100];
char Buffer[128];
std::snprintf(Buffer, sizeof(Buffer), "%Lf", Value);
std::string String(Buffer);
OutString = FString(StringCast<WIDECHAR>(String.c_str()).Get());
OutString = FString(UTF8_TO_TCHAR(Buffer));
}
};
@@ -430,12 +421,9 @@ struct TFSGLogString<long double>
{
static void Format(const long double Value, FString& OutString)
{
char Buffer[100];
char Buffer[128];
std::snprintf(Buffer, sizeof(Buffer), "%Lf", Value);
std::string String(Buffer);
OutString = FString(StringCast<WIDECHAR>(String.c_str()).Get());
OutString = FString(UTF8_TO_TCHAR(Buffer));
}
};
@@ -445,18 +433,18 @@ struct TFSGLogString<const std::size_t>
{
static void Format(const std::size_t Value, FString& OutString)
{
OutString = FString::Printf(TEXT("%d"), Value);
OutString = LexToString(Value);
}
};
#endif /* ! PLATFORM_ANDROID && PLATFORM_LINUX */
#if ! PLATFORM_ANDROID && PLATFORM_LINUX
template <>
template<>
struct TFSGLogString<std::size_t>
{
static void Format(const std::size_t Value, FString& OutString)
{
OutString = FString::Printf(TEXT("%d"), Value);
OutString = LexToString(Value);
}
};
#endif /* ! PLATFORM_ANDROID && PLATFORM_LINUX */
@@ -464,72 +452,72 @@ struct TFSGLogString<std::size_t>
template<>
struct TFSGLogString<const uint8>
{
static void Format(const int8 Value, FString& OutString)
static void Format(const uint8 Value, FString& OutString)
{
OutString = FString::Printf(TEXT("%d"), Value);
OutString = LexToString(Value);
}
};
template<>
struct TFSGLogString<uint8>
{
static void Format(const int8 Value, FString& OutString)
static void Format(const uint8 Value, FString& OutString)
{
OutString = FString::Printf(TEXT("%d"), Value);
OutString = LexToString(Value);
}
};
template<>
struct TFSGLogString<const uint16>
{
static void Format(const int16 Value, FString& OutString)
static void Format(const uint16 Value, FString& OutString)
{
OutString = FString::Printf(TEXT("%d"), Value);
OutString = LexToString(Value);
}
};
template<>
struct TFSGLogString<uint16>
{
static void Format(const int16 Value, FString& OutString)
static void Format(const uint16 Value, FString& OutString)
{
OutString = FString::Printf(TEXT("%d"), Value);
OutString = LexToString(Value);
}
};
template<>
struct TFSGLogString<const uint32>
{
static void Format(const int32 Value, FString& OutString)
static void Format(const uint32 Value, FString& OutString)
{
OutString = FString::Printf(TEXT("%d"), Value);
OutString = LexToString(Value);
}
};
template<>
struct TFSGLogString<uint32>
{
static void Format(const int32 Value, FString& OutString)
static void Format(const uint32 Value, FString& OutString)
{
OutString = FString::Printf(TEXT("%d"), Value);
OutString = LexToString(Value);
}
};
template<>
struct TFSGLogString<const uint64>
{
static void Format(const int64 Value, FString& OutString)
static void Format(const uint64 Value, FString& OutString)
{
OutString = FString::Printf(TEXT("%d"), Value);
OutString = LexToString(Value);
}
};
template<>
struct TFSGLogString<uint64>
{
static void Format(const int64 Value, FString& OutString)
static void Format(const uint64 Value, FString& OutString)
{
OutString = FString::Printf(TEXT("%d"), Value);
OutString = LexToString(Value);
}
};
@@ -538,7 +526,7 @@ struct TFSGLogString<const std::string>
{
static void Format(const std::string& Value, FString& OutString)
{
OutString = FString(StringCast<WIDECHAR>(Value.c_str()).Get());
OutString = FString(UTF8_TO_TCHAR(Value.c_str()));
}
};
@@ -547,7 +535,7 @@ struct TFSGLogString<std::string>
{
static void Format(const std::string& Value, FString& OutString)
{
OutString = FString(StringCast<WIDECHAR>(Value.c_str()).Get());
OutString = FString(UTF8_TO_TCHAR(Value.c_str()));
}
};
@@ -556,7 +544,7 @@ struct TFSGLogString<const wchar_t[L]>
{
static void Format(const wchar_t* Value, FString& OutString)
{
OutString = FString::Printf(TEXT("%s"), Value);
OutString = FString(StringCast<TCHAR>(Value).Get());
}
};
@@ -565,7 +553,7 @@ struct TFSGLogString<wchar_t[L]>
{
static void Format(const wchar_t* Value, FString& OutString)
{
OutString = FString::Printf(TEXT("%s"), Value);
OutString = FString(StringCast<TCHAR>(Value).Get());
}
};
@@ -574,7 +562,7 @@ struct TFSGLogString<const wchar_t*>
{
static void Format(const wchar_t* Value, FString& OutString)
{
OutString = FString::Printf(TEXT("%s"), Value);
OutString = FString(StringCast<TCHAR>(Value).Get());
}
};
@@ -583,7 +571,7 @@ struct TFSGLogString<wchar_t*>
{
static void Format(const wchar_t* Value, FString& OutString)
{
OutString = FString::Printf(TEXT("%s"), Value);
OutString = FString(StringCast<TCHAR>(Value).Get());
}
};
@@ -592,7 +580,7 @@ struct TFSGLogString<const std::wstring>
{
static void Format(const std::wstring& Value, FString& OutString)
{
OutString = FString::Printf(TEXT("%s"), Value.c_str());
OutString = FString(StringCast<TCHAR>(Value.data(), Value.size()).Get(), Value.size());
}
};
@@ -601,7 +589,7 @@ struct TFSGLogString<std::wstring>
{
static void Format(const std::wstring& Value, FString& OutString)
{
OutString = FString::Printf(TEXT("%s"), Value.c_str());
OutString = FString(StringCast<TCHAR>(Value.data(), Value.size()).Get(), Value.size());
}
};
@@ -658,8 +646,7 @@ private:
void operator()(const FStaticImpl* Pointer) const;
};
static std::unique_ptr<FStaticImpl, FStaticImplDeleter> SPimpl;
static FStaticImplDeleter SPimplDeleter;
static TUniquePtr<FStaticImpl, FStaticImplDeleter> SPimpl;
struct FImpl;
@@ -668,7 +655,7 @@ private:
void operator()(const FImpl* Pointer) const;
};
std::unique_ptr<FImpl, FImplDeleter> Pimpl;
TUniquePtr<FImpl, FImplDeleter> Pimpl;
FImplDeleter PimplDeleter;
private:
@@ -35,12 +35,74 @@
#include "SGTracking/SGHMDTracker.h"
#include "Runtime/Launch/Resources/Version.h"
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
#include "Async/Async.h"
#include "Async/Future.h"
#include "Async/TaskGraphInterfaces.h"
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
#include "Engine/Engine.h"
#include "IHeadMountedDisplay.h"
#include "IXRTrackingSystem.h"
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
#include "Misc/Optional.h"
#include "Misc/Timespan.h"
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
#include "SGSettings/SGSettings.h"
struct FSGHMDTracker::FStaticImpl
{
/************************
* Static methods
************************/
static void GetHMDMonitorInfo(
IHeadMountedDisplay* Device, IHeadMountedDisplay::MonitorInfo& OutMonitorInfo);
/************************
* Constructor / Destructor
************************/
explicit FStaticImpl() = default;
virtual ~FStaticImpl() = delete;
};
void FSGHMDTracker::FStaticImpl::GetHMDMonitorInfo(
IHeadMountedDisplay* Device, IHeadMountedDisplay::MonitorInfo& OutMonitorInfo)
{
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION <= 5
Device->GetHMDMonitorInfo(OutMonitorInfo);
return;
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION <= 5 */
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 6
TPromise<TOptional<IHeadMountedDisplay::MonitorInfo>> Promise;
const TFuture<TOptional<IHeadMountedDisplay::MonitorInfo>> Future{Promise.GetFuture()};
AsyncTask(ENamedThreads::ActualRenderingThread,
[
Device,
Promise = MoveTemp(Promise)]() mutable
{
IHeadMountedDisplay::MonitorInfo MonitorInfo;
Device->GetHMDMonitorInfo(MonitorInfo);
Promise.SetValue(MoveTemp(MonitorInfo));
});
if (Future.WaitFor(FTimespan::FromMilliseconds(100)))
{
TOptional<IHeadMountedDisplay::MonitorInfo> Result{Future.Get()};
if (Result.IsSet())
{
OutMonitorInfo = Result.GetValue();
}
}
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 6 */
}
FName FSGHMDTracker::GetDeviceName()
{
if (GEngine && GEngine->XRSystem.IsValid() && GEngine->XRSystem->IsHeadTrackingAllowed())
@@ -145,7 +207,7 @@ bool FSGHMDTracker::IsHtcVivePro()
if (Device)
{
IHeadMountedDisplay::MonitorInfo HmdMonitorInfo;
Device->GetHMDMonitorInfo(HmdMonitorInfo);
FStaticImpl::GetHMDMonitorInfo(Device, HmdMonitorInfo);
/// NOTE
// VIVE Pro:
@@ -218,7 +280,7 @@ bool FSGHMDTracker::IsHtcViveFocus3()
if (Device)
{
IHeadMountedDisplay::MonitorInfo HmdMonitorInfo;
Device->GetHMDMonitorInfo(HmdMonitorInfo);
FStaticImpl::GetHMDMonitorInfo(Device, HmdMonitorInfo);
/// NOTE
// VIVE Pro:
@@ -292,7 +354,7 @@ bool FSGHMDTracker::IsHtcViveXRElite()
if (Device)
{
IHeadMountedDisplay::MonitorInfo HmdMonitorInfo;
Device->GetHMDMonitorInfo(HmdMonitorInfo);
FStaticImpl::GetHMDMonitorInfo(Device, HmdMonitorInfo);
/// NOTE
// VIVE Pro:
@@ -366,7 +428,7 @@ bool FSGHMDTracker::IsHtcViveFocusVision()
if (Device)
{
IHeadMountedDisplay::MonitorInfo HmdMonitorInfo;
Device->GetHMDMonitorInfo(HmdMonitorInfo);
FStaticImpl::GetHMDMonitorInfo(Device, HmdMonitorInfo);
/// NOTE
// VIVE Pro:
@@ -35,6 +35,11 @@
#include "SGTracking/SGXRTracker.h"
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
#include "Async/Async.h"
#include "Async/Future.h"
#include "Async/TaskGraphInterfaces.h"
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
#include "Containers/Array.h"
#include "Containers/Map.h"
#include "Engine/Engine.h"
@@ -46,6 +51,10 @@
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 4 */
#include "IOpenXRHMDModule.h"
#include "IXRTrackingSystem.h"
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
#include "Misc/Optional.h"
#include "Misc/Timespan.h"
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
#include "OpenXRCore.h"
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION <= 3
#include "OpenXRHMD.h"
@@ -2204,6 +2213,7 @@ bool FSGXRTracker::FImpl::GetControllerTransform(
IMotionController::GetModularFeatureName())
};
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION <= 4
for (const IMotionController* MotionController: MotionControllers)
{
if (!MotionController)
@@ -2237,6 +2247,68 @@ bool FSGXRTracker::FImpl::GetControllerTransform(
break;
}
}
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION <= 4 */
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
TPromise<TOptional<FTransform>> Promise;
const TFuture<TOptional<FTransform>> Future{Promise.GetFuture()};
AsyncTask(ENamedThreads::ActualRenderingThread,
[
this,
WorldToMetersScale,
&PositionalTrackingHardwareMotionSource,
&TargetPositionalTrackingProviderName,
MotionControllers,
Promise = MoveTemp(Promise)]() mutable
{
for (const IMotionController* MotionController: MotionControllers)
{
if (!MotionController)
{
continue;
}
const ETrackingStatus TrackingStatus = MotionController->GetControllerTrackingStatus(
DeviceIndex, PositionalTrackingHardwareMotionSource);
if (TrackingStatus == ETrackingStatus::NotTracked)
{
continue;
}
const FName DeviceTypeName{MotionController->GetMotionControllerDeviceTypeName()};
if (DeviceTypeName != TargetPositionalTrackingProviderName)
{
continue;
}
FRotator Orientation;
FVector Position;
const bool bGotTransform = MotionController->GetControllerOrientationAndPosition(
DeviceIndex, PositionalTrackingHardwareMotionSource,
Orientation, Position, WorldToMetersScale);
if (bGotTransform)
{
FTransform Transform{Orientation, Position};
Promise.SetValue(MoveTemp(Transform));
return;
}
}
Promise.SetValue(TOptional<FTransform>{});
});
if (Future.WaitFor(FTimespan::FromMilliseconds(100)))
{
TOptional<FTransform> Result{Future.Get()};
if (Result.IsSet())
{
OutTransform = Result.GetValue();
bOutMotionSourceHandTracking = false;
bTracked = true;
}
}
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
}
if (!bTracked && bFallbackToHandTrackingIfNoGloveDetected)
@@ -51,6 +51,9 @@ struct SENSEGLOVETRACKING_API FSGHMDTracker
{
GENERATED_BODY()
private:
struct FStaticImpl;
public:
static FName GetDeviceName();
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More