mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 13:26:02 +00:00
feat(dual-screen): bottom-screen Dashboard with downloads, notifications, screenshots, Steam chat and In-game stats (#1920)
A Dashboard mode for the second screen of dual-screen handhelds (developed on a Retroid Pocket Duo), the default on dual-screen devices. It opens on Chat at each Steam start and switches to In-game stats when a game starts. - Downloads: Steam downloads and updates (SD-card libraries too), shader caches and DroidDeck store downloads. - Notifications: other apps' notifications once access is allowed, kept in memory only. - Screenshots: a game screenshot without the overlay, and a gallery of DroidDeck's and Steam's screenshots. - Chat & voice: mic and game volume buttons, and Steam's web chat signed in with the Steam client's own session. - In-game stats: FPS, CPU, GPU, RAM and battery plus the running game or Steam client type, and a racing dash from Codemasters, Forza and OutGauge games' data output, with War Thunder and Elite Dangerous layouts; speed in km/h or mph. - Send dashboard data: turns a Codemasters game's data output on for the dash (per game or Automatic) and keeps the original setting to put back. - DiRT 3 / DiRT Showdown: with their data output on they stop with error 10038 at race end; a ws2_32.dll stand-in (tools/dirt-ws2) is swapped into the prefix while the game runs, skipped on DroidDeck-Proton 11-11.10 which has the fix built in. Same behaviour as DiRTTelemetryErrorFix by RoccoC, based on Carsten Gottschling's fix. About "telemetry": here it means a racing game's own live driving data (speed, gear, rpm, pedals), not app analytics. For In-game stats no information leaves the device and nothing is shared: the game sends its data to 127.0.0.1 on the same device, DroidDeck only listens there while the page is open and keeps the numbers in memory just long enough to draw them. DroidDeck sends no data about the user or their use of the app; logs leave the device only when the user taps Share logs.
This commit is contained in:
1 parent
bfa61b5139
commit
8a7022fc14
52 files changed
+4576
-63
No files matched your search
@@ -222,5 +222,20 @@
|
||||
"cmake",
|
||||
"xz-utils"
|
||||
]
|
||||
},
|
||||
"dirt-ws2": {
|
||||
"script": "tools/components/recipes/dirt-ws2.sh",
|
||||
"inputs": [
|
||||
"tools/dirt-ws2",
|
||||
"tools/components/recipes/dirt-ws2.sh"
|
||||
],
|
||||
"outputs": [
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-dirt/ws2_32.dll"
|
||||
],
|
||||
"packages": [
|
||||
"clang",
|
||||
"lld",
|
||||
"llvm"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
bash tools/dirt-ws2/build.sh app/src/main/assets/linuxfs/usr/local/lib/droiddeck-dirt
|
||||
@@ -0,0 +1,19 @@
|
||||
# DiRT 3 / DiRT Showdown ws2_32 stand-in
|
||||
|
||||
DiRT 3 (`dirt3_game.exe`) and DiRT Showdown (`showdown.exe`, `showdown_avx.exe`) close their motion telemetry UDP
|
||||
socket at the end of a race, and when leaving Joyride, but keep calling `sendto()` on it. `sendto()` fails with
|
||||
WSAENOTSOCK and the game stops with "sendto failed with error 10038". The same happens on Windows.
|
||||
|
||||
`ws2_32.dll` here is a 32-bit stand-in: every export jumps to the same-ordinal export of Wine's own `ws2_32.dll`;
|
||||
only a `sendto()` that fails with 10038 reports 0 bytes sent instead. Same behaviour as
|
||||
[DiRTTelemetryErrorFix](https://github.com/RoccoC/DiRTTelemetryErrorFix) by RoccoC (MIT), based on the original fix
|
||||
by Carsten Gottschling.
|
||||
|
||||
Wine loads `ws2_32` as a KnownDLL, so a copy beside the game is ignored. `droiddeck-game-env` puts the stand-in in
|
||||
place of the prefix's `syswow64/ws2_32.dll` for these games while their telemetry output is on, adds
|
||||
`WINEDLLOVERRIDES=ws2_32=n,b`, and puts Wine's file back when the game exits. It skips the swap when the game's
|
||||
Proton already has the fix in its own `ws2_32.dll` (DroidDeck-Proton patch
|
||||
`dirt-telemetry-sendto-closed-socket.patch`).
|
||||
|
||||
`build.sh OUT` builds it with clang, lld and llvm-dlltool and checks its exports against `ws2_32-exports.txt`
|
||||
(taken from Wine 11's `ws2_32.dll`).
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
# Builds the 32-bit ws2_32.dll stand-in for DiRT 3 and DiRT Showdown into the given folder.
|
||||
set -euo pipefail
|
||||
here=$(cd "$(dirname "$0")" && pwd)
|
||||
mkdir -p "$1"
|
||||
out=$(cd "$1" && pwd)
|
||||
work=$(mktemp -d)
|
||||
trap 'rm -rf "$work"' EXIT
|
||||
|
||||
tool() {
|
||||
local found
|
||||
found=$(command -v "$1" || ls /usr/lib/llvm-*/bin/"$1" 2>/dev/null | sort -V | tail -n1 || true)
|
||||
[ -n "$found" ] || { echo "dirt-ws2: $1 not found" >&2; exit 1; }
|
||||
echo "$found"
|
||||
}
|
||||
clang=$(tool clang)
|
||||
dlltool=$(tool llvm-dlltool)
|
||||
tool ld.lld > /dev/null
|
||||
|
||||
python3 "$here/gen.py" generate "$here" "$work"
|
||||
"$dlltool" -m i386 -k -d "$here/kernel32.def" -l "$work/libkernel32.a"
|
||||
"$clang" --target=i686-w64-mingw32 -O2 -Wall -Wextra -Werror -ffreestanding -fno-stack-protector -fno-builtin \
|
||||
-nostdlib -shared -fuse-ld=lld -o "$work/ws2_32.dll" "$here/ws2_32.c" "$work/thunks.c" "$work/ws2_32.def" \
|
||||
-L"$work" -lkernel32 -Wl,--entry,DllMain@12 -Wl,--no-insert-timestamp
|
||||
python3 "$here/gen.py" verify "$here" "$work/ws2_32.dll"
|
||||
install -m 644 "$work/ws2_32.dll" "$out/ws2_32.dll"
|
||||
@@ -0,0 +1,74 @@
|
||||
"""ws2_32 stand-in helpers.
|
||||
|
||||
gen.py generate SRC OUT writes OUT/thunks.c (one jump per export) and OUT/ws2_32.def from SRC/ws2_32-exports.txt.
|
||||
gen.py verify SRC DLL checks that DLL exports exactly the ordinals and names in SRC/ws2_32-exports.txt.
|
||||
"""
|
||||
import struct
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def exports_list(src):
|
||||
rows = []
|
||||
for line in (Path(src) / 'ws2_32-exports.txt').read_text().splitlines():
|
||||
ordinal, name = line.split()
|
||||
rows.append((int(ordinal), name))
|
||||
return rows
|
||||
|
||||
|
||||
def generate(src, out):
|
||||
rows = exports_list(src)
|
||||
passed = [(o, n) for o, n in rows if n != 'sendto']
|
||||
c = ['/* Generated by tools/dirt-ws2/gen.py. */',
|
||||
'const unsigned short dirtfix_ordinals[%d] = {%s};' % (len(passed), ', '.join(str(o) for o, _ in passed)),
|
||||
'const unsigned int dirtfix_count = %d;' % len(passed),
|
||||
'void *dirtfix_real[%d];' % len(passed),
|
||||
'__asm__(".text\\n"']
|
||||
for i, (o, _) in enumerate(passed):
|
||||
c.append(' ".globl _dirtfix_t%d\\n_dirtfix_t%d:\\n\\tjmp *_dirtfix_real+%d\\n"' % (o, o, 4 * i))
|
||||
c.append(');')
|
||||
(Path(out) / 'thunks.c').write_text('\n'.join(c) + '\n')
|
||||
d = ['LIBRARY ws2_32.dll', 'EXPORTS']
|
||||
d += [' %s=%s @%d' % (n, 'dirtfix_sendto@24' if n == 'sendto' else 'dirtfix_t%d' % o, o) for o, n in rows]
|
||||
(Path(out) / 'ws2_32.def').write_text('\n'.join(d) + '\n')
|
||||
|
||||
|
||||
def pe_exports(path):
|
||||
data = Path(path).read_bytes()
|
||||
pe = struct.unpack_from('<I', data, 0x3c)[0]
|
||||
machine, sections = struct.unpack_from('<HH', data, pe + 4)
|
||||
optional_size = struct.unpack_from('<H', data, pe + 20)[0]
|
||||
optional = pe + 24
|
||||
export_rva = struct.unpack_from('<I', data, optional + 96)[0]
|
||||
table = [struct.unpack_from('<IIII', data, optional + optional_size + 40 * i + 8) for i in range(sections)]
|
||||
|
||||
def offset(rva):
|
||||
for size, address, raw_size, raw in table:
|
||||
if address <= rva < address + max(size, raw_size):
|
||||
return rva - address + raw
|
||||
raise ValueError('RVA %#x outside the sections' % rva)
|
||||
|
||||
base, functions, names, function_rva, name_rva, ordinal_rva = struct.unpack_from('<IIIIII', data, offset(export_rva) + 16)
|
||||
named = {}
|
||||
for i in range(names):
|
||||
text = struct.unpack_from('<I', data, offset(name_rva) + 4 * i)[0]
|
||||
index = struct.unpack_from('<H', data, offset(ordinal_rva) + 2 * i)[0]
|
||||
named[index] = data[offset(text):].split(b'\0')[0].decode()
|
||||
result = [(base + i, named.get(i)) for i in range(functions) if struct.unpack_from('<I', data, offset(function_rva) + 4 * i)[0]]
|
||||
return machine, result
|
||||
|
||||
|
||||
def verify(src, dll):
|
||||
machine, found = pe_exports(dll)
|
||||
if machine != 0x14c:
|
||||
sys.exit('%s is not a 32-bit x86 DLL (machine %#x)' % (dll, machine))
|
||||
expected = exports_list(src)
|
||||
if found != expected:
|
||||
sys.exit('%s exports differ from ws2_32-exports.txt: %d found, %d expected' % (dll, len(found), len(expected)))
|
||||
if b'droiddeck-dirt-ws2_32' not in Path(dll).read_bytes():
|
||||
sys.exit('%s lacks the stand-in marker' % dll)
|
||||
print('%s: %d exports match, marker present' % (dll, len(found)))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
{'generate': generate, 'verify': verify}[sys.argv[1]](sys.argv[2], sys.argv[3])
|
||||
@@ -0,0 +1,7 @@
|
||||
LIBRARY kernel32.dll
|
||||
EXPORTS
|
||||
LoadLibraryW@4
|
||||
GetProcAddress@8
|
||||
GetSystemDirectoryW@8
|
||||
GetEnvironmentVariableW@12
|
||||
GetFileAttributesW@4
|
||||
@@ -0,0 +1,135 @@
|
||||
1 accept
|
||||
2 bind
|
||||
3 closesocket
|
||||
4 connect
|
||||
5 getpeername
|
||||
6 getsockname
|
||||
7 getsockopt
|
||||
8 htonl
|
||||
9 htons
|
||||
10 ioctlsocket
|
||||
11 inet_addr
|
||||
12 inet_ntoa
|
||||
13 listen
|
||||
14 ntohl
|
||||
15 ntohs
|
||||
16 recv
|
||||
17 recvfrom
|
||||
18 select
|
||||
19 send
|
||||
20 sendto
|
||||
21 setsockopt
|
||||
22 shutdown
|
||||
23 socket
|
||||
24 FreeAddrInfoEx
|
||||
25 FreeAddrInfoExW
|
||||
26 FreeAddrInfoW
|
||||
27 GetAddrInfoExCancel
|
||||
28 GetAddrInfoExOverlappedResult
|
||||
29 GetAddrInfoExW
|
||||
30 GetAddrInfoW
|
||||
31 GetHostNameW
|
||||
32 GetNameInfoW
|
||||
33 InetNtopW
|
||||
34 InetPtonW
|
||||
35 WSApSetPostRoutine
|
||||
36 WPUCompleteOverlappedRequest
|
||||
37 WSAAccept
|
||||
38 WSAAddressToStringA
|
||||
39 WSAAddressToStringW
|
||||
40 WSACloseEvent
|
||||
41 WSAConnect
|
||||
42 WSAConnectByNameA
|
||||
43 WSAConnectByNameW
|
||||
44 WSACreateEvent
|
||||
45 WSADuplicateSocketA
|
||||
46 WSADuplicateSocketW
|
||||
47 WSAEnumNameSpaceProvidersA
|
||||
48 WSAEnumNameSpaceProvidersW
|
||||
49 WSAEnumNetworkEvents
|
||||
50 WSAEnumProtocolsA
|
||||
51 gethostbyaddr
|
||||
52 gethostbyname
|
||||
53 getprotobyname
|
||||
54 getprotobynumber
|
||||
55 getservbyname
|
||||
56 getservbyport
|
||||
57 gethostname
|
||||
58 WSAEnumProtocolsW
|
||||
59 WSAEventSelect
|
||||
60 WSAGetOverlappedResult
|
||||
61 WSAGetQOSByName
|
||||
62 WSAGetServiceClassInfoA
|
||||
63 WSAGetServiceClassInfoW
|
||||
64 WSAGetServiceClassNameByClassIdA
|
||||
65 WSAGetServiceClassNameByClassIdW
|
||||
66 WSAHtonl
|
||||
67 WSAHtons
|
||||
68 WSAInstallServiceClassA
|
||||
69 WSAInstallServiceClassW
|
||||
70 WSAIoctl
|
||||
71 WSAJoinLeaf
|
||||
72 WSALookupServiceBeginA
|
||||
73 WSALookupServiceBeginW
|
||||
74 WSALookupServiceEnd
|
||||
75 WSALookupServiceNextA
|
||||
76 WSALookupServiceNextW
|
||||
77 WSANSPIoctl
|
||||
78 WSANtohl
|
||||
79 WSANtohs
|
||||
80 WSAPoll
|
||||
81 WSAProviderConfigChange
|
||||
82 WSARecv
|
||||
83 WSARecvDisconnect
|
||||
84 WSARecvFrom
|
||||
85 WSARemoveServiceClass
|
||||
86 WSAResetEvent
|
||||
87 WSASend
|
||||
88 WSASendDisconnect
|
||||
89 WSASendMsg
|
||||
90 WSASendTo
|
||||
91 WSASetEvent
|
||||
92 WSASetServiceA
|
||||
93 WSASetServiceW
|
||||
94 WSASocketA
|
||||
95 WSASocketW
|
||||
96 WSAStringToAddressA
|
||||
97 WSAStringToAddressW
|
||||
98 WSAWaitForMultipleEvents
|
||||
99 WSCDeinstallProvider
|
||||
100 WSCEnableNSProvider
|
||||
101 WSAAsyncSelect
|
||||
102 WSAAsyncGetHostByAddr
|
||||
103 WSAAsyncGetHostByName
|
||||
104 WSAAsyncGetProtoByNumber
|
||||
105 WSAAsyncGetProtoByName
|
||||
106 WSAAsyncGetServByPort
|
||||
107 WSAAsyncGetServByName
|
||||
108 WSACancelAsyncRequest
|
||||
109 WSASetBlockingHook
|
||||
110 WSAUnhookBlockingHook
|
||||
111 WSAGetLastError
|
||||
112 WSASetLastError
|
||||
113 WSACancelBlockingCall
|
||||
114 WSAIsBlocking
|
||||
115 WSAStartup
|
||||
116 WSACleanup
|
||||
117 WSCEnumProtocols
|
||||
118 WSCEnumProtocols32
|
||||
119 WSCGetApplicationCategory
|
||||
120 WSCGetProviderInfo
|
||||
121 WSCGetProviderPath
|
||||
122 WSCInstallNameSpace
|
||||
123 WSCInstallProvider
|
||||
124 WSCSetApplicationCategory
|
||||
125 WSCUnInstallNameSpace
|
||||
126 WSCUpdateProvider
|
||||
127 WSCWriteNameSpaceOrder
|
||||
128 WSCWriteProviderOrder
|
||||
129 freeaddrinfo
|
||||
130 getaddrinfo
|
||||
131 getnameinfo
|
||||
132 inet_ntop
|
||||
133 inet_pton
|
||||
151 __WSAFDIsSet
|
||||
500 WEP
|
||||
@@ -0,0 +1,103 @@
|
||||
/* ws2_32.dll stand-in for DiRT 3 and DiRT Showdown (32-bit).
|
||||
*
|
||||
* Both games close their motion telemetry UDP socket at the end of a race (and when leaving Joyride) and keep
|
||||
* calling sendto() on it; the WSAENOTSOCK (10038) failure stops the game. Every export here jumps to the
|
||||
* same-ordinal export of Wine's own ws2_32.dll, except that a sendto() failing with 10038 reports 0 bytes sent.
|
||||
* Same behaviour as DiRTTelemetryErrorFix by RoccoC (MIT), based on the fix by Carsten Gottschling. */
|
||||
|
||||
typedef unsigned short WCHAR;
|
||||
typedef unsigned long DWORD;
|
||||
typedef unsigned int UINT;
|
||||
typedef unsigned int UINT_PTR;
|
||||
typedef int BOOL;
|
||||
typedef void *HMODULE;
|
||||
#define WINAPI __attribute__((stdcall))
|
||||
#define WSAENOTSOCK 10038
|
||||
#define ORDINAL(n) ((const char *)(UINT_PTR)(n))
|
||||
|
||||
__attribute__((dllimport)) HMODULE WINAPI LoadLibraryW(const WCHAR *name);
|
||||
__attribute__((dllimport)) void *WINAPI GetProcAddress(HMODULE module, const char *name);
|
||||
__attribute__((dllimport)) UINT WINAPI GetSystemDirectoryW(WCHAR *buffer, UINT size);
|
||||
__attribute__((dllimport)) DWORD WINAPI GetEnvironmentVariableW(const WCHAR *name, WCHAR *buffer, DWORD size);
|
||||
__attribute__((dllimport)) DWORD WINAPI GetFileAttributesW(const WCHAR *name);
|
||||
|
||||
/* droiddeck-game-env recognises a swapped-in copy by this text. */
|
||||
__attribute__((used)) const char dirtfix_marker[] = "droiddeck-dirt-ws2_32";
|
||||
|
||||
extern const unsigned short dirtfix_ordinals[];
|
||||
extern const unsigned int dirtfix_count;
|
||||
extern void *dirtfix_real[];
|
||||
|
||||
static int (WINAPI *real_sendto)(UINT_PTR, const char *, int, int, const void *, int);
|
||||
static int (WINAPI *real_WSAGetLastError)(void);
|
||||
static void (WINAPI *real_WSASetLastError)(int);
|
||||
|
||||
int WINAPI dirtfix_sendto(UINT_PTR s, const char *buf, int len, int flags, const void *to, int tolen)
|
||||
{
|
||||
int ret = real_sendto(s, buf, len, flags, to, tolen);
|
||||
if (ret == -1 && real_WSAGetLastError() == WSAENOTSOCK)
|
||||
{
|
||||
real_WSASetLastError(0);
|
||||
return 0;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void append(WCHAR *dst, const char *src)
|
||||
{
|
||||
while (*dst) dst++;
|
||||
while ((*dst++ = (WCHAR)(unsigned char)*src++));
|
||||
}
|
||||
|
||||
static void append_number(WCHAR *dst, UINT n)
|
||||
{
|
||||
char digits[12];
|
||||
int i = 11;
|
||||
|
||||
digits[i] = 0;
|
||||
do digits[--i] = (char)('0' + n % 10); while (n /= 10);
|
||||
append(dst, digits + i);
|
||||
}
|
||||
|
||||
/* When this file replaces the prefix's syswow64\ws2_32.dll, Wine's own copy is the i386-windows\ws2_32.dll in one
|
||||
* of the builtin DLL folders Wine lists in WINEDLLDIR0, WINEDLLDIR1, ... as NT paths (\??\Z:\...). */
|
||||
static HMODULE load_wine_ws2_32(HMODULE self)
|
||||
{
|
||||
WCHAR name[24], path[600];
|
||||
HMODULE real;
|
||||
UINT n, d;
|
||||
|
||||
for (d = 0; d < 16; d++)
|
||||
{
|
||||
name[0] = 0;
|
||||
append(name, "WINEDLLDIR");
|
||||
append_number(name, d);
|
||||
n = GetEnvironmentVariableW(name, path, 500);
|
||||
if (!n || n >= 500) continue;
|
||||
if (path[0] == '\\' && path[1] == '?' && path[2] == '?' && path[3] == '\\') path[1] = '\\';
|
||||
append(path, "\\i386-windows\\ws2_32.dll");
|
||||
if (GetFileAttributesW(path) == (DWORD)-1) continue;
|
||||
if ((real = LoadLibraryW(path)) && real != self) return real;
|
||||
}
|
||||
n = GetSystemDirectoryW(path, 280);
|
||||
if (!n || n >= 280) return 0;
|
||||
path[n] = 0;
|
||||
append(path, "\\ws2_32.dll");
|
||||
real = LoadLibraryW(path);
|
||||
return real != self ? real : 0;
|
||||
}
|
||||
|
||||
BOOL WINAPI DllMain(HMODULE self, DWORD reason, void *reserved)
|
||||
{
|
||||
HMODULE real;
|
||||
UINT i;
|
||||
|
||||
(void)reserved;
|
||||
if (reason != 1) return 1;
|
||||
if (!(real = load_wine_ws2_32(self))) return 0;
|
||||
for (i = 0; i < dirtfix_count; i++) dirtfix_real[i] = GetProcAddress(real, ORDINAL(dirtfix_ordinals[i]));
|
||||
real_sendto = GetProcAddress(real, ORDINAL(20));
|
||||
real_WSAGetLastError = GetProcAddress(real, ORDINAL(111));
|
||||
real_WSASetLastError = GetProcAddress(real, ORDINAL(112));
|
||||
return real_sendto && real_WSAGetLastError && real_WSASetLastError;
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import json
|
||||
import os
|
||||
import re
|
||||
import runpy
|
||||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
@@ -735,7 +736,147 @@ def directaudio_settings(env):
|
||||
return env
|
||||
|
||||
|
||||
def start(launch, launch_env, digest):
|
||||
DIRT_GAMES = {"dirt3_game": "dirt3", "showdown": "dirtshowdown", "showdown_avx": "dirtshowdown"}
|
||||
DIRT_WS2 = "/usr/local/lib/droiddeck-dirt/ws2_32.dll"
|
||||
DIRT_MARKER = b"droiddeck-dirt-ws2_32"
|
||||
DIRT_FIXED = "showdown_avx.exe".encode("utf-16-le")
|
||||
DIRT_SAVED = ".droiddeck-original"
|
||||
|
||||
|
||||
def dirt_telemetry_on(prefix, game):
|
||||
"""Whether the game's UDP/motion output is on, as In-game stats or another listener sets it ("dbox" is its default)."""
|
||||
try:
|
||||
folders = [f for f in (Path(prefix) / "pfx/drive_c/users/steamuser/Documents/My Games").iterdir()
|
||||
if f.name.lower().replace(" ", "") == game]
|
||||
except OSError:
|
||||
return False
|
||||
for folder in folders:
|
||||
try:
|
||||
text = (folder / "hardwaresettings/hardware_settings_config.xml").read_text(encoding="latin-1")
|
||||
except OSError:
|
||||
continue
|
||||
for tag in ("udp", "motion"):
|
||||
element = re.search(r"<%s\s[^>]*>" % tag, text)
|
||||
if element:
|
||||
attrs = dict(re.findall(r'\s(\w+)="([^"]*)"', element.group(0)))
|
||||
return attrs.get("enabled") == "true" and attrs.get("ip", "").lower() not in ("", "dbox")
|
||||
return False
|
||||
|
||||
|
||||
def proton_ws2(proton):
|
||||
return Path(proton).parent / "files/lib/wine/i386-windows/ws2_32.dll"
|
||||
|
||||
|
||||
def proton_has_dirt_fix(proton):
|
||||
try:
|
||||
return DIRT_FIXED in proton_ws2(proton).read_bytes()
|
||||
except OSError:
|
||||
return False
|
||||
|
||||
|
||||
WINE_DLL_DIRS = ("/lib/wine/i386-windows", "/lib/wine/x86_64-windows", "/lib/wine/aarch64-windows", "/lib/wine",
|
||||
"/lib/wine/fakedlls", "/lib64/wine", "/lib64/wine/fakedlls", "/lib64/wine/x86_64-windows")
|
||||
|
||||
|
||||
def is_wine_dll_link(path):
|
||||
"""A link into a Wine DLL folder: the rule Proton uses to tell its own DLLs in a prefix (file_is_wine_builtin_dll)."""
|
||||
try:
|
||||
return os.path.islink(path) and os.path.dirname(os.readlink(path)).endswith(WINE_DLL_DIRS)
|
||||
except OSError:
|
||||
return False
|
||||
|
||||
|
||||
def prefix_ws2(prefix):
|
||||
return Path(prefix) / "pfx/drive_c/windows/syswow64/ws2_32.dll"
|
||||
|
||||
|
||||
def is_dirt_stand_in(path):
|
||||
try:
|
||||
return not path.is_symlink() and DIRT_MARKER in path.read_bytes()
|
||||
except OSError:
|
||||
return False
|
||||
|
||||
|
||||
def dirt_ws2_wanted(command, env):
|
||||
"""The prefix to give the ws2_32 stand-in: a DiRT 3 / Showdown launch with telemetry on and a Proton without the fix."""
|
||||
prefix = env.get("STEAM_COMPAT_DATA_PATH", "").rstrip("/")
|
||||
if len(command) < 3 or not prefix or not os.path.isfile(DIRT_WS2):
|
||||
return None
|
||||
game = DIRT_GAMES.get(os.path.splitext(os.path.basename(command[2]))[0].lower())
|
||||
if not game or not dirt_telemetry_on(prefix, game) or proton_has_dirt_fix(command[0]):
|
||||
return None
|
||||
return prefix if os.path.lexists(prefix_ws2(prefix)) else None
|
||||
|
||||
|
||||
def swap_dirt_ws2(prefix):
|
||||
"""Puts the stand-in where the prefix's syswow64/ws2_32.dll is; that file is kept beside it."""
|
||||
target = prefix_ws2(prefix)
|
||||
saved = target.with_name(target.name + DIRT_SAVED)
|
||||
data = Path(DIRT_WS2).read_bytes()
|
||||
if not is_dirt_stand_in(target):
|
||||
if os.path.lexists(saved):
|
||||
os.unlink(saved)
|
||||
os.replace(target, saved)
|
||||
staged = target.with_name(target.name + ".droiddeck-tmp")
|
||||
staged.write_bytes(data)
|
||||
os.replace(staged, target)
|
||||
|
||||
|
||||
def restore_dirt_ws2(prefix, proton):
|
||||
"""Puts a Wine syswow64/ws2_32.dll back if the stand-in is still there; true when it changed something.
|
||||
|
||||
That is the prefix's own one, unless it was a link to a Wine DLL folder and the game ran on another Proton since
|
||||
the swap: Proton then relinked the prefix's other DLLs to itself but left the stand-in, so a link to the running
|
||||
Proton's ws2_32.dll goes back instead. Anything else (a native file, a link to a mod's DLL) goes back as it was."""
|
||||
target = prefix_ws2(prefix)
|
||||
saved = target.with_name(target.name + DIRT_SAVED)
|
||||
own = proton_ws2(proton)
|
||||
had_saved = os.path.lexists(saved)
|
||||
if had_saved:
|
||||
if os.path.lexists(target) and not is_dirt_stand_in(target):
|
||||
os.unlink(saved)
|
||||
return False
|
||||
if not own.is_file() or not is_wine_dll_link(saved) or os.path.realpath(saved) == os.path.realpath(own):
|
||||
os.replace(saved, target)
|
||||
return True
|
||||
os.unlink(saved)
|
||||
if own.is_file() and (is_dirt_stand_in(target) or (had_saved and not os.path.lexists(target))):
|
||||
link = target.with_name(target.name + ".droiddeck-tmp")
|
||||
if os.path.lexists(link):
|
||||
os.unlink(link)
|
||||
os.symlink(own, link)
|
||||
os.replace(link, target)
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def wait_forwarding_signals(process):
|
||||
def forward(signum, frame):
|
||||
try:
|
||||
process.send_signal(signum)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
previous = {signum: signal.signal(signum, forward) for signum in (signal.SIGTERM, signal.SIGINT, signal.SIGHUP)}
|
||||
try:
|
||||
code = process.wait()
|
||||
finally:
|
||||
for signum, handler in previous.items():
|
||||
signal.signal(signum, handler)
|
||||
return 128 - code if code < 0 else code
|
||||
|
||||
|
||||
def start(launch, launch_env, digest, after=None):
|
||||
if after:
|
||||
process = subprocess.Popen(launch, env=launch_env)
|
||||
try:
|
||||
return wait_forwarding_signals(process)
|
||||
finally:
|
||||
try:
|
||||
after()
|
||||
except OSError as error:
|
||||
print("droiddeck-game-env: DiRT telemetry fix: prefix ws2_32 not put back (%s); the next launch does it" % error,
|
||||
file=sys.stderr)
|
||||
if digest:
|
||||
code = subprocess.run(launch, env=launch_env, check=False).returncode
|
||||
if code == 0:
|
||||
@@ -760,6 +901,7 @@ def main():
|
||||
except OSError:
|
||||
digest = None
|
||||
app_id = game_id(env)
|
||||
dirt_prefix = None
|
||||
if app_id:
|
||||
gl_default = gl_vsync(env)
|
||||
waiting = len(command) > 1 and command[1] == "waitforexitandrun"
|
||||
@@ -779,6 +921,10 @@ def main():
|
||||
if components:
|
||||
own = fixes.get("WINEDLLOVERRIDES")
|
||||
fixes["WINEDLLOVERRIDES"] = components + ";" + own if own else components
|
||||
dirt_prefix = dirt_ws2_wanted(command, env)
|
||||
if dirt_prefix:
|
||||
own = fixes.get("WINEDLLOVERRIDES")
|
||||
fixes["WINEDLLOVERRIDES"] = own + ";ws2_32=n,b" if own else "ws2_32=n,b"
|
||||
path = Path.home() / ".config/droiddeck/game-environment.json"
|
||||
config = {}
|
||||
try:
|
||||
@@ -823,16 +969,45 @@ def main():
|
||||
return 1
|
||||
if xbox_result is not None:
|
||||
return xbox_result
|
||||
after = None
|
||||
prefix = env.get("STEAM_COMPAT_DATA_PATH", "").rstrip("/")
|
||||
if app_id and prefix and len(command) > 1 and command[1] == "waitforexitandrun":
|
||||
try:
|
||||
if dirt_prefix:
|
||||
after = lambda: restore_dirt_ws2(dirt_prefix, command[0])
|
||||
swap_dirt_ws2(dirt_prefix)
|
||||
print("droiddeck-game-env: DiRT telemetry fix: ws2_32 stand-in in the prefix until the game exits",
|
||||
file=sys.stderr)
|
||||
elif restore_dirt_ws2(prefix, command[0]):
|
||||
print("droiddeck-game-env: DiRT telemetry fix: put the prefix's own ws2_32 back", file=sys.stderr)
|
||||
except OSError as error:
|
||||
print("droiddeck-game-env: DiRT telemetry fix not applied (%s)" % error, file=sys.stderr)
|
||||
if after:
|
||||
after = None
|
||||
try:
|
||||
restore_dirt_ws2(dirt_prefix, command[0])
|
||||
except OSError as undo:
|
||||
print("droiddeck-game-env: DiRT telemetry fix: prefix ws2_32 not put back (%s); Wine uses its own copy "
|
||||
"and the next launch puts the file back" % undo, file=sys.stderr)
|
||||
sync = load_sync()
|
||||
launch, launch_env = select_sync(command, env, sync)
|
||||
if launch[0] != command[0]:
|
||||
try:
|
||||
return start(launch, launch_env, digest)
|
||||
return start(launch, launch_env, digest, after)
|
||||
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)
|
||||
return start(launch, launch_env, digest)
|
||||
try:
|
||||
return start(launch, launch_env, digest, after)
|
||||
except OSError:
|
||||
if after:
|
||||
try:
|
||||
after()
|
||||
except OSError as error:
|
||||
print("droiddeck-game-env: DiRT telemetry fix: prefix ws2_32 not put back (%s); the next launch does it" % error,
|
||||
file=sys.stderr)
|
||||
raise
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -23,7 +23,7 @@ PACK_NAMES = ['proot', 'directaudio', 'tracking', 'xbox', 'comet', 'butler']
|
||||
SOURCE_PATHS = ['app/build.gradle', 'app/src/main/cpp/fakeinput_steam.cpp', 'app/src/main/assets/pulseaudio.tzst',
|
||||
'tools/linuxfs', 'tools/proot', 'tools/aaudio-sink', 'tools/directaudio', 'tools/packs',
|
||||
'tools/gamescope/release.env', 'tools/droiddeck-esync/release.env',
|
||||
'tools/mangoapp', 'tools/msitools', 'tools/pipewire', 'tools/comet', 'tools/xbox', 'tools/components', 'tools/ci', 'tools/build_local.sh',
|
||||
'tools/mangoapp', 'tools/msitools', 'tools/pipewire', 'tools/comet', 'tools/xbox', 'tools/dirt-ws2', 'tools/components', 'tools/ci', 'tools/build_local.sh',
|
||||
'tools/release/runtime_inputs.py', 'app/src/main/assets/desktop-removal',
|
||||
'tools/quest', 'tools/vr/src', 'tools/vr/driver_droiddeck', 'tools/vr/layer', 'tools/vr/build.sh',
|
||||
'app/src/main/cpp/waylandcomp/src/headpose_shm.h',
|
||||
|
||||
@@ -29,6 +29,222 @@ def config_text(entries):
|
||||
return '"InstallConfigStore" { "Software" { "Valve" { "Steam" { "CompatToolMapping" { %s } } } } }' % mapping
|
||||
|
||||
|
||||
class DirtTelemetryFixTest(unittest.TestCase):
|
||||
SHOWDOWN_ON = '<x><motion enabled="true" ip="127.0.0.1" port="20777" delay="1" extradata="3" /></x>'
|
||||
SHOWDOWN_DEFAULT = '<x><motion enabled="true" ip="dbox" port="20777" delay="1" extradata="0" /></x>'
|
||||
|
||||
def setUp(self):
|
||||
self.tmp = tempfile.TemporaryDirectory()
|
||||
root = Path(self.tmp.name)
|
||||
self.prefix = root / "compatdata/2848447563"
|
||||
self.proton = root / "Proton/proton"
|
||||
self.own = root / "Proton/files/lib/wine/i386-windows/ws2_32.dll"
|
||||
self.own.parent.mkdir(parents=True)
|
||||
self.own.write_bytes(b"MZ wine ws2_32")
|
||||
self.proton.write_text("")
|
||||
self.target = self.prefix / "pfx/drive_c/windows/syswow64/ws2_32.dll"
|
||||
self.target.parent.mkdir(parents=True)
|
||||
self.target.symlink_to(self.own)
|
||||
self.stand_in = root / "droiddeck-dirt/ws2_32.dll"
|
||||
self.stand_in.parent.mkdir()
|
||||
self.stand_in.write_bytes(b"MZ droiddeck-dirt-ws2_32 stand-in")
|
||||
self.patch = mock.patch.dict(MODULE["dirt_ws2_wanted"].__globals__, {"DIRT_WS2": str(self.stand_in)})
|
||||
self.patch.start()
|
||||
|
||||
def tearDown(self):
|
||||
self.patch.stop()
|
||||
self.tmp.cleanup()
|
||||
|
||||
def config(self, folder, text):
|
||||
path = self.prefix / "pfx/drive_c/users/steamuser/Documents/My Games" / folder / "hardwaresettings/hardware_settings_config.xml"
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text(text)
|
||||
|
||||
def command(self, exe="showdown.exe"):
|
||||
return [str(self.proton), "waitforexitandrun", "/root/Storage/games/DiRT Showdown/" + exe]
|
||||
|
||||
def env(self):
|
||||
return {"STEAM_COMPAT_DATA_PATH": str(self.prefix)}
|
||||
|
||||
def test_telemetry_counts_as_on_when_the_game_sends_somewhere(self):
|
||||
self.config("DiRT Showdown", self.SHOWDOWN_DEFAULT)
|
||||
self.assertFalse(MODULE["dirt_telemetry_on"](self.prefix, "dirtshowdown"))
|
||||
self.config("DiRT Showdown", self.SHOWDOWN_ON)
|
||||
self.assertTrue(MODULE["dirt_telemetry_on"](self.prefix, "dirtshowdown"))
|
||||
self.config("DiRT Showdown", self.SHOWDOWN_ON.replace('enabled="true"', 'enabled="false"'))
|
||||
self.assertFalse(MODULE["dirt_telemetry_on"](self.prefix, "dirtshowdown"))
|
||||
self.config("DiRT3", '<x><motion enabled="true" ip="192.168.1.20" port="20777" /></x>')
|
||||
self.assertTrue(MODULE["dirt_telemetry_on"](self.prefix, "dirt3"))
|
||||
|
||||
def test_stand_in_is_wanted_only_for_the_dirt_games_with_telemetry_on_and_a_proton_without_the_fix(self):
|
||||
wanted = MODULE["dirt_ws2_wanted"]
|
||||
self.config("DiRT Showdown", self.SHOWDOWN_DEFAULT)
|
||||
self.assertIsNone(wanted(self.command(), self.env()))
|
||||
self.config("DiRT Showdown", self.SHOWDOWN_ON)
|
||||
self.assertEqual(wanted(self.command(), self.env()), str(self.prefix))
|
||||
self.assertEqual(wanted(self.command("Showdown_AVX.exe"), self.env()), str(self.prefix))
|
||||
self.assertIsNone(wanted(self.command("DiRTRally2.exe"), self.env()))
|
||||
self.own.write_bytes(b"MZ wine ws2_32 " + "showdown_avx.exe".encode("utf-16-le"))
|
||||
self.assertIsNone(wanted(self.command(), self.env()))
|
||||
|
||||
def test_swap_keeps_the_prefix_link_and_restore_puts_it_back(self):
|
||||
MODULE["swap_dirt_ws2"](self.prefix)
|
||||
saved = self.target.with_name("ws2_32.dll.droiddeck-original")
|
||||
self.assertFalse(self.target.is_symlink())
|
||||
self.assertEqual(self.target.read_bytes(), self.stand_in.read_bytes())
|
||||
self.assertEqual(os.readlink(saved), str(self.own))
|
||||
self.assertEqual(self.own.read_bytes(), b"MZ wine ws2_32")
|
||||
MODULE["swap_dirt_ws2"](self.prefix)
|
||||
self.assertEqual(os.readlink(saved), str(self.own))
|
||||
self.assertTrue(MODULE["restore_dirt_ws2"](self.prefix, self.proton))
|
||||
self.assertEqual(os.readlink(self.target), str(self.own))
|
||||
self.assertFalse(os.path.lexists(saved))
|
||||
self.assertFalse(MODULE["restore_dirt_ws2"](self.prefix, self.proton))
|
||||
|
||||
def test_restore_keeps_a_file_proton_put_back_meanwhile(self):
|
||||
MODULE["swap_dirt_ws2"](self.prefix)
|
||||
newer = self.own.with_name("ws2_32-newer.dll")
|
||||
newer.write_bytes(b"MZ newer wine ws2_32")
|
||||
self.target.unlink()
|
||||
self.target.symlink_to(newer)
|
||||
self.assertFalse(MODULE["restore_dirt_ws2"](self.prefix, self.proton))
|
||||
self.assertEqual(os.readlink(self.target), str(newer))
|
||||
self.assertFalse(os.path.lexists(self.target.with_name("ws2_32.dll.droiddeck-original")))
|
||||
|
||||
def test_after_a_proton_switch_the_running_protons_file_goes_back(self):
|
||||
MODULE["swap_dirt_ws2"](self.prefix)
|
||||
other = Path(self.tmp.name) / "GE-Proton/proton"
|
||||
other_own = other.parent / "files/lib/wine/i386-windows/ws2_32.dll"
|
||||
other_own.parent.mkdir(parents=True)
|
||||
other_own.write_bytes(b"MZ GE wine ws2_32")
|
||||
other.write_text("")
|
||||
self.assertTrue(MODULE["restore_dirt_ws2"](self.prefix, other))
|
||||
self.assertEqual(os.readlink(self.target), str(other_own))
|
||||
self.assertFalse(os.path.lexists(self.target.with_name("ws2_32.dll.droiddeck-original")))
|
||||
|
||||
def test_restore_follows_a_proton_reached_through_a_linked_folder(self):
|
||||
MODULE["swap_dirt_ws2"](self.prefix)
|
||||
pack = Path(self.tmp.name) / "pack"
|
||||
(pack / "files/lib/wine").mkdir(parents=True)
|
||||
(pack / "files/lib/wine/i386-windows").symlink_to(self.own.parent)
|
||||
(pack / "proton").write_text("")
|
||||
self.assertTrue(MODULE["restore_dirt_ws2"](self.prefix, pack / "proton"))
|
||||
self.assertEqual(os.readlink(self.target), str(self.own))
|
||||
|
||||
def test_a_stand_in_left_without_the_saved_link_is_replaced_by_protons_own_file(self):
|
||||
self.target.unlink()
|
||||
self.target.write_bytes(self.stand_in.read_bytes())
|
||||
self.assertTrue(MODULE["restore_dirt_ws2"](self.prefix, self.proton))
|
||||
self.assertEqual(os.readlink(self.target), str(self.own))
|
||||
|
||||
def test_launch_swaps_the_stand_in_in_for_the_game_and_back_afterwards(self):
|
||||
self.config("DiRT Showdown", self.SHOWDOWN_ON)
|
||||
self.proton.write_text("#!" + sys.executable + "\nimport os, sys\n"
|
||||
"target = os.path.join(os.environ['STEAM_COMPAT_DATA_PATH'], 'pfx/drive_c/windows/syswow64/ws2_32.dll')\n"
|
||||
"print(os.environ.get('WINEDLLOVERRIDES', ''))\n"
|
||||
"print(os.path.islink(target), b'droiddeck-dirt-ws2_32' in open(target, 'rb').read())\n")
|
||||
self.proton.chmod(0o755)
|
||||
runner = Path(self.tmp.name) / "run.py"
|
||||
runner.write_text("import runpy, sys\nmain = runpy.run_path(sys.argv[1])['main']\nmain.__globals__['DIRT_WS2'] = sys.argv[2]\n"
|
||||
"sys.argv = [sys.argv[1]] + sys.argv[3:]\nsys.exit(main())\n")
|
||||
home = Path(self.tmp.name) / "home"
|
||||
home.mkdir()
|
||||
result = subprocess.run([sys.executable, str(runner), str(BIN / "droiddeck-game-env"), str(self.stand_in), *self.command()],
|
||||
env={**os.environ, "HOME": str(home), "STEAM_COMPAT_DATA_PATH": str(self.prefix)}, text=True, capture_output=True)
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
overrides, state = result.stdout.splitlines()[-2:]
|
||||
self.assertIn("ws2_32=n,b", overrides.split(";"))
|
||||
self.assertEqual(state, "False True")
|
||||
self.assertIn("DiRT telemetry fix: ws2_32 stand-in", result.stderr)
|
||||
self.assertEqual(os.readlink(self.target), str(self.own))
|
||||
self.assertFalse(os.path.lexists(self.target.with_name("ws2_32.dll.droiddeck-original")))
|
||||
|
||||
def test_a_proton_that_cannot_start_leaves_the_prefix_as_it_was(self):
|
||||
self.config("DiRT Showdown", self.SHOWDOWN_ON)
|
||||
self.proton.write_text("not a program")
|
||||
self.proton.chmod(0o644)
|
||||
runner = Path(self.tmp.name) / "run.py"
|
||||
runner.write_text("import runpy, sys\nmain = runpy.run_path(sys.argv[1])['main']\nmain.__globals__['DIRT_WS2'] = sys.argv[2]\n"
|
||||
"sys.argv = [sys.argv[1]] + sys.argv[3:]\nsys.exit(main())\n")
|
||||
home = Path(self.tmp.name) / "home"
|
||||
home.mkdir()
|
||||
result = subprocess.run([sys.executable, str(runner), str(BIN / "droiddeck-game-env"), str(self.stand_in), *self.command()],
|
||||
env={**os.environ, "HOME": str(home), "STEAM_COMPAT_DATA_PATH": str(self.prefix)}, text=True, capture_output=True)
|
||||
self.assertNotEqual(result.returncode, 0)
|
||||
self.assertIn("DiRT telemetry fix: ws2_32 stand-in", result.stderr)
|
||||
self.assertEqual(os.readlink(self.target), str(self.own))
|
||||
self.assertFalse(os.path.lexists(self.target.with_name("ws2_32.dll.droiddeck-original")))
|
||||
|
||||
def test_launch_with_telemetry_off_leaves_the_prefix_alone(self):
|
||||
self.config("DiRT Showdown", self.SHOWDOWN_DEFAULT)
|
||||
self.proton.write_text("#!" + sys.executable + "\nimport os\nprint(os.environ.get('WINEDLLOVERRIDES', ''))\n")
|
||||
self.proton.chmod(0o755)
|
||||
home = Path(self.tmp.name) / "home"
|
||||
home.mkdir()
|
||||
result = subprocess.run([sys.executable, str(BIN / "droiddeck-game-env"), *self.command()],
|
||||
env={**os.environ, "HOME": str(home), "STEAM_COMPAT_DATA_PATH": str(self.prefix)}, text=True, capture_output=True)
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
self.assertNotIn("ws2_32=n,b", result.stdout)
|
||||
self.assertEqual(os.readlink(self.target), str(self.own))
|
||||
|
||||
def test_a_failed_put_back_does_not_end_the_launch_with_an_error(self):
|
||||
def fail():
|
||||
raise OSError(28, "No space left on device")
|
||||
stderr = io.StringIO()
|
||||
with mock.patch("sys.stderr", stderr):
|
||||
code = MODULE["start"]([sys.executable, "-c", "raise SystemExit(0)"], dict(os.environ), None, fail)
|
||||
self.assertEqual(code, 0)
|
||||
self.assertIn("not put back", stderr.getvalue())
|
||||
|
||||
def test_a_half_done_swap_is_put_back(self):
|
||||
saved = self.target.with_name("ws2_32.dll.droiddeck-original")
|
||||
os.replace(self.target, saved)
|
||||
self.assertTrue(MODULE["restore_dirt_ws2"](self.prefix, self.proton))
|
||||
self.assertEqual(os.readlink(self.target), str(self.own))
|
||||
self.assertFalse(os.path.lexists(saved))
|
||||
|
||||
def test_a_native_ws2_32_goes_back_as_it_was_after_a_proton_switch(self):
|
||||
self.target.unlink()
|
||||
self.target.write_bytes(b"MZ a mod's own ws2_32")
|
||||
MODULE["swap_dirt_ws2"](self.prefix)
|
||||
other = Path(self.tmp.name) / "GE-Proton/proton"
|
||||
(other.parent / "files/lib/wine/i386-windows").mkdir(parents=True)
|
||||
(other.parent / "files/lib/wine/i386-windows/ws2_32.dll").write_bytes(b"MZ GE wine ws2_32")
|
||||
other.write_text("")
|
||||
self.assertTrue(MODULE["restore_dirt_ws2"](self.prefix, other))
|
||||
self.assertFalse(self.target.is_symlink())
|
||||
self.assertEqual(self.target.read_bytes(), b"MZ a mod's own ws2_32")
|
||||
|
||||
def test_a_link_to_a_mods_ws2_32_goes_back_as_it_was(self):
|
||||
mod = Path(self.tmp.name) / "mods/ws2_32.dll"
|
||||
mod.parent.mkdir()
|
||||
mod.write_bytes(b"MZ a mod's ws2_32")
|
||||
self.target.unlink()
|
||||
self.target.symlink_to(mod)
|
||||
MODULE["swap_dirt_ws2"](self.prefix)
|
||||
other = Path(self.tmp.name) / "GE-Proton/proton"
|
||||
(other.parent / "files/lib/wine/i386-windows").mkdir(parents=True)
|
||||
(other.parent / "files/lib/wine/i386-windows/ws2_32.dll").write_bytes(b"MZ GE wine ws2_32")
|
||||
other.write_text("")
|
||||
self.assertTrue(MODULE["restore_dirt_ws2"](self.prefix, other))
|
||||
self.assertEqual(os.readlink(self.target), str(mod))
|
||||
|
||||
def test_start_gives_the_signal_handlers_back(self):
|
||||
import signal
|
||||
before = {s: signal.getsignal(s) for s in (signal.SIGTERM, signal.SIGINT, signal.SIGHUP)}
|
||||
MODULE["start"]([sys.executable, "-c", "pass"], dict(os.environ), None, lambda: None)
|
||||
self.assertEqual(before, {s: signal.getsignal(s) for s in before})
|
||||
|
||||
def test_start_puts_the_file_back_after_the_game_exits(self):
|
||||
calls = []
|
||||
code = MODULE["start"]([sys.executable, "-c", "raise SystemExit(3)"], dict(os.environ), None, lambda: calls.append("restored"))
|
||||
self.assertEqual(code, 3)
|
||||
self.assertEqual(calls, ["restored"])
|
||||
with self.assertRaises(OSError):
|
||||
MODULE["start"]([str(Path(self.tmp.name) / "missing")], dict(os.environ), None, lambda: calls.append("again"))
|
||||
self.assertEqual(calls, ["restored"])
|
||||
|
||||
|
||||
class GameDebugLoggingTest(unittest.TestCase):
|
||||
def test_maintenance_precision_survives_run_with_performance_game_settings(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
|
||||
Reference in new issue
Block a user