mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 12:35:42 +00:00
fix(bionic): run games from a DroidDeck-Proton prefix that start through a launcher (#3336)
* fix(bionic): run games from a DroidDeck-Proton prefix that start through a launcher Europa Universalis IV, moved from DroidDeck-Proton to DroidDeck-Bionic, never got past its launcher: - The network adapter list (GetAdaptersAddresses) never answered with the layer's default if_nameindex code, so the Paradox Launcher waited forever. launch.sh sets WINE_NEW_NDIS=1 (the layer's getifaddrs code); a game's environment can still set 0. - The game reported "Steam not detected": the prefix still named Proton's steam.exe (PID 0x20) as Steam's running client, and here that PID is the program Steam started, which quits after starting the game. launch.sh writes the PID this tool's own prefixes carry (0xfffe) before Wine starts. - Its Workshop mod was missing: DroidDeck-Proton's s: drive names the guest path of the Steam library, which this Wine cannot follow. proton gives the prefix's guest drive links their Android paths for the launch; a session's start gives them their guest paths back. * fix(bionic): give each launch its own temporary file for the registry and drive rewrites
This commit is contained in:
1 parent
a8aafad145
commit
ecaec5da01
3 files changed
+81
No files matched your search
@@ -109,6 +109,9 @@ export NTSYNC_SHM=$COMPAT/ntsync-shm
|
||||
# DroidDeck's Force SSBS (its glibc libssbs.so preload) is bionic Wine's own WINE_FORCE_SSBS
|
||||
on "${DROIDDECK_FORCE_SSBS:-}" && export WINE_FORCE_SSBS=1
|
||||
export HODLL=libwow64fex.dll WINEDEBUG=err+all,fixme-all
|
||||
# The network adapter list (GetAdaptersAddresses) from the layer's getifaddrs code: its default if_nameindex code never
|
||||
# answered here, and the Paradox Launcher (Europa Universalis IV) waited on it forever.
|
||||
export WINE_NEW_NDIS=${WINE_NEW_NDIS:-1}
|
||||
export XENVIRONMENT=$TOOL/bionic/Xdefaults
|
||||
# The adapter's Wayland swapchain gets its buffers back from gamescope later than DroidDeck-Proton's Turnip does;
|
||||
# with gamescope's default three images the game waits for one about a fifth of the time at high frame rates.
|
||||
@@ -306,6 +309,21 @@ if [ "$verb" != runinprefix ] && prefix_busy; then
|
||||
fi
|
||||
prefix_busy || rm -f "$NTSYNC_SHM".v*
|
||||
|
||||
# Steam's running client, as a game's steam_api checks it: Proton names its steam.exe (the prefix's first program,
|
||||
# alive while the game runs), which this tool does not start. Here the first program is the one Steam started, so a
|
||||
# launcher that starts the game and quits (EU4's dowser.exe) left a game that reported "Steam not detected". The
|
||||
# PID is the one this tool's own prefixes carry.
|
||||
steam_pid() {
|
||||
R=$COMPAT/pfx/user.reg
|
||||
[ -f "$R" ] || return 0
|
||||
awk '/^\[/ { on = index($0, "[Software\\\\Valve\\\\Steam\\\\ActiveProcess]") == 1 }
|
||||
on && /^"PID"=dword:/ && $0 != "\"PID\"=dword:0000fffe" { found = 1 } END { exit !found }' "$R" || return 0
|
||||
awk '/^\[/ { on = index($0, "[Software\\\\Valve\\\\Steam\\\\ActiveProcess]") == 1 }
|
||||
on && /^"PID"=dword:/ { print "\"PID\"=dword:0000fffe"; next } { print }' "$R" > "$R.dd-new.$$" && mv -f "$R.dd-new.$$" "$R" &&
|
||||
echo "$(date +%H:%M:%S) Steam's process ID in the registry set to this tool's"
|
||||
}
|
||||
prefix_busy || steam_pid
|
||||
|
||||
# Links into a tool that is gone (an older DroidDeck-Bionic, a deleted DroidDeck-Proton) or to a file it no longer has.
|
||||
# Wine's update cannot write over them, so drivers (network, controller) and other files stay missing. Drop them and
|
||||
# clear both stamps: prepare_prefix relinks this tool's files and Wine's update puts its own back.
|
||||
|
||||
@@ -36,6 +36,21 @@ zpath() {
|
||||
esac
|
||||
}
|
||||
|
||||
# Drive links of the prefix in compatdata folder $1 that name guest paths (DroidDeck-Proton's s: for the Steam library)
|
||||
# -> their Android paths, which this Wine follows. A game's mods on S: were missing otherwise. A session's start
|
||||
# gives them their guest paths back (NativeGuest.relinkPrefixDrives); z: is launch.sh's.
|
||||
android_drives() {
|
||||
local d t a
|
||||
for d in "$1"/pfx/dosdevices/[a-y]:; do
|
||||
[ -L "$d" ] || continue
|
||||
t=$(readlink "$d")
|
||||
case "$t" in /*) ;; *) continue ;; esac
|
||||
a=$(real "$t")
|
||||
[ "$a" = "$t" ] && continue
|
||||
ln -sfn "$a" "$d.dd-new.$$" && mv -fT "$d.dd-new.$$" "$d" && echo "drive ${d##*/} -> $a"
|
||||
done
|
||||
}
|
||||
|
||||
# Where a game launch's log goes in DroidDeck's session folder (Share logs takes that folder): the game's log folder
|
||||
# when Detailed graphics logs made one (droiddeck-game-env), else a folder of its own; nothing for other verbs
|
||||
session_logs() {
|
||||
@@ -109,6 +124,7 @@ print(" ".join(sorted(n for n in names if re.fullmatch(r"[A-Za-z_][A-Za-z0-9_]*"
|
||||
PY
|
||||
)
|
||||
export DROIDDECK_BIONIC_KEEP
|
||||
[ -n "${STEAM_COMPAT_DATA_PATH:-}" ] && android_drives "$STEAM_COMPAT_DATA_PATH" >&2
|
||||
exec /system/bin/sh "$tool/bionic/launch.sh" "$verb" "$compat" "$exe" ${args[@]+"${args[@]}"} ;;
|
||||
getcompatpath)
|
||||
p=$(real "${1:-}")
|
||||
|
||||
@@ -144,6 +144,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