From 59f752c70d8161871d6c55cf90acd342061779ea Mon Sep 17 00:00:00 2001 From: XxJSONDeruloxX Date: Thu, 15 Oct 2026 17:36:02 -0400 Subject: [PATCH] fix: provide Quest seated tracking origin --- docs/quest.md | 9 +++++++++ tools/tests/test_vr_chaperone.py | 25 ++++++++++++++++++++++++ tools/vr/src/driver_droiddeck.cpp | 9 +++++++++ tools/vr/src/xr_chaperone.h | 29 ++++++++++++++++++++++++++++ tools/vr/tests/test_xr_chaperone.cpp | 14 ++++++++++++++ 5 files changed, 86 insertions(+) create mode 100644 tools/tests/test_vr_chaperone.py create mode 100644 tools/vr/src/xr_chaperone.h create mode 100644 tools/vr/tests/test_xr_chaperone.cpp diff --git a/docs/quest.md b/docs/quest.md index 5beb4b430..28ec53063 100644 --- a/docs/quest.md +++ b/docs/quest.md @@ -77,6 +77,15 @@ is required. Other devices retain their existing SteamVR start behavior. The left Touch menu button is SteamVR's system button and toggles its dashboard. The right Meta button remains reserved by the headset OS. +The driver supplies SteamVR's version-5 chaperone configuration through +`Prop_DriverProvidedChaperoneJson_String`, following Valve's driver API. Standing +tracking keeps the OpenXR stage coordinates; seated tracking starts at the head's +position and yaw. No synthetic play area or collision walls are advertised. +Without a seated transform, SteamVR reported valid raw and standing poses but +invalid seated poses, causing Thumper to remain behind its tracking-loss fade. +On Quest, supplying both transforms made all three origins valid; seated height +started within a millimetre of zero while standing and raw height stayed unchanged. + The panel compositor detaches before OpenXR starts displaying guest frames. Session suspension accounts for the immersive activity while the panel is hidden. Closing the immersive activity stops SteamVR. The panel remains available for diff --git a/tools/tests/test_vr_chaperone.py b/tools/tests/test_vr_chaperone.py new file mode 100644 index 000000000..074cd2daf --- /dev/null +++ b/tools/tests/test_vr_chaperone.py @@ -0,0 +1,25 @@ +import json +from pathlib import Path +import shutil +import subprocess +import tempfile +import unittest + + +@unittest.skipUnless(shutil.which("g++"), "needs a Linux C++ compiler") +class XrChaperoneTest(unittest.TestCase): + def test_seated_origin_and_stage_preservation(self): + repository = Path(__file__).resolve().parents[2] + with tempfile.TemporaryDirectory() as directory: + executable = Path(directory) / "chaperone-test" + subprocess.run(["g++", "-std=c++17", "-Wall", "-Wextra", "-Werror", "-O2", + str(repository / "tools/vr/tests/test_xr_chaperone.cpp"), "-o", str(executable)], check=True) + result = json.loads(subprocess.check_output([str(executable)], text=True)) + self.assertEqual((result["jsonid"], result["version"]), ("chaperone_info", 5)) + self.assertEqual(result["time"], "2026-10-15T21:00:00Z") + universe, = result["universes"] + self.assertEqual(int(universe["universeID"]), 2) + self.assertEqual(universe["standing"], {"translation": [0, 0, 0], "yaw": 0}) + self.assertEqual(universe["collision_bounds"], []) + self.assertEqual(universe["play_area"], [0, 0]) + self.assertAlmostEqual(universe["seated"]["translation"][1], -1.6, places=6) diff --git a/tools/vr/src/driver_droiddeck.cpp b/tools/vr/src/driver_droiddeck.cpp index 50bdb42d8..7aef171ef 100644 --- a/tools/vr/src/driver_droiddeck.cpp +++ b/tools/vr/src/driver_droiddeck.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -21,6 +22,7 @@ #include "xr_frame_math.h" #include "xr_vsync_timing.h" #include "xr_touch_input.h" +#include "xr_chaperone.h" #define DD_EXPORT extern "C" __attribute__((visibility("default"))) @@ -557,6 +559,13 @@ public: VRProperties()->SetFloatProperty(c, Prop_DisplayFrequency_Float, hz); VRProperties()->SetFloatProperty(c, Prop_SecondsFromVsyncToPhotons_Float, 0.011f); VRProperties()->SetUint64Property(c, Prop_CurrentUniverseId_Uint64, 2); + if (xrMode_) { + char timestamp[32]; + std::time_t now = std::time(nullptr); std::tm utc{}; gmtime_r(&now, &utc); + std::strftime(timestamp, sizeof(timestamp), "%Y-%m-%dT%H:%M:%SZ", &utc); + const auto chaperone = xr_chaperone_json(xr.head, timestamp); + VRProperties()->SetStringProperty(c, Prop_DriverProvidedChaperoneJson_String, chaperone.c_str()); + } VRProperties()->SetBoolProperty(c, Prop_IsOnDesktop_Bool, false); VRProperties()->SetBoolProperty(c, Prop_DisplayDebugMode_Bool, false); directMode_ = VRSettings()->GetBool(kSettingsSection, "directMode"); diff --git a/tools/vr/src/xr_chaperone.h b/tools/vr/src/xr_chaperone.h new file mode 100644 index 000000000..5473cc5a6 --- /dev/null +++ b/tools/vr/src/xr_chaperone.h @@ -0,0 +1,29 @@ +#pragma once +#include "xr_tracking.h" +#include +#include +#include +#include +#include + +struct XrSeatedOrigin { + double yaw, translation[3]; +}; + +inline XrSeatedOrigin xr_seated_origin(const DroidDeckXrPose &head) { + const auto *q = head.orientation; + double yaw = std::atan2(2 * (q[0] * q[2] + q[3] * q[1]), 1 - 2 * (q[0] * q[0] + q[1] * q[1])); + double c = std::cos(yaw), s = std::sin(yaw); + return {-yaw, {-c * head.position[0] + s * head.position[2], -head.position[1], + -s * head.position[0] - c * head.position[2]}}; +} + +inline std::string xr_chaperone_json(const DroidDeckXrPose &head, const char *timestamp) { + auto seated = xr_seated_origin(head); + std::ostringstream json; json.imbue(std::locale::classic()); json << std::setprecision(9); + json << "{\"jsonid\":\"chaperone_info\",\"version\":5,\"time\":\"" << timestamp + << "\",\"universes\":[{\"universeID\":\"2\",\"standing\":{\"translation\":[0,0,0],\"yaw\":0}," + << "\"seated\":{\"translation\":[" << seated.translation[0] << ',' << seated.translation[1] << ',' << seated.translation[2] + << "],\"yaw\":" << seated.yaw << "},\"play_area\":[0,0],\"collision_bounds\":[]}]}"; + return json.str(); +} diff --git a/tools/vr/tests/test_xr_chaperone.cpp b/tools/vr/tests/test_xr_chaperone.cpp new file mode 100644 index 000000000..fb60a20c4 --- /dev/null +++ b/tools/vr/tests/test_xr_chaperone.cpp @@ -0,0 +1,14 @@ +#include "../src/xr_chaperone.h" +#include +#include + +int main() { + DroidDeckXrPose head{{0, 0, 0, 1}, {2, 1.6f, -3}, 15}; + auto origin = xr_seated_origin(head); + assert(origin.translation[0] == -2 && std::abs(origin.translation[1] + 1.6) < 1e-6 && origin.translation[2] == 3); + head.orientation[1] = head.orientation[3] = std::sqrt(0.5f); + origin = xr_seated_origin(head); + assert(std::abs(origin.yaw + 1.57079632679) < 1e-6); + assert(std::abs(origin.translation[0] + 3) < 1e-6 && std::abs(origin.translation[2] + 2) < 1e-6); + std::puts(xr_chaperone_json(head, "2026-10-15T21:00:00Z").c_str()); +}