From 23a222fcebe77e14fcea2f1fa35a09b470f0450f Mon Sep 17 00:00:00 2001 From: Meister1593 Date: Sun, 8 Jun 2025 10:32:21 +0200 Subject: [PATCH 01/10] fix(steamvr_launcher): find steam folder by using steamlocate-rs library --- Cargo.lock | 110 +++++++++++++++++++++++++++++- alvr/server_io/Cargo.toml | 1 + alvr/server_io/src/openvrpaths.rs | 31 +++++---- 3 files changed, 126 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5bd582b94b..607ee1bc60 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -433,6 +433,7 @@ dependencies = [ "encoding_rs_io", "runas", "serde_json", + "steamlocate", ] [[package]] @@ -3117,6 +3118,27 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "keyvalues-parser" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e4c8354918309196302015ac9cae43362f1a13d0d5c5539a33b4c2fd2cd6d25" +dependencies = [ + "pest", + "pest_derive", + "thiserror 1.0.69", +] + +[[package]] +name = "keyvalues-serde" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2db0b750e9ae64e6c3d913832dc19ed580b9210bcd7c4dd6d0dd21af469fc14" +dependencies = [ + "keyvalues-parser", + "serde", +] + [[package]] name = "khronos-egl" version = "6.0.0" @@ -4188,6 +4210,51 @@ version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" +[[package]] +name = "pest" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "198db74531d58c70a361c42201efde7e2591e976d518caf7662a47dc5720e7b6" +dependencies = [ + "memchr", + "thiserror 2.0.11", + "ucd-trie", +] + +[[package]] +name = "pest_derive" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d725d9cfd79e87dccc9341a2ef39d1b6f6353d68c4b33c177febbe1a402c97c5" +dependencies = [ + "pest", + "pest_generator", +] + +[[package]] +name = "pest_generator" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db7d01726be8ab66ab32f9df467ae8b1148906685bbe75c82d1e65d7f5b3f841" +dependencies = [ + "pest", + "pest_meta", + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "pest_meta" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f9f832470494906d1fca5329f8ab5791cc60beb230c74815dff541cbd2b5ca0" +dependencies = [ + "once_cell", + "pest", + "sha2", +] + [[package]] name = "pico-args" version = "0.5.0" @@ -4685,7 +4752,7 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "winreg", + "winreg 0.50.0", ] [[package]] @@ -5082,6 +5149,17 @@ dependencies = [ "digest", ] +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "sharded-slab" version = "0.1.7" @@ -5246,6 +5324,20 @@ dependencies = [ "rand 0.8.5", ] +[[package]] +name = "steamlocate" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a13160bc6ea5cd80cde195ad4a4c629701db2bf397b62c139aa9e739016d2499" +dependencies = [ + "crc", + "home", + "keyvalues-parser", + "keyvalues-serde", + "serde", + "winreg 0.55.0", +] + [[package]] name = "strict-num" version = "0.1.1" @@ -5901,6 +5993,12 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" +[[package]] +name = "ucd-trie" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" + [[package]] name = "uds_windows" version = "1.1.0" @@ -7032,6 +7130,16 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "winreg" +version = "0.55.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb5a765337c50e9ec252c2069be9bf91c7df47afb103b642ba3a53bf8101be97" +dependencies = [ + "cfg-if", + "windows-sys 0.59.0", +] + [[package]] name = "winres" version = "0.1.12" diff --git a/alvr/server_io/Cargo.toml b/alvr/server_io/Cargo.toml index 3ba728c3e8..2ba1ee6dcc 100644 --- a/alvr/server_io/Cargo.toml +++ b/alvr/server_io/Cargo.toml @@ -17,6 +17,7 @@ encoding_rs_io = "0.1" dirs = "6" runas = "^1.2" # version 1.1 is broken serde_json = "1" +steamlocate = "2.0.1" [target.'cfg(not(target_os = "linux"))'.dependencies] cpal = "0.15" diff --git a/alvr/server_io/src/openvrpaths.rs b/alvr/server_io/src/openvrpaths.rs index f371d82d81..f5e6b1af1b 100644 --- a/alvr/server_io/src/openvrpaths.rs +++ b/alvr/server_io/src/openvrpaths.rs @@ -1,13 +1,14 @@ use alvr_common::{ anyhow::{bail, Result}, - ToAny, + debug, ToAny, }; use encoding_rs_io::DecodeReaderBytes; use serde_json as json; use std::{ + fmt::format, fs::{self, File}, io::Read, - path::PathBuf, + path::{self, Path, PathBuf}, }; fn openvr_source_file_path() -> Result { @@ -27,20 +28,20 @@ fn openvr_source_file_path() -> Result { } pub fn steamvr_settings_file_path() -> Result { - let path = if cfg!(windows) { - // N.B. if ever implementing this: given Steam can be installed on another - // drive, etc., this should probably start by looking at Windows registry keys. - bail!("Not implemented for Windows.") // Original motive for implementation had little reason for Windows. - } else { - dirs::data_dir() - } - .to_any()? - .join("Steam/config/steamvr.vrsettings"); - - if path.exists() { - Ok(path) + let steam_dir = steamlocate::SteamDir::locate()?; + let steamvr_vrsettings_path = steam_dir.path().join("config/steamvr.vrsettings"); + debug!( + "steamvr_vrsettings_path: {}", + steamvr_vrsettings_path.display() + ); + + if steamvr_vrsettings_path.exists() { + Ok(steamvr_vrsettings_path) } else { - bail!("{} does not exist", path.to_string_lossy()) + bail!( + "Couldn't find SteamVR config file (steamvr.vrsettings). + Please make sure SteamVR is launched at least once." + ) } } From ab3c976657f692bc4d0bb3906d1c13fa55d204e8 Mon Sep 17 00:00:00 2001 From: Meister1593 Date: Sun, 8 Jun 2025 10:36:59 +0200 Subject: [PATCH 02/10] returned cfg gate for windows, formatted message to oneline --- alvr/server_io/src/openvrpaths.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/alvr/server_io/src/openvrpaths.rs b/alvr/server_io/src/openvrpaths.rs index f5e6b1af1b..d4c0a21252 100644 --- a/alvr/server_io/src/openvrpaths.rs +++ b/alvr/server_io/src/openvrpaths.rs @@ -28,6 +28,12 @@ fn openvr_source_file_path() -> Result { } pub fn steamvr_settings_file_path() -> Result { + if cfg!(windows) { + // N.B. if ever implementing this: given Steam can be installed on another + // drive, etc., this should probably start by looking at Windows registry keys. + bail!("Not implemented for Windows.") // Original motive for implementation had little reason for Windows. + } + let steam_dir = steamlocate::SteamDir::locate()?; let steamvr_vrsettings_path = steam_dir.path().join("config/steamvr.vrsettings"); debug!( @@ -39,8 +45,7 @@ pub fn steamvr_settings_file_path() -> Result { Ok(steamvr_vrsettings_path) } else { bail!( - "Couldn't find SteamVR config file (steamvr.vrsettings). - Please make sure SteamVR is launched at least once." + "Couldn't find SteamVR config file (steamvr.vrsettings). Please make sure SteamVR is launched at least once." ) } } From 4b02186b1b3c55b361e4d53713b434d9b9f3dba2 Mon Sep 17 00:00:00 2001 From: Meister1593 Date: Sun, 8 Jun 2025 10:46:48 +0200 Subject: [PATCH 03/10] remove unused imports --- alvr/server_io/src/openvrpaths.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/alvr/server_io/src/openvrpaths.rs b/alvr/server_io/src/openvrpaths.rs index d4c0a21252..38ec046df4 100644 --- a/alvr/server_io/src/openvrpaths.rs +++ b/alvr/server_io/src/openvrpaths.rs @@ -5,10 +5,9 @@ use alvr_common::{ use encoding_rs_io::DecodeReaderBytes; use serde_json as json; use std::{ - fmt::format, fs::{self, File}, io::Read, - path::{self, Path, PathBuf}, + path::PathBuf, }; fn openvr_source_file_path() -> Result { From e98b0b416973f44d48a14e33b64acfcdb56bb6ea Mon Sep 17 00:00:00 2001 From: Meister1593 Date: Sun, 8 Jun 2025 13:44:22 +0200 Subject: [PATCH 04/10] fix(steamvr_launcher): add test for steamvr config locations on linux --- Cargo.lock | 72 +++++++++++++++++++++---------- alvr/server_io/Cargo.toml | 6 ++- alvr/server_io/src/openvrpaths.rs | 42 ++++++++++++++++++ 3 files changed, 96 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 607ee1bc60..22488b35f1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -431,9 +431,11 @@ dependencies = [ "cpal", "dirs", "encoding_rs_io", + "injectorpp", "runas", "serde_json", "steamlocate", + "tempfile", ] [[package]] @@ -812,7 +814,7 @@ dependencies = [ "futures-lite", "parking", "polling", - "rustix", + "rustix 0.38.44", "slab", "tracing", "windows-sys 0.59.0", @@ -855,7 +857,7 @@ dependencies = [ "cfg-if", "event-listener", "futures-lite", - "rustix", + "rustix 0.38.44", "tracing", ] @@ -882,7 +884,7 @@ dependencies = [ "cfg-if", "futures-core", "futures-io", - "rustix", + "rustix 0.38.44", "signal-hook-registry", "slab", "windows-sys 0.59.0", @@ -1203,7 +1205,7 @@ dependencies = [ "bitflags 2.8.0", "log", "polling", - "rustix", + "rustix 0.38.44", "slab", "thiserror 1.0.69", ] @@ -1215,7 +1217,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95a66a987056935f7efce4ab5668920b5d0dac4a7c99991a67395f13702ddd20" dependencies = [ "calloop", - "rustix", + "rustix 0.38.44", "wayland-backend", "wayland-client", ] @@ -3007,6 +3009,15 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "injectorpp" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33df6d572ef2523db0ba0e71414ae9e32e3c4d922872a517d527f6995349d7a2" +dependencies = [ + "libc", +] + [[package]] name = "inout" version = "0.1.4" @@ -3246,6 +3257,12 @@ version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" +[[package]] +name = "linux-raw-sys" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" + [[package]] name = "litemap" version = "0.7.5" @@ -4361,7 +4378,7 @@ dependencies = [ "concurrent-queue", "hermit-abi", "pin-project-lite", - "rustix", + "rustix 0.38.44", "tracing", "windows-sys 0.59.0", ] @@ -4900,7 +4917,20 @@ dependencies = [ "bitflags 2.8.0", "errno 0.3.10", "libc", - "linux-raw-sys", + "linux-raw-sys 0.4.15", + "windows-sys 0.59.0", +] + +[[package]] +name = "rustix" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266" +dependencies = [ + "bitflags 2.8.0", + "errno 0.3.10", + "libc", + "linux-raw-sys 0.9.4", "windows-sys 0.59.0", ] @@ -5240,7 +5270,7 @@ dependencies = [ "libc", "log", "memmap2", - "rustix", + "rustix 0.38.44", "thiserror 1.0.69", "wayland-backend", "wayland-client", @@ -5327,8 +5357,7 @@ dependencies = [ [[package]] name = "steamlocate" version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a13160bc6ea5cd80cde195ad4a4c629701db2bf397b62c139aa9e739016d2499" +source = "git+https://github.com/WilliamVenner/steamlocate-rs.git?rev=6fc7aeef928a5b9cc40823a02de61ed0cc38a759#6fc7aeef928a5b9cc40823a02de61ed0cc38a759" dependencies = [ "crc", "home", @@ -5542,15 +5571,14 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "tempfile" -version = "3.17.1" +version = "3.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22e5a0acb1f3f55f65cc4a866c361b2fb2a0ff6366785ae6fbb5f85df07ba230" +checksum = "e8a64e3985349f2441a1a9ef0b853f869006c3855f2cda6862a94d26ebb9d6a1" dependencies = [ - "cfg-if", "fastrand", "getrandom 0.3.1", "once_cell", - "rustix", + "rustix 1.0.7", "windows-sys 0.59.0", ] @@ -6265,7 +6293,7 @@ checksum = "b7208998eaa3870dad37ec8836979581506e0c5c64c20c9e79e9d2a10d6f47bf" dependencies = [ "cc", "downcast-rs", - "rustix", + "rustix 0.38.44", "scoped-tls", "smallvec", "wayland-sys", @@ -6278,7 +6306,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2120de3d33638aaef5b9f4472bff75f07c56379cf76ea320bd3a3d65ecaf73f" dependencies = [ "bitflags 2.8.0", - "rustix", + "rustix 0.38.44", "wayland-backend", "wayland-scanner", ] @@ -6300,7 +6328,7 @@ version = "0.31.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a93029cbb6650748881a00e4922b076092a6a08c11e7fbdb923f064b23968c5d" dependencies = [ - "rustix", + "rustix 0.38.44", "wayland-client", "xcursor", ] @@ -6537,7 +6565,7 @@ dependencies = [ "either", "home", "once_cell", - "rustix", + "rustix 0.38.44", ] [[package]] @@ -7091,7 +7119,7 @@ dependencies = [ "pin-project", "raw-window-handle", "redox_syscall 0.4.1", - "rustix", + "rustix 0.38.44", "sctk-adwaita", "smithay-client-toolkit", "smol_str", @@ -7204,7 +7232,7 @@ dependencies = [ "libc", "libloading", "once_cell", - "rustix", + "rustix 0.38.44", "x11rb-protocol", ] @@ -7221,8 +7249,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e105d177a3871454f754b33bb0ee637ecaaac997446375fd3e5d43a2ed00c909" dependencies = [ "libc", - "linux-raw-sys", - "rustix", + "linux-raw-sys 0.4.15", + "rustix 0.38.44", ] [[package]] diff --git a/alvr/server_io/Cargo.toml b/alvr/server_io/Cargo.toml index 2ba1ee6dcc..4968e6920a 100644 --- a/alvr/server_io/Cargo.toml +++ b/alvr/server_io/Cargo.toml @@ -15,9 +15,11 @@ alvr_session.workspace = true encoding_rs_io = "0.1" dirs = "6" -runas = "^1.2" # version 1.1 is broken +runas = "^1.2" # version 1.1 is broken serde_json = "1" -steamlocate = "2.0.1" +steamlocate = { git = "https://github.com/WilliamVenner/steamlocate-rs.git", rev = "6fc7aeef928a5b9cc40823a02de61ed0cc38a759" } +injectorpp = "0.3.3" +tempfile = "3.20.0" [target.'cfg(not(target_os = "linux"))'.dependencies] cpal = "0.15" diff --git a/alvr/server_io/src/openvrpaths.rs b/alvr/server_io/src/openvrpaths.rs index 38ec046df4..c8ef83b311 100644 --- a/alvr/server_io/src/openvrpaths.rs +++ b/alvr/server_io/src/openvrpaths.rs @@ -99,3 +99,45 @@ fn get_single_openvr_path(path_type: &str) -> Result { pub fn steamvr_root_dir() -> Result { get_single_openvr_path("runtime") } + +mod tests { + + #[cfg(target_os = "linux")] + #[test] + pub(crate) fn test_steamvr_settings_file_path() { + use std::fs; + use std::path::Path; + use tempfile::TempDir; + + let possible_config_locations = [ + ( + true, + ".var/app/com.valvesoftware.Steam/.local/share/Steam/config", + ), + (true, ".local/share/Steam/config"), + (true, ".steam/steam/config"), + (true, ".steam/debian-installation/config"), + (false, ".some/random/directory"), + ]; + let user_folder_path = Path::new("home/user"); + for (is_correct, location) in possible_config_locations { + let tmp: TempDir = tempfile::tempdir().unwrap(); + + let steam_config_folder = tmp.path().join(user_folder_path).join(location); + assert!(fs::create_dir_all(&steam_config_folder).is_ok()); + let steamvr_vrsettings_path = steam_config_folder.join("steamvr.vrsettings"); + assert!(fs::File::create(&steamvr_vrsettings_path).is_ok()); + std::env::set_var("HOME", tmp.path().join(user_folder_path)); + + let result = super::steamvr_settings_file_path(); + if is_correct { + assert!(result.is_ok()); + if let Ok(steamvr_file) = result { + assert_eq!(steamvr_vrsettings_path, steamvr_file) + } + } else { + assert!(result.is_err()); + } + } + } +} From 0ed31a9b329beef1309040c0b117299eda9659b8 Mon Sep 17 00:00:00 2001 From: Meister1593 Date: Sun, 8 Jun 2025 13:46:22 +0200 Subject: [PATCH 05/10] remove unused deps --- Cargo.lock | 10 ---------- alvr/server_io/Cargo.toml | 1 - 2 files changed, 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 22488b35f1..ee85c22f01 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -431,7 +431,6 @@ dependencies = [ "cpal", "dirs", "encoding_rs_io", - "injectorpp", "runas", "serde_json", "steamlocate", @@ -3009,15 +3008,6 @@ dependencies = [ "hashbrown", ] -[[package]] -name = "injectorpp" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33df6d572ef2523db0ba0e71414ae9e32e3c4d922872a517d527f6995349d7a2" -dependencies = [ - "libc", -] - [[package]] name = "inout" version = "0.1.4" diff --git a/alvr/server_io/Cargo.toml b/alvr/server_io/Cargo.toml index 4968e6920a..b1e6f3fdec 100644 --- a/alvr/server_io/Cargo.toml +++ b/alvr/server_io/Cargo.toml @@ -18,7 +18,6 @@ dirs = "6" runas = "^1.2" # version 1.1 is broken serde_json = "1" steamlocate = { git = "https://github.com/WilliamVenner/steamlocate-rs.git", rev = "6fc7aeef928a5b9cc40823a02de61ed0cc38a759" } -injectorpp = "0.3.3" tempfile = "3.20.0" [target.'cfg(not(target_os = "linux"))'.dependencies] From b849c666bcbaabbee7593ebfd84ffb5cc69f43c5 Mon Sep 17 00:00:00 2001 From: Meister1593 Date: Sun, 8 Jun 2025 15:49:35 +0200 Subject: [PATCH 06/10] fix comment format --- alvr/server_io/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/alvr/server_io/Cargo.toml b/alvr/server_io/Cargo.toml index b1e6f3fdec..b56f5fe753 100644 --- a/alvr/server_io/Cargo.toml +++ b/alvr/server_io/Cargo.toml @@ -15,7 +15,7 @@ alvr_session.workspace = true encoding_rs_io = "0.1" dirs = "6" -runas = "^1.2" # version 1.1 is broken +runas = "^1.2" # version 1.1 is broken serde_json = "1" steamlocate = { git = "https://github.com/WilliamVenner/steamlocate-rs.git", rev = "6fc7aeef928a5b9cc40823a02de61ed0cc38a759" } tempfile = "3.20.0" From b160520dc061da2e9a0f44a5821025a96c18b423 Mon Sep 17 00:00:00 2001 From: Meister1593 Date: Mon, 9 Jun 2025 18:08:33 +0200 Subject: [PATCH 07/10] review features - use steamlocate-rs for finding steamvr root directory, refactor --- .../src/steamvr_launcher/linux_steamvr.rs | 4 +--- alvr/server_io/src/openvrpaths.rs | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/alvr/dashboard/src/steamvr_launcher/linux_steamvr.rs b/alvr/dashboard/src/steamvr_launcher/linux_steamvr.rs index 9ac7bfb26f..f6a4ca9a7b 100644 --- a/alvr/dashboard/src/steamvr_launcher/linux_steamvr.rs +++ b/alvr/dashboard/src/steamvr_launcher/linux_steamvr.rs @@ -150,9 +150,7 @@ fn linux_gpu_checks(device_infos: &[(&wgpu::Adapter, DeviceInfo)]) { let steamvr_root_dir = match alvr_server_io::steamvr_root_dir() { Ok(dir) => dir, Err(e) => { - error!("Couldn't detect openvr or steamvr files. \ - Please make sure you have installed and ran SteamVR at least once. \ - Or if you're using Flatpak Steam, make sure to use ALVR Dashboard from Flatpak ALVR. {e}"); + error!("{e}"); return; } }; diff --git a/alvr/server_io/src/openvrpaths.rs b/alvr/server_io/src/openvrpaths.rs index c8ef83b311..22a6211be9 100644 --- a/alvr/server_io/src/openvrpaths.rs +++ b/alvr/server_io/src/openvrpaths.rs @@ -1,5 +1,5 @@ use alvr_common::{ - anyhow::{bail, Result}, + anyhow::{bail, Error, Result}, debug, ToAny, }; use encoding_rs_io::DecodeReaderBytes; @@ -90,14 +90,16 @@ pub fn to_openvr_paths(paths: &[PathBuf]) -> json::Value { json::Value::Array(paths_vec) } -fn get_single_openvr_path(path_type: &str) -> Result { - let openvr_paths_json = load_openvr_paths_json()?; - let paths_json = openvr_paths_json.get(path_type).to_any()?; - from_openvr_paths(paths_json).first().cloned().to_any() -} - pub fn steamvr_root_dir() -> Result { - get_single_openvr_path("runtime") + let steam_dir = steamlocate::SteamDir::locate()?; + const STEAMVR_APPID: u32 = 250_820; + match steam_dir.find_app(STEAMVR_APPID)? { + // 250820 - SteamVR appid + Some((app, library)) => Ok(library.resolve_app_dir(&app)), + None => Err(Error::msg( + "Couldn't locate SteamVR, please make sure you have installed it.", + )), + } } mod tests { From 399e208a7453de975fdb7880e6b33bb761adae7b Mon Sep 17 00:00:00 2001 From: Meister1593 Date: Mon, 9 Jun 2025 21:36:44 +0200 Subject: [PATCH 08/10] remove unnecessary comment --- alvr/server_io/src/openvrpaths.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/alvr/server_io/src/openvrpaths.rs b/alvr/server_io/src/openvrpaths.rs index 22a6211be9..9817308f44 100644 --- a/alvr/server_io/src/openvrpaths.rs +++ b/alvr/server_io/src/openvrpaths.rs @@ -94,7 +94,6 @@ pub fn steamvr_root_dir() -> Result { let steam_dir = steamlocate::SteamDir::locate()?; const STEAMVR_APPID: u32 = 250_820; match steam_dir.find_app(STEAMVR_APPID)? { - // 250820 - SteamVR appid Some((app, library)) => Ok(library.resolve_app_dir(&app)), None => Err(Error::msg( "Couldn't locate SteamVR, please make sure you have installed it.", From 6965cd1ef469d2310ff2d0584bafdf2cbafa1641 Mon Sep 17 00:00:00 2001 From: Meister1593 Date: Mon, 9 Jun 2025 21:39:46 +0200 Subject: [PATCH 09/10] move tempfile into dev dependencies --- alvr/server_io/Cargo.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/alvr/server_io/Cargo.toml b/alvr/server_io/Cargo.toml index b56f5fe753..c8f0e6601b 100644 --- a/alvr/server_io/Cargo.toml +++ b/alvr/server_io/Cargo.toml @@ -18,6 +18,8 @@ dirs = "6" runas = "^1.2" # version 1.1 is broken serde_json = "1" steamlocate = { git = "https://github.com/WilliamVenner/steamlocate-rs.git", rev = "6fc7aeef928a5b9cc40823a02de61ed0cc38a759" } + +[dev-dependencies] tempfile = "3.20.0" [target.'cfg(not(target_os = "linux"))'.dependencies] From 1026d25813b9bb24476ed63e6ebff63f91fe8cbb Mon Sep 17 00:00:00 2001 From: Meister1593 Date: Mon, 16 Jun 2025 09:31:34 +0200 Subject: [PATCH 10/10] review pr changes #1 --- alvr/server_io/src/openvrpaths.rs | 53 ++----------------------------- 1 file changed, 3 insertions(+), 50 deletions(-) diff --git a/alvr/server_io/src/openvrpaths.rs b/alvr/server_io/src/openvrpaths.rs index 9817308f44..2b17404693 100644 --- a/alvr/server_io/src/openvrpaths.rs +++ b/alvr/server_io/src/openvrpaths.rs @@ -27,14 +27,9 @@ fn openvr_source_file_path() -> Result { } pub fn steamvr_settings_file_path() -> Result { - if cfg!(windows) { - // N.B. if ever implementing this: given Steam can be installed on another - // drive, etc., this should probably start by looking at Windows registry keys. - bail!("Not implemented for Windows.") // Original motive for implementation had little reason for Windows. - } - - let steam_dir = steamlocate::SteamDir::locate()?; - let steamvr_vrsettings_path = steam_dir.path().join("config/steamvr.vrsettings"); + let steamvr_vrsettings_path = steamlocate::SteamDir::locate()? + .path() + .join("config/steamvr.vrsettings"); debug!( "steamvr_vrsettings_path: {}", steamvr_vrsettings_path.display() @@ -100,45 +95,3 @@ pub fn steamvr_root_dir() -> Result { )), } } - -mod tests { - - #[cfg(target_os = "linux")] - #[test] - pub(crate) fn test_steamvr_settings_file_path() { - use std::fs; - use std::path::Path; - use tempfile::TempDir; - - let possible_config_locations = [ - ( - true, - ".var/app/com.valvesoftware.Steam/.local/share/Steam/config", - ), - (true, ".local/share/Steam/config"), - (true, ".steam/steam/config"), - (true, ".steam/debian-installation/config"), - (false, ".some/random/directory"), - ]; - let user_folder_path = Path::new("home/user"); - for (is_correct, location) in possible_config_locations { - let tmp: TempDir = tempfile::tempdir().unwrap(); - - let steam_config_folder = tmp.path().join(user_folder_path).join(location); - assert!(fs::create_dir_all(&steam_config_folder).is_ok()); - let steamvr_vrsettings_path = steam_config_folder.join("steamvr.vrsettings"); - assert!(fs::File::create(&steamvr_vrsettings_path).is_ok()); - std::env::set_var("HOME", tmp.path().join(user_folder_path)); - - let result = super::steamvr_settings_file_path(); - if is_correct { - assert!(result.is_ok()); - if let Ok(steamvr_file) = result { - assert_eq!(steamvr_vrsettings_path, steamvr_file) - } - } else { - assert!(result.is_err()); - } - } - } -}