From 36ebd41cb31cf48154a0c582e0821e2ee33eb9f2 Mon Sep 17 00:00:00 2001 From: The412Banner <205237651+The412Banner@users.noreply.github.com> Date: Sun, 29 Nov 2026 20:23:00 +0000 Subject: [PATCH] fix(steamvr): Quest library Play installs SteamVR through the app and logs the launch --- .../com/droiddeck/launcher/SessionActivity.kt | 17 ++++++++---- .../session/EnhancedSessionLogShare.kt | 1 + .../launcher/session/QuestSteamVrLaunch.kt | 4 +++ .../session/EnhancedSessionLogShareTest.kt | 17 ++++++++++++ .../session/QuestSteamVrLaunchTest.kt | 24 +++++++++++++++++ docs/development/rayneo-xr.md | 6 +++-- docs/quest.md | 4 +++ .../usr/local/bin/droiddeck-steam-compat | 6 ++--- .../overlay/usr/local/bin/droiddeck-steamvr | 10 +++---- tools/tests/test_steam_compat_live.py | 6 +++-- tools/tests/test_steamvr_helper.py | 26 +++++++++++++++++++ 11 files changed, 104 insertions(+), 17 deletions(-) create mode 100644 app/src/test/java/com/droiddeck/launcher/session/QuestSteamVrLaunchTest.kt diff --git a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt index 8473957bcd..3c496848bb 100644 --- a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt @@ -6349,10 +6349,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde if (!intent.hasExtra(EXTRA_LINK_TASK)) intent.putExtra(EXTRA_LINK_TASK, this.intent.getIntExtra(EXTRA_LINK_TASK, -1)) setIntent(intent) if (::pip.isInitialized) pip.refresh(true) - if (intent.getBooleanExtra(EXTRA_STEAMVR, false) && SessionState.mode == SessionService.MODE_STEAM) { - SessionState.steamVr = true - steamVrAutoTried = false - } + if (intent.getBooleanExtra(EXTRA_STEAMVR, false) && SessionState.mode == SessionService.MODE_STEAM) requestSteamVr() if (intent.action == SessionService.ACTION_HOME_GUIDE) { handleHomeGuideIntent(intent) } else if (intent.action == SessionService.ACTION_RESUME) { @@ -6441,7 +6438,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde private val questSteamVrRequest = object : Runnable { override fun run() { if (com.droiddeck.launcher.session.QuestSteamVrLaunch.takeRequest(this@SessionActivity) && - SessionState.running && SessionState.mode == SessionService.MODE_STEAM) steamVrAction("start") + SessionState.running && SessionState.mode == SessionService.MODE_STEAM) { + if (com.droiddeck.launcher.session.QuestSteamVrLaunch.opensDirectly(steamVrStatus)) steamVrAction("start") + else requestSteamVr() + } uiHandler.postDelayed(this, 1000) } } @@ -6500,6 +6500,12 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde updateHeadTracker() } + private fun requestSteamVr() { + SessionState.steamVr = true + steamVrAutoTried = false + steamVrInstallTried = false + } + private fun steamVrAction(action: String) { if (action == "start" && com.droiddeck.launcher.session.QuestExperimental.isSupported()) { startActivity(android.content.Intent(this, QuestXrActivity::class.java)) @@ -6977,6 +6983,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde SessionState.mode == SessionService.MODE_STEAM, steamVrAutoTried, steamVrInstallTried) ?: return if (action == "start") steamVrAutoTried = true else steamVrInstallTried = true Log.i(TAG, "requested SteamVR $action (glasses=${glasses.model}, output=$glassesOutputActive, control=${glasses.canControl})") + if (action == "install") Toast.makeText(this, R.string.cardboard_steamvr_installing, Toast.LENGTH_LONG).show() steamVrAction(action) } diff --git a/app/src/main/java/com/droiddeck/launcher/session/EnhancedSessionLogShare.kt b/app/src/main/java/com/droiddeck/launcher/session/EnhancedSessionLogShare.kt index c9c55f9c27..5ccce148ca 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/EnhancedSessionLogShare.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/EnhancedSessionLogShare.kt @@ -951,6 +951,7 @@ internal object EnhancedSessionLogShare { "battlenet.log", "spawned.log", "flatpak-install.log", "cef_log.txt", "cef_log.previous.txt", "droiddeck-bionic.log", "console_log.txt", "webhelper_js.txt", "controller_support.txt", "systemperfmanager.txt", "rpcs3", "RPCS3.log", + "droiddeck-steamvr-launch.log", "droiddeck-vrstartup.log", ) private val KNOWN_COMPONENT_PATTERNS = listOf( Regex("[0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{2,}-[a-z0-9-]{1,24}"), diff --git a/app/src/main/java/com/droiddeck/launcher/session/QuestSteamVrLaunch.kt b/app/src/main/java/com/droiddeck/launcher/session/QuestSteamVrLaunch.kt index 8f619b86b3..1dba2c17d7 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/QuestSteamVrLaunch.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/QuestSteamVrLaunch.kt @@ -1,6 +1,7 @@ package com.droiddeck.launcher.session import android.content.Context +import com.droiddeck.launcher.gpu.SteamVr import java.io.File /** @@ -32,4 +33,7 @@ object QuestSteamVrLaunch { fun takeRequest(context: Context): Boolean = QuestExperimental.isSupported() && File(context.filesDir, "$DIR/$REQUEST").delete() + + fun opensDirectly(status: SteamVr.Status?): Boolean = + status == SteamVr.Status.READY || status == SteamVr.Status.RUNNING } diff --git a/app/src/test/java/com/droiddeck/launcher/session/EnhancedSessionLogShareTest.kt b/app/src/test/java/com/droiddeck/launcher/session/EnhancedSessionLogShareTest.kt index e02523e97f..50112c3be4 100644 --- a/app/src/test/java/com/droiddeck/launcher/session/EnhancedSessionLogShareTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/session/EnhancedSessionLogShareTest.kt @@ -114,6 +114,23 @@ class EnhancedSessionLogShareTest { SessionLogShare.clear(app) } + @Test fun steamVrLaunchLogsAreSharedUnderTheirNames() { + val session = tmp.newFolder("2026-11-29-05-steam") + session.resolve("session.log").writeText("startup ok\n") + val steam = session.resolve("steam").apply { mkdirs() } + steam.resolve("droiddeck-steamvr-launch.log").writeText("downloading SteamVR (571 MB)\n") + steam.resolve("droiddeck-vrstartup.log").writeText("vrstartup ok\n") + steam.resolve("unknown-tool.log").writeText("other\n") + + val zips = EnhancedSessionLogShare.create(app, session) + + val names = zips.flatMap { zip -> ZipFile(zip).use { archive -> archive.entries().toList().map { it.name } } } + assertTrue(names.contains("${session.name}/steam/droiddeck-steamvr-launch.log")) + assertTrue(names.contains("${session.name}/steam/droiddeck-vrstartup.log")) + assertTrue(names.none { it.endsWith("/unknown-tool.log") }) + SessionLogShare.clear(app) + } + @Test fun oversizedFilesKeepBoundedBeginningAndTailAndDeclareTruncation() { val session = tmp.newFolder("2026-11-04-02-game") session.resolve("steam-7.log").writeText("begin\n" + "middle\n".repeat(100) + "tail\n") diff --git a/app/src/test/java/com/droiddeck/launcher/session/QuestSteamVrLaunchTest.kt b/app/src/test/java/com/droiddeck/launcher/session/QuestSteamVrLaunchTest.kt new file mode 100644 index 0000000000..4686fd9a2e --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/session/QuestSteamVrLaunchTest.kt @@ -0,0 +1,24 @@ +package com.droiddeck.launcher.session + +import com.droiddeck.launcher.gpu.SteamVr +import org.junit.Assert.assertEquals +import org.junit.Test + +class QuestSteamVrLaunchTest { + @Test fun aLibraryRequestOpensTheImmersiveViewOnlyWhenSteamVrIsInstalled() { + assertEquals( + setOf(SteamVr.Status.READY, SteamVr.Status.RUNNING), + SteamVr.Status.values().filter { QuestSteamVrLaunch.opensDirectly(it) }.toSet(), + ) + assertEquals(false, QuestSteamVrLaunch.opensDirectly(null)) + } + + @Test fun aRequestThatHasToInstallSteamVrGoesThroughTheAutomaticInstallThenStart() { + assertEquals("install", SteamVr.autoAction(SteamVr.Status.NOT_INSTALLED, requested = true, loading = false, + steamSession = true, startTried = false, installTried = false)) + assertEquals(null, SteamVr.autoAction(SteamVr.Status.INSTALLING, requested = true, loading = false, + steamSession = true, startTried = false, installTried = true)) + assertEquals("start", SteamVr.autoAction(SteamVr.Status.READY, requested = true, loading = false, + steamSession = true, startTried = false, installTried = true)) + } +} diff --git a/docs/development/rayneo-xr.md b/docs/development/rayneo-xr.md index 0de7f77196..85cf0049a1 100644 --- a/docs/development/rayneo-xr.md +++ b/docs/development/rayneo-xr.md @@ -145,8 +145,10 @@ verification against the actual phone's Steam version after installation. The helper serializes installation/startup and avoids restarting an active DroidDeck SteamVR session. Library launch diagnostics are in -`${XDG_RUNTIME_DIR:-/tmp}/droiddeck-steamvr/library-launch.log`; normal runtime -logs remain in `vrstartup.log` and Steam's logs directory. It does not intercept +`droiddeck-steamvr-launch.log` in Steam's logs directory, next to +`droiddeck-vrstartup.log`, and Share logs includes both. On a Quest the helper +only asks the app for SteamVR: the app installs it if needed, showing that it is +downloading, then opens the immersive view. It does not intercept arbitrary external `steam://` URLs or change VR game launch arguments. Only VR-only games (`vr_only`) wait for SteamVR and start it. Games where VR is diff --git a/docs/quest.md b/docs/quest.md index 6f69d06cd2..ac01014c8b 100644 --- a/docs/quest.md +++ b/docs/quest.md @@ -83,6 +83,10 @@ and display timing, and returns owned stereo images tagged with the latest eye p SteamVR haptics return through the tracking bridge. No root or separate XR APK is required. Other devices retain their existing SteamVR start behavior. +Play on SteamVR in Steam's library does the same: if SteamVR is not installed yet, +DroidDeck shows that it is downloading SteamVR, installs it, then opens the +immersive view. + The left Touch menu button is SteamVR's system button and toggles its dashboard. The right Meta button remains reserved by the headset OS. diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-compat b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-compat index 91368dbd96..d87946570b 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-compat +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-compat @@ -546,10 +546,10 @@ VR_JS = r""" def launch_steamvr(): say("SteamVR library launch: using the DroidDeck ARM64 helper") - state = os.path.join(os.environ.get("XDG_RUNTIME_DIR", "/tmp"), "droiddeck-steamvr") + logs = os.path.join(os.path.expanduser("~"), ".local/share/Steam/logs") try: - os.makedirs(state, exist_ok=True) - with open(os.path.join(state, "library-launch.log"), "a") as log: + os.makedirs(logs, exist_ok=True) + with open(os.path.join(logs, "droiddeck-steamvr-launch.log"), "a") as log: return subprocess.Popen([VR_HELPER, "launch"], stdin=subprocess.DEVNULL, stdout=log, stderr=subprocess.STDOUT, start_new_session=True) except OSError as e: diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steamvr b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steamvr index 8abe106a7f..eaa586f9a8 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steamvr +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steamvr @@ -103,15 +103,15 @@ case "${1:-status}" in launch) exec 8>"$state/launch.lock" flock -n 8 || exit 0 + if [ -f "$state/quest-immersive" ]; then + : > "$state/xr-request" + echo "asked DroidDeck to install SteamVR if needed and open the Quest's immersive view" + exit 0 + fi if ! installed; then "$0" install || exit $? while [ -f "$state/installing" ]; do sleep 1; done fi - if [ -f "$state/quest-immersive" ]; then - : > "$state/xr-request" - echo "asked DroidDeck to open the Quest's immersive view, which starts SteamVR" - exit 0 - fi "$0" start ;; status) diff --git a/tools/tests/test_steam_compat_live.py b/tools/tests/test_steam_compat_live.py index 15ae63bb89..07279d6a40 100644 --- a/tools/tests/test_steam_compat_live.py +++ b/tools/tests/test_steam_compat_live.py @@ -1003,13 +1003,15 @@ class SwitchToDesktopTest(unittest.TestCase): self.assertEqual(patched["launch_steamvr"].call_count, 2) def test_vr_launch_runs_helper_without_shell_in_background(self): - with tempfile.TemporaryDirectory() as tmp, mock.patch.dict(os.environ, {"XDG_RUNTIME_DIR": tmp}): + with tempfile.TemporaryDirectory() as tmp, mock.patch.dict(os.environ, {"HOME": tmp}): with mock.patch.object(self.globals["subprocess"], "Popen") as popen: LIVE["launch_steamvr"]() self.assertEqual(popen.call_args.args, ([LIVE["VR_HELPER"], "launch"],)) self.assertTrue(popen.call_args.kwargs["start_new_session"]) self.assertNotIn("shell", popen.call_args.kwargs) - self.assertTrue((Path(tmp) / "droiddeck-steamvr/library-launch.log").exists()) + self.assertEqual(popen.call_args.kwargs["stdout"].name, + str(Path(tmp) / ".local/share/Steam/logs/droiddeck-steamvr-launch.log")) + self.assertTrue((Path(tmp) / ".local/share/Steam/logs/droiddeck-steamvr-launch.log").exists()) def test_the_request_goes_to_steamos_session_select(self): helper = LIVE["Helper"]("/steam", 1) diff --git a/tools/tests/test_steamvr_helper.py b/tools/tests/test_steamvr_helper.py index 95df651c7f..92c81d2a05 100644 --- a/tools/tests/test_steamvr_helper.py +++ b/tools/tests/test_steamvr_helper.py @@ -274,6 +274,32 @@ class SteamVrHelperTest(unittest.TestCase): self.assertTrue(vrpath.is_file()) self.assertTrue(xr.is_symlink()) + def launch(self): + self.executable(self.commands / 'curl', 'echo curl >> "$CURL_CALLS"; exit 22') + self.environment['CURL_CALLS'] = str(self.root / 'curl-calls') + self.helper.chmod(0o755) + return subprocess.run(['sh', str(self.helper), 'launch'], env=self.environment, + capture_output=True, text=True, timeout=5) + + def test_quest_launch_hands_a_missing_steamvr_to_the_app_without_downloading_it(self): + (self.steamvr / 'bin/linuxarm64/vrstartup').unlink() + state = self.runtime / 'droiddeck-steamvr' + state.mkdir(parents=True) + (state / 'quest-immersive').touch() + result = self.launch() + self.assertEqual(result.returncode, 0, result.stderr) + self.assertTrue((state / 'xr-request').is_file()) + self.assertFalse((self.root / 'curl-calls').exists()) + self.assertFalse((state / 'installing').exists()) + + def test_launch_elsewhere_still_installs_a_missing_steamvr_itself(self): + (self.steamvr / 'bin/linuxarm64/vrstartup').unlink() + result = self.launch() + self.assertEqual(result.returncode, 1) + self.assertIn('download failed', result.stdout) + self.assertTrue((self.root / 'curl-calls').is_file()) + self.assertFalse((self.runtime / 'droiddeck-steamvr/xr-request').exists()) + if __name__ == '__main__': unittest.main()