diff --git a/CMakeLists.txt b/CMakeLists.txt index c62d100b..570b5f1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,6 +38,8 @@ auto_option(WIVRN_USE_X264 "Enable x264 software encoder" AUTO) auto_option(WIVRN_USE_PIPEWIRE "Enable pipewire backend" AUTO) auto_option(WIVRN_USE_PULSEAUDIO "Enable pulseaudio backend" AUTO) +set(OPENCOMPOSITE_SEARCH_PATH "/usr/local/lib:/usr/lib:/opt" CACHE STRING "List of places to search for OpenComposite, separated by :") + option(WIVRN_FEATURE_RENDERDOC "Support renderdoc" OFF) option(WIVRN_FEATURE_SOLARXR "Enable SolarXR driver" OFF) option(WIVRN_FEATURE_STEAMVR_LIGHTHOUSE "Enable SteamVR Lighthouse driver" OFF) diff --git a/common/wivrn_config.h.in b/common/wivrn_config.h.in index 0879b051..f5fbf423 100644 --- a/common/wivrn_config.h.in +++ b/common/wivrn_config.h.in @@ -36,3 +36,4 @@ #cmakedefine01 WIVRN_CLIENT_DEBUG_MENU #define WIVRN_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@" +#define OPENCOMPOSITE_SEARCH_PATH "@OPENCOMPOSITE_SEARCH_PATH@" diff --git a/server/active_runtime.cpp b/server/active_runtime.cpp index 0a1aaf8a..36e7de8c 100644 --- a/server/active_runtime.cpp +++ b/server/active_runtime.cpp @@ -46,19 +46,25 @@ std::filesystem::path active_runtime::manifest_path() return std::filesystem::path(WIVRN_INSTALL_PREFIX) / install_location; } +std::filesystem::path active_runtime::opencomposite_path() +{ + std::filesystem::path OpenComposite = "OpenComposite"; + if (auto path = flatpak_key(flatpak::section::instance, "app-path")) + return *path / OpenComposite; + for (auto path: std::ranges::split_view(std::string_view(OPENCOMPOSITE_SEARCH_PATH), std::string_view(":"))) + { + if (auto res = std::string_view(path) / OpenComposite; std::filesystem::exists(res)) + return res; + } + return {}; +} + static std::filesystem::path backup_name(std::filesystem::path file) { file += ".wivrn-backup"; return file; } -static std::filesystem::path find_opencomposite() -{ - if (auto path = flatpak_key(flatpak::section::instance, "app-path")) - return *path + "/OpenComposite"; - return {}; -} - static void move_file(const std::filesystem::path & from, const std::filesystem::path & to) { if (not std::filesystem::exists(from)) @@ -85,7 +91,7 @@ active_runtime::active_runtime() : try { - auto opencomposite = find_opencomposite(); + auto opencomposite = opencomposite_path(); if (not opencomposite.empty()) { std::filesystem::path openvr_manifest = xdg_config_home() / "openvr/openvrpaths.vrpath"; diff --git a/server/active_runtime.h b/server/active_runtime.h index 2f9e8e3d..15cf1dbd 100644 --- a/server/active_runtime.h +++ b/server/active_runtime.h @@ -38,5 +38,6 @@ public: ~active_runtime(); static std::filesystem::path manifest_path(); + static std::filesystem::path opencomposite_path(); }; } // namespace wivrn diff --git a/server/main.cpp b/server/main.cpp index 5aeb0399..889ef380 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -148,17 +148,26 @@ static std::filesystem::path flatpak_app_path() static std::string steam_command() { std::string pressure_vessel_filesystems_rw = "$XDG_RUNTIME_DIR/" XRT_IPC_MSG_SOCK_FILENAME; + std::string vr_override; // Check if in a flatpak if (is_flatpak()) { std::string app_path = flatpak_app_path().string(); // /usr and /var are remapped by steam - if (app_path.starts_with("/usr") or app_path.starts_with("/var")) + if (app_path.starts_with("/var")) pressure_vessel_filesystems_rw += ":" + app_path; } + else if (auto p = active_runtime::opencomposite_path().string(); not p.empty()) + { + // /usr cannot be shared in pressure vessel container + if (p.starts_with("/usr")) + vr_override = " VR_OVERRIDE=/run/host" + p; + else if (p.starts_with("/var")) + pressure_vessel_filesystems_rw += ":" + p; + } - std::string command = "PRESSURE_VESSEL_FILESYSTEMS_RW=" + pressure_vessel_filesystems_rw + " %command%"; + std::string command = "PRESSURE_VESSEL_FILESYSTEMS_RW=" + pressure_vessel_filesystems_rw + vr_override + " %command%"; if (auto p = active_runtime::manifest_path().string(); p.starts_with("/usr")) command = "XR_RUNTIME_JSON=/run/host" + p + " " + command;