Skip to content

Commit

Permalink
[OpenXR] Remove DoF filtering
Browse files Browse the repository at this point in the history
We were filtering by DoF in order not to suggest some profiles for
devices not supporting 6DoF controllers. On the one hand, this was
only needed for HVR so we better handle it as an exception. And on
the other hand, there is really no need to filter out profiles in
general as the runtime will select the most appropiate one.
  • Loading branch information
svillar committed Nov 6, 2024
1 parent 73b5abc commit 5794cd8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 37 deletions.
8 changes: 1 addition & 7 deletions app/src/main/cpp/DeviceUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,10 @@ vrb::GeometryPtr DeviceUtils::GetSphereGeometry(vrb::CreationContextPtr& context
return std::move(geometry);
}

device::DeviceType DeviceUtils::GetDeviceTypeFromSystem(bool is6DoF) {
device::DeviceType DeviceUtils::GetDeviceTypeFromSystem() {
char model[128];
int length = PopulateDeviceModelString(model);

#ifdef HVR
// Huawei glasses can be attached to multiple different phones, so we basically cannot filter
// by device type in this case.
return is6DoF ? device::HVR6DoF : device::HVR3DoF;
#endif

if (deviceNamesMap.empty()) {
deviceNamesMap.emplace("Quest", device::OculusQuest);
deviceNamesMap.emplace("Quest 2", device::OculusQuest2);
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/cpp/DeviceUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class DeviceUtils {
const uint32_t aMaxWidth, const uint32_t aMaxHeight,
uint32_t& aTargetWidth, uint32_t& aTargetHeight);
static vrb::GeometryPtr GetSphereGeometry(vrb::CreationContextPtr& context, uint32_t resolution, float radius);
static device::DeviceType GetDeviceTypeFromSystem(bool is6DoF);
static device::DeviceType GetDeviceTypeFromSystem();

private:
static vrb::Matrix CalculateReorientationMatrixWithThreshold(const vrb::Matrix& aHeadTransform, const vrb::Vector& aHeightPosition,
Expand Down
20 changes: 0 additions & 20 deletions app/src/openxr/cpp/OpenXRInputMappings.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,8 @@ namespace crow {
OpenXRHandFlags hand;
};

enum DoF {
IS_3DOF,
IS_6DOF,
};

struct OpenXRInputMapping {
const char* const path { nullptr };
DoF systemDoF;
const char* const leftControllerModel { nullptr };
const char* const rightControllerModel { nullptr };
device::DeviceType controllerType { device::OculusQuest };
Expand All @@ -143,7 +137,6 @@ namespace crow {
// Oculus Touch v2: https://github.com/immersive-web/webxr-input-profiles/blob/master/packages/registry/profiles/oculus/oculus-touch-v2.json
const OpenXRInputMapping OculusTouch {
"/interaction_profiles/oculus/touch_controller",
IS_6DOF,
"vr_controller_oculusquest_left.obj",
"vr_controller_oculusquest_right.obj",
device::OculusQuest,
Expand All @@ -170,7 +163,6 @@ namespace crow {
// Oculus Touch v3: https://github.com/immersive-web/webxr-input-profiles/blob/master/packages/registry/profiles/oculus/oculus-touch-v3.json
const OpenXRInputMapping OculusTouch2 {
"/interaction_profiles/oculus/touch_controller",
IS_6DOF,
"vr_controller_oculusquest2_left.obj",
"vr_controller_oculusquest2_right.obj",
device::OculusQuest2,
Expand All @@ -197,7 +189,6 @@ namespace crow {
// Meta Quest Touch Pro: https://github.com/immersive-web/webxr-input-profiles/blob/main/packages/registry/profiles/meta/meta-quest-touch-pro.json
const OpenXRInputMapping MetaQuestTouchPro {
"/interaction_profiles/oculus/touch_controller",
IS_6DOF,
"vr_controller_metaquestpro_left.obj",
"vr_controller_metaquestpro_right.obj",
device::MetaQuestPro,
Expand All @@ -224,7 +215,6 @@ namespace crow {
// Meta Quest Touch Plus: https://github.com/immersive-web/webxr-input-profiles/blob/master/packages/registry/profiles/meta/meta-quest-touch-plus.json
const OpenXRInputMapping MetaTouchPlus {
"/interaction_profiles/oculus/touch_controller",
IS_6DOF,
"vr_controller_metaquest3_left.obj",
"vr_controller_metaquest3_right.obj",
device::MetaQuest3,
Expand All @@ -251,7 +241,6 @@ namespace crow {
// Pico controller: this definition was created for the Pico 4, but the Neo 3 will likely also be compatible
const OpenXRInputMapping Pico4xOld {
"/interaction_profiles/pico/neo3_controller",
IS_6DOF,
"vr_controller_pico4_left.obj",
"vr_controller_pico4_right.obj",
device::Pico4x,
Expand All @@ -276,7 +265,6 @@ namespace crow {

const OpenXRInputMapping Pico4x {
"/interaction_profiles/bytedance/pico4_controller",
IS_6DOF,
"vr_controller_pico4_left.obj",
"vr_controller_pico4_right.obj",
device::Pico4x,
Expand All @@ -301,7 +289,6 @@ namespace crow {

const OpenXRInputMapping Pico4U {
"/interaction_profiles/bytedance/pico4_controller",
IS_6DOF,
"vr_controller_pico4u_left.obj",
"vr_controller_pico4u_right.obj",
device::Pico4U,
Expand All @@ -326,7 +313,6 @@ namespace crow {

const OpenXRInputMapping PicoNeo3 {
"/interaction_profiles/pico/neo3_controller",
IS_6DOF,
"vr_controller_piconeo3_left.obj",
"vr_controller_piconeo3_right.obj",
device::PicoNeo3,
Expand All @@ -352,7 +338,6 @@ namespace crow {
// HVR 3DOF: https://github.com/immersive-web/webxr-input-profiles/blob/master/packages/registry/profiles/generic/generic-trigger-touchpad.json
const OpenXRInputMapping Hvr3DOF {
"/interaction_profiles/huawei/controller",
IS_3DOF,
nullptr,
"vr_controller_focus.obj",
device::HVR3DoF,
Expand All @@ -372,7 +357,6 @@ namespace crow {

const OpenXRInputMapping Hvr6DOF {
"/interaction_profiles/huawei/6dof_controller",
IS_6DOF,
"hvr_6dof_left.obj",
"hvr_6dof_right.obj",
device::HVR6DoF,
Expand Down Expand Up @@ -403,7 +387,6 @@ namespace crow {

const OpenXRInputMapping LenovoVRX {
"/interaction_profiles/oculus/touch_controller",
IS_6DOF,
"vr_controller_vrx_left.obj",
"vr_controller_vrx_right.obj",
device::LenovoVRX,
Expand All @@ -429,7 +412,6 @@ namespace crow {

const OpenXRInputMapping MagicLeap2 {
"/interaction_profiles/ml/ml2_controller",
IS_6DOF,
"",
"vr_controller_magicleap2.obj",
device::MagicLeap2,
Expand All @@ -449,7 +431,6 @@ namespace crow {

const OpenXRInputMapping HandInteraction {
kInteractionProfileHandInteraction,
IS_6DOF,
"",
"",
device::UnknownType,
Expand All @@ -464,7 +445,6 @@ namespace crow {

const OpenXRInputMapping MSFTHandInteraction {
kInteractionProfileMSFTHandInteraction,
IS_6DOF,
"",
"",
device::UnknownType,
Expand Down
16 changes: 7 additions & 9 deletions app/src/openxr/cpp/OpenXRInputSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,13 @@ XrResult OpenXRInputSource::Initialize()
RETURN_IF_XR_FAILED(mActionSet.GetOrCreateAction(XR_ACTION_TYPE_VIBRATION_OUTPUT, "haptic", OpenXRHandFlags::Both, mHapticAction));

// Filter mappings
#if HVR
// Huawei glasses can be attached to multiple phones, so we can't filter by device type.
bool systemIs6DoF = mSystemProperties.trackingProperties.positionTracking == XR_TRUE;
auto systemDoF = systemIs6DoF ? DoF::IS_6DOF : DoF::IS_3DOF;
mDeviceType = DeviceUtils::GetDeviceTypeFromSystem(systemIs6DoF);
// Add a workaround for Monado not reporting properly device capabilities
// https://gitlab.freedesktop.org/monado/monado/-/issues/265
if (mDeviceType == device::LenovoVRX) {
systemIs6DoF = true;
systemDoF = DoF::IS_6DOF;
}
mDeviceType = return systemIs6DoF ? device::HVR6DoF : device::HVR3DoF;
#else
mDeviceType = DeviceUtils::GetDeviceTypeFromSystem();
#endif
for (auto& mapping: OpenXRInputMappings) {
// Always populate default/fall-back profiles
if (mapping.controllerType == device::UnknownType) {
Expand All @@ -80,7 +78,7 @@ XrResult OpenXRInputSource::Initialize()
mMappings.back().controllerType = mDeviceType;
continue;
}
if ((mDeviceType != mapping.controllerType) || (systemDoF != mapping.systemDoF))
if (mDeviceType != mapping.controllerType)
continue;
mMappings.push_back(mapping);
}
Expand Down

0 comments on commit 5794cd8

Please sign in to comment.