From 6515838efacb688f02a96cd05dd531834a284778 Mon Sep 17 00:00:00 2001 From: Sapphire Date: Wed, 28 Jan 2026 15:15:44 -0600 Subject: [PATCH 1/3] Pass padded_string json into SearchUniverse instead of file path --- src/VRDriver.cpp | 54 ++++++++++++++++++++++++++---------------------- src/VRDriver.hpp | 2 +- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/src/VRDriver.cpp b/src/VRDriver.cpp index c249d13..36442cd 100644 --- a/src/VRDriver.cpp +++ b/src/VRDriver.cpp @@ -384,31 +384,25 @@ SlimeVRDriver::UniverseTranslation SlimeVRDriver::UniverseTranslation::parse(sim return res; } -std::optional SlimeVRDriver::VRDriver::SearchUniverse(std::string path, uint64_t target) { - try { - auto json = simdjson::padded_string::load(path); // load VR Path Registry - simdjson::ondemand::document doc = json_parser_.iterate(json); +std::optional SlimeVRDriver::VRDriver::SearchUniverse(const simdjson::padded_string &json, uint64_t target) { + simdjson::ondemand::document doc = json_parser_.iterate(json); - for (simdjson::ondemand::object uni: doc["universes"]) { - // TODO: universeID comes after the translation, would it be faster to unconditionally parse the translation? - auto elem = uni["universeID"]; - uint64_t parsed_universe; + for (simdjson::ondemand::object uni: doc["universes"]) { + // TODO: universeID comes after the translation, would it be faster to unconditionally parse the translation? + auto elem = uni["universeID"]; + uint64_t parsed_universe; - auto is_integer = elem.is_integer(); - if (!is_integer.error() && is_integer.value_unsafe()) { - parsed_universe = elem.get_uint64(); - } else { - parsed_universe = elem.get_uint64_in_string(); - } + auto is_integer = elem.is_integer(); + if (!is_integer.error() && is_integer.value_unsafe()) { + parsed_universe = elem.get_uint64(); + } else { + parsed_universe = elem.get_uint64_in_string(); + } - if (parsed_universe == target) { - auto standing_uni = uni["standing"].get_object(); - return SlimeVRDriver::UniverseTranslation::parse(standing_uni.value()); - } + if (parsed_universe == target) { + auto standing_uni = uni["standing"].get_object(); + return SlimeVRDriver::UniverseTranslation::parse(standing_uni.value()); } - } catch (simdjson::simdjson_error& e) { - logger_->Log("Error getting universes from {}: {}", path, e.what()); - return std::nullopt; } return std::nullopt; @@ -417,14 +411,24 @@ std::optional SlimeVRDriver::VRDriver::Searc std::optional SlimeVRDriver::VRDriver::SearchUniverses(uint64_t target) { auto driver_chap_path = vr::VRProperties()->GetStringProperty(vr::VRProperties()->TrackedDeviceToPropertyContainer(0), vr::Prop_DriverProvidedChaperonePath_String); if (driver_chap_path != "") { - auto driver_res = SearchUniverse(driver_chap_path, target); - if (driver_res.has_value()) { - return driver_res.value(); + try { + auto driver_res = SearchUniverse(simdjson::padded_string::load(driver_chap_path).take_value(), target); + if (driver_res.has_value()) { + return driver_res.value(); + } + } + catch (simdjson::simdjson_error &e) { + logger_->Log("Error loading chaperone from driver-provided path {}: {}", driver_chap_path, e.what()); } } if (default_chap_path_.has_value()) { - return SearchUniverse(default_chap_path_.value(), target); + try { + return SearchUniverse(simdjson::padded_string::load(default_chap_path_.value()).take_value(), target); + } + catch (simdjson::simdjson_error &e) { + logger_->Log("Error loading chaperone from default path {}: {}", default_chap_path_.value(), e.what()); + } } return std::nullopt; diff --git a/src/VRDriver.hpp b/src/VRDriver.hpp index 0dbe26a..e6c77ce 100644 --- a/src/VRDriver.hpp +++ b/src/VRDriver.hpp @@ -71,7 +71,7 @@ namespace SlimeVRDriver { vr::ETrackedPropertyError last_universe_error_; std::optional> current_universe_ = std::nullopt; - std::optional SearchUniverse(std::string path, uint64_t target); + std::optional SearchUniverse(const simdjson::padded_string &json, uint64_t target); std::optional SearchUniverses(uint64_t target); }; }; \ No newline at end of file From af44eebd29b27e93ae87a5f769a4fb0068adf704 Mon Sep 17 00:00:00 2001 From: Sapphire Date: Wed, 28 Jan 2026 15:16:52 -0600 Subject: [PATCH 2/3] Search universes in Prop_DriverProvidedChaperoneJson_String --- libraries/openvr | 2 +- src/VRDriver.cpp | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/libraries/openvr b/libraries/openvr index 4c85abc..9182530 160000 --- a/libraries/openvr +++ b/libraries/openvr @@ -1 +1 @@ -Subproject commit 4c85abcb7f7f1f02adaf3812018c99fc593bc341 +Subproject commit 91825305130f446f82054c1ec3d416321ace0072 diff --git a/src/VRDriver.cpp b/src/VRDriver.cpp index 36442cd..b78037a 100644 --- a/src/VRDriver.cpp +++ b/src/VRDriver.cpp @@ -409,7 +409,21 @@ std::optional SlimeVRDriver::VRDriver::Searc } std::optional SlimeVRDriver::VRDriver::SearchUniverses(uint64_t target) { - auto driver_chap_path = vr::VRProperties()->GetStringProperty(vr::VRProperties()->TrackedDeviceToPropertyContainer(0), vr::Prop_DriverProvidedChaperonePath_String); + vr::PropertyContainerHandle_t hmd_prop_container = vr::VRProperties()->TrackedDeviceToPropertyContainer(vr::k_unTrackedDeviceIndex_Hmd); + auto driver_chap_json = vr::VRProperties()->GetStringProperty(hmd_prop_container, vr::Prop_DriverProvidedChaperoneJson_String); + if (driver_chap_json != "") { + try { + auto driver_res = SearchUniverse(driver_chap_json, target); + if (driver_res.has_value()) { + return driver_res.value(); + } + } + catch (simdjson::simdjson_error &e) { + logger_->Log("Error loading driver-provided chaperone JSON: {}", e.what()); + } + } + + auto driver_chap_path = vr::VRProperties()->GetStringProperty(hmd_prop_container, vr::Prop_DriverProvidedChaperonePath_String); if (driver_chap_path != "") { try { auto driver_res = SearchUniverse(simdjson::padded_string::load(driver_chap_path).take_value(), target); From 510d9654993230992fd556c418a3b24f90f605fa Mon Sep 17 00:00:00 2001 From: Sapphire Date: Wed, 28 Jan 2026 16:49:08 -0600 Subject: [PATCH 3/3] Don't link to openvr --- CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 27cfe93..09c33ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,8 +56,6 @@ elseif(APPLE) set(PLATFORM_NAME "osx") endif() -find_library(OPENVR_LIB openvr_api HINTS "${CMAKE_CURRENT_SOURCE_DIR}/libraries/openvr/lib/${PLATFORM_NAME}${PROCESSOR_ARCH}/" NO_DEFAULT_PATH ) - # Protobuf # Installation: # Please refer to this readme to install protobuf in your system: https://github.com/protocolbuffers/protobuf/blob/master/src/README.md @@ -82,7 +80,6 @@ set(DEPS_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/src/" ) set(DEPS_LIBS - "${OPENVR_LIB}" protobuf::libprotoc protobuf::libprotobuf protobuf::libprotobuf-lite