Merge main into Wine timezone fix

This commit is contained in:
Kurt Himebauch committed 2026-12-06 09:36:33 -05:00
commit 3f3932d575
941 files changed
+106838 -7538

No files matched your search

+13 -5
View File
@@ -35,10 +35,13 @@ GAMESCOPE_COMMIT=8f212644c46460549035971ab914421180f61a7c
GAMESCOPE_PATCHES="0117-wsi-cache-present-bypass-check.patch 0119-wsi-default-images-under-limiter.patch"
VULKAN_HEADERS_TAG=v1.4.341
# The bionic DroidDeck-Proton layer the pack is made for: linked against (libwayland-client) and checked against, not packed.
# Layer v16 (067c719d) plus the ARM64EC code-map fix for 39-bit hosts (d4c9ffa7, run 44291095238).
LAYER_URL=https://github.com/The412Banner/proton-wine/releases/download/build-bionic-layers-20261118-v16-unwind/DroidDeck-Proton-11.0-12.8-arm64ec.wcp
LAYER_SHA256=3cc74b877bc8707d75aa2cc22e335373b6a6c0b6b1937c7b3c2cd98e55de2e89 # proton-wine d48e30a1 (a188791d + fecf7376 on d4c9ffa7)
LAYER_VERSION=12.8
# Layer v18: DroidDeck-Proton 11-14.1 (Valve Wine a47c73f52fd7, as GE-Proton11-14), the build Bannerlator ships; it
# carries the ARM64EC code-map and unwind fixes the 12.8 layer had (5ebfaa6f, 2515a989, e88fab40). This build adds the
# original Xbox fixes on top of v18 (special APC delivery, boot video aperture, 0 timer resolution: each off unless
# droiddeck-game-env sets its variable; FileAllocationInfo, MFCreateWaveFormatEx NULL size).
LAYER_URL=https://github.com/The412Banner/proton-wine/releases/download/build-bionic-layers-20261203-ogxbox/DroidDeck-proton-11.0-14.1-arm64ec.wcp
LAYER_SHA256=a779747c880c64bacc0171cf26822f3398eaf32f0b214bca3448a95bf4127a90 # proton-wine ee646200 (run 47122517177)
LAYER_VERSION=14.1
# Packed into the DroidDeck-Bionic tool next to the layer: FEX with Android-built unix libraries, and default
# DXVK / VKD3D-Proton (DroidDeck components can swap these in files/lib/wine/{dxvk,vkd3d-proton} later).
FEX_URL=https://github.com/The412Banner/Nightlies/releases/download/FEXCore-2611.1/FEXCore-2611.1-unix.wcp
@@ -183,7 +186,7 @@ echo "== DroidDeck fake input (app/src/main/cpp/fakeinput_steam.cpp), heap-taggi
"$CXX" -shared -fPIC -O2 -Wall -Wno-attributes -pthread -std=c++17 "$ROOT/app/src/main/cpp/fakeinput_steam.cpp" \
-ldl -static-libstdc++ -o "$PACK/preload/libfakeinput.so"
"$CC" -shared -fPIC -O2 -Wall "$HERE/notag.c" -ldl -o "$PACK/preload/libnotag.so"
"$CC" -shared -fPIC -O2 -Wall "$HERE/execshim.c" -ldl -o "$PACK/preload/libexecshim.so"
"$CC" -shared -fPIC -O2 -Wall "$HERE/execshim.c" "$HERE/handoff.c" -ldl -o "$PACK/preload/libexecshim.so"
"$CC" -shared -fPIC -O2 -Wall -Wextra -fvisibility=hidden "$HERE/steamshm.c" -ldl -o "$PACK/preload/libsteamshm.so"
"$CC" -O2 -Wall "$HERE/gstag.c" -o "$PACK/bin/gstag"
"$STRIP" --strip-unneeded "$PACK/layer/"*.so "$PACK/preload/"*.so "$PACK/bin/gstag"
@@ -237,6 +240,11 @@ cp "$WORK/FEX/system32/"*.dll "$T/files/runtime/fex/aarch64-windows/"
install -m 755 "$HERE/tool/proton" "$T/proton"
install -m 755 "$HERE/tool/launch.sh" "$T/bionic/launch.sh"
cp "$HERE/tool/desktop.reg" "$HERE/tool/Xdefaults" "$T/bionic/"
# dd-directcontroller: the XInput DLLs launch.sh puts in the prefix of a game set to start without Steam, and the
# host test of their ring reader
"$HERE/dd-directcontroller/build.sh" host "$WORK/dd-directcontroller-host"
"$WORK/dd-directcontroller-host/host_test"
"$HERE/dd-directcontroller/build.sh" dlls "$T/bionic/dd-directcontroller"
cp "$HERE/tool/toolmanifest.vdf" "$T/"
# The name Steam registers the tool under ends in -Proton: Steam maps Windows save folders (WinAppDataLocal, WinMyDocuments
# ...) into compatdata/<app>/pfx only for tools whose name contains "proton" (a case-insensitive search in
+272
View File
@@ -0,0 +1,272 @@
#!/usr/bin/env bash
# dd-directcontroller: build the XInput DLLs DroidDeck-Bionic puts in a prefix for games set to start without Steam
# (launch.sh). Used by tools/bionic-runtime/build.sh.
#
# build.sh toolchain fetch the pinned llvm-mingw into $LLVM_MINGW (default ~/.cache/...)
# build.sh dlls <outdir> <outdir>/{arm64x,i386}/<dll>.dll for every XInput DLL name, each export table
# (both views of an ARM64X image), import list and machine type checked
# build.sh host <outdir> <outdir>/host_test (native, cc): the ring snapshot reader against a writer
#
# The PE side uses bylaws/llvm-mingw (its arm64ec target does not predefine __x86_64__, unlike upstream's).
# One C source (src/dd_directcontroller.c) is linked once per DLL name with that name's .def file (def/), so each
# DLL has exactly the exports and ordinals of the Windows DLL it stands in for. i386 .def files get stdcall
# decorations here and the link strips them (--kill-at).
#
# arm64x (system32 of the arm64ec layer): the source is compiled for ARM64EC and for native ARM64 and both
# objects are linked into one ARM64X image (lld: -m arm64xpe, the .def for the EC view, -defarm64native for
# the native view; each view gets its own CRT, the native one taken from the toolchain's own aarch64 link
# line). An x64 game loads the EC view, a native ARM64 process (Wine's own control.exe, ...) the ARM64 view;
# an ARM64EC-only image fails there with c000007b. i386 goes to syswow64 for 32-bit games.
#
# Every DLL carries a VERSIONINFO resource with the file version of the Wine builtin DLL it replaces, so a
# program reading it sees the same number as before.
set -euo pipefail
HERE="$(cd "$(dirname "$0")" && pwd)"
LLVM_MINGW_VER=20250920
case "$(uname -m)" in
aarch64|arm64)
LLVM_MINGW_HOST=aarch64; HOST_SUFFIX=-aarch64
LLVM_MINGW_SHA256=bce5cc755c613515fd44e1ee9523123d854103abae147571adb645450036274d ;;
*)
LLVM_MINGW_HOST=x86_64; HOST_SUFFIX=
LLVM_MINGW_SHA256=8dd8c34fc051a50c2fae86015f35057f8aae93fe1e19b34537ef1269a8b4c772 ;;
esac
LLVM_MINGW_TAR="llvm-mingw-${LLVM_MINGW_VER}-ucrt-ubuntu-22.04-${LLVM_MINGW_HOST}.tar.xz"
LLVM_MINGW_URL="https://github.com/bylaws/llvm-mingw/releases/download/${LLVM_MINGW_VER}/${LLVM_MINGW_TAR}"
LLVM_MINGW="${LLVM_MINGW:-$HOME/.cache/llvm-mingw-bylaws-${LLVM_MINGW_VER}${HOST_SUFFIX}}"
DLLS="xinput1_1 xinput1_2 xinput1_3 xinput1_4 xinput9_1_0 xinputuap"
ARCHES="arm64x i386"
MARKER="dd-directcontroller: "
say() { printf '== dd-directcontroller: %s\n' "$*"; }
die() { printf '::error::dd-directcontroller: %s\n' "$*" >&2; exit 1; }
toolchain() {
if [ ! -x "$LLVM_MINGW/bin/arm64ec-w64-mingw32-clang" ]; then
say "fetching $LLVM_MINGW_TAR"
local tmp; tmp="$(mktemp -d)"
curl -fsSL --retry 5 --retry-delay 5 -o "$tmp/t.tar.xz" "$LLVM_MINGW_URL"
echo "$LLVM_MINGW_SHA256 $tmp/t.tar.xz" | sha256sum -c -
mkdir -p "$LLVM_MINGW"
tar -xJf "$tmp/t.tar.xz" -C "$LLVM_MINGW" --strip-components=1
rm -rf "$tmp"
fi
export PATH="$LLVM_MINGW/bin:$PATH"
for t in i686 arm64ec aarch64; do
command -v "$t-w64-mingw32-clang" >/dev/null || die "llvm-mingw has no $t-w64-mingw32-clang"
done
for t in i686 aarch64; do
command -v "$t-w64-mingw32-windres" >/dev/null || die "llvm-mingw has no $t-w64-mingw32-windres"
done
say "llvm-mingw $LLVM_MINGW_VER: $(arm64ec-w64-mingw32-clang --version | head -1)"
}
windres_for() {
case "$1" in
i386) echo i686-w64-mingw32-windres ;;
arm64x) echo aarch64-w64-mingw32-windres ;;
*) die "unknown arch $1" ;;
esac
}
# File version of the Wine builtin each DLL replaces (dlls/<name>/version.rc).
DLL_VERSIONS='xinput1_1:9,12,589,0 xinput1_2:9,14,701,0 xinput1_3:9,15,779,0 xinput1_4:6,3,9600,16384 xinput9_1_0:9,10,455,0 xinputuap:10,0,19041,746'
version_res() { # version_res <arch> <dll> <tmpdir> -> path of a COFF object with the DLL's VERSIONINFO
local ver="" kv rc="$3/$2.rc" obj="$3/$2-ver-$1.o"
for kv in $DLL_VERSIONS; do [ "${kv%%:*}" = "$2" ] && ver="${kv#*:}"; done
[ -n "$ver" ] || die "no version for $2 in DLL_VERSIONS"
cat >"$rc" <<EOF
1 VERSIONINFO
FILEVERSION $ver
PRODUCTVERSION $ver
FILEFLAGSMASK 0x3f
FILEFLAGS 0x0
FILEOS 0x40004
FILETYPE 0x2
FILESUBTYPE 0x0
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "DroidDeck"
VALUE "FileDescription", "dd-directcontroller controller API (DroidDeck)"
VALUE "FileVersion", "${ver//,/.}"
VALUE "InternalName", "$2"
VALUE "LegalCopyright", "GPL-3.0"
VALUE "OriginalFilename", "$2.dll"
VALUE "ProductName", "DroidDeck"
VALUE "ProductVersion", "${ver//,/.}"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
EOF
"$(windres_for "$1")" "$rc" -O coff -o "$obj"
echo "$obj"
}
# stdcall argument bytes of every export (i386 decoration).
I386_DECOR='DllMain:12 XInputGetState:8 XInputSetState:8 XInputGetStateEx:8 XInputGetCapabilities:12 XInputGetDSoundAudioDeviceGuids:12 XInputGetBatteryInformation:12 XInputGetKeystroke:12 XInputWaitForGuideButton:12 XInputEnable:4 XInputCancelGuideButtonWait:4 XInputPowerOffController:4 XInputGetAudioDeviceIds:20 XInputGetCapabilitiesEx:16'
def_for() { # def_for <arch> <dll> <tmpdir> -> path of the .def to link with
local src="$HERE/def/$2.def"
if [ "$1" != i386 ]; then echo "$src"; return; fi
awk -v table="$I386_DECOR" 'BEGIN { n = split(table, a, " "); for (i = 1; i <= n; i++) { split(a[i], kv, ":"); m[kv[1]] = kv[2] } }
($1 in m) { sub($1, $1 "@" m[$1]) } { print }' "$src" > "$3/$2.def"
echo "$3/$2.def"
}
# expected "<ordinal> <name|->" lines of a .def (NONAME exports have no name)
def_exports() {
awk 'f && NF { ord = ""; for (i = 2; i <= NF; i++) if ($i ~ /^@[0-9]+$/) ord = substr($i, 2);
name = $1; for (i = 2; i <= NF; i++) if ($i == "NONAME") name = "-";
print (ord == "" ? "?" : ord), name }
/^EXPORTS/ { f = 1 }' "$1" | sort
}
# actual "<ordinal> <name|->" lines of a DLL (unused ordinals between the numbered ones have RVA 0 and are
# skipped). dll_exports <file> [main|hybrid]: llvm-readobj prints an ARM64X image's native view first, then
# its EC view inside "HybridObject {".
dll_exports() {
llvm-readobj --coff-exports "$1" | awk -v view="${2:-main}" '
/HybridObject \{/ { h = 1; next }
(view == "main" && h) || (view == "hybrid" && !h) { next }
/^ *Export \{/ { o = ""; n = "-"; r = "" }
/^ *Ordinal:/ { o = $2 }
/^ *Name:/ { if (NF >= 2) n = $2 }
/^ *RVA:/ { r = $2 }
/^ *\}/ { if (o != "" && r != "" && r != "0x0") print o, n; o = "" }' | sort
}
compare_exports() { # compare_exports <label> <file> <def> <view>
local want got
want="$(def_exports "$HERE/def/$3.def")"
got="$(dll_exports "$2" "$4")"
if [ "$want" != "$got" ]; then
printf 'want:\n%s\ngot:\n%s\n' "$want" "$got"
die "$1 exports differ from def/$3.def"
fi
}
check_dll() { # check_dll <arch> <dll name> <file>
local arch="$1" name="$2" f="$3" fmts fmt hyb machine lc imports bad res
fmts="$(llvm-readobj --file-headers "$f" | sed -n 's/^ *Format: //p')"
fmt="$(sed -n 1p <<<"$fmts")"
hyb="$(sed -n 2p <<<"$fmts")"
case "$arch" in
i386) [ "$fmt" = "COFF-i386" ] && [ -z "$hyb" ] || die "$f is $fmt${hyb:+ + $hyb}, want COFF-i386" ;;
arm64x)
# Native view: an ARM64 PE (what an ARM64 process maps). EC view: ARM64EC (what an x64 process sees
# through the ARM64X dynamic relocations). Both need the CHPE metadata.
machine="$(python3 -c 'import struct,sys; d=open(sys.argv[1],"rb").read(4096); o=struct.unpack_from("<I",d,0x3c)[0]; print(hex(struct.unpack_from("<H",d,o+4)[0]) if d[o:o+4]==b"PE\0\0" else "?")' "$f")"
[ "$machine" = 0xaa64 ] || die "$f PE header machine is $machine, want 0xaa64 (ARM64)"
[ "$hyb" = "COFF-ARM64EC" ] || die "$f has no ARM64EC hybrid view (formats: $(echo $fmts))"
lc="$(llvm-readobj --coff-load-config "$f")"
grep -q 'CHPEMetadata' <<<"$lc" || die "$f has no CHPE metadata"
grep -q 'Arm64X' <<<"$lc" || die "$f has no ARM64X dynamic relocations"
# One TLS directory serves both views and would list native ARM64 callbacks (see src/notls.c).
llvm-readobj --file-headers "$f" | grep -q 'TLSTableRVA: 0x[1-9a-fA-F]' && die "$f has a TLS directory"
fmt="$fmt/$hyb/$machine"
;;
esac
compare_exports "$arch/$name.dll" "$f" "$name" main
[ "$arch" != arm64x ] || compare_exports "$arch/$name.dll (EC view)" "$f" "$name" hybrid
imports="$(llvm-readobj --coff-imports "$f" | sed -n 's/^ *Name: //p' | tr 'A-Z' 'a-z' | sort -u)"
bad="$(grep -vxE 'kernel32\.dll|ucrtbase\.dll|msvcrt\.dll|api-ms-win-crt-[a-z0-9-]+\.dll' <<<"$imports" || true)"
[ -z "$bad" ] || die "$arch/$name.dll imports $(echo $bad) (only kernel32 and the C runtime are allowed)"
grep -aqF "$MARKER" "$f" || die "$arch/$name.dll lacks its '$MARKER' marker (launch.sh and the rumble path look for it)"
res="$(llvm-readobj --coff-resources "$f")"
grep -q 'Type: VERSIONINFO (ID 16)' <<<"$res" || die "$arch/$name.dll has no VERSIONINFO resource"
printf ' %-7s %-15s %6d bytes %-24s imports: %s\n' "$arch" "$name.dll" "$(stat -c %s "$f")" "$fmt" "$(echo $imports)"
}
# The objects and archives the toolchain links into an aarch64 DLL (CRT start-up, mingw/ucrt/kernel32 import
# libraries, compiler-rt), as absolute paths: the native view of an ARM64X image needs its own.
native_link_inputs() { # native_link_inputs <tmpdir>
printf 'int x;\n' > "$1/empty.c"
aarch64-w64-mingw32-clang -shared -o "$1/empty.dll" "$1/empty.c" -### 2>&1 | python3 -c '
import os, shlex, sys
line = [l for l in sys.stdin.read().splitlines() if "ld.lld" in l or "lld-link" in l]
if not line:
sys.exit("no link line in the -### output")
toks = shlex.split(line[-1])
dirs = [t[2:] for t in toks if t.startswith("-L")]
out = []
for t in toks[1:]:
if t.startswith("-l"):
name = t[2:]
hit = next((os.path.join(d, c) for d in dirs for c in ("lib%s.a" % name, "lib%s.dll.a" % name, "%s.lib" % name)
if os.path.isfile(os.path.join(d, c))), None)
if not hit:
sys.exit("cannot resolve -l%s in %s" % (name, dirs))
out.append(hit)
elif t.endswith((".o", ".a", ".obj", ".lib")) and os.path.isabs(t) and os.path.isfile(t):
out.append(t)
seen = set()
print("\n".join(p for p in out if not (p in seen or seen.add(p))))
'
}
# notls-*.o (src/notls.c) come before the CRT so the image gets no TLS directory.
link_arm64x() { # link_arm64x <out> <def> <ec obj> <native obj> <native inputs file> <ec notls obj> <native notls obj> <version res obj>
local nat=()
mapfile -t nat <"$5"
arm64ec-w64-mingw32-clang -shared -s -Wl,--no-insert-timestamp -Wl,-marm64xpe "-Wl,--Xlink=-defarm64native:$2" \
-o "$1" "$3" "$6" "$4" "$7" "$8" "$2" "${nat[@]}" -lkernel32
}
CFLAGS_COMMON="-std=gnu11 -O2 -Wall -Wextra -Werror -fno-strict-aliasing -I$HERE/src"
dlls() {
local out="${1:?usage: build.sh dlls <outdir>}" tmp arch name def
toolchain
mkdir -p "$out"; out="$(cd "$out" && pwd)"
tmp="$(mktemp -d)"
for arch in $ARCHES; do
mkdir -p "$out/$arch"
if [ "$arch" = arm64x ]; then
arm64ec-w64-mingw32-clang $CFLAGS_COMMON -DDDC_HYBRID=1 -c "$HERE/src/dd_directcontroller.c" -o "$tmp/ddc-arm64ec.o"
aarch64-w64-mingw32-clang $CFLAGS_COMMON -DDDC_HYBRID=1 -c "$HERE/src/dd_directcontroller.c" -o "$tmp/ddc-aarch64.o"
arm64ec-w64-mingw32-clang $CFLAGS_COMMON -c "$HERE/src/notls.c" -o "$tmp/notls-arm64ec.o"
aarch64-w64-mingw32-clang $CFLAGS_COMMON -c "$HERE/src/notls.c" -o "$tmp/notls-aarch64.o"
native_link_inputs "$tmp" >"$tmp/native-inputs"
for name in $DLLS; do
link_arm64x "$out/$arch/$name.dll" "$HERE/def/$name.def" "$tmp/ddc-arm64ec.o" "$tmp/ddc-aarch64.o" "$tmp/native-inputs" \
"$tmp/notls-arm64ec.o" "$tmp/notls-aarch64.o" "$(version_res "$arch" "$name" "$tmp")"
check_dll "$arch" "$name" "$out/$arch/$name.dll"
done
continue
fi
# i386: SSE2 so a full fence is mfence
i686-w64-mingw32-clang $CFLAGS_COMMON -msse2 -mfpmath=sse -c "$HERE/src/dd_directcontroller.c" -o "$tmp/ddc-i386.o"
for name in $DLLS; do
def="$(def_for "$arch" "$name" "$tmp")"
i686-w64-mingw32-clang -shared -s -Wl,--no-insert-timestamp -Wl,--kill-at -o "$out/$arch/$name.dll" "$tmp/ddc-i386.o" \
"$(version_res "$arch" "$name" "$tmp")" "$def" -lkernel32
check_dll "$arch" "$name" "$out/$arch/$name.dll"
done
done
rm -rf "$tmp"
say "$(ls "$out"/*/*.dll | wc -l) DLLs in $out"
}
host() {
local out="${1:?usage: build.sh host <outdir>}"
mkdir -p "$out"
"${CC:-cc}" -std=gnu11 -O2 -Wall -Wextra -Werror -pthread -I"$HERE/src" -o "$out/host_test" "$HERE/test/host_test.c"
say "host_test built for $(uname -m)"
}
case "${1:-}" in
toolchain) toolchain ;;
dlls) dlls "${2:-}" ;;
host) host "${2:-}" ;;
*) die "usage: $0 toolchain | dlls <outdir> | host <outdir>" ;;
esac
@@ -0,0 +1,11 @@
LIBRARY xinput1_1.dll
EXPORTS
XInputEnable @1
XInputGetCapabilities @2
XInputGetDSoundAudioDeviceGuids @3
XInputSetState @4
XInputGetState @5
XInputGetStateEx @100
XInputWaitForGuideButton @101
XInputCancelGuideButtonWait @102
XInputPowerOffController @103
@@ -0,0 +1,11 @@
LIBRARY xinput1_2.dll
EXPORTS
XInputEnable @1
XInputGetCapabilities @2
XInputGetDSoundAudioDeviceGuids @3
XInputSetState @4
XInputGetState @5
XInputGetStateEx @100
XInputWaitForGuideButton @101
XInputCancelGuideButtonWait @102
XInputPowerOffController @103
@@ -0,0 +1,14 @@
LIBRARY xinput1_3.dll
EXPORTS
DllMain @1
XInputGetState @2
XInputSetState @3
XInputGetCapabilities @4
XInputEnable @5
XInputGetDSoundAudioDeviceGuids @6
XInputGetBatteryInformation @7
XInputGetKeystroke @8
XInputGetStateEx @100
XInputWaitForGuideButton @101
XInputCancelGuideButtonWait @102
XInputPowerOffController @103
@@ -0,0 +1,15 @@
LIBRARY xinput1_4.dll
EXPORTS
DllMain @1
XInputGetState @2
XInputSetState @3
XInputGetCapabilities @4
XInputEnable @5
XInputGetBatteryInformation @7
XInputGetKeystroke @8
XInputGetAudioDeviceIds @10
XInputGetStateEx @100
XInputWaitForGuideButton @101
XInputCancelGuideButtonWait @102
XInputPowerOffController @103
XInputGetCapabilitiesEx @108
@@ -0,0 +1,10 @@
LIBRARY xinput9_1_0.dll
EXPORTS
XInputGetCapabilities @1
XInputGetDSoundAudioDeviceGuids @2
XInputSetState @3
XInputGetState @4
XInputGetStateEx @100
XInputWaitForGuideButton @101
XInputCancelGuideButtonWait @102
XInputPowerOffController @103
@@ -0,0 +1,14 @@
LIBRARY xinputuap.dll
EXPORTS
DllMain @1
XInputEnable @2
XInputGetAudioDeviceIds @3
XInputGetBatteryInformation @4
XInputGetCapabilities @5
XInputGetKeystroke @6
XInputGetState @7
XInputSetState @8
XInputGetStateEx @100
XInputWaitForGuideButton @101
XInputCancelGuideButtonWait @102
XInputPowerOffController @103
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,163 @@
/*
* dd-directcontroller: the read side of DroidDeck's controller ring file (one per pad slot), shared by the
* XInput DLL and its host test.
*
* The app (input/FakeInputWriter.java) writes each slot's ring file; fakeinput_steam.cpp reads its events
* for Wine's evdev path. The 64-byte header (FakeInputRingHeader, ABI-stable) also carries a snapshot of
* the whole pad that the writer updates on every publish, under a sequence counter:
*
* 0 u32 magic 0x46494252 16 u64 write_seq 40 u32 snapshot buttons (bit = BUTTON_MAP index)
* 4 u32 version 2 24 u64 generation 44 i16 snapshot axes[8]
* 8 u32 event size 24 32 u64 snapshot_seq 60 u32 resync_seq
* 12 u32 capacity 4096
*
* Snapshot protocol (FakeInputWriter.writeSnapshotLocked): seq + 1 (odd), store fence, buttons and axes,
* store fence, seq + 2 (even). A reader takes the state when it saw the same even seq before and after.
* Only 32-bit loads are used: on i386 a 64-bit atomic load is a cmpxchg8b, which writes and so faults on a
* read-only view; the low halves of seq and generation are enough to see a change.
*
* Axes: [0] left X, [1] left Y, [2] right X, [3] right Y (evdev sense, -32767..32767, Y positive = down),
* [4] right trigger, [5] left trigger (0..255), [6] hat X, [7] hat Y (-1, 0, 1; Y -1 = up).
*/
#ifndef DD_DIRECTCONTROLLER_RING_H
#define DD_DIRECTCONTROLLER_RING_H
#include <stddef.h>
#include <stdint.h>
#define DDC_RING_MAGIC 0x46494252u
#define DDC_RING_VERSION 2u
#define DDC_RING_EVENT_SIZE 24u
#define DDC_RING_CAPACITY 4096u
#define DDC_RING_HEADER_SIZE 64u
#define DDC_OFF_MAGIC 0u
#define DDC_OFF_VERSION 4u
#define DDC_OFF_EVENT_SIZE 8u
#define DDC_OFF_CAPACITY 12u
#define DDC_OFF_GENERATION 24u /* low half */
#define DDC_OFF_SNAP_SEQ 32u /* low half */
#define DDC_OFF_SNAP_BUTTONS 40u
#define DDC_OFF_SNAP_AXES 44u
/* Snapshot button bits: FakeInputWriter.BUTTON_MAP index (QAM = DroidDeck's quick-access button). */
enum {
DDC_B_A, DDC_B_B, DDC_B_X, DDC_B_Y, DDC_B_TL, DDC_B_TR, DDC_B_SELECT, DDC_B_START,
DDC_B_THUMBL, DDC_B_THUMBR, DDC_B_MODE, DDC_B_QAM,
};
enum { DDC_A_LX, DDC_A_LY, DDC_A_RX, DDC_A_RY, DDC_A_RT, DDC_A_LT, DDC_A_HATX, DDC_A_HATY };
/* XInput button bits */
#define DDC_XI_DPAD_UP 0x0001u
#define DDC_XI_DPAD_DOWN 0x0002u
#define DDC_XI_DPAD_LEFT 0x0004u
#define DDC_XI_DPAD_RIGHT 0x0008u
#define DDC_XI_START 0x0010u
#define DDC_XI_BACK 0x0020u
#define DDC_XI_LEFT_THUMB 0x0040u
#define DDC_XI_RIGHT_THUMB 0x0080u
#define DDC_XI_LEFT_SHOULDER 0x0100u
#define DDC_XI_RIGHT_SHOULDER 0x0200u
#define DDC_XI_GUIDE 0x0400u
#define DDC_XI_A 0x1000u
#define DDC_XI_B 0x2000u
#define DDC_XI_X 0x4000u
#define DDC_XI_Y 0x8000u
typedef struct {
uint32_t seq; /* low half of snapshot_seq (even) */
uint32_t generation; /* low half */
uint32_t buttons;
int16_t axes[8];
} ddc_snap;
typedef struct {
uint16_t buttons;
uint8_t lt, rt;
int16_t lx, ly, rx, ry;
} ddc_pad;
static inline uint32_t ddc_ld32(const uint8_t *v, uint32_t off, int order) {
return __atomic_load_n((const uint32_t *)(const void *)(v + off), order);
}
/* 1 if the view starts with a version-2 ring header of the size this file reads. */
static inline int ddc_valid(const uint8_t *v) {
return ddc_ld32(v, DDC_OFF_MAGIC, __ATOMIC_RELAXED) == DDC_RING_MAGIC &&
ddc_ld32(v, DDC_OFF_VERSION, __ATOMIC_RELAXED) == DDC_RING_VERSION &&
ddc_ld32(v, DDC_OFF_EVENT_SIZE, __ATOMIC_RELAXED) == DDC_RING_EVENT_SIZE &&
ddc_ld32(v, DDC_OFF_CAPACITY, __ATOMIC_RELAXED) == DDC_RING_CAPACITY;
}
/* A consistent copy of the snapshot, in at most `attempts` tries; 0 if the writer kept lapping it. */
static inline int ddc_snapshot(const uint8_t *v, ddc_snap *out, unsigned attempts) {
for (unsigned i = 0; i < attempts; i++) {
uint32_t s1 = ddc_ld32(v, DDC_OFF_SNAP_SEQ, __ATOMIC_ACQUIRE);
if (s1 & 1u) continue;
uint32_t gen = ddc_ld32(v, DDC_OFF_GENERATION, __ATOMIC_RELAXED);
uint32_t buttons = ddc_ld32(v, DDC_OFF_SNAP_BUTTONS, __ATOMIC_RELAXED);
uint32_t w[4];
for (unsigned k = 0; k < 4; k++) w[k] = ddc_ld32(v, DDC_OFF_SNAP_AXES + 4u * k, __ATOMIC_RELAXED);
__atomic_thread_fence(__ATOMIC_ACQUIRE);
if (ddc_ld32(v, DDC_OFF_SNAP_SEQ, __ATOMIC_RELAXED) != s1) continue;
out->seq = s1;
out->generation = gen;
out->buttons = buttons;
for (unsigned k = 0; k < 4; k++) { /* little endian: axis 2k in the low half */
out->axes[2 * k] = (int16_t)(uint16_t)(w[k] & 0xffffu);
out->axes[2 * k + 1] = (int16_t)(uint16_t)(w[k] >> 16);
}
return 1;
}
return 0;
}
static inline int16_t ddc_flip(int16_t v) { /* evdev Y (down = +) to XInput Y (up = +) */
return v == INT16_MIN ? INT16_MAX : (int16_t)-v;
}
static inline uint8_t ddc_trigger(int16_t v) {
return v <= 0 ? 0 : v >= 255 ? 255 : (uint8_t)v;
}
/* The snapshot as an XInput pad; Guide only when `guide` (XInputGetStateEx). */
static inline void ddc_map(const ddc_snap *s, int guide, ddc_pad *p) {
static const uint16_t bit[11] = {
DDC_XI_A, DDC_XI_B, DDC_XI_X, DDC_XI_Y, DDC_XI_LEFT_SHOULDER, DDC_XI_RIGHT_SHOULDER,
DDC_XI_BACK, DDC_XI_START, DDC_XI_LEFT_THUMB, DDC_XI_RIGHT_THUMB, DDC_XI_GUIDE,
};
uint16_t b = 0;
for (unsigned i = 0; i < 11; i++)
if (s->buttons & (1u << i)) b |= bit[i];
if (!guide) b &= (uint16_t)~DDC_XI_GUIDE;
if (s->axes[DDC_A_HATX] < 0) b |= DDC_XI_DPAD_LEFT;
if (s->axes[DDC_A_HATX] > 0) b |= DDC_XI_DPAD_RIGHT;
if (s->axes[DDC_A_HATY] < 0) b |= DDC_XI_DPAD_UP;
if (s->axes[DDC_A_HATY] > 0) b |= DDC_XI_DPAD_DOWN;
p->buttons = b;
p->lx = s->axes[DDC_A_LX];
p->ly = ddc_flip(s->axes[DDC_A_LY]);
p->rx = s->axes[DDC_A_RX];
p->ry = ddc_flip(s->axes[DDC_A_RY]);
p->lt = ddc_trigger(s->axes[DDC_A_LT]);
p->rt = ddc_trigger(s->axes[DDC_A_RT]);
}
/* FAKE_EVDEV_MEMFD_PATHS: "<slot>=<unix path>;..." -> take(ctx, slot, path, len) for slots 0..max-1. */
#define DDC_DEFINE_PARSE_PATHS(fname, CH) \
static void fname(const CH *s, void (*take)(void *, uint32_t, const CH *, size_t), void *ctx, \
uint32_t max) { \
while (s && *s) { \
const CH *e = s; \
while (*e && *e != ';') e++; \
const CH *q = s; \
uint32_t slot = 0; \
int digits = 0; \
while (q < e && *q >= '0' && *q <= '9' && digits < 3) slot = slot * 10u + (uint32_t)(*q++ - '0'), digits++; \
if (digits && q < e && *q == '=' && q + 1 < e && slot < max) take(ctx, slot, q + 1, (size_t)(e - q - 1)); \
s = *e ? e + 1 : e; \
} \
}
#endif
@@ -0,0 +1,17 @@
/*
* Linked into both views of the ARM64X image only (build.sh link_arm64x), ahead of the mingw CRT.
*
* The CRT's DLL start-up (dllcrt2.o) references __dyn_tls_init_callback, which pulls tlssup.o and
* with it _tls_used, the TLS directory. An ARM64X image has one TLS directory for both views (the
* linker takes the native view's and emits no ARM64X relocation for it), so its callbacks are the
* native ARM64 ones. In an x64 process (the EC view) Wine treats non-EC code as x64 and the emulator
* runs those ARM64 bytes as x86 on every thread start: a stray write to the image header (base+0x42)
* that the loader catches, but a game's own first-chance exception handler sees first (Cyberpunk
* 2077's crash reporter exits on it).
*
* Defining the symbol here keeps tlssup.o out, so the image has no TLS directory. The CRT checks the
* pointer for NULL before calling it; this DLL has no thread-local variables.
*/
#include <windows.h>
const PIMAGE_TLS_CALLBACK __dyn_tls_init_callback = NULL;
@@ -0,0 +1,142 @@
/*
* dd-directcontroller host test: the ring snapshot reader (dd_directcontroller_ring.h) against a writer that follows
* FakeInputWriter.writeSnapshotLocked, on a shared file mapping (the app and the guest map the same file),
* plus the XInput mapping and the FAKE_EVDEV_MEMFD_PATHS parser.
*/
#include <fcntl.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <unistd.h>
#include "dd_directcontroller_ring.h"
static int failures;
#define CHECK(c, ...) do { if (!(c)) { failures++; printf("FAIL %s:%d: ", __FILE__, __LINE__); printf(__VA_ARGS__); printf("\n"); } } while (0)
static uint8_t *wmap;
static volatile int stop;
static void put32(uint32_t off, uint32_t v) { __atomic_store_n((uint32_t *)(void *)(wmap + off), v, __ATOMIC_RELAXED); }
static void put64(uint32_t off, uint64_t v) { __atomic_store_n((uint64_t *)(void *)(wmap + off), v, __ATOMIC_RELAXED); }
static void header(void) {
put32(DDC_OFF_MAGIC, DDC_RING_MAGIC);
put32(DDC_OFF_VERSION, DDC_RING_VERSION);
put32(DDC_OFF_EVENT_SIZE, DDC_RING_EVENT_SIZE);
put32(DDC_OFF_CAPACITY, DDC_RING_CAPACITY);
}
/* FakeInputWriter.writeSnapshotLocked: seq + 1, fence, fields, fence, seq + 2 */
static void publish(uint64_t *seq, uint32_t buttons, const int16_t axes[8]) {
put64(DDC_OFF_SNAP_SEQ, *seq + 1);
__atomic_thread_fence(__ATOMIC_RELEASE);
put32(DDC_OFF_SNAP_BUTTONS, buttons);
for (int k = 0; k < 8; k++)
__atomic_store_n((int16_t *)(void *)(wmap + DDC_OFF_SNAP_AXES + 2 * k), axes[k], __ATOMIC_RELAXED);
__atomic_thread_fence(__ATOMIC_RELEASE);
put64(DDC_OFF_SNAP_SEQ, *seq + 2);
*seq += 2;
}
/* Every field carries the same counter, so a torn read shows up as fields that differ. */
static uint64_t writer_seq;
static void *writer(void *arg) {
(void)arg;
uint64_t seq = writer_seq; /* the sequence continues: a reused value would let a stale read pass (ABA) */
uint32_t n = 1;
while (!stop) {
int16_t v = (int16_t)(n & 0x3fff);
int16_t axes[8] = {v, v, v, v, v, v, v, v};
publish(&seq, (uint32_t)v, axes);
n++;
}
return NULL;
}
static void take(void *ctx, uint32_t slot, const char *p, size_t len) {
char *out = ctx;
char buf[64];
snprintf(buf, sizeof buf, "%u:%.*s|", slot, (int)len, p);
strcat(out, buf);
}
DDC_DEFINE_PARSE_PATHS(parse_paths, char)
int main(void) {
char path[] = "/tmp/ddc-ring-XXXXXX";
int fd = mkstemp(path);
CHECK(fd >= 0, "mkstemp");
size_t size = DDC_RING_HEADER_SIZE + DDC_RING_CAPACITY * DDC_RING_EVENT_SIZE;
CHECK(ftruncate(fd, (off_t)size) == 0, "ftruncate");
wmap = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
const uint8_t *rmap = mmap(NULL, DDC_RING_HEADER_SIZE, PROT_READ, MAP_SHARED, fd, 0);
CHECK(wmap != MAP_FAILED && rmap != MAP_FAILED, "mmap");
unlink(path);
CHECK(!ddc_valid(rmap), "an empty file is not a ring");
header();
CHECK(ddc_valid(rmap), "a version-2 header is a ring");
put32(DDC_OFF_VERSION, 1);
CHECK(!ddc_valid(rmap), "version 1 is refused");
put32(DDC_OFF_VERSION, DDC_RING_VERSION);
/* mapping */
uint64_t seq = 0;
int16_t axes[8] = {1000, 2000, -3000, -32767, 255, 128, -1, 1};
uint32_t buttons = (1u << DDC_B_A) | (1u << DDC_B_TR) | (1u << DDC_B_START) | (1u << DDC_B_MODE) | (1u << DDC_B_QAM);
publish(&seq, buttons, axes);
ddc_snap s;
CHECK(ddc_snapshot(rmap, &s, 64), "snapshot of a settled ring");
CHECK(s.seq == 2, "seq %u", s.seq);
ddc_pad p;
ddc_map(&s, 0, &p);
CHECK(p.buttons == (DDC_XI_A | DDC_XI_RIGHT_SHOULDER | DDC_XI_START | DDC_XI_DPAD_LEFT | DDC_XI_DPAD_DOWN),
"buttons 0x%04x (no Guide, no QAM, hat left + down)", p.buttons);
CHECK(p.lx == 1000 && p.ly == -2000 && p.rx == -3000 && p.ry == 32767, "sticks %d %d %d %d (Y flipped)", p.lx, p.ly,
p.rx, p.ry);
CHECK(p.rt == 255 && p.lt == 128, "triggers lt %u rt %u", p.lt, p.rt);
ddc_map(&s, 1, &p);
CHECK(p.buttons & DDC_XI_GUIDE, "Guide in GetStateEx");
int16_t edge[8] = {INT16_MIN, INT16_MIN, 0, 0, -5, 300, 0, -1};
publish(&seq, 0, edge);
CHECK(ddc_snapshot(rmap, &s, 64), "snapshot");
ddc_map(&s, 0, &p);
CHECK(p.ly == INT16_MAX && p.lt == 255 && p.rt == 0 && p.buttons == DDC_XI_DPAD_UP, "edges: ly %d lt %u rt %u b 0x%x",
p.ly, p.lt, p.rt, p.buttons);
/* an odd seq (a write in progress) is never taken */
put64(DDC_OFF_SNAP_SEQ, seq + 1);
CHECK(!ddc_snapshot(rmap, &s, 64), "a snapshot mid-write is refused");
put64(DDC_OFF_SNAP_SEQ, seq);
/* no torn reads against a running writer; the state before its first publish is consistent too */
int16_t zero[8] = {0};
publish(&seq, 0, zero);
writer_seq = seq;
pthread_t t;
pthread_create(&t, NULL, writer, NULL);
unsigned ok = 0, lapped = 0, torn = 0;
for (unsigned i = 0; i < 2000000u; i++) {
if (!ddc_snapshot(rmap, &s, 64)) { lapped++; continue; }
ok++;
for (int k = 1; k < 8; k++)
if (s.axes[k] != s.axes[0]) { torn++; break; }
if ((int16_t)s.buttons != s.axes[0]) torn++;
}
stop = 1;
pthread_join(t, NULL);
CHECK(torn == 0, "%u torn snapshots", torn);
CHECK(ok > 0, "no snapshot taken");
printf("concurrent: %u snapshots, %u lapped, %u torn\n", ok, lapped, torn);
/* FAKE_EVDEV_MEMFD_PATHS */
char got[256] = "";
parse_paths("0=/a/r0;1=/a/r1;4=/a/mouse;x=bad;2=;3=/a/r3", take, got, 4);
CHECK(!strcmp(got, "0:/a/r0|1:/a/r1|3:/a/r3|"), "parsed '%s' (slot 4 = mouse and malformed entries skipped)", got);
printf(failures ? "host_test: %d failure(s)\n" : "host_test: OK\n", failures);
return failures ? 1 : 0;
}
+5
View File
@@ -25,6 +25,9 @@ typedef struct __posix_spawn_file_actions *posix_spawn_file_actions_t;
#define LINKER "/system/bin/linker64"
// handoff.c: returns unless the exec was handed to one of the app's worker processes
void ddh_bionic_exec(const char *file, char *const args[], char *const envp[], const char *path, char *const argv[]);
enum kind { PASS, VIA_LINKER, VIA_INTERP };
// What starting `path` needs; for scripts, the interpreter and its optional argument.
@@ -205,6 +208,8 @@ int execve(const char *path, char *const argv[], char *const envp[]) {
char storage[6 * PATH_MAX]; // stack only: this may run in posix_spawn's vfork-like child (where it passes)
const char *file = path;
char **args = rewrite(path, argv, &file, storage);
// the app may run it in a worker instead (handoff.c): matched by the program, sent as the start below
ddh_bionic_exec(file, args ? args : argv, envp, path, argv);
int ret = real(file, args ? args : argv, envp);
int saved = errno;
free(args);
+1
View File
@@ -1,6 +1,7 @@
# GStreamer plugins packed for winegstreamer (game video/audio), from the imagefs's lib/gstreamer-1.0 by name
# (libgst<name>.so): Proton's usual set as far as this imagefs has it (no vpx; videoconvert+videoscale are videoconvertscale).
coreelements
debug
app
audioconvert
audiorate
+422
View File
@@ -0,0 +1,422 @@
// handoff: part of libexecshim.so, preloaded into the bionic Wine processes. The native hook's exec
// handoff (tools/nativeguest/hook/handoff.c, docs/phantom-processes.md) built for bionic: a program a
// Wine process forks and execs runs as the main process of one of the app's worker processes instead of
// as a child Android counts against its limit. The glibc session's hook cannot reach these processes
// (they run on Android's libc), so without this every Wine process of a bionic game was counted.
//
// What the native hook does around the handoff and this file does too: fork() records the child for
// its parent's table, close(), close_range(), dup2() and dup3() leave the table and the worker's binder
// fds alone (hook/kept.c), and execve() offers the exec to the app before it runs (execshim.c calls
// ddh_bionic_exec() with the start it is about to make: "/system/bin/linker64 PROGRAM ARGS" for a
// program in the app's data, matched against DD_HANDOFF by PROGRAM). wait*(), kill() and _exit() are
// the handoff's own (hook/handoff.c). Nothing here acts without DD_SPAWN and DD_HANDOFF in the
// environment (tools/bionic-runtime/tool/launch.sh keeps them).
#define _GNU_SOURCE
#include <dlfcn.h>
#include <elf.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <pthread.h>
#include <sched.h>
#include <signal.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/resource.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <sys/un.h>
#include <sys/wait.h>
// bionic has no thread cancellation: nothing can cancel the table's setup
#ifndef PTHREAD_CANCEL_ENABLE
#define PTHREAD_CANCEL_ENABLE 0
#define PTHREAD_CANCEL_DISABLE 1
static int pthread_setcancelstate(int state, int *old) {
(void)state;
if (old) *old = PTHREAD_CANCEL_ENABLE;
return 0;
}
#endif
#ifndef CLOSE_RANGE_UNSHARE
#define CLOSE_RANGE_UNSHARE (1U << 1)
#endif
#ifndef CLOSE_RANGE_CLOEXEC
#define CLOSE_RANGE_CLOEXEC (1U << 2)
#endif
#ifndef __NR_close_range
#define __NR_close_range 436
#endif
#include <sys/sysmacros.h>
static void pthread_testcancel(void) {}
int close_range(unsigned int first, unsigned int last, int flags);
// bionic has no on_exit(): the handoff reports a program's exit status from it (exit() runs it).
// atexit() handlers get no status, so exit() below notes it first; a return from main() reaches
// exit() inside libc and reports 0.
static void (*g_on_exit_fn)(int, void *);
static void *g_on_exit_arg;
static int g_exit_status;
static void run_on_exit(void) {
if (g_on_exit_fn) g_on_exit_fn(g_exit_status, g_on_exit_arg);
}
static int on_exit(void (*fn)(int, void *), void *arg) {
g_on_exit_fn = fn;
g_on_exit_arg = arg;
return atexit(run_on_exit);
}
// The native hook's names for the plain system call and for a guest path: here there is no guest root.
static long call_orig_syscall(long nr, unsigned long a, unsigned long b, unsigned long c, unsigned long d,
unsigned long e, unsigned long f) {
return syscall(nr, a, b, c, d, e, f);
}
static const char *rewrite_path(const char *path, char *out, size_t size) {
(void)out;
(void)size;
return path;
}
// The native hook's SIGCHLD handling (hook/signals.c) is not part of this shim: its programs record their
// first parent for the session's subreapers, and reap nothing themselves.
static void ddnatv_manage_sigchld(void) {}
static void ddh_reap_unclaimed(void) __attribute__((unused));
#include "../nativeguest/hook/kept.c"
#include "../nativeguest/hook/handoff.c"
void exit(int status) {
g_exit_status = status;
void (*real)(int) = (void (*)(int))dlsym(RTLD_NEXT, "exit");
if (real) real(status);
syscall(SYS_exit_group, status);
__builtin_unreachable();
}
static int ddh_is_linker(const char *path) {
const char *base = path ? strrchr(path, '/') : NULL;
return base && strcmp(base + 1, "linker64") == 0;
}
static int ddh_regular(const char *path, int mode) {
struct stat st;
return path && stat(path, &st) == 0 && S_ISREG(st.st_mode) && access(path, mode) == 0;
}
// Android refuses execve() of a file in the app's data unless SELinux is permissive (execshim.c makes the
// dynamic ones linker64 starts). An unreadable setting counts as enforcing.
static int ddh_selinux_permissive(void) {
char c = 0;
int fd = (int)syscall(SYS_openat, AT_FDCWD, "/sys/fs/selinux/enforce", O_RDONLY | O_CLOEXEC, 0);
if (fd < 0) return 0;
long n = syscall(SYS_read, fd, &c, 1);
syscall(SYS_close, fd);
return n == 1 && c == '0';
}
// A handed-off start that fails fails in the worker, where the caller cannot see it and try its next
// candidate (Wine tries its preloader, then its loader), so only a start that would succeed here goes.
static int ddh_bionic_startable(const char *file, char *const args[]) {
char real[PATH_MAX];
// env takes an argument with '=' for a variable, and looks a name without '/' up in PATH
if (!file || strchr(file, '=') || !strchr(file, '/')) return 0;
if (!ddh_regular(file, X_OK) || !realpath(file, real)) return 0;
if (ddh_is_linker(real))
return args && args[0] && args[1] && args[1][0] != '-' && ddh_regular(args[1], R_OK) && ddh_startable(args[1]);
if (strncmp(real, "/data/", 6) == 0 && !ddh_selinux_permissive()) return 0;
// env starts FILE with FILE as argv[0]
return args && args[0] && strcmp(args[0], file) == 0 && ddh_startable(file);
}
void ddh_bionic_exec(const char *file, char *const args[], char *const envp[], const char *path, char *const argv[]) {
if (ddh_env(envp, "DD_HANDOFF_DEBUG")) {
char why[200];
struct ddh_table *own = __atomic_load_n(&g_ddh, __ATOMIC_ACQUIRE);
snprintf(why, sizeof(why), "bionic exec (spawn %d list %d table %d owner %d up %d ppid %d) of", ddh_env(envp, "DD_SPAWN") != NULL,
ddh_env(envp, "DD_HANDOFF") != NULL, own != NULL, own ? (int)g_ddh_owner : 0, g_ddh_up != NULL, (int)getppid());
ddh_debug(envp, why, path ? path : "(null)");
}
if (!ddh_env(envp, "DD_SPAWN") || !ddh_env(envp, "DD_HANDOFF")) return;
if (!ddh_bionic_startable(file, args)) {
ddh_debug(envp, "bionic exec stays here (not startable as a handoff):", path ? path : "(null)");
return;
}
// Wine's own starts through the system linker ("/system/bin/linker64 PROGRAM ARGS") are listed by PROGRAM
const char *match = path;
char *const *match_argv = argv;
if (ddh_is_linker(path) && argv && argv[0] && argv[1]) {
match = argv[1];
match_argv = argv + 1;
}
// The app starts a handed-off program from the glibc root's shell (GuestWorkers), which cannot load this
// runtime's LD_PRELOAD and LD_LIBRARY_PATH (bionic libraries). The request carries them as arguments of
// Android's env instead, which the shell execs and which puts them back for the program: the worker's main
// process ends up as the program all the same. Stack only (this may run in a vfork child).
int nargs = 0, nenv = 0;
while (args[nargs]) nargs++;
while (envp && envp[nenv]) nenv++;
// env, up to two loader variables, FILE, args[1..], NULL (nargs >= 1: ddh_bionic_startable)
char *wrapped[nargs + 4];
char *trimmed[nenv + 1];
int w = 0, t = 0;
wrapped[w++] = (char *)"/system/bin/env";
for (int i = 0; i < nenv; i++) {
if (strncmp(envp[i], "LD_PRELOAD=", 11) == 0 || strncmp(envp[i], "LD_LIBRARY_PATH=", 16) == 0) {
if (w < 3) wrapped[w++] = envp[i];
} else {
trimmed[t++] = envp[i];
}
}
trimmed[t] = NULL;
// env runs the program by the path its first argument gives: the start's file, then the rest of its argv
wrapped[w++] = (char *)file;
for (int i = 1; i < nargs; i++) wrapped[w++] = args[i];
wrapped[w] = NULL;
ddh_try_as("/system/bin/env", wrapped, trimmed, match, match_argv);
ddh_debug(envp, "bionic exec stays here:", path ? path : "(null)");
}
// bionic's exec functions call the execve system call stub inside libc, past execshim.c's execve(): Wine
// starts its programs with execv() (its preloader) and execvp(), so these go through execve() here.
extern char **environ;
int execv(const char *path, char *const argv[]) { return execve(path, argv, environ); }
// bionic's execvpe(), through execve() here: an unset PATH is libc's default (Android 14's; an empty one, and an empty
// entry, are the current directory), and a file the kernel cannot start (ENOEXEC) runs under /system/bin/sh.
#define DDH_DEFPATH "/product/bin:/apex/com.android.runtime/bin:/apex/com.android.art/bin:/system_ext/bin:/system/bin:/system/xbin:/odm/bin:/vendor/bin:/vendor/xbin"
static int exec_as_script(const char *file, char *const argv[], char *const envp[]) {
int n = 0;
while (argv && argv[n]) n++;
char *script[(n > 0 ? n : 1) + 2];
int s = 0;
script[s++] = (char *)"sh";
script[s++] = (char *)file;
for (int i = 1; i < n; i++) script[s++] = argv[i];
script[s] = NULL;
return execve("/system/bin/sh", script, envp);
}
int execvpe(const char *file, char *const argv[], char *const envp[]) {
if (!file || !*file) {
errno = ENOENT;
return -1;
}
if (strchr(file, '/')) {
execve(file, argv, envp);
return errno == ENOEXEC ? exec_as_script(file, argv, envp) : -1;
}
const char *dirs = getenv("PATH");
if (!dirs) dirs = DDH_DEFPATH;
int saw_eacces = 0;
size_t flen = strlen(file);
for (const char *p = dirs;;) {
const char *end = strchr(p, ':');
size_t len = end ? (size_t)(end - p) : strlen(p);
const char *dir = len ? p : ".";
if (!len) len = 1;
char full[PATH_MAX];
if (len + flen + 2 > sizeof(full)) {
errno = ENAMETOOLONG;
} else {
memcpy(full, dir, len);
full[len] = '/';
memcpy(full + len + 1, file, flen + 1);
execve(full, argv, envp);
}
switch (errno) {
case EISDIR:
case ELOOP:
case ENAMETOOLONG:
case ENOENT:
case ENOTDIR:
break;
case ENOEXEC:
return exec_as_script(full, argv, envp);
case EACCES:
saw_eacces = 1;
break;
default:
return -1;
}
if (!end) break;
p = end + 1;
}
if (saw_eacces) errno = EACCES;
return -1;
}
int execvp(const char *file, char *const argv[]) { return execvpe(file, argv, environ); }
// execl(), execlp(), execle(): the list as an argv on the stack
#define EXECL_ARGV(first, ap, n) \
do { \
va_list count_ap; \
va_copy(count_ap, ap); \
n = first ? 1 : 0; \
if (first) \
while (va_arg(count_ap, const char *)) n++; \
va_end(count_ap); \
} while (0)
int execl(const char *path, const char *arg0, ...) {
va_list ap;
va_start(ap, arg0);
int n;
EXECL_ARGV(arg0, ap, n);
char *argv[n + 1];
argv[0] = (char *)arg0;
for (int i = 1; i < n; i++) argv[i] = va_arg(ap, char *);
argv[n] = NULL;
va_end(ap);
return execve(path, argv, environ);
}
int execlp(const char *file, const char *arg0, ...) {
va_list ap;
va_start(ap, arg0);
int n;
EXECL_ARGV(arg0, ap, n);
char *argv[n + 1];
argv[0] = (char *)arg0;
for (int i = 1; i < n; i++) argv[i] = va_arg(ap, char *);
argv[n] = NULL;
va_end(ap);
return execvp(file, argv);
}
int execle(const char *path, const char *arg0, ...) {
va_list ap;
va_start(ap, arg0);
int n;
EXECL_ARGV(arg0, ap, n);
char *argv[n + 1];
argv[0] = (char *)arg0;
for (int i = 1; i < n; i++) argv[i] = va_arg(ap, char *);
argv[n] = NULL;
if (arg0) (void)va_arg(ap, char *); // the list's NULL
char *const *envp = va_arg(ap, char *const *);
va_end(ap);
return execve(path, argv, envp);
}
pid_t fork(void) {
static pid_t (*orig_fork)(void) = NULL;
if (!orig_fork) orig_fork = (pid_t (*)(void))dlsym(RTLD_NEXT, "fork");
if (!orig_fork) {
errno = ENOSYS;
return -1;
}
ddh_prepare();
pid_t forker = (pid_t)syscall(SYS_gettid);
pid_t forking = (pid_t)syscall(SYS_getpid);
pid_t pid = orig_fork();
if (pid == 0) {
kept_forked();
kept_close_forked();
ddh_drop_worker_binder();
ddh_forked(forker);
ddh_record_parent((pid_t)syscall(SYS_getpid), forking);
} else if (pid > 0) {
ddh_child_created(pid, 1);
}
return pid;
}
int close(int fd) {
static int (*orig_close)(int) = NULL;
if (!orig_close) orig_close = (int (*)(int))dlsym(RTLD_NEXT, "close");
uint64_t ticket = kept_close_begin();
if (kept_any() > 0 && is_kept_fd(fd)) {
kept_close_end(ticket);
return 0;
}
int r = orig_close ? orig_close(fd) : (errno = ENOSYS, -1);
int saved = errno;
kept_close_end(ticket);
errno = saved;
return r;
}
static int dup_moved(int (*dup_fn)(int, int, int), int oldfd, int newfd, int flags) {
int pidfd_from = -1, locked = 0;
if (oldfd != newfd) {
locked = ddh_parent_pidfd_lock(newfd);
pidfd_from = ddh_parent_pidfd_moves(newfd);
}
int ret = dup_fn(oldfd, newfd, flags);
ddh_parent_pidfd_settle(pidfd_from, ret >= 0);
int saved = errno;
ddh_parent_pidfd_unlock(locked);
errno = saved;
return ret;
}
static int (*g_orig_dup2)(int, int);
static int (*g_orig_dup3)(int, int, int);
static int call_dup2(int oldfd, int newfd, int flags) {
(void)flags;
return g_orig_dup2 ? g_orig_dup2(oldfd, newfd) : (errno = ENOSYS, -1);
}
static int call_dup3(int oldfd, int newfd, int flags) {
return g_orig_dup3 ? g_orig_dup3(oldfd, newfd, flags) : (errno = ENOSYS, -1);
}
int dup2(int oldfd, int newfd) {
if (!g_orig_dup2) g_orig_dup2 = (int (*)(int, int))dlsym(RTLD_NEXT, "dup2");
return dup_moved(call_dup2, oldfd, newfd, 0);
}
int dup3(int oldfd, int newfd, int flags) {
if (!g_orig_dup3) g_orig_dup3 = (int (*)(int, int, int))dlsym(RTLD_NEXT, "dup3");
return dup_moved(call_dup3, oldfd, newfd, flags);
}
static int close_range_part(unsigned int first, unsigned int last, void *flags) {
return (int)syscall(__NR_close_range, first, last, *(int *)flags);
}
static int close_range_unshare(void) {
return (int)syscall(__NR_close_range, ~0U, ~0U, CLOSE_RANGE_UNSHARE);
}
int close_range(unsigned int first, unsigned int last, int flags) {
// what the kernel refuses, refused before the range is split or the table unshared
if (first > last || (flags & ~(int)(CLOSE_RANGE_UNSHARE | CLOSE_RANGE_CLOEXEC))) {
errno = EINVAL;
return -1;
}
uint64_t ticket = kept_close_begin();
int r = 0;
// The table is unshared first, once, and this thread goes on with its own copy of the kept list
// (kept_split())
if (flags & CLOSE_RANGE_UNSHARE) {
r = kept_split(close_range_unshare);
flags &= ~(int)CLOSE_RANGE_UNSHARE;
}
if (r == 0) {
int snapshot[DDNATV_MAX_KEPT_FDS];
const int *kept = (flags & CLOSE_RANGE_CLOEXEC) ? g_cloexec_kept_fds : snapshot;
int count = (flags & CLOSE_RANGE_CLOEXEC) ? g_cloexec_kept_count : kept_snapshot(snapshot);
r = count == 0 ? close_range_part(first, last, &flags)
: for_each_range_without(first, last, kept, count, close_range_part, &flags);
}
int saved = errno;
kept_close_end(ticket);
errno = saved;
return r;
}
// The native hook's own uses of these (exec.c) have no counterpart here
__attribute__((unused)) static void *const glibc_only[] = {(void *)ddh_try, (void *)ddh_spawn_wanted};
+97 -6
View File
@@ -29,6 +29,11 @@ echo "$(date +%H:%M:%S) $verb $EXE ($VERSION, uid $(id -u), DISPLAY ${DISPLAY:-u
# Keep Steam's game identity, DroidDeck's input/display/driver/sync settings and its game environment (the names
# ../proton lists in DROIDDECK_BIONIC_KEEP); drop the rest of the glibc guest's environment.
KEEP=" ${DROIDDECK_BIONIC_KEEP:-} "
# The built-in DirectAudio driver reads DroidDeck's AUDIO_DIRECT_* settings (the microphone switch among them) under
# the BANNER_ names droiddeck-proton gives them for Proton.
for v in $(env | sed -n 's/^\(AUDIO_DIRECT_[A-Za-z0-9_]*\)=.*/\1/p'); do
eval "export BANNER_$v=\"\$$v\""
done
for v in $(env | sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)=.*/\1/p'); do
case "$KEEP" in *" $v "*) continue ;; esac
case "$v" in
@@ -36,7 +41,7 @@ for v in $(env | sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)=.*/\1/p'); do
ANDROID_*|BOOTCLASSPATH|DEX2OATBOOTCLASSPATH|SYSTEMSERVERCLASSPATH|EXTERNAL_STORAGE|ASEC_MOUNTPOINT) ;;
FAKE_*|SDL_*|DD_WIDTH|DD_HEIGHT|DD_VK_DRIVER|WINEDLLOVERRIDES) ;;
DISPLAY|GAMESCOPE_WAYLAND_DISPLAY|FEX_*) ;;
TU_DEBUG|MESA_NO_ERROR|DXVK_CONFIG|DXVK_HUD|DROIDDECK_FORCE_SSBS) ;;
TU_DEBUG|MESA_NO_ERROR|DXVK_CONFIG|DXVK_HUD|DROIDDECK_FORCE_SSBS|DROIDDECK_NO_STEAM|BANNER_AUDIO_DIRECT_*) ;;
mesa_glthread|vblank_mode|ZINK_*|GALLIUM_HUD|GALLIUM_THREAD) ;;
DD_SYNC|DD_FSYNC_FIRST|DD_SYNC_FALLBACK|PROTON_NO_ESYNC|PROTON_NO_FSYNC|PROTON_NO_NTSYNC|WINEESYNC) ;;
PROTON_USE_D7VK) ;;
@@ -47,6 +52,13 @@ for v in $(env | sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)=.*/\1/p'); do
DROIDDECK_GPU_LOAD|DROIDDECK_GPU_LOAD_DIR|DROIDDECK_VRAM_CAP|DROIDDECK_VRAM_CAP_MB|DROIDDECK_DISPLAY_DRIVER) ;;
DROIDDECK_GUEST_ROOT) ;;
VKD3D_FEATURE_LEVEL|VKD3D_SHADER_MODEL|vk_x11_strict_image_count) ;;
# droiddeck-game-env's original Xbox switches for this layer's Wine and the Xbox VKD3D-Proton build
WINE_SPECIAL_APC_INTERRUPT|WINE_MF_DISPLAY_APERTURE|WINE_PRECISE_SLEEP) ;;
VKD3D_INTEROP_PRESENT|VKD3D_PACKED_422|VKD3D_PACKED_422_SWIZZLE) ;;
# The exec handoff (../handoff.c): the app's spawn socket and list (the app starts a handed-off program from the
# glibc root's shell, so its path too), and what a worker hands the program it runs (this script, when it runs
# in one): the first Wine process's hook knows the worker's binder fds are not its own.
DD_SPAWN|DD_SPAWN_SESSION|DD_HANDOFF|DD_HANDOFF_DEBUG|DD_HANDOFF_PRESSURE|DDH_*|DDNATV_ROOT) ;;
*) unset "$v" 2>/dev/null ;;
esac
done
@@ -81,7 +93,8 @@ RTD=$APP/.wayland-rt
export VK_ICD_FILENAMES=$PACK/adapter/icd.json ADRENOTOOLS_DRIVER_PATH=$DRVDIR/ ADRENOTOOLS_HOOKS_PATH=$PACK/lib
export ADRENOTOOLS_DRIVER_NAME=$(drvlib "$DRVDIR")
export VK_ADD_IMPLICIT_LAYER_PATH=$PACK/layer ENABLE_GAMESCOPE_WSI=1 GAMESCOPE_WAYLAND_DISPLAY=${GAMESCOPE_WAYLAND_DISPLAY:-gamescope-0}
export XDG_RUNTIME_DIR=$RTD DROIDDECK_WSI_BYPASS_CHECK_MS=100 GAMESCOPE_WSI_FORCE_BYPASS=1
export XDG_RUNTIME_DIR=$RTD DROIDDECK_WSI_BYPASS_CHECK_MS=100 GAMESCOPE_WSI_FORCE_BYPASS=0
echo "WSI forced XWayland bypass disabled (GAMESCOPE_WSI_FORCE_BYPASS=$GAMESCOPE_WSI_FORCE_BYPASS)"
[ -e "$RTD/droiddeck-gamescope-limiter" ] && export GAMESCOPE_LIMITER_FILE=$RTD/droiddeck-gamescope-limiter
# Wine: DXVK/VKD3D over the builtins, X11 inside gamescope (winewayland would pick DroidDeck's compositor),
@@ -104,6 +117,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.
@@ -122,6 +138,13 @@ echo "sync ntsync=$WINENTSYNC esync=$WINEESYNC ssbs=${WINE_FORCE_SSBS:-0} tu_deb
export WINESTEAMCLIENTPATH64=$ROOTFS/root/.local/share/Steam/androidarm64/libsteamclient.so
# The layer sends a game's steamclient(64).dll to lsteamclient (and so to DroidDeck's Steam through the library
# above) only with WINE_LSTEAMCLIENT set; without it Valve's Windows steamclient runs alone and SteamAPI_Init fails.
# A game set to start without Steam has no Steam client behind lsteamclient, and a steamclient64.dll it brings itself
# (a Steam emulator such as gbe_fork's ColdClient loader) would be replaced by it, so the game quit after its splash
# screen. Such a game keeps its own; a WINE_LSTEAMCLIENT the player set wins.
if [ -z "${WINE_LSTEAMCLIENT:-}" ] && on "${DROIDDECK_NO_STEAM:-}"; then
echo "lsteamclient off: started without Steam"
export WINE_LSTEAMCLIENT=0
fi
export WINE_LSTEAMCLIENT=${WINE_LSTEAMCLIENT:-1}
# Steam Input data (Valve's Steam Deck layouts with game actions) lives in DroidDeck's /dev/shm; libsteamshm.so
# points the Android library's shared memory there (it keeps its own in-process otherwise) and gives it the
@@ -250,7 +273,7 @@ prepare_prefix() {
prefix_busy() { # a process of this prefix is running
for p in /proc/[0-9]*; do
[ "${p#/proc/}" = "$$" ] && continue
tr '\0' '\n' < "$p/environ" 2>/dev/null | grep -qx "WINEPREFIX=$COMPAT/pfx" && return 0
tr '\0' '\n' 2>/dev/null < "$p/environ" | grep -qx "WINEPREFIX=$COMPAT/pfx" && return 0
done
return 1
}
@@ -265,7 +288,7 @@ programs_left() { # a program of this prefix is still running, apart from Wine's
""|wineserver|services.exe|winedevice.exe|plugplay.exe|explorer.exe|svchost.exe|rpcss.exe|conhost.exe|start.exe|\
winemenubuilder|wineboot.exe|tabtip.exe) continue ;;
esac
tr '\0' '\n' < "$p/environ" 2>/dev/null | grep -qx "WINEPREFIX=$COMPAT/pfx" && return 0
tr '\0' '\n' 2>/dev/null < "$p/environ" | grep -qx "WINEPREFIX=$COMPAT/pfx" && return 0
done
return 1
}
@@ -274,7 +297,7 @@ stop_wine() { # wineserver -k, then whatever of this prefix is left (e.g. a game
wineserver_ -k 2>/dev/null
sleep 1
for p in /proc/[0-9]*; do
tr '\0' '\n' < "$p/environ" 2>/dev/null | grep -qx "WINEPREFIX=$COMPAT/pfx" || continue
tr '\0' '\n' 2>/dev/null < "$p/environ" | grep -qx "WINEPREFIX=$COMPAT/pfx" || continue
[ "${p#/proc/}" = "$$" ] && continue
echo "$(date +%H:%M:%S) left over: ${p#/proc/} $(cat "$p/comm" 2>/dev/null)"
kill -9 "${p#/proc/}" 2>/dev/null
@@ -301,6 +324,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.
@@ -388,6 +426,59 @@ elif [ -L "$S/ddraw_.dll" ] || [ -e "$S/ddraw_.dll" ]; then
ln -s "$F/lib/wine/i386-windows/ddraw.dll" "$S/ddraw.dll"
echo "$(date +%H:%M:%S) D7VK off: Wine's ddraw again"
fi
# dd-directcontroller: a game set to start without Steam reads the controller through dd-directcontroller's XInput DLLs
# (bionic/dd-directcontroller), which answer from the pad state DroidDeck keeps in each ring file instead of the queue
# of HID reports Wine's xinput reads (a game that reads slower than the pad reports kept moving after the stick
# was let go). They go into the prefix as copies, never through the links to this tool's builtins, with Wine's
# xinput1_4 beside them as dd-directcontroller-wine-xinput.dll for rumble and pass-through. The mode file next to the
# controller folder (DD_DIRECTCONTROLLER_CONTROL, '1' direct / '0' pass-through to Wine's xinput) is read by the DLLs
# while the game runs, so DroidDeck can switch it live; it starts as DD_DIRECTCONTROLLER says (0 = pass-through). A game
# no longer set to start without Steam gets Wine's links back.
DDC=$TOOL/bionic/dd-directcontroller
ddc_names="xinput1_1 xinput1_2 xinput1_3 xinput1_4 xinput9_1_0 xinputuap"
ddc_put() { # src dst: dst becomes a copy of src; a link there is removed first, so the file it names stays as it was
[ ! -L "$2" ] && cmp -s "$1" "$2" && return 0
rm -f "$2" && cp "$1" "$2"
}
ddc_ours() { [ -f "$1" ] && [ ! -L "$1" ] && grep -qF "dd-directcontroller: " "$1"; }
DDCW=$COMPAT/pfx/drive_c/windows
if on "${DROIDDECK_NO_STEAM:-}" && [ -d "$DDC/arm64x" ] && [ -d "$DDC/i386" ]; then
for a in arm64x:system32:aarch64-windows i386:syswow64:i386-windows; do
src=$DDC/${a%%:*}; rest=${a#*:}; dir=$DDCW/${rest%%:*}; wine=$F/lib/wine/${rest#*:}
[ -d "$dir" ] || continue
for n in $ddc_names; do
t=$dir/$n.dll
# a native DLL that is neither Wine's nor ours (a game's own or a tool's) stays, as link_dir keeps it
if [ -f "$t" ] && [ ! -L "$t" ] && ! is_builtin "$t" && ! ddc_ours "$t"; then
echo "$(date +%H:%M:%S) dd-directcontroller: kept ${dir##*/}/$n.dll (not Wine's)"
continue
fi
ddc_put "$src/$n.dll" "$t"
done
ddc_put "$wine/xinput1_4.dll" "$dir/dd-directcontroller-wine-xinput.dll"
done
export WINEDLLOVERRIDES="$WINEDLLOVERRIDES;xinput1_1,xinput1_2,xinput1_3,xinput1_4,xinput9_1_0,xinputuap=n,b"
ddc_mode=1 ddc_name=direct
[ "${DD_DIRECTCONTROLLER:-1}" = 0 ] && ddc_mode=0 ddc_name=pass-through
if [ -n "${FAKE_EVDEV_DIR:-}" ] && echo "$ddc_mode" > "${FAKE_EVDEV_DIR%/*}/dd-directcontroller.mode"; then
export DD_DIRECTCONTROLLER_CONTROL="${FAKE_EVDEV_DIR%/*}/dd-directcontroller.mode"
else
ddc_name="direct (no mode file)"
fi
echo "$(date +%H:%M:%S) dd-directcontroller on (starts $ddc_name)"
else
back=0
for a in system32:aarch64-windows syswow64:i386-windows; do
dir=$DDCW/${a%%:*}; wine=$F/lib/wine/${a#*:}
for n in $ddc_names; do
ddc_ours "$dir/$n.dll" || continue
rm -f "$dir/$n.dll" && ln -s "$wine/$n.dll" "$dir/$n.dll" && back=$((back + 1))
done
rm -f "$dir/dd-directcontroller-wine-xinput.dll"
done
[ $back -gt 0 ] && echo "$(date +%H:%M:%S) dd-directcontroller off: Wine's xinput again"
fi
# A Windows path (an Xbox game on its own drive letter) starts in the folder Steam gave.
case "$EXE" in [A-Za-z]:[\\/]*) ;; *) cd "$(dirname "$EXE")" || exit 1 ;; esac
@@ -403,7 +494,7 @@ comm=$(echo "$name" | cut -c1-15)
game_pids() { # processes of this prefix with the game's name (two prefixes can run programs with the same name)
for p in $(grep -lFx "$comm" /proc/[0-9]*/comm 2>/dev/null); do
p=${p%/comm}
tr '\0' '\n' < "$p/environ" 2>/dev/null | grep -qxF "WINEPREFIX=$COMPAT/pfx" && echo "${p#/proc/}"
tr '\0' '\n' 2>/dev/null < "$p/environ" | grep -qxF "WINEPREFIX=$COMPAT/pfx" && echo "${p#/proc/}"
done
}
# The game's windows go straight to gamescope's X server, as with DroidDeck-Proton (no Wine desktop): the game
+16
View File
@@ -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:-}")