···25252626## Usage
27272828+> NOTE: If you plan to use the SteamVR Lighthouse driver with:
2929+> - Flatpak Steam
3030+> - WiVRn without a lighthouse-tracked headset (for example if you want to use lighthouse body trackers, but don't own a lighthouse headset)
3131+>
3232+> ..you'll have to calibrate using AtomicXR instead of Envision: `axr calibrate steamvr-lh`
3333+2834CLI:
2935- Configure: `axr icfg`
3036- Apply configuration & update applications: `axr apply`
+57
src/atomic-xr/mod.nu
···6767 }
6868}
69697070+def "ask yn" [prompt: string] {
7171+ loop {
7272+ match (input -n 1 $"($prompt) [y/n]: " | str downcase) {
7373+ "y" => (return true)
7474+ "n" => (return false)
7575+ _ => (log error "Invalid option, please choose `y` or `n`.")
7676+ }
7777+ }
7878+}
7979+8080+# SteamVR Quick Calibration
8181+export def "calibrate steamvr-lh" [] {
8282+ if (ask yn "Do you own a lighthouse-tracked HMD? (e.g. Index, Vive Pro)") {
8383+ input -sn 1 "Please connect your headset and place it on the floor, then press any key to start the calibration."
8484+8585+ log info "Starting SteamVR Lighthouse calibration"
8686+8787+ # TODO: Support using native steam installation
8888+ log warning "This is intended for Flatpak Steam, if you're using native Steam, please use Envision instead."
8989+ log warning "If you'd like to see this functionality in AtomicXR, please open an issue on Codeberg."
9090+9191+ let vrcmd_bin: path = $"($env.HOME)/.steam/root/steamapps/common/SteamVR/bin/linux64/vrcmd"
9292+ let environment = $"LD_LIBRARY_PATH=('~/.var/app/com.valvesoftware.Steam/.steam/root/steamapps/common/SteamVR/bin/linux64' | path expand)"
9393+9494+ let server = job spawn {flatpak run --command=$"($vrcmd_bin)" --env=$"($environment)" com.valvesoftware.Steam --pollposes}
9595+ sleep 2sec # TODO: detect when the server is ready
9696+ try {
9797+ flatpak run --command=$"($vrcmd_bin)" --env=$"($environment)" com.valvesoftware.Steam --resetroomsetup
9898+ } catch {|err|
9999+ job kill $server
100100+ error make $err
101101+ }
102102+103103+ job kill $server
104104+ log info "Calibration finished"
105105+ } else {
106106+ log info "Creating default Lighthouse Database"
107107+108108+ if not ("~/.steam/root/config/lighthouse/" | path exists) {
109109+ error make {
110110+ msg: "Could not find lighthouse configuration directory."
111111+ help: "Make sure you have SteamVR installed, and .steam points to the correct location. You may need to select \"Symlink .steam directory\" in `axr icfg` if you're using the Steam Flatpak."
112112+ }
113113+ }
114114+115115+ {
116116+ base_stations: []
117117+ known_objects: []
118118+ known_universes: []
119119+ revision: 1
120120+ }
121121+ | save -f ~/.steam/root/config/lighthouse/lighthousedb.json
122122+123123+ log info "Created default Lighthouse Database"
124124+ }
125125+}
126126+70127# Apply current configuration (and update applications)
71128export def apply [
72129 --sysconfigs-only (-s)