Update SolarXR patches

This commit is contained in:
Sapphire
2026-02-05 16:06:40 -06:00
parent e1c12b8720
commit 994f67d5fe
11 changed files with 52 additions and 42 deletions
@@ -1,4 +1,4 @@
From 19832bb0ff8394ee577978ee22980cdb593a2791 Mon Sep 17 00:00:00 2001
From 0595d01bb32c959e2e64b96d5187fdb5f0f2d929 Mon Sep 17 00:00:00 2001
From: Patrick Nicolas <patricknicolas@laposte.net>
Date: Tue, 22 Oct 2024 15:23:19 +0200
Subject: [PATCH 01/11] c/multi: early wake of compositor
@@ -1,4 +1,4 @@
From 722eac50d86482cf5974a60d721deb158dedb255 Mon Sep 17 00:00:00 2001
From bda12c93b506dd46980ca8f7e3dee6581fbdf549 Mon Sep 17 00:00:00 2001
From: Patrick Nicolas <patricknicolas@laposte.net>
Date: Tue, 8 Oct 2024 22:13:15 +0200
Subject: [PATCH 02/11] Use extern socket fd
@@ -1,4 +1,4 @@
From 52d939fa1dc9709b3d7773653c2663cb9d14b82b Mon Sep 17 00:00:00 2001
From a258427c4c622f838a0360c1f4c1ead3bd3e182a Mon Sep 17 00:00:00 2001
From: galister <85970-galister@users.noreply.gitlab.freedesktop.org>
Date: Sat, 23 Nov 2024 02:42:12 +0900
Subject: [PATCH 03/11] change environment blend mode selection logic
@@ -1,4 +1,4 @@
From 1f6b04eb3feb14ca332e0bdfc2ff0fd73c564049 Mon Sep 17 00:00:00 2001
From 4ebef00766669bcda9f27f57ef6e10da4e66a60e Mon Sep 17 00:00:00 2001
From: Patrick Nicolas <patricknicolas@laposte.net>
Date: Sat, 15 Mar 2025 22:19:48 +0100
Subject: [PATCH 04/11] st/oxr: forward 0 refresh rate
@@ -1,4 +1,4 @@
From 9bc7706f3fcd7fdaf31da2f305d6939a49817797 Mon Sep 17 00:00:00 2001
From fb72a558ef3ccdcd9428345efcd2d2f15e474d27 Mon Sep 17 00:00:00 2001
From: Patrick Nicolas <patricknicolas@laposte.net>
Date: Wed, 11 Sep 2024 22:56:29 +0200
Subject: [PATCH 05/11] Replace distortion with foveation
@@ -1,4 +1,4 @@
From 25660f30f1fffeeeec864e66280619a0fb127859 Mon Sep 17 00:00:00 2001
From c63be87d014aa9b67d7a8766a952a70701a629b4 Mon Sep 17 00:00:00 2001
From: no name <git-am@invalid>
Date: Sun, 28 Sep 2025 11:33:10 +0200
Subject: [PATCH 06/11] d/steamvr_lh: prevent crash on vive pro2/WiVRn
@@ -1,4 +1,4 @@
From 6d9977658df239ae367db0ace23ae5e3744899b5 Mon Sep 17 00:00:00 2001
From ccd1bef8ef971f29bf521abd74b9ebc97cb689fb Mon Sep 17 00:00:00 2001
From: Sapphire <imsapphire0@gmail.com>
Date: Fri, 7 Nov 2025 20:41:16 -0600
Subject: [PATCH 07/11] st/oxr: push XrEventDataInteractionProfileChanged when
@@ -1,4 +1,4 @@
From 8a05785464f1f8d1ba8f947b57ebf88d37177954 Mon Sep 17 00:00:00 2001
From b0e8426914c2b3bec366dbeaccce7db0260fa252 Mon Sep 17 00:00:00 2001
From: rcelyte <rcelyte@battletrains.org>
Date: Mon, 8 Dec 2025 19:29:28 +0000
Subject: [PATCH 08/11] d/solarxr: Fix flatpak socket path
@@ -1,4 +1,4 @@
From 677fcc118afabccb285c2b4f83c41ef7d3dbfa93 Mon Sep 17 00:00:00 2001
From b975312f8c05fc12cefe31af791d3db3bc34ac3c Mon Sep 17 00:00:00 2001
From: rcelyte <rcelyte@battletrains.org>
Date: Fri, 14 Nov 2025 19:48:59 +0000
Subject: [PATCH 09/11] d/solarxr: Sync at fixed rate This improves tracking
@@ -1,16 +1,18 @@
From 13b8bff84a6bddb7cbf961985575af5aaea09838 Mon Sep 17 00:00:00 2001
From c39ea86d5312a3b0da0e376161df57a590a4a856 Mon Sep 17 00:00:00 2001
From: rcelyte <rcelyte@battletrains.org>
Date: Mon, 15 Sep 2025 22:46:15 +0000
Subject: [PATCH 10/11] d/solarxr: Feed device poses to server
For now this utilizes SlimeVR's separate "SteamVR Feeder" API,
waiting on https://github.com/SlimeVR/SlimeVR-Server/issues/895.
---
src/xrt/drivers/CMakeLists.txt | 2 +
src/xrt/drivers/solarxr/feeder.c | 331 ++++++++++++++++++++
src/xrt/drivers/solarxr/feeder.c | 339 ++++++++++++++++++++
src/xrt/drivers/solarxr/feeder.h | 85 +++++
src/xrt/drivers/solarxr/protocol.h | 30 +-
src/xrt/drivers/solarxr/solarxr_device.c | 161 ++++++----
src/xrt/drivers/solarxr/solarxr_interface.h | 20 ++
6 files changed, 565 insertions(+), 64 deletions(-)
6 files changed, 573 insertions(+), 64 deletions(-)
create mode 100644 src/xrt/drivers/solarxr/feeder.c
create mode 100644 src/xrt/drivers/solarxr/feeder.h
@@ -29,10 +31,10 @@ index b44617e1a..040bd76b7 100644
solarxr/solarxr_device.c
diff --git a/src/xrt/drivers/solarxr/feeder.c b/src/xrt/drivers/solarxr/feeder.c
new file mode 100644
index 000000000..596a61008
index 000000000..3c79eef8b
--- /dev/null
+++ b/src/xrt/drivers/solarxr/feeder.c
@@ -0,0 +1,331 @@
@@ -0,0 +1,339 @@
+// Copyright 2025, rcelyte
+// SPDX-License-Identifier: BSL-1.0
+/*!
@@ -48,6 +50,9 @@ index 000000000..596a61008
+#include "xrt/xrt_device.h"
+
+#include <math.h>
+#include <pb.h>
+
+static const char manufacturer[] = "Monado";
+
+#define PROTOBUF_FLOAT(v_) ((uint8_t *)&(v_))[0], ((uint8_t *)&(v_))[1], ((uint8_t *)&(v_))[2], ((uint8_t *)&(v_))[3]
+#define PROTOBUF_INT32(v_) \
@@ -115,15 +120,20 @@ index 000000000..596a61008
+ // serialize announcement packet
+ const uint32_t serial_len = strlen(xdev->serial), name_len = strlen(xdev->str);
+ const uint8_t message_1[] = {
+ (3 << 3) | 2, PROTOBUF_INT32(0), // ProtobufMessage::tracker_added
+ (1 << 3) | 0, PROTOBUF_INT32(feeder->next_id), // TrackerAdded::tracker_id
+ (4 << 3) | 0, role, // TrackerAdded::tracker_role
+ (2 << 3) | 2, PROTOBUF_INT32(serial_len),
+ (3 << 3) | PB_WT_STRING, PROTOBUF_INT32(0), // ProtobufMessage::tracker_added
+ (1 << 3) | PB_WT_VARINT, PROTOBUF_INT32(feeder->next_id), // TrackerAdded::tracker_id
+ (4 << 3) | PB_WT_VARINT, role, // TrackerAdded::tracker_role
+ (2 << 3) | PB_WT_STRING, PROTOBUF_INT32(serial_len),
+ };
+ const uint8_t message_2[] = {
+ (3 << 3) | 2,
+ static_assert(sizeof(manufacturer) - 1 < 0x80, "");
+ uint8_t message_2[] = {
+ (5 << 3) | PB_WT_STRING,
+ sizeof(manufacturer) - 1,
+ // TrackerAdded::manufacturer
+ [2 + (sizeof(manufacturer) - 1)] = (3 << 3) | PB_WT_STRING,
+ PROTOBUF_INT32(name_len),
+ };
+ memcpy(&message_2[2], manufacturer, sizeof(manufacturer) - 1);
+ uint8_t packet[sizeof(struct solarxr_ipc_message) + sizeof(message_1) + sizeof(xdev->serial) +
+ sizeof(message_2) + sizeof(xdev->str)];
+ struct solarxr_ipc_message *const message = solarxr_ipc_message_start(packet, &packet[ARRAY_SIZE(packet)]);
@@ -139,6 +149,10 @@ index 000000000..596a61008
+ assert(false);
+ goto unlock;
+ }
+ const uint8_t tracker_added[] = {
+ PROTOBUF_INT32(packet_len - sizeof(*message) - sizeof((uint8_t[]){0, PROTOBUF_INT32(0)})),
+ };
+ memcpy(&message->body[1], tracker_added, sizeof(tracker_added));
+
+ // initialize tracked state for the device
+ struct feeder_device *const device = malloc(sizeof(*device));
@@ -155,10 +169,6 @@ index 000000000..596a61008
+ u_hashmap_int_insert(feeder->devices, (uint64_t)(uintptr_t)xdev, device);
+
+ // send the announcement
+ const uint8_t tracker_added[] = {
+ PROTOBUF_INT32(packet_len - sizeof(*message) - sizeof((uint8_t[]){0, PROTOBUF_INT32(0)})),
+ };
+ memcpy(&message->body[1], tracker_added, sizeof(tracker_added));
+ solarxr_ipc_socket_send_raw(&feeder->socket, packet, packet_len);
+ U_LOG_IFL_D(feeder->socket.log_level, " \"%s\" [id=%" PRIu32 " serial=\"%s\" role=TrackerRole::%s]",
+ xdev->str, device->id, xdev->serial, role_name);
@@ -237,10 +247,10 @@ index 000000000..596a61008
+ device->battery_charging = charging;
+ device->battery_charge = charge;
+ uint8_t message[] = {
+ (5 << 3) | 2, 0, // ProtobufMessage::battery
+ (1 << 3) | 0, PROTOBUF_INT32(device->id), // Battery::tracker_id
+ (2 << 3) | 5, PROTOBUF_FLOAT(charge), // Battery::battery_level
+ (3 << 3) | 0, charging, // Battery::is_charging
+ (5 << 3) | PB_WT_STRING, 0, // ProtobufMessage::battery
+ (1 << 3) | PB_WT_VARINT, PROTOBUF_INT32(device->id), // Battery::tracker_id
+ (2 << 3) | PB_WT_32BIT, PROTOBUF_FLOAT(charge), // Battery::battery_level
+ (3 << 3) | PB_WT_VARINT, charging, // Battery::is_charging
+ };
+ message[1] = sizeof(message) - 2;
+ solarxr_ipc_message_write_single(&data->packet_end, &data->packet[ARRAY_SIZE(data->packet)],
@@ -253,20 +263,20 @@ index 000000000..596a61008
+ if (xrt_device_get_tracked_pose(xdev, device->input_name, data->time, &relation) == XRT_SUCCESS &&
+ (relation.relation_flags & XRT_SPACE_RELATION_ORIENTATION_VALID_BIT) != 0) {
+ uint8_t message[30 + 15] = {
+ (1 << 3) | 2, 0, // ProtobufMessage::position
+ (1 << 3) | 0, PROTOBUF_INT32(device->id), // Position::tracker_id
+ (5 << 3) | 5, PROTOBUF_FLOAT(relation.pose.orientation.x), // Position::qx
+ (6 << 3) | 5, PROTOBUF_FLOAT(relation.pose.orientation.y), // Position::qy
+ (7 << 3) | 5, PROTOBUF_FLOAT(relation.pose.orientation.z), // Position::qz
+ (8 << 3) | 5, PROTOBUF_FLOAT(relation.pose.orientation.w), // Position::qw
+ (9 << 3) | 0, 3, // Position::data_source = DataSource::FULL
+ (1 << 3) | PB_WT_STRING, 0, // ProtobufMessage::position
+ (1 << 3) | PB_WT_VARINT, PROTOBUF_INT32(device->id), // Position::tracker_id
+ (5 << 3) | PB_WT_32BIT, PROTOBUF_FLOAT(relation.pose.orientation.x), // Position::qx
+ (6 << 3) | PB_WT_32BIT, PROTOBUF_FLOAT(relation.pose.orientation.y), // Position::qy
+ (7 << 3) | PB_WT_32BIT, PROTOBUF_FLOAT(relation.pose.orientation.z), // Position::qz
+ (8 << 3) | PB_WT_32BIT, PROTOBUF_FLOAT(relation.pose.orientation.w), // Position::qw
+ (9 << 3) | PB_WT_VARINT, 3, // Position::data_source = DataSource::FULL
+ };
+ uint32_t message_len = sizeof(message);
+ if ((relation.relation_flags & XRT_SPACE_RELATION_POSITION_VALID_BIT) != 0) {
+ const uint8_t position[15] = {
+ (2 << 3) | 5, PROTOBUF_FLOAT(relation.pose.position.x), // Position::x
+ (3 << 3) | 5, PROTOBUF_FLOAT(relation.pose.position.y), // Position::y
+ (4 << 3) | 5, PROTOBUF_FLOAT(relation.pose.position.z), // Position::z
+ (2 << 3) | PB_WT_32BIT, PROTOBUF_FLOAT(relation.pose.position.x), // Position::x
+ (3 << 3) | PB_WT_32BIT, PROTOBUF_FLOAT(relation.pose.position.y), // Position::y
+ (4 << 3) | PB_WT_32BIT, PROTOBUF_FLOAT(relation.pose.position.z), // Position::z
+ };
+ memcpy(&message[sizeof(message) - sizeof(position)], position, sizeof(position));
+ } else {
@@ -285,9 +295,9 @@ index 000000000..596a61008
+ if (status != device->last_status) {
+ device->last_status = status;
+ uint8_t message[] = {
+ (4 << 3) | 2, 0, // ProtobufMessage::tracker_status
+ (1 << 3) | 0, PROTOBUF_INT32(device->id), // TrackerStatus::tracker_id
+ (2 << 3) | 0, status, // TrackerStatus::status
+ (4 << 3) | PB_WT_STRING, 0, // ProtobufMessage::tracker_status
+ (1 << 3) | PB_WT_VARINT, PROTOBUF_INT32(device->id), // TrackerStatus::tracker_id
+ (2 << 3) | PB_WT_VARINT, status, // TrackerStatus::status
+ };
+ message[1] = sizeof(message) - 2;
+ solarxr_ipc_message_write_single(&data->packet_end, &data->packet[ARRAY_SIZE(data->packet)], message,
@@ -1,4 +1,4 @@
From fe9b669d6d023db39409fb60e66eb498d0610732 Mon Sep 17 00:00:00 2001
From 671ac1619a8986ef95cdb2dc3ca4c9db79930585 Mon Sep 17 00:00:00 2001
From: no name <git-am@invalid>
Date: Thu, 15 Jan 2026 12:13:06 +0100
Subject: [PATCH 11/11] Don't get pose data for fast path