mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 05:46:03 +00:00
* feat: Epic Games Launcher for Linux Install Epic's official Linux launcher (EGLv2) from Epic's CDN with Valve's Steam Runtime 4 and run it under FEX, signed in with the linked Epic account. Epic games launch through a hidden launcher instance so they get the launcher's own arguments, with the exchange-code launch as the fallback, and DroidDeck installs show up in the launcher as installed. In the launcher, touch scrolls like a phone app and the gamepad drives the UI: D-pad and left stick move the selection, A opens, B goes back, the right stick and triggers scroll proportionally, X opens the options menu, Y the keyboard and LB/RB switch tabs. * feat: Epic Games Launcher for Linux Install Epic's official Linux launcher (EGLv2) from Epic's CDN with Valve's Steam Runtime 4 and run it under FEX, signed in with the linked Epic account. Epic games launch through a hidden launcher instance so they get the launcher's own arguments, with the exchange-code launch as the fallback, and DroidDeck installs show up in the launcher as installed. In the launcher, touch scrolls like a phone app and the gamepad drives the UI: D-pad and left stick move the selection, A opens, B goes back, the right stick and triggers scroll proportionally, X opens the options menu, Y the keyboard and LB/RB switch tabs. * Route Epic games through Steam, import launcher installs, offer the second library - Every Epic launch goes Steam -> Epic Games Launcher -> game; Play inside the open launcher hands the game to Steam - Games installed from inside the launcher get a Games-tab entry and launch through Steam; the launcher installs to the last Stores target - Stores install picker offers the Steam second library, with side-by-side choices - uruntime xattr-only failures no longer fail the launcher unpack (app-extract) * Hand launcher Play and Steam links to Steam, wait for FEX on first run Play on a game the launcher just installed is matched to its install record and handed to Steam. Steam games listed in the launcher open steam://rungameid links, which now start the game in a Steam session. Opening the launcher before Steam has downloaded FEX asks Steam for it and starts Steam instead of failing with no-fex. * Address review: FEX check, play-in-Steam action, touch route thread, scroll scale fexReady needs a FEX binary in Steam's FEX tool, not just its folder. The play-in-Steam action stays until the link is handled, so Run Steam at startup can't start a session first. The pad touch route reads the mouse mode without side effects off the main thread and posts the pad update there. Vertical scroll uses the output height. A status-2 unpack counts only when AppRun is there. The xdg-open command is tested end to end for Steam links. * Open the launcher through Steam, recover dropped shortcuts, sign out of both The Epic Games Launcher now runs as its own Steam shortcut, so opening it starts Steam, which opens the launcher, and Play inside it goes to the running Steam. Steam dropped a running shortcut from its library when the game exited after a sleep/wake replay or a server re-logon, and launching it then waited forever at ShowInterstitials. login1 only replays sleep/wake when Steam is asleep. The session restarts Steam when a requested shortcut is missing, and when a game exits with its shortcut gone and nothing else runs. Resuming after a long pause no longer reports failure while traced processes are still waking, so "Steam is paused" goes away on the first tap. Signing out of the launcher signs DroidDeck's Epic store out, and signing out in DroidDeck restarts the launcher signed out and clears the Epic web cookies. * Address review: one session-switch poll, Epic setup can't block a session A new switch confirmation replaces the pending poll instead of adding a second one that could start the session again. Epic library sync and install-folder setup at session start are each guarded, so a bad preference no longer stops the guest from launching. * Uninstall the Epic Games Launcher from the Games tab An Uninstall button next to Launch asks first, closes a running session, and removes the launcher and its runtime. The launcher's sign-in and install records stay, so its games keep their Games-tab entries and a reinstall comes back signed in. Its Steam shortcut goes away on the next Steam start. * Address review: uninstall only after the session has ended The launcher's files are removed only once the session is not running and its phase has ended; a shutdown still in progress after the wait reports failure instead. The confirmation reads the session state from the front-end state. * Find FEX that Steam installed on the second library Steam's tools on a second library live in DroidDeck's private copy, which the session binds over the library. The launcher's FEX check only looked on the shared storage, so with FEX there it always asked Steam for FEX and only Steam opened. It now checks the private copy too. * Start games without Steam, per-game Settings menu with Wine sync "Start without Steam" now really leaves the Steam client out: the game runs in its own Proton/FEX through droiddeck-proton-run in a run session, and the Epic Games Launcher opens on its own with its games playing in it. Run sessions for these games are not pinned to the big cores and get DirectAudio and the added-games list like Steam. The Games tab card is now "Settings", titled "<game> Settings": Start without Steam, FEX preset, Wine sync (ntsync, fsync, esync, wineserver or the app default) and Default, which puts everything changed for the game back to the app's settings. The app-wide Wine sync choice is shown in the Steam settings Session tab. * Address review: uninstall guard, routed games, shortcut matching Opening or reinstalling the Epic Games Launcher waits while it is being uninstalled. Added games that are Steam installs keep their Start without Steam setting under their Steam app id and start as that Steam game. Live shortcut lookups wait for Steam's library to load and match a same-name shortcut by its executable, so no duplicate is added. The session treats the open launcher as itself even when it could not tell its Steam app id. * Address review: drop a queued launcher switch when it is uninstalled A confirmed switch to the Epic Games Launcher that is still waiting for the old session to end is cancelled when the launcher is uninstalled, and never starts while the uninstall runs. The launcher id test sets its environment for its own runs only.
175 lines
8.5 KiB
Python
175 lines
8.5 KiB
Python
import os
|
|
from pathlib import Path
|
|
import subprocess
|
|
import tempfile
|
|
import textwrap
|
|
import unittest
|
|
|
|
SESSION = Path(__file__).resolve().parents[1] / "linuxfs/overlay/usr/local/bin/droiddeck-session"
|
|
SOURCE = SESSION.read_text()
|
|
START = SOURCE.index(" steam_other_game_running() {")
|
|
END = SOURCE.index(" steam_bring_forward() {", START)
|
|
FUNCTIONS = textwrap.dedent(SOURCE[START:END])
|
|
GAME = str((3333273269 << 32) | 0x02000000)
|
|
|
|
|
|
class SteamShortcutRecoveryTest(unittest.TestCase):
|
|
def setUp(self):
|
|
self.temp = tempfile.TemporaryDirectory()
|
|
self.addCleanup(self.temp.cleanup)
|
|
self.root = Path(self.temp.name)
|
|
self.launch = self.root / "session"
|
|
self.launch.mkdir()
|
|
self.bin = self.root / "bin"
|
|
self.bin.mkdir()
|
|
steam = self.root / "steam/steamrtarm64"
|
|
steam.mkdir(parents=True)
|
|
self.steam_log = self.root / "steam-args"
|
|
(steam / "steam").write_text("#!/bin/sh\nprintf '%s\\n' \"$*\" >> \"$STEAM_LOG\"\n")
|
|
(steam / "steam").chmod(0o755)
|
|
self.agent = self.bin / "droiddeck-agent"
|
|
self.agent.write_text(
|
|
"#!/bin/sh\n"
|
|
"n=$(cat \"$AGENT_COUNT\" 2>/dev/null || echo 0); n=$((n + 1)); echo $n > \"$AGENT_COUNT\"\n"
|
|
"i=0; last=0\n"
|
|
"for s in $AGENT_STATES; do i=$((i + 1)); last=$s; [ \"$i\" -eq \"$n\" ] && exit \"$s\"; done\n"
|
|
"exit \"$last\"\n")
|
|
self.agent.chmod(0o755)
|
|
|
|
def launch_game(self, states, focusable="769", extra=None):
|
|
xprop = self.bin / "xprop"
|
|
xprop.write_text("#!/bin/sh\necho 'GAMESCOPE_FOCUSABLE_APPS(CARDINAL) = %s'\n" % focusable)
|
|
xprop.chmod(0o755)
|
|
script = "nap() { :; }\nsteam_root=%s\n%s\nsteam_launch_game %s\n" % (
|
|
self.root / "steam", FUNCTIONS.replace("/usr/local/bin/droiddeck-agent", str(self.agent)), GAME)
|
|
env = dict(os.environ, HOME=str(self.root), BL_LAUNCH_DIR=str(self.launch),
|
|
PATH=str(self.bin) + os.pathsep + os.environ["PATH"], STEAM_LOG=str(self.steam_log),
|
|
AGENT_COUNT=str(self.root / "agent-count"), AGENT_STATES=states, **(extra or {}))
|
|
result = subprocess.run(["bash", "-c", script], env=env, text=True, capture_output=True, timeout=10)
|
|
self.assertEqual(0, result.returncode, result.stderr)
|
|
steam = self.steam_log.read_text().splitlines() if self.steam_log.exists() else []
|
|
restart = self.root / ".bl-restart-game"
|
|
return steam, restart.read_text().strip() if restart.exists() else None, result.stdout
|
|
|
|
def test_a_shortcut_that_stays_known_launches_once(self):
|
|
steam, restart, _ = self.launch_game("0")
|
|
self.assertEqual(["steam://rungameid/" + GAME], steam)
|
|
self.assertIsNone(restart)
|
|
self.assertEqual("9", (self.root / "agent-count").read_text().strip())
|
|
|
|
def test_a_shortcut_dropped_while_launching_restarts_steam_for_it(self):
|
|
steam, restart, out = self.launch_game("0 0 4")
|
|
self.assertEqual(["steam://rungameid/" + GAME, "-shutdown"], steam)
|
|
self.assertEqual(GAME, restart)
|
|
self.assertIn("dropped shortcut", out)
|
|
|
|
def test_a_shortcut_already_lost_restarts_steam_without_launching(self):
|
|
steam, restart, out = self.launch_game("4")
|
|
self.assertEqual(["-shutdown"], steam)
|
|
self.assertEqual(GAME, restart)
|
|
self.assertIn("lost shortcut", out)
|
|
|
|
def test_steam_is_restarted_only_once_for_the_same_game(self):
|
|
steam, restart, _ = self.launch_game("4")
|
|
self.assertEqual(GAME, restart)
|
|
(self.root / ".bl-restart-game").unlink()
|
|
self.steam_log.unlink()
|
|
(self.root / "agent-count").unlink()
|
|
steam, restart, out = self.launch_game("4")
|
|
self.assertEqual(["steam://rungameid/" + GAME], steam)
|
|
self.assertIsNone(restart)
|
|
self.assertIn("already restarted", out)
|
|
|
|
def test_a_ready_shortcut_allows_a_later_restart_again(self):
|
|
self.launch_game("4")
|
|
(self.root / ".bl-restart-game").unlink()
|
|
(self.root / "agent-count").unlink()
|
|
self.launch_game("0")
|
|
self.assertFalse((self.root / ".bl-restarted-for").exists())
|
|
|
|
def test_a_running_game_is_never_cut_off_by_a_restart(self):
|
|
steam, restart, _ = self.launch_game("0 4", focusable="769,3703311242")
|
|
self.assertEqual(["steam://rungameid/" + GAME], steam)
|
|
self.assertIsNone(restart)
|
|
steam, restart, _ = self.launch_game("4", focusable="769,3703311242")
|
|
self.assertIsNone(restart)
|
|
|
|
def test_the_open_launcher_does_not_count_as_a_running_game(self):
|
|
(self.launch / "epic-open").write_text("2702387189\n")
|
|
steam, restart, _ = self.launch_game("0 4", focusable="769,2702387189")
|
|
self.assertEqual(GAME, restart)
|
|
|
|
def test_the_launcher_without_its_steam_id_still_does_not_count_as_a_running_game(self):
|
|
(self.launch / "epic-open").write_text("1\n")
|
|
launcher = {"BL_EPIC_APP_ID": "2702387189"}
|
|
steam, restart, _ = self.launch_game("0 4", focusable="769,2702387189", extra=launcher)
|
|
self.assertEqual(GAME, restart)
|
|
for marker in (".bl-restart-game", ".bl-restarted-for", "agent-count"):
|
|
(self.root / marker).unlink(missing_ok=True)
|
|
steam, restart, _ = self.launch_game("4", focusable="769,2702387189,3703311242", extra=launcher)
|
|
self.assertIsNone(restart)
|
|
|
|
def test_steam_games_are_launched_without_watching(self):
|
|
steam, restart, _ = self.launch_game("3")
|
|
self.assertEqual(["steam://rungameid/" + GAME], steam)
|
|
self.assertIsNone(restart)
|
|
self.assertEqual("1", (self.root / "agent-count").read_text().strip())
|
|
|
|
def check_exits(self, listings, states, beats):
|
|
pgrep = self.bin / "pgrep"
|
|
pgrep.write_text(
|
|
"#!/bin/bash\n"
|
|
"n=$(cat \"$PGREP_COUNT\" 2>/dev/null || echo 0); n=$((n + 1)); echo $n > \"$PGREP_COUNT\"\n"
|
|
"IFS='|' read -r -a runs <<< \"$PGREP_RUNS\"\n"
|
|
"line=${runs[$((n - 1))]:-}\n"
|
|
"[ -n \"$line\" ] || exit 1\n"
|
|
"printf '%s\\n' \"$line\"\n")
|
|
pgrep.chmod(0o755)
|
|
script = "steam_root=%s\n%s\ndeclare -A _bl_ran=()\n_bl_exited=\n%s" % (
|
|
self.root / "steam", FUNCTIONS.replace("/usr/local/bin/droiddeck-agent", str(self.agent)),
|
|
"steam_check_exits\n" * beats)
|
|
env = dict(os.environ, HOME=str(self.root), BL_LAUNCH_DIR=str(self.launch),
|
|
PATH=str(self.bin) + os.pathsep + os.environ["PATH"], STEAM_LOG=str(self.steam_log),
|
|
AGENT_COUNT=str(self.root / "agent-count"), AGENT_STATES=states,
|
|
PGREP_COUNT=str(self.root / "pgrep-count"), PGREP_RUNS="|".join(listings))
|
|
result = subprocess.run(["bash", "-c", script], env=env, text=True, capture_output=True, timeout=10)
|
|
self.assertEqual(0, result.returncode, result.stderr)
|
|
steam = self.steam_log.read_text().splitlines() if self.steam_log.exists() else []
|
|
agent = self.root / "agent-count"
|
|
return steam, (self.root / ".bl-restart-lost").exists(), int(agent.read_text()) if agent.exists() else 0, result.stdout
|
|
|
|
RUNNING = "41 /root/.local/share/Steam/steamrtarm64/reaper SteamLaunch AppId=3333273269 -- /x/.droiddeck-launch.bat"
|
|
|
|
def test_a_shortcut_dropped_when_its_game_exits_restarts_steam_once_nothing_runs(self):
|
|
steam, marker, asked, out = self.check_exits([self.RUNNING, "", "", ""], "4", 3)
|
|
self.assertEqual(["-shutdown"], steam)
|
|
self.assertTrue(marker)
|
|
self.assertEqual(1, asked)
|
|
self.assertIn("3333273269", out)
|
|
|
|
def test_a_shortcut_still_listed_after_its_game_exits_is_left_alone(self):
|
|
steam, marker, asked, _ = self.check_exits([self.RUNNING, "", "", ""], "0", 4)
|
|
self.assertEqual([], steam)
|
|
self.assertFalse(marker)
|
|
self.assertEqual(1, asked)
|
|
|
|
def test_the_check_waits_a_quiet_beat_after_the_exit(self):
|
|
steam, _, asked, _ = self.check_exits([self.RUNNING, ""], "4", 2)
|
|
self.assertEqual([], steam)
|
|
self.assertEqual(0, asked)
|
|
|
|
def test_a_game_started_meanwhile_is_never_cut_off(self):
|
|
steam, marker, _, _ = self.check_exits([self.RUNNING, "", "", self.RUNNING], "4", 3)
|
|
self.assertEqual([], steam)
|
|
self.assertFalse(marker)
|
|
|
|
def test_steam_games_are_not_checked(self):
|
|
game = "41 /root/.local/share/Steam/steamrtarm64/reaper SteamLaunch AppId=1245620 -- /x/eldenring.exe"
|
|
steam, _, asked, _ = self.check_exits([game, "", "", ""], "4", 3)
|
|
self.assertEqual([], steam)
|
|
self.assertEqual(0, asked)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|