mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 21:15:43 +00:00
Merge main into Wine timezone fix
This commit is contained in:
commit
3f3932d575
941 files changed
+106838
-7538
No files matched your search
@@ -2,6 +2,7 @@ import importlib.machinery
|
||||
import importlib.util
|
||||
import os
|
||||
import re
|
||||
import runpy
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
@@ -68,13 +69,167 @@ class ToolArguments(unittest.TestCase):
|
||||
def test_wine_keeps_the_zone_and_its_wine_host_form(self):
|
||||
text = LAUNCH.read_text()
|
||||
start = text.index('KEEP=" ')
|
||||
loop = text[start:text.index('\ndone\n', start) + 6]
|
||||
env = {'PATH': os.environ['PATH'], 'TZ': 'Asia/Yekaterinburg', 'WINE_HOST_TZ': 'Asia/Yekaterinburg',
|
||||
loop = text[start:text.index('export PATH=/system/bin', start)]
|
||||
env = {'PATH': os.environ['PATH'], 'DROIDDECK_BIONIC_KEEP': 'PATH',
|
||||
'TZ': 'Asia/Yekaterinburg', 'WINE_HOST_TZ': 'Asia/Yekaterinburg',
|
||||
'STALE_HOST': '1'}
|
||||
result = subprocess.run(['bash', '-c', loop + 'echo "${TZ-}|${WINE_HOST_TZ-}|${STALE_HOST-unset}"'],
|
||||
env=env, capture_output=True, text=True, check=True)
|
||||
self.assertEqual('Asia/Yekaterinburg|Asia/Yekaterinburg|unset', result.stdout.strip())
|
||||
|
||||
def test_directaudio_settings_reach_the_built_in_driver(self):
|
||||
text = LAUNCH.read_text()
|
||||
block = text[text.index('KEEP="'):text.index('export PATH=/system/bin')]
|
||||
script = block + 'env | grep -E "AUDIO_DIRECT_|^OTHER=" | sort\n'
|
||||
env = {'PATH': os.environ['PATH'], 'DROIDDECK_BIONIC_KEEP': 'PATH', 'AUDIO_DIRECT_MIC': '1', 'AUDIO_DIRECT_MS': '60', 'OTHER': 'x'}
|
||||
result = subprocess.run(['sh', '-c', script], env=env, text=True, capture_output=True, check=True)
|
||||
self.assertEqual(['BANNER_AUDIO_DIRECT_MIC=1', 'BANNER_AUDIO_DIRECT_MS=60'], result.stdout.split())
|
||||
|
||||
|
||||
def test_original_xbox_switches_reach_wine(self):
|
||||
game_env = runpy.run_path(str(BIN / 'droiddeck-game-env'))
|
||||
switches = dict(game_env['XBOX_BACK_COMPAT_ENV'], VKD3D_PACKED_422_SWIZZLE='rbg1')
|
||||
text = LAUNCH.read_text()
|
||||
block = text[text.index('KEEP="'):text.index('export PATH=/system/bin')]
|
||||
env = dict(switches, PATH=os.environ['PATH'], DROIDDECK_BIONIC_KEEP='PATH', OTHER='x')
|
||||
result = subprocess.run(['sh', '-c', block + 'env\n'], env=env, text=True, capture_output=True, check=True)
|
||||
kept = dict(line.split('=', 1) for line in result.stdout.splitlines() if '=' in line)
|
||||
self.assertEqual(switches, {name: kept.get(name) for name in switches})
|
||||
self.assertNotIn('OTHER', kept)
|
||||
|
||||
def test_start_without_steam_reaches_wine(self):
|
||||
text = LAUNCH.read_text()
|
||||
block = text[text.index('KEEP="'):text.index('export PATH=/system/bin')]
|
||||
env = dict(PATH=os.environ['PATH'], DROIDDECK_BIONIC_KEEP='PATH', DROIDDECK_NO_STEAM='1')
|
||||
result = subprocess.run(['sh', '-c', block + 'env\n'], env=env, text=True, capture_output=True, check=True)
|
||||
self.assertIn('DROIDDECK_NO_STEAM=1', result.stdout.splitlines())
|
||||
|
||||
|
||||
def lsteamclient(**env):
|
||||
text = LAUNCH.read_text()
|
||||
on = re.search(r'^on\(\) \{.*\}$', text, re.M).group(0)
|
||||
last = 'export WINE_LSTEAMCLIENT=${WINE_LSTEAMCLIENT:-1}\n'
|
||||
block = text[text.index('# A game set to start without Steam'):text.index(last) + len(last)]
|
||||
script = on + '\n' + block + 'echo "value=$WINE_LSTEAMCLIENT"\n'
|
||||
result = subprocess.run(['sh', '-c', script], env=dict(env, PATH=os.environ['PATH']),
|
||||
text=True, capture_output=True, check=True)
|
||||
return result.stdout.splitlines()[-1].split('=', 1)[1]
|
||||
|
||||
|
||||
class SteamBridge(unittest.TestCase):
|
||||
def test_games_with_steam_use_lsteamclient(self):
|
||||
self.assertEqual('1', lsteamclient())
|
||||
self.assertEqual('1', lsteamclient(DROIDDECK_NO_STEAM='0'))
|
||||
|
||||
def test_a_game_started_without_steam_keeps_its_own_steamclient(self):
|
||||
for value in ('1', 'on', 'true', 'yes'):
|
||||
self.assertEqual('0', lsteamclient(DROIDDECK_NO_STEAM=value))
|
||||
|
||||
def test_the_players_value_wins(self):
|
||||
self.assertEqual('1', lsteamclient(DROIDDECK_NO_STEAM='1', WINE_LSTEAMCLIENT='1'))
|
||||
self.assertEqual('0', lsteamclient(WINE_LSTEAMCLIENT='0'))
|
||||
|
||||
|
||||
DDC_NAMES = ('xinput1_1', 'xinput1_2', 'xinput1_3', 'xinput1_4', 'xinput9_1_0', 'xinputuap')
|
||||
|
||||
|
||||
class DirectController(unittest.TestCase):
|
||||
"""launch.sh's dd-directcontroller step on a prefix laid out as prepare_prefix leaves it (links to the tool)."""
|
||||
|
||||
def setUp(self):
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.root)
|
||||
self.tool, self.compat = self.root / 'tool', self.root / 'compat'
|
||||
self.f = self.tool / 'files'
|
||||
self.win = self.compat / 'pfx/drive_c/windows'
|
||||
for ours, wine, pfx in (('arm64x', 'aarch64-windows', 'system32'), ('i386', 'i386-windows', 'syswow64')):
|
||||
(self.tool / 'bionic/dd-directcontroller' / ours).mkdir(parents=True)
|
||||
(self.f / 'lib/wine' / wine).mkdir(parents=True)
|
||||
(self.win / pfx).mkdir(parents=True)
|
||||
for n in DDC_NAMES:
|
||||
(self.tool / 'bionic/dd-directcontroller' / ours / f'{n}.dll').write_bytes(f'MZ dd-directcontroller: {ours} {n}'.encode())
|
||||
builtin = self.f / 'lib/wine' / wine / f'{n}.dll'
|
||||
builtin.write_bytes(f'MZ Wine builtin DLL {wine} {n}'.encode())
|
||||
(self.win / pfx / f'{n}.dll').symlink_to(builtin)
|
||||
|
||||
def run_step(self, **env):
|
||||
text = LAUNCH.read_text()
|
||||
on = re.search(r'^on\(\) \{.*\}$', text, re.M).group(0)
|
||||
on += '\n' + re.search(r'^is_builtin\(\) \{.*\}$', text, re.M).group(0)
|
||||
start = text.index('# dd-directcontroller: a game set to start')
|
||||
end = text.index("dd-directcontroller off: Wine's xinput again\"\nfi\n") + len("dd-directcontroller off: Wine's xinput again\"\nfi\n")
|
||||
script = on + '\n' + text[start:end] + 'echo "overrides=$WINEDLLOVERRIDES"; echo "control=${DD_DIRECTCONTROLLER_CONTROL:-}"\n'
|
||||
(self.root / 'session/dev/input').mkdir(parents=True, exist_ok=True)
|
||||
base = dict(PATH=os.environ['PATH'], TOOL=str(self.tool), COMPAT=str(self.compat), F=str(self.f),
|
||||
WINEDLLOVERRIDES='d3d11=n,b', FAKE_EVDEV_DIR=str(self.root / 'session/dev/input'))
|
||||
result = subprocess.run(['sh', '-c', script], env=dict(base, **env), text=True, capture_output=True, check=True)
|
||||
return result.stdout
|
||||
|
||||
def builtins_untouched(self):
|
||||
for wine in ('aarch64-windows', 'i386-windows'):
|
||||
for n in DDC_NAMES:
|
||||
self.assertEqual(f'MZ Wine builtin DLL {wine} {n}', (self.f / 'lib/wine' / wine / f'{n}.dll').read_text())
|
||||
|
||||
def test_a_game_started_without_steam_gets_the_dlls_as_copies(self):
|
||||
out = self.run_step(DROIDDECK_NO_STEAM='1')
|
||||
for ours, pfx in (('arm64x', 'system32'), ('i386', 'syswow64')):
|
||||
for n in DDC_NAMES:
|
||||
t = self.win / pfx / f'{n}.dll'
|
||||
self.assertFalse(t.is_symlink())
|
||||
self.assertEqual(f'MZ dd-directcontroller: {ours} {n}', t.read_text())
|
||||
self.assertIn('Wine builtin DLL', (self.win / pfx / 'dd-directcontroller-wine-xinput.dll').read_text())
|
||||
self.builtins_untouched()
|
||||
self.assertIn('overrides=d3d11=n,b;xinput1_1,xinput1_2,xinput1_3,xinput1_4,xinput9_1_0,xinputuap=n,b', out)
|
||||
mode = self.root / 'session/dev/dd-directcontroller.mode'
|
||||
self.assertEqual('1', mode.read_text().strip())
|
||||
self.assertIn(f'control={mode}', out)
|
||||
self.assertIn('dd-directcontroller on (starts direct)', out)
|
||||
|
||||
def test_switched_off_puts_wines_links_back(self):
|
||||
self.run_step(DROIDDECK_NO_STEAM='1')
|
||||
out = self.run_step()
|
||||
for wine, pfx in (('aarch64-windows', 'system32'), ('i386-windows', 'syswow64')):
|
||||
for n in DDC_NAMES:
|
||||
t = self.win / pfx / f'{n}.dll'
|
||||
self.assertTrue(t.is_symlink())
|
||||
self.assertEqual(self.f / 'lib/wine' / wine / f'{n}.dll', Path(os.readlink(t)))
|
||||
self.assertFalse((self.win / pfx / 'dd-directcontroller-wine-xinput.dll').exists())
|
||||
self.builtins_untouched()
|
||||
self.assertIn('overrides=d3d11=n,b\n', out)
|
||||
self.assertIn("dd-directcontroller off: Wine's xinput again", out)
|
||||
|
||||
def test_dd_directcontroller_0_starts_in_pass_through(self):
|
||||
out = self.run_step(DROIDDECK_NO_STEAM='1', DD_DIRECTCONTROLLER='0')
|
||||
self.assertFalse((self.win / 'system32/xinput1_3.dll').is_symlink())
|
||||
self.assertEqual('0', (self.root / 'session/dev/dd-directcontroller.mode').read_text().strip())
|
||||
self.assertIn('dd-directcontroller on (starts pass-through)', out)
|
||||
|
||||
def test_without_a_controller_folder_it_stays_direct(self):
|
||||
text = self.run_step(DROIDDECK_NO_STEAM='1', FAKE_EVDEV_DIR='')
|
||||
self.assertIn('control=\n', text)
|
||||
self.assertIn('dd-directcontroller on (starts direct (no mode file))', text)
|
||||
|
||||
def test_a_foreign_native_xinput_is_kept_when_installing(self):
|
||||
t = self.win / 'system32/xinput1_3.dll'
|
||||
t.unlink()
|
||||
t.write_bytes(b'MZ someone else')
|
||||
copy = self.win / 'system32/xinput1_4.dll'
|
||||
copy.unlink()
|
||||
copy.write_bytes(b'MZ Wine builtin DLL copied by Proton')
|
||||
out = self.run_step(DROIDDECK_NO_STEAM='1')
|
||||
self.assertEqual('MZ someone else', t.read_text())
|
||||
self.assertIn("kept system32/xinput1_3.dll (not Wine's)", out)
|
||||
self.assertEqual('MZ dd-directcontroller: arm64x xinput1_4', copy.read_text())
|
||||
self.builtins_untouched()
|
||||
|
||||
def test_a_native_xinput_that_is_not_ours_stays(self):
|
||||
t = self.win / 'system32/xinput1_3.dll'
|
||||
t.unlink()
|
||||
t.write_bytes(b'MZ someone else')
|
||||
out = self.run_step()
|
||||
self.assertEqual('MZ someone else', t.read_text())
|
||||
self.assertNotIn('dd-directcontroller off', out)
|
||||
|
||||
|
||||
class SessionLogs(unittest.TestCase):
|
||||
SESSION = '/data/user/0/com.droiddeck.launcher/files/logs/2026-11-22-09-steam'
|
||||
@@ -146,6 +301,53 @@ class LaunchLog(unittest.TestCase):
|
||||
self.assertIn('DXVK_LOG_PATH=${DXVK_LOG_PATH:-$COMPAT}', text)
|
||||
|
||||
|
||||
class PrefixFromProton(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.tmp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(self.tmp.cleanup)
|
||||
self.compat = Path(self.tmp.name) / 'compatdata/236850'
|
||||
self.drives = self.compat / 'pfx/dosdevices'
|
||||
self.drives.mkdir(parents=True)
|
||||
|
||||
def test_guest_drive_links_get_android_paths(self):
|
||||
for name, target in (('c:', '../drive_c'), ('s:', '/root/.local/share/Steam'), ('d:', '/mnt/sd/Steam'),
|
||||
('e:', '/storage/emulated/0/Games'), ('z:', '/')):
|
||||
os.symlink(target, self.drives / name)
|
||||
out = proton_function('android_drives "$1"', str(self.compat))
|
||||
links = {p.name: os.readlink(p) for p in self.drives.iterdir()}
|
||||
self.assertEqual({'c:': '../drive_c', 's:': ANDROID + '/root/.local/share/Steam', 'd:': '/storage/1234-5678/Steam/Steam',
|
||||
'e:': '/storage/emulated/0/Games', 'z:': '/'}, links)
|
||||
self.assertEqual(2, len(out.splitlines()))
|
||||
self.assertEqual('', proton_function('android_drives "$1"', str(self.compat)))
|
||||
|
||||
def test_a_prefix_without_drives_is_left_alone(self):
|
||||
self.assertEqual('', proton_function('android_drives "$1"', str(Path(self.tmp.name) / 'compatdata/1')))
|
||||
|
||||
def steam_pid(self, reg):
|
||||
text = LAUNCH.read_text()
|
||||
function = text[text.index('steam_pid() {'):text.index('prefix_busy || steam_pid')]
|
||||
(self.compat / 'pfx/user.reg').write_text(reg)
|
||||
out = subprocess.run(['sh', '-c', function + 'steam_pid'], env=dict(os.environ, COMPAT=str(self.compat)),
|
||||
capture_output=True, text=True, check=True).stdout
|
||||
return out, (self.compat / 'pfx/user.reg').read_text()
|
||||
|
||||
def test_steams_process_id_is_this_tools(self):
|
||||
reg = ('[Software\\\\Valve\\\\Steam\\\\ActiveProcess] 1795314478\n#time=1dd7a2916a0be94\n"PID"=dword:00000020\n'
|
||||
'"SteamPath"="C:\\\\Program Files (x86)\\\\Steam"\n\n[Software\\\\Other] 1\n"PID"=dword:00000020\n')
|
||||
out, after = self.steam_pid(reg)
|
||||
self.assertIn('process ID', out)
|
||||
self.assertEqual(reg.replace('"PID"=dword:00000020', '"PID"=dword:0000fffe', 1), after)
|
||||
out, again = self.steam_pid(after)
|
||||
self.assertEqual(('', after), (out, again))
|
||||
|
||||
def test_a_prefix_without_steams_key_is_unchanged(self):
|
||||
reg = '[Software\\\\Wine] 1\n"PID"=dword:00000020\n'
|
||||
self.assertEqual(('', reg), self.steam_pid(reg))
|
||||
|
||||
def test_the_network_list_uses_getifaddrs(self):
|
||||
self.assertIn('export WINE_NEW_NDIS=${WINE_NEW_NDIS:-1}', LAUNCH.read_text())
|
||||
|
||||
|
||||
class StorePaths(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.tmp = tempfile.TemporaryDirectory()
|
||||
|
||||
Reference in new issue
Block a user