From e62d0ced36ad2d681a899fdd9caceca031e90f89 Mon Sep 17 00:00:00 2001 From: Gabriele Musco Date: Mon, 6 Jan 2025 16:51:26 +0100 Subject: [PATCH] fix: get ovr compatibility module runtime dir from profile ovr compatibility module struct --- src/file_builders/openvrpaths_vrpath.rs | 12 +++--------- src/profile.rs | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/file_builders/openvrpaths_vrpath.rs b/src/file_builders/openvrpaths_vrpath.rs index 842acf8..7bd431b 100644 --- a/src/file_builders/openvrpaths_vrpath.rs +++ b/src/file_builders/openvrpaths_vrpath.rs @@ -1,12 +1,11 @@ -use std::path::{Path, PathBuf}; - use crate::{ paths::get_backup_dir, - profile::{OvrCompatibilityModuleType, Profile}, + profile::Profile, util::file_utils::{copy_file, deserialize_file, get_writer, set_file_readonly}, xdg::XDG, }; use serde::{ser::Error, Deserialize, Serialize}; +use std::path::{Path, PathBuf}; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub struct OpenVrPaths { @@ -98,12 +97,7 @@ pub fn build_profile_openvrpaths(profile: &Profile) -> OpenVrPaths { external_drivers: None, jsonid: "vrpathreg".into(), log: vec![datadir.join("Steam/logs")], - runtime: match profile.ovr_comp.mod_type { - OvrCompatibilityModuleType::Opencomposite => vec![profile.ovr_comp.path.join("build")], - OvrCompatibilityModuleType::Xrizer => { - vec![profile.ovr_comp.path.join("target/release")] - } - }, + runtime: vec![profile.ovr_comp.runtime_dir()], version: 1, } } diff --git a/src/profile.rs b/src/profile.rs index 89177ac..ad6b170 100644 --- a/src/profile.rs +++ b/src/profile.rs @@ -313,7 +313,7 @@ pub struct ProfileOvrCompatibilityModule { } impl ProfileOvrCompatibilityModule { - fn default_for_uuid(uuid: &str) -> Self { + pub fn default_for_uuid(uuid: &str) -> Self { let mod_type = OvrCompatibilityModuleType::default(); Self { mod_type, @@ -322,6 +322,15 @@ impl ProfileOvrCompatibilityModule { path: get_data_dir().join(uuid).join(mod_type.to_string()), } } + + /// get the directory corresponding to the openvr runtime. + /// this should correspond to the build output directory + pub fn runtime_dir(&self) -> PathBuf { + match self.mod_type { + OvrCompatibilityModuleType::Opencomposite => self.path.join("build"), + OvrCompatibilityModuleType::Xrizer => self.path.join("target/release"), + } + } } impl Default for ProfileOvrCompatibilityModule { @@ -453,8 +462,8 @@ impl Profile { pub fn env_vars_full(&self) -> Vec { vec![ // format!( - // "VR_OVERRIDE={opencomp}/build", - // opencomp = self.opencomposite_path, + // "VR_OVERRIDE={}", + // self.ovr_comp.runtime_dir(), // ), self.xr_runtime_json_env_var(), format!(