mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 13:55:58 +00:00
Add experimental Xbox and PC Game Pass store support (#1156)
This commit is contained in:
1 parent
af57286c98
commit
f5bba17f53
56 files changed
+3720
-47
No files matched your search
@@ -179,6 +179,17 @@ class GameEnvironmentTest(unittest.TestCase):
|
||||
(other / "Other.exe").touch()
|
||||
self.assertEqual(MODULE["engine_fixes"](str(other / "Other.exe"), []), ({}, [], []))
|
||||
|
||||
def test_deep_rock_gdk_avoids_the_raytracing_pipeline_crash(self):
|
||||
game = "/game/FSD/Binaries/WinGDK/FSD-WinGDK-Shipping.exe"
|
||||
env, extra, notes = MODULE["engine_fixes"](game, [])
|
||||
self.assertEqual(extra, ["-noraytracing", "-ini:Engine:[/Script/Engine.RendererSettings]:r.RayTracing=False"])
|
||||
self.assertEqual(env, {})
|
||||
self.assertTrue(notes)
|
||||
for choice in ("-raytracing", "-noraytracing"):
|
||||
self.assertEqual(MODULE["engine_fixes"](game, [choice]), ({}, [], []))
|
||||
self.assertEqual(MODULE["engine_fixes"]("/game/FSD-Win64-Shipping.exe", []), ({}, [], []))
|
||||
self.assertEqual(MODULE["engine_fixes"]("/game/Other-WinGDK-Shipping.exe", []), ({}, [], []))
|
||||
|
||||
def test_arkham_city_gets_full_x87_precision_over_the_preset(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
city = Path(tmp) / "Batman Arkham City GOTY/Binaries/Win32"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Requested Steam games are handed over as soon as the interface is up; a shortcut is handed over again only if it never took focus."""
|
||||
"""Retry a dropped shortcut without duplicating a launch that is still preparing its first window."""
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
@@ -48,14 +48,21 @@ class SteamColdLaunchTest(unittest.TestCase):
|
||||
sleep = self.bin / "sleep"
|
||||
sleep.write_text("#!/bin/sh\nprintf '%s\n' \"$@\" >> \"$SLEEP_ARGS\"\n")
|
||||
sleep.chmod(0o755)
|
||||
pgrep = self.bin / "pgrep"
|
||||
pgrep.write_text(
|
||||
"#!/bin/sh\n"
|
||||
"printf '%s\\n' \"$@\" > \"$HOME/pgrep-args\"\n"
|
||||
"n=$(cat \"$HOME/pgrep-count\" 2>/dev/null || echo 0); n=$((n + 1)); echo $n > \"$HOME/pgrep-count\"\n"
|
||||
"[ \"$n\" -ge \"${RUNNING_AFTER:-999}\" ]\n")
|
||||
pgrep.chmod(0o755)
|
||||
self.block = LAUNCH_BLOCK.replace("/usr/local/bin/droiddeck-agent", str(agent))
|
||||
|
||||
def run_launch(self, target, focus="769", helper_status=0):
|
||||
def run_launch(self, target, focus="769", helper_status=0, running_after=999):
|
||||
env = dict(os.environ, HOME=str(self.root), BL_LAUNCH_DIR=str(self.launch_dir),
|
||||
PATH=str(self.bin) + os.pathsep + os.environ["PATH"],
|
||||
AGENT_ARGS=str(self.agent_args), SLEEP_ARGS=str(self.sleep_args),
|
||||
AGENT_COUNT=str(self.agent_count), AGENT_STATUS=str(helper_status),
|
||||
FOCUS=focus, FOCUS_COUNT=str(self.focus_count))
|
||||
FOCUS=focus, FOCUS_COUNT=str(self.focus_count), RUNNING_AFTER=str(running_after))
|
||||
script = self.block + "\nprintf 'ARG:%s\n' \"$@\"\nwait\n"
|
||||
url = target if target.startswith("steam://") else "steam://rungameid/" + target
|
||||
result = subprocess.run(["bash", "-c", script, "cold-launch", url],
|
||||
@@ -85,6 +92,20 @@ class SteamColdLaunchTest(unittest.TestCase):
|
||||
self.assertEqual(2, len(self.hand_offs(result)), result.stdout)
|
||||
self.assertIn("overview status 1", result.stdout)
|
||||
|
||||
def test_a_game_still_starting_without_a_window_is_not_launched_twice(self):
|
||||
result = self.run_launch(SHORTCUT, running_after=1)
|
||||
self.assertEqual(1, len(self.hand_offs(result)), result.stdout)
|
||||
self.assertFalse(self.agent_args.exists())
|
||||
self.assertEqual(["-f", "reaper SteamLaunch AppId=3551182975( |$)"],
|
||||
(self.root / "pgrep-args").read_text().splitlines())
|
||||
self.assertIn("already starting", result.stdout)
|
||||
|
||||
def test_a_game_starting_during_the_overview_wait_is_not_launched_twice(self):
|
||||
result = self.run_launch(SHORTCUT, running_after=2)
|
||||
self.assertEqual(1, len(self.hand_offs(result)), result.stdout)
|
||||
self.assertTrue(self.agent_args.exists())
|
||||
self.assertIn("started while waiting", result.stdout)
|
||||
|
||||
def test_a_game_that_takes_focus_during_the_overview_wait_is_not_started_twice(self):
|
||||
focus = " ".join(["769"] * 23) + " 4242"
|
||||
result = self.run_launch(SHORTCUT, focus=focus, helper_status=0)
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import runpy
|
||||
import socket
|
||||
import tempfile
|
||||
import threading
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
BIN = Path(__file__).resolve().parents[1] / 'linuxfs/overlay/usr/local/bin'
|
||||
xbox = runpy.run_path(str(BIN / 'droiddeck-xbox'))
|
||||
|
||||
|
||||
class XboxLaunchTest(unittest.TestCase):
|
||||
def test_other_stores_keep_their_existing_launch(self):
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
folder = Path(root)
|
||||
(folder / '.droiddeck-store.json').write_text(json.dumps({'store': 'gog', 'id': '1'}))
|
||||
self.assertIsNone(xbox['launch'](['/proton', 'waitforexitandrun', str(folder / 'Game.exe')], {}))
|
||||
|
||||
def test_bridge_authenticates_before_forwarding(self):
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
path = str(Path(root) / 'service.sock')
|
||||
upstream = socket.socket(socket.AF_UNIX)
|
||||
upstream.bind(path); upstream.listen(1); upstream.settimeout(3)
|
||||
received = []
|
||||
def serve():
|
||||
connection, _ = upstream.accept()
|
||||
with connection:
|
||||
received.append(connection.recv(8))
|
||||
connection.sendall(b'reply')
|
||||
worker = threading.Thread(target=serve); worker.start()
|
||||
port, key, close = xbox['bridge'](path)
|
||||
try:
|
||||
with socket.create_connection(('127.0.0.1', port), timeout=2) as denied:
|
||||
denied.sendall(b'x' * 64)
|
||||
self.assertEqual(denied.recv(1), b'')
|
||||
with socket.create_connection(('127.0.0.1', port), timeout=2) as client:
|
||||
client.sendall(key[:20].encode())
|
||||
client.sendall(key[20:].encode() + b'request')
|
||||
self.assertEqual(client.recv(5), b'reply')
|
||||
worker.join(3)
|
||||
self.assertFalse(worker.is_alive())
|
||||
self.assertEqual(received, [b'request'])
|
||||
finally:
|
||||
close(); upstream.close()
|
||||
|
||||
def test_wine_wrapper_preserves_selected_proton_args_and_prefix_isolation(self):
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
root = Path(root)
|
||||
prefix = root / 'compat/pfx'
|
||||
prefix.mkdir(parents=True)
|
||||
runtime = root / 'runtime/windows'; runtime.mkdir(parents=True)
|
||||
for name in xbox['DLLS']:
|
||||
(runtime / name).write_bytes(b'MZ-synthetic')
|
||||
command = root / 'command.json'
|
||||
command.write_text(json.dumps(['/selected/proton', 'waitforexitandrun', '/encrypted/Game.exe', '--custom', 'two words']))
|
||||
env = {'STEAM_COMPAT_DATA_PATH': str(prefix.parent), 'DROIDDECK_XBOX_COMMAND_FILE': str(command),
|
||||
'DROIDDECK_XBOX_CREDENTIAL_SOCKET': 'private-account-channel', 'XODUS_BRIDGE_KEY': 'runtime-key'}
|
||||
with patch.dict(os.environ, env), patch.dict(xbox['wine'].__globals__, RUNTIME=runtime.parent), patch('subprocess.run') as initialize, patch('subprocess.call', return_value=7) as call:
|
||||
initialize.return_value.returncode = 0
|
||||
self.assertEqual(xbox['wine'](['/private-view/Game.exe']), 7)
|
||||
argv = call.call_args.args[0]
|
||||
self.assertEqual(argv, ['/selected/proton', 'waitforexitandrun', '/private-view/Game.exe', '--custom', 'two words'])
|
||||
self.assertIn('xgameruntime=n', call.call_args.kwargs['env']['WINEDLLOVERRIDES'])
|
||||
self.assertEqual((prefix / 'drive_c/windows/system32/xgameruntime.dll').read_bytes(), b'MZ-synthetic')
|
||||
initialize.assert_called_once()
|
||||
for child in (initialize, call):
|
||||
child_env = child.call_args.kwargs['env']
|
||||
self.assertNotIn('DROIDDECK_XBOX_CREDENTIAL_SOCKET', child_env)
|
||||
self.assertNotIn('DROIDDECK_XBOX_COMMAND_FILE', child_env)
|
||||
self.assertEqual(child_env['XODUS_BRIDGE_KEY'], 'runtime-key')
|
||||
Reference in new issue
Block a user