From fafe01b76a6d70531790e0816d91812a6fa4bd88 Mon Sep 17 00:00:00 2001 From: Guillaume Meunier Date: Sat, 5 Jul 2025 21:38:36 +0200 Subject: [PATCH 1/6] Enable passthrough in splash screen --- AndroidManifest.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index dddc5896..7f9b6505 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -88,6 +88,8 @@ + + From c9e078bd476a70e8e453b0ea345694b12677ec62 Mon Sep 17 00:00:00 2001 From: Guillaume Meunier Date: Sun, 6 Jul 2025 09:09:48 +0200 Subject: [PATCH 2/6] Avoid segfault if xrCreatePassthroughFB fails --- client/xr/passthrough.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/xr/passthrough.cpp b/client/xr/passthrough.cpp index 8e7dc568..dbbc0823 100644 --- a/client/xr/passthrough.cpp +++ b/client/xr/passthrough.cpp @@ -51,6 +51,7 @@ xr::passthrough_layer_fb::passthrough_layer_fb(instance & inst, session & s, con static XrPassthroughFB create_passthrough_fb(xr::instance & inst, xr::session & s) { PFN_xrCreatePassthroughFB xrCreatePassthroughFB = inst.get_proc("xrCreatePassthroughFB"); + xrDestroyPassthroughFB = inst.get_proc("xrDestroyPassthroughFB"); XrPassthroughFB id; XrPassthroughCreateInfoFB info{ @@ -71,7 +72,6 @@ xr::passthrough_fb::passthrough_fb(instance & inst, session & s) : .purpose = XR_PASSTHROUGH_LAYER_PURPOSE_RECONSTRUCTION_FB, }) { - xrDestroyPassthroughFB = inst.get_proc("xrDestroyPassthroughFB"); xrPassthroughStartFB = inst.get_proc("xrPassthroughStartFB"); xrPassthroughPauseFB = inst.get_proc("xrPassthroughPauseFB"); xrPassthroughLayerPauseFB = inst.get_proc("xrPassthroughLayerPauseFB"); From be504b5944459a26f8976b224187be1b6d746e2a Mon Sep 17 00:00:00 2001 From: Guillaume Meunier Date: Sun, 6 Jul 2025 09:42:34 +0200 Subject: [PATCH 3/6] Add controller offset for Quest 3 --- client/hardware.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/client/hardware.cpp b/client/hardware.cpp index c558deff..745be7bf 100644 --- a/client/hardware.cpp +++ b/client/hardware.cpp @@ -348,6 +348,24 @@ std::pair controller_offset(std::string_view profile, xr:: default: break; } + else if (profile == "meta-quest-touch-plus") + { + switch (space) + { + case xr::spaces::grip_left: + case xr::spaces::grip_right: + return {{0, -0.010, -0.025}, glm::angleAxis(glm::radians(-12.f), glm::vec3{1, 0, 0})}; + + case xr::spaces::aim_left: + return {{0, 0, 0.03}, {1, 0, 0, 0}}; + + case xr::spaces::aim_right: + return {{0, 0, 0.03}, {1, 0, 0, 0}}; + + default: + break; + } + } else if (profile == "htc-vive-focus-3") switch (space) { From fbe5430dc2b2cd4006d0e46a6e39a668b677b57b Mon Sep 17 00:00:00 2001 From: Sapphire Date: Sun, 6 Jul 2025 02:31:30 -0500 Subject: [PATCH 4/6] Skip Nix CI step for apk repo --- .github/workflows/Build.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml index d6ad8099..df2800ed 100644 --- a/.github/workflows/Build.yml +++ b/.github/workflows/Build.yml @@ -153,11 +153,13 @@ jobs: nix-test: name: Test Nix package and devshell runs-on: ubuntu-24.04 + if: ${{ vars.APK_ONLY == '' }} + steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - + - uses: cachix/install-nix-action@v31 - run: nix flake check - run: nix build From 11cd9235d915709a5eb84927c4da7d7be5abe2a1 Mon Sep 17 00:00:00 2001 From: Patrick Nicolas Date: Thu, 3 Jul 2025 21:43:49 +0200 Subject: [PATCH 5/6] Allow multiple configuration files Will merge contents from @CMAKE_INSTALL_PREFIX@/share/wivrn/config.json /etc/wivrn/config.json ~/.config/wivrn.config.json (XDG_CONFIG_DIR in fact) If -f option is provided, just parse that file, don't merge anything --- docs/configuration.md | 8 ++- server/active_runtime.cpp | 2 +- server/driver/configuration.cpp | 99 ++++++++++++++++++++--------- server/driver/configuration.h | 7 +- server/driver/wivrn_connection.cpp | 2 +- server/driver/wivrn_controller.cpp | 2 +- server/driver/wivrn_hmd.cpp | 2 +- server/driver/wivrn_session.cpp | 2 +- server/encoder/encoder_settings.cpp | 8 --- server/main.cpp | 18 ++++-- server/start_application.cpp | 2 +- 11 files changed, 99 insertions(+), 53 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 5e52937f..ffc1ec76 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -1,6 +1,12 @@ # Configurable items -Configuration is done on server side, in `$XDG_CONFIG_HOME/wivrn/config.json` or if `$XDG_CONFIG_HOME` is not set, `$HOME/.config/wivrn/config.json`. +Configuration is done on server side. +Files are read from +- `/usr/share/wivrn/config.json` (where `/usr` is selected at configure time with `CMAKE_INSTALL_PREFIX`) +- `/etc/wivrn/config.json` +- `$XDG_CONFIG_HOME/wivrn/config.json` or if `$XDG_CONFIG_HOME` is not set, `$HOME/.config/wivrn/config.json`. + +Files later in the list replace top-level values from previous ones. All elements are optional and have default values. diff --git a/server/active_runtime.cpp b/server/active_runtime.cpp index 84022a88..532f0531 100644 --- a/server/active_runtime.cpp +++ b/server/active_runtime.cpp @@ -76,7 +76,7 @@ std::filesystem::path active_runtime::openvr_compat_path() return std::filesystem::path(); }, }, - configuration::read_user_configuration().openvr_compat_path); + configuration().openvr_compat_path); } static std::filesystem::path backup_name(std::filesystem::path file) diff --git a/server/driver/configuration.cpp b/server/driver/configuration.cpp index 2f7fc4b6..7bcd7a0f 100644 --- a/server/driver/configuration.cpp +++ b/server/driver/configuration.cpp @@ -19,6 +19,8 @@ #define JSON_DISABLE_ENUM_SERIALIZATION 1 +#include "configuration.h" + #include #include #include @@ -31,10 +33,10 @@ #include "util/u_logging.h" -#include "configuration.h" #include "utils/xdg_base_directory.h" +#include "wivrn_config.h" -static std::filesystem::path config_file = xdg_config_home() / "wivrn" / "config.json"; +static std::filesystem::path config_file; static std::filesystem::path known_keys_file = xdg_config_home() / "wivrn" / "known_keys.json"; static std::filesystem::path cookie_file = xdg_config_home() / "wivrn" / "cookie"; @@ -65,12 +67,56 @@ void configuration::set_config_file(const std::filesystem::path & path) { config_file = path; } - -const std::filesystem::path & configuration::get_config_file() +std::filesystem::path configuration::get_config_file() { + if (config_file.empty()) + return xdg_config_home() / "wivrn" / "config.json"; return config_file; } +nlohmann::json configuration::read_configuration() +{ + if (config_file.empty()) + { + nlohmann::json merged; + for (std::filesystem::path prefix: { + std::filesystem::path(WIVRN_INSTALL_PREFIX "/share"), + std::filesystem::path("/etc"), + xdg_config_home(), + }) + { + auto path = prefix / "wivrn" / "config.json"; + if (std::filesystem::exists(path)) + { + try + { + for (const auto & [key, value]: nlohmann::json::parse(std::ifstream(path)).get()) + { + merged[key] = value; + } + } + catch (std::exception & e) + { + U_LOG_E("Invalid configuration file %s: %s", path.c_str(), e.what()); + } + } + } + return merged; + } + else + { + try + { + return nlohmann::json::parse(std::ifstream(config_file)); + } + catch (std::exception & e) + { + U_LOG_E("Invalid configuration file %s: %s", config_file.c_str(), e.what()); + return nlohmann::json(); + } + } +} + configuration::encoder parse_encoder(const nlohmann::json & item) { configuration::encoder e; @@ -94,85 +140,78 @@ configuration::encoder parse_encoder(const nlohmann::json & item) return e; } -configuration configuration::read_user_configuration() +configuration::configuration() { - configuration result; - if (not std::filesystem::exists(config_file)) - return result; - std::ifstream file(config_file); try { - auto json = nlohmann::json::parse(file); + auto json = read_configuration(); if (auto it = json.find("scale"); it != json.end()) { if (it->is_number()) - result.scale = std::array{*it, *it}; + scale = std::array{*it, *it}; else - result.scale = *it; + scale = *it; } if (auto it = json.find("grip-surface"); it != json.end()) { - result.grip_surface = *it; + grip_surface = *it; } if (auto it = json.find("bitrate"); it != json.end()) - result.bitrate = *it; + bitrate = *it; if (auto it = json.find("encoders"); it != json.end()) { for (const auto & encoder: *it) - result.encoders.push_back(parse_encoder(encoder)); + encoders.push_back(parse_encoder(encoder)); } if (auto it = json.find("encoder-passthrough"); it != json.end()) - result.encoder_passthrough = parse_encoder(*it); + encoder_passthrough = parse_encoder(*it); if (auto it = json.find("application"); it != json.end()) { if (it->is_string()) - result.application.push_back(*it); + application.push_back(*it); else { for (const auto & i: *it) - result.application.push_back(i); + application.push_back(i); } } if (auto it = json.find("debug-gui"); it != json.end()) - result.debug_gui = *it; + debug_gui = *it; if (auto it = json.find("use-steamvr-lh"); it != json.end()) - result.use_steamvr_lh = *it; + use_steamvr_lh = *it; if (auto it = json.find("tcp-only"); it != json.end()) - result.tcp_only = *it; + tcp_only = *it; else if (auto it = json.find("tcp_only"); it != json.end()) - result.tcp_only = *it; + tcp_only = *it; if (auto it = json.find("publish-service"); it != json.end()) { - result.publication = *it; - if (result.publication == service_publication(-1)) + publication = *it; + if (publication == service_publication(-1)) throw std::runtime_error("invalid service publication " + it->get()); } if (auto it = json.find("openvr-compat-path"); it != json.end()) { if (it->is_null()) - result.openvr_compat_path = nullptr; + openvr_compat_path = nullptr; else - result.openvr_compat_path = *it; + openvr_compat_path = *it; } } catch (const std::exception & e) { - U_LOG_E("Invalid configuration file: %s", e.what()); - return {}; + U_LOG_E("Configuration file error: %s", e.what()); } - - return result; } std::string server_cookie() diff --git a/server/driver/configuration.h b/server/driver/configuration.h index 86eea9de..53c0ba80 100644 --- a/server/driver/configuration.h +++ b/server/driver/configuration.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -68,8 +69,10 @@ struct configuration std::variant openvr_compat_path; static void set_config_file(const std::filesystem::path &); - static const std::filesystem::path & get_config_file(); - static configuration read_user_configuration(); + static std::filesystem::path get_config_file(); + + static nlohmann::json read_configuration(); + configuration(); }; std::string server_cookie(); diff --git a/server/driver/wivrn_connection.cpp b/server/driver/wivrn_connection.cpp index 76c4756a..327d19b8 100644 --- a/server/driver/wivrn_connection.cpp +++ b/server/driver/wivrn_connection.cpp @@ -88,7 +88,7 @@ void wivrn::wivrn_connection::init(std::stop_token stop_token, std::function angles = grip_surface.value(); float deg_2_rad = std::numbers::pi / 180.0; diff --git a/server/driver/wivrn_hmd.cpp b/server/driver/wivrn_hmd.cpp index 18cbac36..51f11eaa 100644 --- a/server/driver/wivrn_hmd.cpp +++ b/server/driver/wivrn_hmd.cpp @@ -89,7 +89,7 @@ wivrn_hmd::wivrn_hmd(wivrn::wivrn_session * cnx, }, cnx(cnx) { - const auto config = configuration::read_user_configuration(); + const auto config = configuration(); auto eye_width = info.recommended_eye_width; eye_width = ((eye_width + 3) / 4) * 4; diff --git a/server/driver/wivrn_session.cpp b/server/driver/wivrn_session.cpp index 7a50da03..884f5775 100644 --- a/server/driver/wivrn_session.cpp +++ b/server/driver/wivrn_session.cpp @@ -179,7 +179,7 @@ wivrn::wivrn_session::wivrn_session(std::unique_ptr connection static_roles.hand_tracking.right = xdevs[xdev_count++] = &right_hand; #if WIVRN_FEATURE_STEAMVR_LIGHTHOUSE - auto use_steamvr_lh = configuration::read_user_configuration().use_steamvr_lh || std::getenv("WIVRN_USE_STEAMVR_LH"); + auto use_steamvr_lh = configuration().use_steamvr_lh || std::getenv("WIVRN_USE_STEAMVR_LH"); xrt_system_devices * lhdevs = NULL; if (use_steamvr_lh && steamvr_lh_create_devices(&lhdevs) == XRT_SUCCESS) diff --git a/server/encoder/encoder_settings.cpp b/server/encoder/encoder_settings.cpp index 1b44539e..0e974abc 100644 --- a/server/encoder/encoder_settings.cpp +++ b/server/encoder/encoder_settings.cpp @@ -330,14 +330,6 @@ static uint16_t align(uint16_t value, uint16_t alignment) std::vector get_encoder_settings(wivrn_vk_bundle & bundle, uint32_t & width, uint32_t & height, const from_headset::headset_info_packet & info) { configuration config; - try - { - config = configuration::read_user_configuration(); - } - catch (const std::exception & e) - { - U_LOG_E("Failed to read encoder configuration: %s", e.what()); - } if (config.encoders.empty()) config.encoders = get_encoder_default_settings(bundle, info.supported_codecs); if (not config.encoder_passthrough) diff --git a/server/main.cpp b/server/main.cpp index 98108a81..91329ea5 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -479,7 +479,7 @@ gboolean headset_connected_success(void *) expose_known_keys_on_dbus(); - start_server(configuration::read_user_configuration()); + start_server(configuration()); try { start_app(); @@ -855,9 +855,15 @@ void on_name_acquired(GDBusConnection * connection, const gchar * name, gpointer on_headset_info_packet({}); - std::ifstream file(configuration::get_config_file()); - std::string config{std::istreambuf_iterator(file), std::istreambuf_iterator()}; - + std::string config; + try + { + config = configuration::read_configuration().dump(); + } + catch (std::exception & e) + { + std::cerr << "Invalid configuration: " << e.what() << std::endl; + } wivrn_server_set_json_configuration(dbus_server, config.c_str()); expose_known_keys_on_dbus(); @@ -1035,11 +1041,11 @@ int main(int argc, char * argv[]) if (*no_publish) publication = wivrn::service_publication::none; else - publication = configuration::read_user_configuration().publication; + publication = configuration().publication; #if WIVRN_USE_SYSTEMD if (*app_flag) - return exec_application(configuration::read_user_configuration()); + return exec_application(configuration()); #endif try { diff --git a/server/start_application.cpp b/server/start_application.cpp index a2e4aebf..b3f09941 100644 --- a/server/start_application.cpp +++ b/server/start_application.cpp @@ -219,7 +219,7 @@ pid_t wivrn::start_unit_file() pid_t wivrn::fork_application() { - auto config = configuration::read_user_configuration(); + configuration config; if (config.application.empty()) return 0; From 8686233b4939cb5960d09cc7d4ae86fed23b5420 Mon Sep 17 00:00:00 2001 From: Guillaume Meunier Date: Sun, 6 Jul 2025 09:19:05 +0200 Subject: [PATCH 6/6] Fix depth test in lobby on Quest 3 --- client/scenes/lobby.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/client/scenes/lobby.cpp b/client/scenes/lobby.cpp index f60e8cd2..7bceb033 100644 --- a/client/scenes/lobby.cpp +++ b/client/scenes/lobby.cpp @@ -966,6 +966,12 @@ void scenes::lobby::render(const XrFrameState & frame_state) .depthMask = true, .compareOp = application::get_config().passthrough_enabled ? XR_COMPARE_OP_LESS_FB : XR_COMPARE_OP_LESS_OR_EQUAL_FB, }; + XrCompositionLayerDepthTestFB layer_depth_test_bg{ + .type = XR_TYPE_COMPOSITION_LAYER_DEPTH_TEST_FB, + .next = nullptr, + .depthMask = true, + .compareOp = XR_COMPARE_OP_ALWAYS_FB, + }; // if (composition_layer_depth_test_supported or not application::get_config().passthrough_enabled) layers_with_z_index.emplace_back(constants::lobby::zindex_lobby, reinterpret_cast(&lobby_layer)); @@ -977,7 +983,7 @@ void scenes::lobby::render(const XrFrameState & frame_state) if (composition_layer_depth_test_supported) { - lobby_layer.next = &layer_depth_test; + lobby_layer.next = &layer_depth_test_bg; for (auto & [z_index, layer]: imgui_layers) {