check hmd auto-detection against various identifiers as the names returns from the engine is not reliable
This commit is contained in:
@@ -54,12 +54,83 @@ FName FSGHeadMountDisplay::GetDeviceName()
|
|||||||
return NAME_None;
|
return NAME_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FSGHeadMountDisplay::IsMetaQuest2()
|
||||||
|
{
|
||||||
|
static const FName MetaQuest2DeviceIdentifier{TEXT("Meta Quest 2")};
|
||||||
|
static const FName OculusQuest2DeviceIdentifier{TEXT("Oculus Quest2")};
|
||||||
|
static const FString Quest2DeviceIdentifier1{TEXT("Quest 2")};
|
||||||
|
static const FString Quest2DeviceIdentifier2{TEXT("Quest2")};
|
||||||
|
|
||||||
|
const FName DeviceName{GetDeviceName()};
|
||||||
|
bool bMatched = DeviceName == MetaQuest2DeviceIdentifier || DeviceName == OculusQuest2DeviceIdentifier;
|
||||||
|
if (!bMatched)
|
||||||
|
{
|
||||||
|
const FString DeviceNameString{GetDeviceName().ToString()};
|
||||||
|
bMatched = DeviceNameString.Contains(Quest2DeviceIdentifier1)
|
||||||
|
|| DeviceNameString.Contains(Quest2DeviceIdentifier2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return bMatched;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FSGHeadMountDisplay::IsMetaQuestPro()
|
||||||
|
{
|
||||||
|
static const FName MetaQuestProDeviceIdentifier{TEXT("Meta Quest Pro")};
|
||||||
|
static const FName OculusQuestProDeviceIdentifier{TEXT("Oculus QuestPro")};
|
||||||
|
static const FString QuestProDeviceIdentifier1{TEXT("Quest Pro")};
|
||||||
|
static const FString QuestProDeviceIdentifier2{TEXT("QuestPro")};
|
||||||
|
|
||||||
|
const FName DeviceName{GetDeviceName()};
|
||||||
|
bool bMatched = DeviceName == MetaQuestProDeviceIdentifier || DeviceName == OculusQuestProDeviceIdentifier;
|
||||||
|
if (!bMatched)
|
||||||
|
{
|
||||||
|
const FString DeviceNameString{GetDeviceName().ToString()};
|
||||||
|
bMatched = DeviceNameString.Contains(QuestProDeviceIdentifier1)
|
||||||
|
|| DeviceNameString.Contains(QuestProDeviceIdentifier2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return bMatched;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FSGHeadMountDisplay::IsMetaQuest3()
|
||||||
|
{
|
||||||
|
static const FName MetaQuest3DeviceIdentifier{TEXT("Meta Quest 3")};
|
||||||
|
static const FName OculusQuest3DeviceIdentifier{TEXT("Oculus Quest3")};
|
||||||
|
static const FString Quest3DeviceIdentifier1{TEXT("Quest 3")};
|
||||||
|
static const FString Quest3DeviceIdentifier2{TEXT("Quest3")};
|
||||||
|
|
||||||
|
const FName DeviceName{GetDeviceName()};
|
||||||
|
bool bMatched = DeviceName == MetaQuest3DeviceIdentifier || DeviceName == OculusQuest3DeviceIdentifier;
|
||||||
|
if (!bMatched)
|
||||||
|
{
|
||||||
|
const FString DeviceNameString{GetDeviceName().ToString()};
|
||||||
|
bMatched = DeviceNameString.Contains(Quest3DeviceIdentifier1)
|
||||||
|
|| DeviceNameString.Contains(Quest3DeviceIdentifier2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return bMatched;
|
||||||
|
}
|
||||||
|
|
||||||
bool FSGHeadMountDisplay::IsHtcVivePro()
|
bool FSGHeadMountDisplay::IsHtcVivePro()
|
||||||
{
|
{
|
||||||
#if !PLATFORM_ANDROID
|
#if PLATFORM_ANDROID
|
||||||
|
return false;
|
||||||
|
#else /* PLATFORM_ANDROID */
|
||||||
static const FName DeviceIdentifier{TEXT("Vive OpenXR: Vive SRanipal")};
|
static const FName DeviceIdentifier{TEXT("Vive OpenXR: Vive SRanipal")};
|
||||||
const bool bIdentifierMatches = GetDeviceName() == DeviceIdentifier;
|
static const FString ViveDeviceIdentifier{TEXT("Vive")};
|
||||||
if (bIdentifierMatches)
|
static const FString SRanipalDeviceIdentifier{TEXT("SRanipal")};
|
||||||
|
|
||||||
|
const FName DeviceName{GetDeviceName()};
|
||||||
|
|
||||||
|
bool bMatched = DeviceName == DeviceIdentifier;
|
||||||
|
if (!bMatched)
|
||||||
|
{
|
||||||
|
const FString DeviceNameString{GetDeviceName().ToString()};
|
||||||
|
bMatched = DeviceNameString.Contains(ViveDeviceIdentifier)
|
||||||
|
|| DeviceNameString.Contains(SRanipalDeviceIdentifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bMatched)
|
||||||
{
|
{
|
||||||
if (GEngine->XRSystem.IsValid() && GEngine->XRSystem->IsHeadTrackingAllowed())
|
if (GEngine->XRSystem.IsValid() && GEngine->XRSystem->IsHeadTrackingAllowed())
|
||||||
{
|
{
|
||||||
@@ -78,25 +149,37 @@ bool FSGHeadMountDisplay::IsHtcVivePro()
|
|||||||
// - Unreal OpenXR Resolution: 5016 x 2508
|
// - Unreal OpenXR Resolution: 5016 x 2508
|
||||||
if (HmdMonitorInfo.ResolutionX < 5000 && HmdMonitorInfo.ResolutionY > 2700)
|
if (HmdMonitorInfo.ResolutionX < 5000 && HmdMonitorInfo.ResolutionY > 2700)
|
||||||
{
|
{
|
||||||
return true;
|
bMatched = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* !PLATFORM_ANDROID */
|
|
||||||
|
|
||||||
return false;
|
return bMatched;
|
||||||
|
#endif /* PLATFORM_ANDROID */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool FSGHeadMountDisplay::IsHtcViveFocus3()
|
bool FSGHeadMountDisplay::IsHtcViveFocus3()
|
||||||
{
|
{
|
||||||
static const FName DeviceIdentifier{TEXT("Vive OpenXR: Vive SRanipal")};
|
static const FName DeviceIdentifier{TEXT("Vive OpenXR: Vive SRanipal")};
|
||||||
const bool bIdentifierMatches = GetDeviceName() == DeviceIdentifier;
|
static const FString ViveDeviceIdentifier{TEXT("Vive")};
|
||||||
|
static const FString SRanipalDeviceIdentifier{TEXT("SRanipal")};
|
||||||
|
|
||||||
|
const FName DeviceName{GetDeviceName()};
|
||||||
|
|
||||||
|
bool bMatched = DeviceName == DeviceIdentifier;
|
||||||
|
if (!bMatched)
|
||||||
|
{
|
||||||
|
const FString DeviceNameString{GetDeviceName().ToString()};
|
||||||
|
bMatched = DeviceNameString.Contains(ViveDeviceIdentifier)
|
||||||
|
|| DeviceNameString.Contains(SRanipalDeviceIdentifier);
|
||||||
|
}
|
||||||
|
|
||||||
#if PLATFORM_ANDROID
|
#if PLATFORM_ANDROID
|
||||||
return bIdentifierMatches;
|
return bMatched;
|
||||||
#else /* PLATFORM_ANDROID */
|
#else /* PLATFORM_ANDROID */
|
||||||
if (bIdentifierMatches)
|
if (bMatched)
|
||||||
{
|
{
|
||||||
if (GEngine->XRSystem.IsValid() && GEngine->XRSystem->IsHeadTrackingAllowed())
|
if (GEngine->XRSystem.IsValid() && GEngine->XRSystem->IsHeadTrackingAllowed())
|
||||||
{
|
{
|
||||||
@@ -116,13 +199,13 @@ bool FSGHeadMountDisplay::IsHtcViveFocus3()
|
|||||||
if (HmdMonitorInfo.ResolutionX > 5000
|
if (HmdMonitorInfo.ResolutionX > 5000
|
||||||
&& (HmdMonitorInfo.ResolutionY > 2500 && HmdMonitorInfo.ResolutionY < 2700))
|
&& (HmdMonitorInfo.ResolutionY > 2500 && HmdMonitorInfo.ResolutionY < 2700))
|
||||||
{
|
{
|
||||||
return true;
|
bMatched = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return bMatched;
|
||||||
#endif /* PLATFORM_ANDROID */
|
#endif /* PLATFORM_ANDROID */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,23 +54,9 @@ struct SENSEGLOVE_API FSGHeadMountDisplay
|
|||||||
public:
|
public:
|
||||||
static FName GetDeviceName();
|
static FName GetDeviceName();
|
||||||
|
|
||||||
FORCEINLINE static bool IsMetaQuest2()
|
static bool IsMetaQuest2();
|
||||||
{
|
static bool IsMetaQuestPro();
|
||||||
static const FName DeviceIdentifier{TEXT("Meta Quest 2")};
|
static bool IsMetaQuest3();
|
||||||
return GetDeviceName() == DeviceIdentifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
FORCEINLINE static bool IsMetaQuestPro()
|
|
||||||
{
|
|
||||||
static const FName DeviceIdentifier{TEXT("Meta Quest Pro")};
|
|
||||||
return GetDeviceName() == DeviceIdentifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
FORCEINLINE static bool IsMetaQuest3()
|
|
||||||
{
|
|
||||||
static const FName DeviceIdentifier{TEXT("Meta Quest 3")};
|
|
||||||
return GetDeviceName() == DeviceIdentifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool IsHtcVivePro();
|
static bool IsHtcVivePro();
|
||||||
static bool IsHtcViveFocus3();
|
static bool IsHtcViveFocus3();
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
[1mdiff --git a/Source/SenseGlove/Private/SenseGlove/SGHeadMountDisplay.cpp b/Source/SenseGlove/Private/SenseGlove/SGHeadMountDisplay.cpp[m
|
|
||||||
[1mindex bc65ea56..1bda9233 100644[m
|
|
||||||
[1m--- a/Source/SenseGlove/Private/SenseGlove/SGHeadMountDisplay.cpp[m
|
|
||||||
[1m+++ b/Source/SenseGlove/Private/SenseGlove/SGHeadMountDisplay.cpp[m
|
|
||||||
[36m@@ -38,6 +38,7 @@[m
|
|
||||||
#include "Engine/Engine.h"[m
|
|
||||||
#include "IHeadMountedDisplay.h"[m
|
|
||||||
#include "IXRTrackingSystem.h"[m
|
|
||||||
[32m+[m[32m#include "SGLog/SGLog.h"[m
|
|
||||||
[m
|
|
||||||
FName FSGHeadMountDisplay::GetDeviceName()[m
|
|
||||||
{[m
|
|
||||||
[36m@@ -52,6 +53,17 @@[m [mFName FSGHeadMountDisplay::GetDeviceName()[m
|
|
||||||
[m
|
|
||||||
ESGHeadMountDisplayDevice FSGHeadMountDisplay::GetDeviceType()[m
|
|
||||||
{[m
|
|
||||||
[32m+[m[32m if (GEngine->XRSystem.IsValid() && GEngine->XRSystem->IsHeadTrackingAllowed())[m
|
|
||||||
[32m+[m[32m {[m
|
|
||||||
[32m+[m[32m IHeadMountedDisplay::MonitorInfo HmdMonitorInfo;[m
|
|
||||||
[32m+[m[32m IHeadMountedDisplay* Device{GEngine->XRSystem->GetHMDDevice()};[m
|
|
||||||
[32m+[m[32m Device->GetHMDMonitorInfo(HmdMonitorInfo);[m
|
|
||||||
[32m+[m[32m const int32 ResX = HmdMonitorInfo.ResolutionX;[m
|
|
||||||
[32m+[m[32m const int32 ResY = HmdMonitorInfo.ResolutionY;[m
|
|
||||||
[32m+[m[32m SGLOG(HmdMonitorInfo.MonitorName, ResX, ResY, HmdMonitorInfo.DesktopX, HmdMonitorInfo.DesktopY,[m
|
|
||||||
[32m+[m[32m HmdMonitorInfo.WindowSizeX, HmdMonitorInfo.WindowSizeY);[m
|
|
||||||
[32m+[m[32m }[m
|
|
||||||
[32m+[m
|
|
||||||
if (IsMetaQuest2())[m
|
|
||||||
{[m
|
|
||||||
return ESGHeadMountDisplayDevice::MetaQuest2;[m
|
|
||||||
Reference in New Issue
Block a user