mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 13:55:58 +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.
327 lines
12 KiB
Python
Executable File
327 lines
12 KiB
Python
Executable File
#!/usr/bin/python3
|
|
import json
|
|
import os
|
|
import re
|
|
import runpy
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
SYNC_KEYS = ("BL_SYNC", "BL_SYNC_FALLBACK", "BL_FSYNC_FIRST", "BL_SYNC_MIN_NOFILE", "PROTON_NO_ESYNC", "PROTON_NO_FSYNC", "PROTON_NO_NTSYNC", "WINEESYNC")
|
|
SEED_REDISTS = "/usr/local/bin/droiddeck-seed-redists"
|
|
PACK_KEYS = ("WINESERVER", "BL_SYNC_PACK", "WINEESYNC", "PROTON_NO_ESYNC", "PROTON_NO_FSYNC")
|
|
|
|
|
|
def game_id(env):
|
|
prefix = env.get("STEAM_COMPAT_DATA_PATH", "").rstrip("/")
|
|
if not prefix:
|
|
return None
|
|
value = prefix.rsplit("/", 1)[-1]
|
|
if not re.fullmatch(r"-?[0-9]+", value):
|
|
return None
|
|
number = int(value)
|
|
if not -(2**31) <= number < 2**32 or number == 0:
|
|
return None
|
|
return str(number % 2**32)
|
|
|
|
|
|
DOTNET_FEX = {
|
|
"FEX_TSOENABLED": "1",
|
|
"FEX_VECTORTSOENABLED": "1",
|
|
"FEX_MEMCPYSETTSOENABLED": "1",
|
|
"FEX_HALFBARRIERTSOENABLED": "1",
|
|
"FEX_X87REDUCEDPRECISION": "0",
|
|
"FEX_MULTIBLOCK": "0",
|
|
}
|
|
|
|
|
|
def game_files(exe):
|
|
"""Lower-cased names of the files next to the game's executable and one directory below."""
|
|
names = set()
|
|
folder = os.path.dirname(exe)
|
|
try:
|
|
with os.scandir(folder) as top:
|
|
for entry in top:
|
|
names.add(entry.name.lower())
|
|
if entry.is_dir(follow_symlinks=False):
|
|
try:
|
|
with os.scandir(entry.path) as inner:
|
|
names.update(e.name.lower() for e in inner)
|
|
except OSError:
|
|
pass
|
|
except OSError:
|
|
pass
|
|
return names
|
|
|
|
|
|
class Game:
|
|
"""What a fix gets to look at: the executable, its launch arguments and the files beside it."""
|
|
|
|
def __init__(self, exe, args):
|
|
self.exe = exe
|
|
self.args = args
|
|
self.stem = os.path.splitext(os.path.basename(exe))[0].lower()
|
|
self.files = game_files(exe)
|
|
|
|
def has_arg(self, name):
|
|
return any(a == name or a.startswith(name + "=") for a in self.args)
|
|
|
|
|
|
FIXES = []
|
|
|
|
|
|
def fix(function):
|
|
FIXES.append(function)
|
|
return function
|
|
|
|
|
|
def is_godot(game):
|
|
return game.stem + ".pck" in game.files or "godotsharp.dll" in game.files
|
|
|
|
|
|
@fix
|
|
def dotnet_memory_ordering(game):
|
|
if "coreclr.dll" in game.files:
|
|
return DOTNET_FEX, [], ".NET runtime: FEX with full TSO and without multiblock"
|
|
|
|
|
|
@fix
|
|
def godot_vulkan(game):
|
|
if is_godot(game) and not game.has_arg("--rendering-driver"):
|
|
return {}, ["--rendering-driver", "vulkan"], "Godot: Vulkan renderer"
|
|
|
|
|
|
@fix
|
|
def godot_sentry(game):
|
|
sentry = sorted(n[:-4] for n in game.files if n.startswith("libsentry.windows.") and n.endswith(".dll"))
|
|
if is_godot(game) and sentry:
|
|
return {"WINEDLLOVERRIDES": ";".join(n + "=d" for n in sentry)}, [], "Godot: Sentry crash handler off"
|
|
|
|
|
|
@fix
|
|
def arkham_city_x87(game):
|
|
"""Batman: Arkham City (BatmanAC.exe, also started through BmLauncher.exe beside it) leans on x87
|
|
and stops with Unreal's "Fatal error!" right after start when FEX reduces its precision."""
|
|
if "batmanac.exe" in game.files:
|
|
return {"FEX_X87REDUCEDPRECISION": "0"}, [], "Batman: Arkham City: FEX with full x87 precision"
|
|
|
|
|
|
def skip_red_launcher(command):
|
|
"""Cyberpunk 2077's prelauncher opens REDlauncher, a Qt WebEngine window that hands over to the
|
|
game half a minute later and then stays up beside it, well over a core busy for as long as the
|
|
game runs. The game is started itself instead; the prelauncher's own --launcher-skip started it
|
|
twice."""
|
|
if len(command) > 2 and os.path.basename(command[2]).lower() == "redprelauncher.exe":
|
|
game = os.path.join(os.path.dirname(command[2]), "bin", "x64", "Cyberpunk2077.exe")
|
|
if os.path.isfile(game):
|
|
print("droiddeck-game-env: REDlauncher skipped", file=sys.stderr)
|
|
return command[:2] + [game] + command[3:]
|
|
return command
|
|
|
|
|
|
def engine_fixes(exe, args):
|
|
"""Environment and extra arguments a game needs because of what it is built with."""
|
|
game = Game(exe, args)
|
|
env, extra, notes = {}, [], []
|
|
for check in FIXES:
|
|
found = check(game)
|
|
if found:
|
|
env.update(found[0])
|
|
extra += found[1]
|
|
notes.append(found[2])
|
|
return env, extra, notes
|
|
|
|
|
|
def win_components(compat, app_id):
|
|
"""The game's Windows components put into its prefix; returns their WINEDLLOVERRIDES entries."""
|
|
if not compat:
|
|
return ""
|
|
try:
|
|
module = runpy.run_path(str(Path(__file__).resolve().parent / "droiddeck-wincomponents"))
|
|
names, notes = module["apply"](compat.rstrip("/"), app_id)
|
|
for note in notes:
|
|
print("droiddeck-game-env: " + note, file=sys.stderr)
|
|
return module["overrides_value"](names)
|
|
except Exception as error:
|
|
print("droiddeck-game-env: Windows components not applied (%s)" % error, file=sys.stderr)
|
|
return ""
|
|
|
|
|
|
def apply_config(env, config, app_id, fixes=None):
|
|
if config.get("version") != 1:
|
|
raise ValueError("unsupported environment configuration")
|
|
result = env.copy()
|
|
entries = dict(config.get("shared", {}))
|
|
for name, value in (fixes or {}).items():
|
|
if name == "WINEDLLOVERRIDES" and entries.get(name, env.get(name)):
|
|
value = entries.get(name, env.get(name)) + ";" + value
|
|
entries[name] = value
|
|
entries.update(config.get("games", {}).get(app_id, {}))
|
|
for name, value in entries.items():
|
|
if not re.fullmatch(r"[A-Za-z_][A-Za-z0-9_]*", name):
|
|
raise ValueError("invalid environment name")
|
|
if value is None:
|
|
result.pop(name, None)
|
|
elif isinstance(value, str) and "\0" not in value and len(value) <= 8192:
|
|
result[name] = value
|
|
else:
|
|
raise ValueError("invalid environment value")
|
|
game_dxvk = config.get("dxvkConfigGames", {})
|
|
if not isinstance(game_dxvk, dict):
|
|
raise ValueError("invalid game dxvk configuration")
|
|
dxvk = game_dxvk.get(app_id, config.get("dxvkConfig"))
|
|
if dxvk is not None:
|
|
if not isinstance(dxvk, str) or "\0" in dxvk or len(dxvk) > 8192:
|
|
raise ValueError("invalid dxvk configuration")
|
|
if dxvk:
|
|
own = result.get("DXVK_CONFIG", "").strip().rstrip(";").strip()
|
|
result["DXVK_CONFIG"] = own + "; " + dxvk if own else dxvk
|
|
return result
|
|
|
|
|
|
def sync_config(config, app_id):
|
|
games = config.get("games", {})
|
|
return {
|
|
"version": config.get("version"),
|
|
"shared": {name: value for name, value in config.get("shared", {}).items() if name in SYNC_KEYS},
|
|
"games": {app_id: {name: value for name, value in games.get(app_id, {}).items() if name in SYNC_KEYS}},
|
|
}
|
|
|
|
|
|
def load_sync():
|
|
try:
|
|
return runpy.run_path(str(Path(__file__).resolve().parent / "droiddeck-esync"))
|
|
except Exception as error:
|
|
print("droiddeck-game-env: sync selection failed (%s); stock launch" % error, file=sys.stderr)
|
|
return None
|
|
|
|
|
|
def select_sync(command, env, sync=None):
|
|
try:
|
|
sync = sync if sync is not None else load_sync()
|
|
if sync is None:
|
|
return command, env
|
|
chosen, chosen_env = sync["select"](command, env)
|
|
if chosen and all(isinstance(value, str) for value in chosen) and isinstance(chosen_env, dict):
|
|
return list(chosen), dict(chosen_env)
|
|
except Exception as error:
|
|
print("droiddeck-game-env: sync selection failed (%s); stock launch" % error, file=sys.stderr)
|
|
return command, env
|
|
|
|
|
|
def record_stock(sync, command, env):
|
|
try:
|
|
if sync is not None and "record" in sync:
|
|
sync["record"](command, env)
|
|
except Exception as error:
|
|
print("droiddeck-game-env: stock launch not recorded (%s)" % error, file=sys.stderr)
|
|
|
|
|
|
def without_pack(chosen_env, env):
|
|
result = dict(chosen_env)
|
|
for name in PACK_KEYS:
|
|
if name in env:
|
|
result[name] = env[name]
|
|
else:
|
|
result.pop(name, None)
|
|
return result
|
|
|
|
|
|
SSBS_LIB = "/usr/local/lib/libssbs.so"
|
|
|
|
|
|
def force_ssbs(command, env):
|
|
"""DROIDDECK_FORCE_SSBS=1 (a game's or the shared environment): preload libssbs.so into this
|
|
Proton's Wine, which then keeps PSTATE.SSBS set across signal returns - speculative store
|
|
bypass stays allowed, as force_ssbs.diff does inside a rebuilt ntdll. ARM64 Protons only: the
|
|
library is aarch64 and only arm64 Wine has the signal path it fixes."""
|
|
if env.get("DROIDDECK_FORCE_SSBS", "").lower() not in ("1", "on", "true", "yes"):
|
|
return env
|
|
proton = os.path.dirname(command[0]) if command else ""
|
|
if not os.path.isdir(os.path.join(proton, "files/lib/wine/aarch64-unix")):
|
|
print("droiddeck-game-env: force SSBS asked for, but this Proton is not an ARM64 one; left off", file=sys.stderr)
|
|
return env
|
|
if not os.path.isfile(SSBS_LIB):
|
|
print("droiddeck-game-env: force SSBS asked for, but %s is missing; left off" % SSBS_LIB, file=sys.stderr)
|
|
return env
|
|
parts = [p for p in re.split(r"[:\s]+", env.get("LD_PRELOAD", "")) if p]
|
|
if SSBS_LIB not in parts:
|
|
env = dict(env, LD_PRELOAD=":".join(parts + [SSBS_LIB]))
|
|
print("droiddeck-game-env: force SSBS on (libssbs.so preloaded)", file=sys.stderr)
|
|
return env
|
|
|
|
|
|
EVALUATOR_SCRIPT = re.compile(r"(?:^|[\\/])evaluatorscript_[0-9]+\.vdf$", re.IGNORECASE)
|
|
|
|
|
|
def mark_install_scripts(command, env):
|
|
"""The client is about to run a game's install scripts (iscriptevaluator.exe): mark every process
|
|
in them but a Vulkan runtime installer as already run first, so no redistributable installer
|
|
starts - on first launch the shared ones may still be downloading, and on ARM64 Proton the VC++
|
|
ones stop with an error."""
|
|
if not any(arg.lower().replace("\\", "/").endswith("iscriptevaluator.exe") for arg in command):
|
|
return
|
|
root = env.get("STEAM_COMPAT_CLIENT_INSTALL_PATH") or str(Path.home() / ".local/share/Steam")
|
|
scripts = [str(Path(root) / arg.replace("\\", "/")) for arg in command if EVALUATOR_SCRIPT.search(arg)]
|
|
scripts = [path for path in scripts if os.path.isfile(path)]
|
|
if not scripts:
|
|
return
|
|
try:
|
|
subprocess.run([SEED_REDISTS, root], env=dict(env, DROIDDECK_SEED_SCRIPTS="\n".join(scripts)),
|
|
stdout=sys.stderr, timeout=60, check=False)
|
|
except (OSError, subprocess.SubprocessError) as error:
|
|
print("droiddeck-game-env: install scripts not marked (%s)" % error, file=sys.stderr)
|
|
|
|
|
|
def main():
|
|
command = sys.argv[1:]
|
|
if not command:
|
|
return 2
|
|
env = os.environ.copy()
|
|
mic_enabled = env.get("BL_MIC_ENABLED")
|
|
mark_install_scripts(command, env)
|
|
app_id = game_id(env)
|
|
if app_id:
|
|
waiting = len(command) > 1 and command[1] == "waitforexitandrun"
|
|
fixes = {}
|
|
if waiting:
|
|
command = skip_red_launcher(command)
|
|
fixes, extra, notes = engine_fixes(command[2], command[3:]) if len(command) > 2 else ({}, [], [])
|
|
for note in notes:
|
|
print("droiddeck-game-env: " + note, file=sys.stderr)
|
|
command += extra
|
|
components = win_components(env.get("STEAM_COMPAT_DATA_PATH", ""), app_id)
|
|
if components:
|
|
own = fixes.get("WINEDLLOVERRIDES")
|
|
fixes["WINEDLLOVERRIDES"] = components + ";" + own if own else components
|
|
path = Path.home() / ".config/droiddeck/game-environment.json"
|
|
try:
|
|
with path.open(encoding="utf-8") as source:
|
|
config = json.load(source)
|
|
if waiting:
|
|
env = apply_config(env, config, app_id, fixes)
|
|
else:
|
|
env = apply_config(env, sync_config(config, app_id), app_id)
|
|
except FileNotFoundError:
|
|
if waiting:
|
|
env = apply_config(env, {"version": 1}, app_id, fixes)
|
|
except (OSError, ValueError, TypeError, AttributeError):
|
|
print("droiddeck-game-env: invalid configuration; using inherited environment", file=sys.stderr)
|
|
if mic_enabled == "0":
|
|
env["BANNER_AUDIO_DIRECT_MIC"] = "0"
|
|
env = force_ssbs(command, env)
|
|
sync = load_sync()
|
|
launch, launch_env = select_sync(command, env, sync)
|
|
if launch[0] != command[0]:
|
|
try:
|
|
os.execvpe(launch[0], launch, launch_env)
|
|
except OSError as error:
|
|
print("droiddeck-game-env: %s could not start (%s); stock launch" % (launch[0], error), file=sys.stderr)
|
|
launch, launch_env = command, without_pack(launch_env, env)
|
|
record_stock(sync, launch, launch_env)
|
|
os.execvpe(launch[0], launch, launch_env)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|