diff --git a/Cargo.lock b/Cargo.lock index 5bd582b94b..ee85c22f01 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -433,6 +433,8 @@ dependencies = [ "encoding_rs_io", "runas", "serde_json", + "steamlocate", + "tempfile", ] [[package]] @@ -811,7 +813,7 @@ dependencies = [ "futures-lite", "parking", "polling", - "rustix", + "rustix 0.38.44", "slab", "tracing", "windows-sys 0.59.0", @@ -854,7 +856,7 @@ dependencies = [ "cfg-if", "event-listener", "futures-lite", - "rustix", + "rustix 0.38.44", "tracing", ] @@ -881,7 +883,7 @@ dependencies = [ "cfg-if", "futures-core", "futures-io", - "rustix", + "rustix 0.38.44", "signal-hook-registry", "slab", "windows-sys 0.59.0", @@ -1202,7 +1204,7 @@ dependencies = [ "bitflags 2.8.0", "log", "polling", - "rustix", + "rustix 0.38.44", "slab", "thiserror 1.0.69", ] @@ -1214,7 +1216,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95a66a987056935f7efce4ab5668920b5d0dac4a7c99991a67395f13702ddd20" dependencies = [ "calloop", - "rustix", + "rustix 0.38.44", "wayland-backend", "wayland-client", ] @@ -3117,6 +3119,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" @@ -3224,6 +3247,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" @@ -4188,6 +4217,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" @@ -4294,7 +4368,7 @@ dependencies = [ "concurrent-queue", "hermit-abi", "pin-project-lite", - "rustix", + "rustix 0.38.44", "tracing", "windows-sys 0.59.0", ] @@ -4685,7 +4759,7 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "winreg", + "winreg 0.50.0", ] [[package]] @@ -4833,7 +4907,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", ] @@ -5082,6 +5169,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" @@ -5162,7 +5260,7 @@ dependencies = [ "libc", "log", "memmap2", - "rustix", + "rustix 0.38.44", "thiserror 1.0.69", "wayland-backend", "wayland-client", @@ -5246,6 +5344,19 @@ dependencies = [ "rand 0.8.5", ] +[[package]] +name = "steamlocate" +version = "2.0.1" +source = "git+https://github.com/WilliamVenner/steamlocate-rs.git?rev=6fc7aeef928a5b9cc40823a02de61ed0cc38a759#6fc7aeef928a5b9cc40823a02de61ed0cc38a759" +dependencies = [ + "crc", + "home", + "keyvalues-parser", + "keyvalues-serde", + "serde", + "winreg 0.55.0", +] + [[package]] name = "strict-num" version = "0.1.1" @@ -5450,15 +5561,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", ] @@ -5901,6 +6011,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" @@ -6167,7 +6283,7 @@ checksum = "b7208998eaa3870dad37ec8836979581506e0c5c64c20c9e79e9d2a10d6f47bf" dependencies = [ "cc", "downcast-rs", - "rustix", + "rustix 0.38.44", "scoped-tls", "smallvec", "wayland-sys", @@ -6180,7 +6296,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", ] @@ -6202,7 +6318,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", ] @@ -6439,7 +6555,7 @@ dependencies = [ "either", "home", "once_cell", - "rustix", + "rustix 0.38.44", ] [[package]] @@ -6993,7 +7109,7 @@ dependencies = [ "pin-project", "raw-window-handle", "redox_syscall 0.4.1", - "rustix", + "rustix 0.38.44", "sctk-adwaita", "smithay-client-toolkit", "smol_str", @@ -7032,6 +7148,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" @@ -7096,7 +7222,7 @@ dependencies = [ "libc", "libloading", "once_cell", - "rustix", + "rustix 0.38.44", "x11rb-protocol", ] @@ -7113,8 +7239,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/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/Cargo.toml b/alvr/server_io/Cargo.toml index 3ba728c3e8..c8f0e6601b 100644 --- a/alvr/server_io/Cargo.toml +++ b/alvr/server_io/Cargo.toml @@ -17,6 +17,10 @@ encoding_rs_io = "0.1" 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] cpal = "0.15" diff --git a/alvr/server_io/src/openvrpaths.rs b/alvr/server_io/src/openvrpaths.rs index f371d82d81..2b17404693 100644 --- a/alvr/server_io/src/openvrpaths.rs +++ b/alvr/server_io/src/openvrpaths.rs @@ -1,6 +1,6 @@ use alvr_common::{ - anyhow::{bail, Result}, - ToAny, + anyhow::{bail, Error, Result}, + debug, ToAny, }; use encoding_rs_io::DecodeReaderBytes; use serde_json as json; @@ -27,20 +27,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. + let steamvr_vrsettings_path = steamlocate::SteamDir::locate()? + .path() + .join("config/steamvr.vrsettings"); + debug!( + "steamvr_vrsettings_path: {}", + steamvr_vrsettings_path.display() + ); + + if steamvr_vrsettings_path.exists() { + Ok(steamvr_vrsettings_path) } else { - dirs::data_dir() - } - .to_any()? - .join("Steam/config/steamvr.vrsettings"); - - if path.exists() { - Ok(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." + ) } } @@ -85,12 +85,13 @@ 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)? { + Some((app, library)) => Ok(library.resolve_app_dir(&app)), + None => Err(Error::msg( + "Couldn't locate SteamVR, please make sure you have installed it.", + )), + } }