diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 6bb9d6b9..dddc5896 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -60,6 +60,7 @@
+
interaction_profiles{
"/user/hand/right/input/thumbstick/touch",
"/user/hand/right/input/thumbrest/touch",
}},
+ interaction_profile{
+ "/interaction_profiles/htc/vive_xr_tracker",
+ {"XR_HTC_vive_xr_tracker_interaction", "XR_HTC_path_enumeration"},
+ {},
+ },
interaction_profile{
"/interaction_profiles/ext/eye_gaze_interaction",
{"XR_EXT_eye_gaze_interaction"},
@@ -921,6 +926,18 @@ void application::initialize_actions()
profile.input_sources.push_back("/user/hand/right/input/palm_ext/pose");
}
+ // Dynamically add VIVE XR Trackers to the profile if available
+ if (utils::contains(profile.required_extensions, XR_HTC_VIVE_XR_TRACKER_INTERACTION_EXTENSION_NAME))
+ {
+ for (const auto & user_path: get_htc_body_tracker().get_paths())
+ {
+ for (const auto & input_path: get_htc_body_tracker().get_paths(user_path))
+ {
+ profile.input_sources.push_back(path_to_string(user_path) + path_to_string(input_path));
+ }
+ }
+ }
+
suggested_bindings.emplace(profile.profile_name, std::vector{});
for (const std::string & source: profile.input_sources)
@@ -957,6 +974,8 @@ void application::initialize_actions()
spaces[size_t(xr::spaces::palm_right)] = xr_session.create_action_space(a);
else if (name == "/user/hand/left/input/palm_ext/pose")
spaces[size_t(xr::spaces::palm_left)] = xr_session.create_action_space(a);
+ else if (name.contains("/input/entity_htc/pose"))
+ application::get_htc_body_tracker().add(xr_session.create_action_space(a));
}
// Build an action set for each scene
@@ -1040,6 +1059,8 @@ void application::initialize()
opt_extensions.push_back(XR_FB_PASSTHROUGH_EXTENSION_NAME);
opt_extensions.push_back(XR_HTC_PASSTHROUGH_EXTENSION_NAME);
opt_extensions.push_back(XR_HTC_FACIAL_TRACKING_EXTENSION_NAME);
+ opt_extensions.push_back(XR_HTC_PATH_ENUMERATION_EXTENSION_NAME);
+ opt_extensions.push_back(XR_HTC_VIVE_XR_TRACKER_INTERACTION_EXTENSION_NAME);
opt_extensions.push_back(XR_FB_FACE_TRACKING2_EXTENSION_NAME);
opt_extensions.push_back(XR_FB_BODY_TRACKING_EXTENSION_NAME);
opt_extensions.push_back(XR_META_BODY_TRACKING_FULL_BODY_EXTENSION_NAME);
@@ -1152,6 +1173,12 @@ void application::initialize()
fb_body_tracking_supported = fb_body_properties.supportsBodyTracking;
}
+ if (utils::contains_all(xr_extensions, std::array{XR_HTC_PATH_ENUMERATION_EXTENSION_NAME, XR_HTC_VIVE_XR_TRACKER_INTERACTION_EXTENSION_NAME}))
+ {
+ spdlog::info(" HTC body tracking support: true");
+ htc_body_tracking_supported = true;
+ }
+
if (utils::contains(xr_extensions, XR_BD_BODY_TRACKING_EXTENSION_NAME))
{
XrSystemBodyTrackingPropertiesBD bd_body_properties = xr_system_id.bd_body_tracking_properties();
@@ -1228,6 +1255,11 @@ void application::initialize()
fb_body_tracker = xr_session.create_fb_body_tracker();
}
+ if (htc_body_tracking_supported)
+ {
+ htc_body_tracker = xr_session.create_htc_body_tracker();
+ }
+
if (pico_body_tracking_supported)
{
pico_body_tracker = xr_session.create_pico_body_tracker();
@@ -1767,7 +1799,13 @@ void application::poll_events()
exit_requested = true;
}
break;
- case XR_TYPE_EVENT_DATA_INTERACTION_PROFILE_CHANGED:
+ case XR_TYPE_EVENT_DATA_INTERACTION_PROFILE_CHANGED: {
+ if (application::get_htc_body_tracking_supported())
+ {
+ application::get_htc_body_tracker().update_active();
+ }
+ }
+ break;
case XR_TYPE_EVENT_DATA_REFERENCE_SPACE_CHANGE_PENDING:
break;
case XR_TYPE_EVENT_DATA_SESSION_STATE_CHANGED: {
diff --git a/client/application.h b/client/application.h
index b429cf50..75a8989e 100644
--- a/client/application.h
+++ b/client/application.h
@@ -24,6 +24,7 @@
#include "xr/fb_body_tracker.h"
#include "xr/fb_face_tracker2.h"
#include "xr/hand_tracker.h"
+#include "xr/htc_body_tracker.h"
#include "xr/htc_face_tracker.h"
#include "xr/pico_face_tracker.h"
#ifdef __ANDROID__
@@ -140,6 +141,8 @@ class application : public singleton
bool fb_body_tracking_supported = false;
xr::fb_body_tracker fb_body_tracker;
+ bool htc_body_tracking_supported = false;
+ xr::htc_body_tracker htc_body_tracker;
bool pico_body_tracking_supported = false;
xr::pico_body_tracker pico_body_tracker;
@@ -456,6 +459,11 @@ public:
return instance().fb_body_tracking_supported;
}
+ static bool get_htc_body_tracking_supported()
+ {
+ return instance().htc_body_tracking_supported;
+ }
+
static bool get_pico_body_tracking_supported()
{
return instance().pico_body_tracking_supported;
@@ -506,6 +514,11 @@ public:
return instance().fb_body_tracker;
}
+ static xr::htc_body_tracker & get_htc_body_tracker()
+ {
+ return instance().htc_body_tracker;
+ }
+
static xr::pico_body_tracker & get_pico_body_tracker()
{
return instance().pico_body_tracker;
diff --git a/client/configuration.cpp b/client/configuration.cpp
index ca8685e6..d39bcaab 100644
--- a/client/configuration.cpp
+++ b/client/configuration.cpp
@@ -130,6 +130,12 @@ bool configuration::check_feature(feature f) const
if (not application::get_fb_body_tracking_supported())
return false;
break;
+ case model::htc_vive_focus_3:
+ case model::htc_vive_xr_elite:
+ case model::htc_vive_focus_vision:
+ if (not application::get_htc_body_tracking_supported())
+ return false;
+ break;
case model::pico_neo_3:
case model::pico_4:
case model::pico_4s:
diff --git a/client/scenes/lobby_gui.cpp b/client/scenes/lobby_gui.cpp
index a764e275..b258cef2 100644
--- a/client/scenes/lobby_gui.cpp
+++ b/client/scenes/lobby_gui.cpp
@@ -741,7 +741,7 @@ void scenes::lobby::gui_settings()
}
{
- ImGui::BeginDisabled(not(application::get_fb_body_tracking_supported() or application::get_pico_body_tracking_supported()));
+ ImGui::BeginDisabled(not(application::get_fb_body_tracking_supported() or application::get_htc_body_tracking_supported() or application::get_pico_body_tracking_supported()));
bool enabled = config.check_feature(feature::body_tracking);
if (ImGui::Checkbox(_S("Enable body tracking"), &enabled))
{
@@ -759,6 +759,8 @@ void scenes::lobby::gui_settings()
{
if (application::get_fb_body_tracking_supported())
tooltip(_("Requires 'Hand and body tracking' to be enabled in the Quest movement tracking settings,\notherwise body data will be guessed from controller and headset positions"));
+ else if (application::get_htc_body_tracking_supported())
+ tooltip(_("Forwards positions of Vive Ultimate Trackers"));
else if (application::get_pico_body_tracking_supported())
tooltip(_("Uses the Pico Motion Trackers to track body joint positions"));
}
@@ -1482,7 +1484,7 @@ void scenes::lobby::draw_features_status(XrTime predicted_display_time)
});
}
- if (application::get_fb_body_tracking_supported() or application::get_pico_body_tracking_supported())
+ if (application::get_fb_body_tracking_supported() or application::get_htc_body_tracking_supported() or application::get_pico_body_tracking_supported())
{
items.push_back({
.f = feature::body_tracking,
diff --git a/client/scenes/stream.cpp b/client/scenes/stream.cpp
index c4a0aa88..f7cb8d49 100644
--- a/client/scenes/stream.cpp
+++ b/client/scenes/stream.cpp
@@ -18,6 +18,8 @@
*/
#include "utils/overloaded.h"
#include "xr/fb_body_tracker.h"
+#include "xr/htc_body_tracker.h"
+#include "xr/pico_body_tracker.h"
#define GLM_FORCE_RADIANS
#include "stream.h"
@@ -230,6 +232,8 @@ std::shared_ptr scenes::stream::create(std::unique_ptr
+#include
#include
#include
#include
diff --git a/client/xr/htc_body_tracker.cpp b/client/xr/htc_body_tracker.cpp
new file mode 100644
index 00000000..b2d0b2ab
--- /dev/null
+++ b/client/xr/htc_body_tracker.cpp
@@ -0,0 +1,156 @@
+/*
+ * WiVRn VR streaming
+ * Copyright (C) 2025 Awzri
+ * Copyright (C) 2025 Sapphire
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#include "htc_body_tracker.h"
+#include "xr/details/enumerate.h"
+#include "xr/htc_exts.h"
+#include "xr/xr.h"
+#include
+
+// Note: This utilizes extensions not present in the OpenXR spec!
+// For more info see:
+// https://hub.vive.com/apidoc/api/VIVE.OpenXR.Tracker.ViveXRTracker.html
+// https://hub.vive.com/apidoc/api/VIVE.OpenXR.VivePathEnumerationHelper.xrEnumeratePathsForInteractionProfileHTCDelegate.html
+
+xr::vive_xr_tracker::vive_xr_tracker(xr::space && space) :
+ space(std::move(space)) {}
+void xr::vive_xr_tracker::set_active(bool active)
+{
+ is_active = active;
+}
+bool xr::vive_xr_tracker::get_active() const
+{
+ return is_active;
+}
+XrSpace xr::vive_xr_tracker::get_space() const
+{
+ return space;
+}
+
+static wivrn::from_headset::body_tracking::pose locate_space(XrSpace space, XrSpace reference, XrTime time)
+{
+ XrSpaceVelocity velocity{
+ .type = XR_TYPE_SPACE_VELOCITY,
+ };
+
+ XrSpaceLocation location{
+ .type = XR_TYPE_SPACE_LOCATION,
+ .next = &velocity,
+ };
+
+ xrLocateSpace(space, reference, time, &location);
+
+ wivrn::from_headset::body_tracking::pose res{
+ .pose = location.pose,
+ .flags = 0,
+ };
+
+ if (location.locationFlags & XR_SPACE_LOCATION_ORIENTATION_VALID_BIT)
+ res.flags |= wivrn::from_headset::body_tracking::orientation_valid;
+
+ if (location.locationFlags & XR_SPACE_LOCATION_POSITION_VALID_BIT)
+ res.flags |= wivrn::from_headset::body_tracking::position_valid;
+
+ if (location.locationFlags & XR_SPACE_LOCATION_ORIENTATION_TRACKED_BIT)
+ res.flags |= wivrn::from_headset::body_tracking::orientation_tracked;
+
+ if (location.locationFlags & XR_SPACE_LOCATION_POSITION_TRACKED_BIT)
+ res.flags |= wivrn::from_headset::body_tracking::position_tracked;
+
+ return res;
+}
+
+std::vector xr::htc_body_tracker::get_roles()
+{
+ auto paths = get_paths();
+ std::vector roles{};
+ roles.reserve(paths.size());
+
+ for (auto & path: paths)
+ {
+ XrInputSourceLocalizedNameGetInfo get_info{
+ .type = XR_TYPE_INPUT_SOURCE_LOCALIZED_NAME_GET_INFO,
+ .next = nullptr,
+ .sourcePath = path,
+ .whichComponents = XR_INPUT_SOURCE_LOCALIZED_NAME_USER_PATH_BIT,
+ };
+
+ roles.emplace_back(xr::details::enumerate(xrGetInputSourceLocalizedName, s, &get_info));
+ }
+
+ return roles;
+}
+
+xr::htc_body_tracker::htc_body_tracker(instance & inst, session & s) :
+ inst(&inst),
+ s(s)
+{
+ xrEnumeratePathsForInteractionProfileHTC = inst.get_proc("xrEnumeratePathsForInteractionProfileHTC");
+}
+
+std::vector xr::htc_body_tracker::get_paths(XrPath user_path)
+{
+ assert(xrEnumeratePathsForInteractionProfileHTC);
+ XrPath tracker_profile = inst->string_to_path("/interaction_profiles/htc/vive_xr_tracker");
+
+ XrPathsForInteractionProfileEnumerateInfoHTC profile_info{
+ .type = XR_TYPE_UNKNOWN,
+ .next = nullptr,
+ .interactionProfile = tracker_profile,
+ .userPath = user_path,
+ };
+ return xr::details::enumerate(xrEnumeratePathsForInteractionProfileHTC, *inst, profile_info);
+}
+
+void xr::htc_body_tracker::add(xr::space && space)
+{
+ trackers.emplace_back(std::move(space));
+}
+size_t xr::htc_body_tracker::count() const
+{
+ return trackers.size();
+}
+
+void xr::htc_body_tracker::update_active()
+{
+ auto roles = get_roles();
+ assert(roles.size() >= trackers.size());
+ for (int i = 0; i < trackers.size(); i++)
+ trackers[i].set_active(!roles[i].contains('_'));
+}
+
+std::array xr::htc_body_tracker::locate_spaces(XrTime time, XrSpace reference)
+{
+ std::array poses{};
+
+ for (int i = 0; i < trackers.size(); i++)
+ {
+ auto & tracker = trackers.at(i);
+ wivrn::from_headset::body_tracking::pose pose{
+ .pose = {},
+ .flags = 0,
+ };
+ if (tracker.get_active())
+ pose = locate_space(tracker.get_space(), reference, time);
+
+ poses[i] = pose;
+ }
+
+ return poses;
+}
diff --git a/client/xr/htc_body_tracker.h b/client/xr/htc_body_tracker.h
new file mode 100644
index 00000000..d694f570
--- /dev/null
+++ b/client/xr/htc_body_tracker.h
@@ -0,0 +1,66 @@
+/*
+ * WiVRn VR streaming
+ * Copyright (C) 2025 Awzri
+ * Copyright (C) 2025 Sapphire
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#pragma once
+
+#include "wivrn_packets.h"
+#include "xr/htc_exts.h"
+#include "xr/space.h"
+#include
+#include
+#include
+
+namespace xr
+{
+class instance;
+class session;
+
+class vive_xr_tracker
+{
+ bool is_active = false;
+ xr::space space;
+
+public:
+ vive_xr_tracker(xr::space && s);
+ void set_active(bool active);
+ bool get_active() const;
+ XrSpace get_space() const;
+};
+
+class htc_body_tracker
+{
+ instance * inst;
+ XrSession s;
+ std::vector trackers;
+
+ PFN_xrEnumeratePathsForInteractionProfileHTC xrEnumeratePathsForInteractionProfileHTC{};
+
+ std::vector get_roles();
+
+public:
+ htc_body_tracker() = default;
+ htc_body_tracker(instance & inst, session & s);
+
+ std::vector get_paths(XrPath user_path = XR_NULL_PATH);
+ void add(xr::space && space);
+ size_t count() const;
+ void update_active();
+ std::array locate_spaces(XrTime time, XrSpace reference);
+};
+} // namespace xr
diff --git a/client/xr/session.cpp b/client/xr/session.cpp
index 5c92a8e7..fe816159 100644
--- a/client/xr/session.cpp
+++ b/client/xr/session.cpp
@@ -24,6 +24,7 @@
#include "openxr/openxr.h"
#include "utils/contains.h"
#include "xr/fb_body_tracker.h"
+#include "xr/htc_body_tracker.h"
#include "xr/instance.h"
#include "xr/pico_body_tracker.h"
#include "xr/system.h"
@@ -149,6 +150,11 @@ xr::fb_body_tracker xr::session::create_fb_body_tracker()
return {*inst, *this};
}
+xr::htc_body_tracker xr::session::create_htc_body_tracker()
+{
+ return {*inst, *this};
+}
+
xr::pico_body_tracker xr::session::create_pico_body_tracker()
{
XrBodyTrackerCreateInfoBD create_info{
diff --git a/client/xr/session.h b/client/xr/session.h
index e3c31647..0086ce7f 100644
--- a/client/xr/session.h
+++ b/client/xr/session.h
@@ -29,6 +29,7 @@
#include "fb_body_tracker.h"
#include "fb_face_tracker2.h"
#include "hand_tracker.h"
+#include "htc_body_tracker.h"
#include "htc_face_tracker.h"
#include "passthrough.h"
#include "pico_body_tracker.h"
@@ -57,6 +58,7 @@ public:
htc_face_tracker create_htc_face_tracker(XrFacialTrackingTypeHTC);
pico_face_tracker create_pico_face_tracker();
fb_body_tracker create_fb_body_tracker();
+ htc_body_tracker create_htc_body_tracker();
pico_body_tracker create_pico_body_tracker();
std::vector get_swapchain_formats() const;
diff --git a/common/xr/htc_exts.h b/common/xr/htc_exts.h
new file mode 100644
index 00000000..2186293d
--- /dev/null
+++ b/common/xr/htc_exts.h
@@ -0,0 +1,36 @@
+// clang-format off
+#pragma once
+
+#include
+
+// XR_HTC_vive_xr_tracker_interaction is a preprocessor guard. Do not pass it to API calls.
+#define XR_HTC_vive_xr_tracker_interaction 1
+#define XR_HTC_vive_xr_tracker_interaction_SPEC_VERSION 1
+#define XR_HTC_VIVE_XR_TRACKER_INTERACTION_EXTENSION_NAME "XR_HTC_vive_xr_tracker_interaction"
+
+// XR_HTC_path_enumeration is a preprocessor guard. Do not pass it to API calls.
+#define XR_HTC_path_enumeration 1
+#define XR_HTC_path_enumeration_SPEC_VERSION 1
+#define XR_HTC_PATH_ENUMERATION_EXTENSION_NAME "XR_HTC_path_enumeration"
+
+typedef struct XrPathsForInteractionProfileEnumerateInfoHTC {
+ XrStructureType type;
+ const void* XR_MAY_ALIAS next;
+ XrPath interactionProfile;
+ XrPath userPath;
+} XrPathsForInteractionProfileEnumerateInfoHTC;
+
+typedef XrResult (XRAPI_PTR *PFN_xrEnumeratePathsForInteractionProfileHTC)(XrInstance instance, XrPathsForInteractionProfileEnumerateInfoHTC createInfo, uint32_t pathCapacityInput, uint32_t* pathCountOutput, XrPath* paths);
+
+#ifndef XR_NO_PROTOTYPES
+#ifdef XR_EXTENSION_PROTOTYPES
+XRAPI_ATTR XrResult XRAPI_CALL xrEnumeratePathsForInteractionProfileHTC(
+ XrInstance instance,
+ XrPathsForInteractionProfileEnumerateInfoHTC createInfo,
+ uint32_t pathCapacityInput,
+ uint32_t* pathCountOutput,
+ XrPath* paths);
+#endif /* XR_EXTENSION_PROTOTYPES */
+#endif /* !XR_NO_PROTOTYPES */
+
+// clang-format on