diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-compat b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-compat index 7ed1eb71eb..3972faa9b3 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-compat +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-compat @@ -182,6 +182,20 @@ SWITCH_JS = r""" })() """.replace("__BINDING__", SWITCH_BINDING) SESSION_SELECT = "/usr/bin/steamos-session-select" +# Steam opens its Steam Controller welcome tour at every start while the client setting +# controller_show_ibex_tour (CMsgClientSettings field 140014) is on, and only a finished tour turns it +# off; closing it leaves it on. The app's pad is an emulated controller, so the tour never applies. +# A pending firmware update still opens Steam's updater, which checks the update priority instead. +TOUR_JS = r""" +(() => { + let key = 140014 * 8; + const bytes = []; + while (key > 127) { bytes.push((key & 127) | 128); key = Math.floor(key / 128); } + bytes.push(key, 0); + SteamClient.Settings.SetSetting(btoa(String.fromCharCode(...bytes))); + return "off"; +})() +""" VR_BINDING = "droiddeckLaunchSteamVr" VR_HELPER = "/usr/local/bin/droiddeck-steamvr" VR_JS = r""" @@ -528,6 +542,11 @@ class Helper: page.call("Runtime.addBinding", {"name": BINDING}) page.call("Runtime.addBinding", {"name": VR_BINDING}) page.evaluate(VR_JS) + try: + page.evaluate(TOUR_JS) + except RuntimeError: + # The optional tour setting must not block the compat bridge. + pass if not self.steamos: page.call("Runtime.addBinding", {"name": SWITCH_BINDING}) page.evaluate(SWITCH_JS) diff --git a/tools/tests/test_steam_compat_live.py b/tools/tests/test_steam_compat_live.py index 3cf27824b4..a86aab8644 100644 --- a/tools/tests/test_steam_compat_live.py +++ b/tools/tests/test_steam_compat_live.py @@ -774,6 +774,14 @@ class AttachPage: return {"selected": "", "fallback": "", "tools": []} +class TourFailurePage(AttachPage): + def evaluate(self, expression, timeout=30): + self.scripts.append(expression) + if expression == LIVE["TOUR_JS"]: + raise RuntimeError("SteamClient.Settings.SetSetting is unavailable") + return True + + class SwitchToDesktopTest(unittest.TestCase): def setUp(self): self.globals = LIVE["Helper"].attach.__globals__ @@ -798,6 +806,14 @@ class SwitchToDesktopTest(unittest.TestCase): self.assertIn(("Runtime.addBinding", LIVE["VR_BINDING"]), helper.page.calls) self.assertIn(LIVE["VR_JS"], helper.page.scripts) + def test_missing_optional_tour_setting_does_not_block_attach(self): + with mock.patch.dict(self.globals, {"shared_context": lambda port: "/devtools/page/1", "Page": TourFailurePage}): + helper = LIVE["Helper"]("/steam", 1) + self.assertTrue(helper.attach()) + self.assertIn(LIVE["VR_JS"], helper.page.scripts) + self.assertIn(LIVE["TOUR_JS"], helper.page.scripts) + self.assertIsNotNone(helper.page) + def test_vr_bridge_accepts_only_steamvr_and_coalesces_requests(self): helper = LIVE["Helper"]("/steam", 1) helper.page = mock.Mock()