mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 05:16:01 +00:00
Merge origin/main into feat/target-sdk-36
This commit is contained in:
commit
c8baca10e6
980 files changed
+88652
-41628
No files matched your search
@@ -1,9 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
# Compiles module-aaudio-sink.so against the upstream PulseAudio 13.0 headers and the daemon's own
|
||||
# libraries the app ships (app/src/main/jniLibs/arm64-v8a), with the Android NDK.
|
||||
# NDK=<ndk root> tools/aaudio-sink/build.sh <pulseaudio-13.0 source dir> <output dir>
|
||||
# Produces module-aaudio-sink.so in the output dir (the fallback sink; the DirectAudio sinks come
|
||||
# from the pinned DirectAudio release, see tools/directaudio/fetch.sh).
|
||||
set -euo pipefail
|
||||
PA_SRC=$1
|
||||
OUTDIR=$2
|
||||
@@ -40,14 +35,11 @@ sed -e 's/@PA_MAJOR@/13/g' -e 's/@PA_MINOR@/0/g' -e 's/@PA_API_VERSION@/12/g' -e
|
||||
cp "$HERE/config.h" "$HERE/ltdl.h" "$INC/"
|
||||
build_one() {
|
||||
local src=$1 OUT=$2 extra=$3
|
||||
# PulseAudio 13's own headers (pulsecore/atomic.h) predate clang's int-conversion error; that
|
||||
# one is downgraded for them, the modules themselves compile clean.
|
||||
"$CC" -O2 -shared -fPIC -Wall -Wno-unused-parameter -Wno-error=int-conversion -Wno-visibility -DHAVE_CONFIG_H \
|
||||
-I"$INC" -I"$PA_SRC/src" -I"$HERE" \
|
||||
-o "$OUT" "$HERE/$src" \
|
||||
-L"$LIBS" -l:libpulsecore-13.0.so -l:libpulsecommon-13.0.so -l:libpulse.so $extra
|
||||
"$TOOLCHAIN/llvm-strip" --strip-unneeded "$OUT"
|
||||
# What the daemon looks for, and nothing linked that a device would not have.
|
||||
for sym in pa__init pa__done pa__get_author pa__get_description pa__get_usage pa__get_version pa__load_once; do
|
||||
"$TOOLCHAIN/llvm-nm" -D --defined-only "$OUT" | grep -q " $sym$" || { echo "ERROR: $OUT does not export $sym"; exit 1; }
|
||||
done
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
/* The handful of build-time facts PulseAudio 13's headers read, for compiling one module against
|
||||
* the upstream source tree without running its configure. The daemon and libraries the app ships
|
||||
* were built for the same target (Android arm64, bionic), so these match them. */
|
||||
#ifndef DROIDDECK_PA_CONFIG_H
|
||||
#define DROIDDECK_PA_CONFIG_H
|
||||
#define PACKAGE "pulseaudio"
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
/* pulsecore/module.h keeps a libltdl handle in pa_module; the module never touches it, so the
|
||||
* handle type is all that is needed here. */
|
||||
#ifndef DROIDDECK_LTDL_STUB_H
|
||||
#define DROIDDECK_LTDL_STUB_H
|
||||
typedef void *lt_dlhandle;
|
||||
|
||||
@@ -1,15 +1,4 @@
|
||||
/*
|
||||
* module-aaudio-sink: a PulseAudio 13 sink on Android's AAudio, for the DroidDeck app.
|
||||
*
|
||||
* The daemon's IO thread pulls rendered audio from the sink one burst at a time and hands it to
|
||||
* a blocking AAudio output stream; the stream's own buffer paces the thread, and the latency the
|
||||
* sink reports comes from the stream's playback timestamp. With adaptive=1 the buffer grows by a
|
||||
* burst after each underrun, up to a cap, so a device that cannot keep a small buffer fed settles
|
||||
* on one it can.
|
||||
*
|
||||
* Module arguments keep the names the app has always passed (performance_mode, adaptive, volume,
|
||||
* buffer_frames, max_buffer_frames) so the daemon's config line did not have to change.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -58,18 +47,11 @@ PA_MODULE_USAGE(
|
||||
"buffer_frames=<initial buffer size in frames, 0 = two bursts> "
|
||||
"max_buffer_frames=<largest the buffer may grow to, 0 = the stream's capacity>");
|
||||
|
||||
/* The name the app's daemon config addresses (set-default-sink). */
|
||||
#define DEFAULT_SINK_NAME "AAudioSink"
|
||||
/* Underruns are polled every so many writes, not every write. */
|
||||
#define XRUN_CHECK_EVERY 8
|
||||
#define FALLBACK_BURST_FRAMES 192
|
||||
/* The buffer starts at whichever is larger: this many bursts, or this much time. The daemon runs
|
||||
* under proot, where every system call is traced, and a buffer of two bursts (8 ms) left the
|
||||
* client's menu sounds choppy on device; 30 ms is inaudible for a menu and games have their own
|
||||
* path. adaptive=1 still grows it further after real underruns. */
|
||||
#define MIN_BUFFER_BURSTS 2
|
||||
#define MIN_BUFFER_USEC (30 * PA_USEC_PER_MSEC)
|
||||
/* Android's own audio threads run at nice -16 (THREAD_PRIORITY_AUDIO); an app may ask for it. */
|
||||
#define AUDIO_NICE (-16)
|
||||
#define STATS_EVERY_USEC (30 * PA_USEC_PER_SEC)
|
||||
|
||||
@@ -109,7 +91,6 @@ struct userdata {
|
||||
int32_t max_buffer_frames;
|
||||
int32_t requested_buffer_frames;
|
||||
bool adaptive;
|
||||
/* rate= was given: ask the device for exactly that instead of its own rate. */
|
||||
bool rate_requested;
|
||||
int32_t xruns_seen;
|
||||
unsigned writes_since_xrun_check;
|
||||
@@ -127,8 +108,6 @@ static int32_t usec_to_frames(const struct userdata *u, pa_usec_t usec) {
|
||||
return (int32_t) ((uint64_t) usec * u->ss.rate / PA_USEC_PER_SEC);
|
||||
}
|
||||
|
||||
/* Each write hands the device half the buffer, whole bursts, at least one: fewer, larger
|
||||
* trips through proot's tracing than a burst at a time, with half the buffer of slack left. */
|
||||
static void set_chunk(struct userdata *u) {
|
||||
int32_t frames = u->buffer_frames / 2;
|
||||
frames -= frames % u->burst_frames;
|
||||
@@ -166,7 +145,6 @@ static void apply_buffer_size(struct userdata *u, int32_t frames) {
|
||||
set_chunk(u);
|
||||
}
|
||||
|
||||
/* Opens the stream for u->ss; on return u->ss holds what the device actually gave. */
|
||||
static int open_stream(struct userdata *u) {
|
||||
AAudioStreamBuilder *builder = NULL;
|
||||
aaudio_result_t r;
|
||||
@@ -180,9 +158,6 @@ static int open_stream(struct userdata *u) {
|
||||
AAudioStreamBuilder_setSharingMode(builder, AAUDIO_SHARING_MODE_SHARED);
|
||||
AAudioStreamBuilder_setPerformanceMode(builder, u->performance_mode);
|
||||
AAudioStreamBuilder_setFormat(builder, u->ss.format == PA_SAMPLE_FLOAT32NE ? AAUDIO_FORMAT_PCM_FLOAT : AAUDIO_FORMAT_PCM_I16);
|
||||
/* The device's own rate unless one was asked for: at any other rate Android falls back to a
|
||||
* legacy stream with 20 ms bursts and room for three of them, and the daemon under proot
|
||||
* cannot keep that fed. The sink takes whatever rate comes back; PulseAudio resamples clients. */
|
||||
AAudioStreamBuilder_setSampleRate(builder, u->rate_requested ? (int32_t) u->ss.rate : AAUDIO_UNSPECIFIED);
|
||||
AAudioStreamBuilder_setChannelCount(builder, (int32_t) u->ss.channels);
|
||||
|
||||
@@ -240,7 +215,6 @@ static void stop_stream(struct userdata *u) {
|
||||
u->started = false;
|
||||
}
|
||||
|
||||
/* How much audio the device still holds: frames written less frames it reports played. */
|
||||
static pa_usec_t stream_latency(struct userdata *u) {
|
||||
int64_t position = 0, when_ns = 0;
|
||||
|
||||
@@ -267,7 +241,6 @@ static void check_underruns(struct userdata *u) {
|
||||
u->writes_since_xrun_check = 0;
|
||||
|
||||
xruns = AAudioStream_getXRunCount(u->stream);
|
||||
/* A line every so often while underruns keep coming, so a session log shows the count. */
|
||||
if (xruns != u->xruns_reported && pa_rtclock_now() - u->stats_at >= STATS_EVERY_USEC) {
|
||||
pa_log("aaudio-sink: %d underrun(s) so far, buffer %d frames", xruns, u->buffer_frames);
|
||||
u->xruns_reported = xruns;
|
||||
@@ -285,7 +258,6 @@ static void check_underruns(struct userdata *u) {
|
||||
pa_log("aaudio-sink: underrun %d: buffer now %d frames (%u ms)", xruns, u->buffer_frames, (unsigned) (frames_to_usec(u, u->buffer_frames) / PA_USEC_PER_MSEC));
|
||||
}
|
||||
|
||||
/* One burst from the sink into the device. Returns <0 when the stream is gone for good. */
|
||||
static int write_one_burst(struct userdata *u) {
|
||||
const void *data;
|
||||
aaudio_result_t written = 0;
|
||||
@@ -315,8 +287,6 @@ static int write_one_burst(struct userdata *u) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* The device went away (headphones, a route change). Reopen once with the same settings; if
|
||||
* the new stream differs in rate or format there is nothing sane to do but give up. */
|
||||
pa_log("aaudio-sink: AAudioStream_write: %s; reopening the stream", AAudio_convertResultToText(written));
|
||||
{
|
||||
pa_sample_spec before = u->ss;
|
||||
@@ -346,8 +316,6 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
|
||||
return pa_sink_process_msg(o, code, data, offset, chunk);
|
||||
}
|
||||
|
||||
/* Runs in the IO thread: an opened sink means a running stream and a busy loop; a suspended
|
||||
* one means a stopped stream and a thread asleep until a message arrives. */
|
||||
static int sink_set_state_in_io_thread_cb(pa_sink *s, pa_sink_state_t new_state, pa_suspend_cause_t new_suspend_cause) {
|
||||
struct userdata *u = s->userdata;
|
||||
|
||||
@@ -368,8 +336,6 @@ static void thread_func(void *userdata) {
|
||||
|
||||
pa_log_debug("IO thread starting");
|
||||
pa_thread_mq_install(&u->thread_mq);
|
||||
/* Ahead of everything else in the app, as Android's own audio threads are; realtime on top
|
||||
* of that where the kernel allows (it does not, for an app, but it costs nothing to ask). */
|
||||
if (setpriority(PRIO_PROCESS, (id_t) syscall(SYS_gettid), AUDIO_NICE) < 0)
|
||||
pa_log_debug("aaudio-sink: could not raise the IO thread's priority (%s)", strerror(errno));
|
||||
if (u->core->realtime_scheduling)
|
||||
@@ -379,7 +345,6 @@ static void thread_func(void *userdata) {
|
||||
int ret;
|
||||
|
||||
if (PA_SINK_IS_OPENED(u->sink->thread_info.state) && u->started) {
|
||||
/* Nothing written can be taken back from the device, so a rewind is just acknowledged. */
|
||||
if (u->sink->thread_info.rewind_requested)
|
||||
pa_sink_process_rewind(u->sink, 0);
|
||||
if (write_one_burst(u) < 0)
|
||||
@@ -426,7 +391,6 @@ int pa__init(pa_module *m) {
|
||||
pa_log("Invalid sample format specification or channel map");
|
||||
goto fail;
|
||||
}
|
||||
/* AAudio speaks 16-bit or float; anything else is rendered as 16-bit. */
|
||||
if (ss.format != PA_SAMPLE_FLOAT32NE)
|
||||
ss.format = PA_SAMPLE_S16NE;
|
||||
|
||||
|
||||
@@ -45,7 +45,6 @@ def _identity(adb: str, serial: str) -> str | None:
|
||||
|
||||
|
||||
def _rank(serial: str) -> tuple[int, str]:
|
||||
# Prefer a stable mDNS transport over a network address with an ephemeral port.
|
||||
if "_adb-tls-connect._tcp" in serial:
|
||||
return (0, serial)
|
||||
if not re.search(r":\d+$", serial):
|
||||
|
||||
+15
-27
@@ -47,7 +47,6 @@ fi
|
||||
|
||||
ndk_version=${DROIDDECK_NDK_VERSION:-}
|
||||
if [[ -z "${ndk_version}" ]]; then
|
||||
# Only complete NDKs: an interrupted sdkmanager install leaves a directory without source.properties.
|
||||
ndk_path=$(find "${sdk_dir}/ndk" -mindepth 2 -maxdepth 2 -name source.properties -print | xargs -n1 dirname | sort -V | tail -1)
|
||||
ndk_version=${ndk_path##*/}
|
||||
fi
|
||||
@@ -73,7 +72,6 @@ trap cleanup EXIT
|
||||
trap 'exit 130' INT
|
||||
trap 'exit 143' TERM
|
||||
|
||||
# A wedged daemon used to hang indefinitely and then trigger an unnecessary image rebuild.
|
||||
python3 "${repo_root}/tools/docker_preflight.py" "${image_name}"
|
||||
rm -rf -- "${linuxfs_dir}"
|
||||
mkdir -p "${linuxfs_dir}"
|
||||
@@ -84,6 +82,7 @@ docker run --rm --platform linux/amd64 \
|
||||
set -euo pipefail
|
||||
d=app/src/main/assets/linuxfs
|
||||
mkdir -p "$d"
|
||||
put() { mkdir -p "$(dirname "$2")" && cat "$1" > "$2"; }
|
||||
aarch64-linux-gnu-g++ -shared -fPIC -O2 -Wall -Wno-attributes -Wno-nonnull-compare \
|
||||
-pthread -std=c++17 -static-libstdc++ -static-libgcc -Wl,--exclude-libs,ALL \
|
||||
-o "$d/libfakeinput.so" app/src/main/cpp/fakeinput_steam.cpp -ldl
|
||||
@@ -104,16 +103,16 @@ docker run --rm --platform linux/amd64 \
|
||||
aarch64-linux-gnu-gcc -O2 -Wall -Wextra -o "$d/usr/local/bin/droiddeck-clipboard" tools/linuxfs/clipboard/clipboard.c -ldl
|
||||
aarch64-linux-gnu-strip --strip-unneeded "$d/usr/local/bin/droiddeck-clipboard"
|
||||
for script in tools/linuxfs/overlay/usr/local/bin/droiddeck-* tools/linuxfs/overlay/usr/local/bin/steam-compatibility; do
|
||||
install -Dm644 "$script" "$d/usr/local/bin/$(basename "$script")"
|
||||
put "$script" "$d/usr/local/bin/$(basename "$script")"
|
||||
done
|
||||
for f in tools/linuxfs/overlay/usr/bin/* tools/linuxfs/overlay/usr/bin/steamos-polkit-helpers/*; do
|
||||
[ -f "$f" ] && install -Dm644 "$f" "$d/${f#tools/linuxfs/overlay/}"
|
||||
[ -f "$f" ] && put "$f" "$d/${f#tools/linuxfs/overlay/}"
|
||||
done
|
||||
install -Dm644 tools/linuxfs/desktop/droiddeck-desktop "$d/usr/local/bin/droiddeck-desktop"
|
||||
install -Dm644 tools/linuxfs/desktop/droiddeck-gpu "$d/usr/local/bin/droiddeck-gpu"
|
||||
install -Dm644 tools/linuxfs/desktop/droiddeck-desktop-gpu "$d/usr/local/bin/droiddeck-desktop-gpu"
|
||||
install -Dm644 tools/linuxfs/desktop/kwin_wayland_wrapper "$d/usr/local/bin/kwin_wayland_wrapper"
|
||||
install -Dm644 tools/linuxfs/desktop/firefox-droiddeck.js \
|
||||
put tools/linuxfs/desktop/droiddeck-desktop "$d/usr/local/bin/droiddeck-desktop"
|
||||
put tools/linuxfs/desktop/droiddeck-gpu "$d/usr/local/bin/droiddeck-gpu"
|
||||
put tools/linuxfs/desktop/droiddeck-desktop-gpu "$d/usr/local/bin/droiddeck-desktop-gpu"
|
||||
put tools/linuxfs/desktop/kwin_wayland_wrapper "$d/usr/local/bin/kwin_wayland_wrapper"
|
||||
put tools/linuxfs/desktop/firefox-droiddeck.js \
|
||||
"$d/usr/lib/firefox/defaults/pref/droiddeck.js"
|
||||
|
||||
READELF=aarch64-linux-gnu-readelf bash tools/linuxfs/check-preloads.sh "$d"
|
||||
@@ -129,6 +128,8 @@ docker run --rm --platform linux/amd64 \
|
||||
chown -R '"$(id -u):$(id -g)"' app/src/main/assets/linuxfs
|
||||
'
|
||||
|
||||
DROIDDECK_BUILD_IMAGE="${image_name}" "${repo_root}/tools/vr/build.sh" "${linuxfs_dir}/usr/local/lib/droiddeck-vr"
|
||||
|
||||
github_repo=${DROIDDECK_GITHUB_REPOSITORY:-}
|
||||
if [[ -z "${github_repo}" ]]; then
|
||||
origin_url=$(git -C "${repo_root}" remote get-url origin)
|
||||
@@ -145,12 +146,8 @@ if [[ -z "${github_repo}" ]]; then
|
||||
github_repo=${github_repo%.git}
|
||||
fi
|
||||
|
||||
# Pinned downloads are kept between builds, named by their checksum, so a rebuild fetches nothing
|
||||
# it already has. A cached file is checked again before use; a bad one is fetched anew.
|
||||
cache_dir=${DROIDDECK_BUILD_CACHE:-"${HOME}/.cache/droiddeck-build"}
|
||||
mkdir -p "${cache_dir}"
|
||||
# cached <sha256> <name> <command...>: prints the cached path, running the command (which writes
|
||||
# to "$out") only when the cache has no file with that checksum.
|
||||
cached() {
|
||||
local sha=$1 name=$2 out
|
||||
shift 2
|
||||
@@ -177,8 +174,9 @@ fi
|
||||
. "${repo_root}/tools/linuxfs/uruntime.env"
|
||||
uruntime_binary=$(cached "${URUNTIME_SHA256}" "${URUNTIME_ASSET}" \
|
||||
bash -c 'curl -fsSL --retry 3 -o "$out" "$0"' "https://github.com/VHSgunzo/uruntime/releases/download/${URUNTIME_VERSION}/${URUNTIME_ASSET}")
|
||||
install -Dm644 "${uruntime_binary}" "${linuxfs_dir}/usr/local/lib/droiddeck/uruntime"
|
||||
install -Dm644 "${repo_root}/tools/linuxfs/licenses/uruntime-LICENSE" "${linuxfs_dir}/usr/local/share/licenses/uruntime/LICENSE"
|
||||
mkdir -p "${linuxfs_dir}/usr/local/lib/droiddeck" "${linuxfs_dir}/usr/local/share/licenses/uruntime"
|
||||
install -m644 "${uruntime_binary}" "${linuxfs_dir}/usr/local/lib/droiddeck/uruntime"
|
||||
install -m644 "${repo_root}/tools/linuxfs/licenses/uruntime-LICENSE" "${linuxfs_dir}/usr/local/share/licenses/uruntime/LICENSE"
|
||||
|
||||
sync_assets="${repo_root}/app/src/main/assets/droiddeck-esync"
|
||||
if [[ -f "${repo_root}/tools/droiddeck-esync/release.env" ]]; then
|
||||
@@ -237,7 +235,6 @@ install -m644 "${mango_pkgs}/usr/bin/mangoapp" "${mango_dir}/mangoapp"
|
||||
for library in libfmt.so.10 libspdlog.so.1.13 libglfw.so.3 libtraceevent.so.1; do
|
||||
cp -L "${mango_pkgs}/usr/lib/${library}" "${mango_dir}/${library}"
|
||||
done
|
||||
# Ours, not the package's: GPU memory without tracefs (tools/mangoapp/libtracefs-shim.c).
|
||||
docker run --rm --platform linux/amd64 --user "$(id -u):$(id -g)" -v "${repo_root}:/src" -w /src "${image_name}" \
|
||||
aarch64-linux-gnu-gcc -shared -fPIC -O2 -Wall -Wl,-soname,libtracefs.so.1 \
|
||||
-o app/src/main/assets/linuxfs/usr/local/lib/mangoapp/libtracefs.so.1 tools/mangoapp/libtracefs-shim.c
|
||||
@@ -263,8 +260,6 @@ fi
|
||||
sink_output="${staging_dir}/sink-out"
|
||||
"${repo_root}/tools/directaudio/fetch.sh" "${repo_root}" "${sink_output}"
|
||||
"${repo_root}/tools/aaudio-sink/build.sh" "${pa_source}" "${sink_output}"
|
||||
# proot is rebuilt only when its sources (source.env, the patches, the build script) changed since
|
||||
# the libraries in jniLibs were built.
|
||||
proot_out="${repo_root}/app/src/main/jniLibs/arm64-v8a"
|
||||
proot_sources=$(cd "${repo_root}/tools/proot" && find . -type f ! -name '*.pyc' | LC_ALL=C sort | xargs shasum -a 256 | shasum -a 256 | cut -d' ' -f1)
|
||||
proot_inputs=$(printf '%s\n' "${proot_sources}" "${ndk_version}" | shasum -a 256 | cut -d' ' -f1)
|
||||
@@ -294,10 +289,6 @@ tar -cf - -C "${bundle_dir}" . | zstd -19 -T0 -c > "${staging_dir}/pulseaudio.tz
|
||||
mkdir -p "${repo_root}/app/build/prepared-assets"
|
||||
mv "${staging_dir}/pulseaudio.tzst" "${repo_root}/app/build/prepared-assets/pulseaudio.tzst"
|
||||
|
||||
# The GOG / Epic / Amazon download engines are Rust (app/src/main/rust/stores); Gradle's
|
||||
# buildRustStores task cross-compiles them with cargo-ndk, which needs the Android target and the
|
||||
# cargo-ndk binary installed once. DROIDDECK_SKIP_RUST=1 builds an apk without the engines (the
|
||||
# stores then report themselves unavailable) for a machine without a Rust toolchain.
|
||||
gradle_rust_arg=""
|
||||
if [[ "${DROIDDECK_SKIP_RUST:-0}" == 1 ]]; then
|
||||
gradle_rust_arg="-PskipRust=true"
|
||||
@@ -316,6 +307,8 @@ else
|
||||
fi
|
||||
|
||||
cd "${repo_root}"
|
||||
python3 tools/quest/build-driver.py "${NDK}"
|
||||
bash tools/comet/build-local.sh
|
||||
python3 tools/release/runtime_inputs.py record
|
||||
./gradlew "${gradle_task}" --console=plain -PndkVersion="${ndk_version}" ${gradle_rust_arg}
|
||||
python3 tools/release/check_session_assets.py "app/build/outputs/apk/${build_variant}/app-${build_variant}.apk"
|
||||
@@ -376,10 +369,6 @@ grep -qi 'CN=Android, OU=Android, O=Android' <<<"${signature_output}" || {
|
||||
exit 1
|
||||
}
|
||||
|
||||
# With DroidDeck's own key at hand, sign as CI's main builds are (tools/release/sign-apk.sh), so
|
||||
# the apk installs over a release instead of being refused as a different signer. The key's
|
||||
# location and password live in an untracked .signing.env (RELEASE_KEYSTORE, RELEASE_STORE_PASSWORD,
|
||||
# RELEASE_KEY_ALIAS), looked for in this checkout and then in the main one, which worktrees share.
|
||||
signing_env=${DROIDDECK_SIGNING_ENV:-}
|
||||
if [[ -z "${signing_env}" ]]; then
|
||||
for candidate in "${repo_root}/.signing.env" \
|
||||
@@ -391,7 +380,6 @@ if [[ -n "${signing_env}" ]]; then
|
||||
echo "Signing with DroidDeck's key (${signing_env})"
|
||||
(
|
||||
set -a
|
||||
# shellcheck disable=SC1090
|
||||
cd "$(dirname "${signing_env}")"
|
||||
. "${signing_env}"
|
||||
set +a
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
#include "cardboard.h"
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static int failures;
|
||||
#define CHECK(c) do { if (!(c)) { printf("FAIL %s:%d: %s\n", __FILE__, __LINE__, #c); failures++; } } while (0)
|
||||
static int near(float a, float b) { return fabsf(a - b) < 1e-4f; }
|
||||
|
||||
int main(void) {
|
||||
struct cardboard_params p = {.enabled = 7, .source = 9, .ipd_m = 1.0f, .screen_dist_m = 0.0f,
|
||||
.screen_width_m = 100.0f, .k1 = 5.0f, .k2 = -5.0f, .fov_deg = 500.0f,
|
||||
.lens_inset = 1.0f, .chroma = -1.0f};
|
||||
cardboard_clamp(&p);
|
||||
CHECK(p.enabled == 1);
|
||||
CHECK(p.source == CARDBOARD_SOURCE_SCREEN);
|
||||
CHECK(near(p.ipd_m, 0.1f));
|
||||
CHECK(near(p.screen_dist_m, 0.5f));
|
||||
CHECK(near(p.screen_width_m, 60.0f));
|
||||
CHECK(near(p.k1, 2.0f) && near(p.k2, -1.0f));
|
||||
CHECK(near(p.fov_deg, 140.0f));
|
||||
CHECK(near(p.lens_inset, 0.25f) && near(p.chroma, 0.0f));
|
||||
|
||||
struct cardboard_params q = {.enabled = 1, .source = CARDBOARD_SOURCE_SCREEN, .ipd_m = 0.064f, .screen_dist_m = 3.0f,
|
||||
.screen_width_m = 4.0f, .k1 = 0.34f, .k2 = 0.55f, .fov_deg = 90.0f,
|
||||
.lens_inset = 0.05f, .chroma = 0.006f};
|
||||
const float pose[9] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
float pc[24];
|
||||
cardboard_push_constants(&q, pose, 1920, 1080, 2400, 1080, pc);
|
||||
CHECK(near(pc[0], 1) && near(pc[1], 2) && near(pc[2], 3) && near(pc[3], 0.032f));
|
||||
CHECK(near(pc[4], 4) && near(pc[5], 5) && near(pc[6], 6) && near(pc[7], 3.0f));
|
||||
CHECK(near(pc[8], 7) && near(pc[9], 8) && near(pc[10], 9) && near(pc[11], 2.0f));
|
||||
CHECK(near(pc[12], 0.34f) && near(pc[13], 0.55f) && near(pc[14], 1.0f) && near(pc[15], 0.006f));
|
||||
CHECK(near(pc[16], 0.05f) && near(pc[17], 1920.0f / 1080.0f) && near(pc[18], 0.0f) && near(pc[19], 1200.0f / 1080.0f));
|
||||
|
||||
q.source = CARDBOARD_SOURCE_SBS;
|
||||
cardboard_push_constants(&q, pose, 3840, 1080, 2400, 1080, pc);
|
||||
CHECK(near(pc[17], 1920.0f / 1080.0f) && near(pc[18], 1.0f));
|
||||
cardboard_push_constants(&q, pose, 0, 0, 0, 0, pc);
|
||||
CHECK(isfinite(pc[17]) && isfinite(pc[19]));
|
||||
|
||||
if (failures) return 1;
|
||||
printf("PASS: cardboard params\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
# GOG Galaxy achievements
|
||||
|
||||
Comet v0.3.2, pinned to `3d7488ee72f83b7e8462a70fd4c4638d6da71360`, and its
|
||||
protocol submodule are built for glibc ARM64. Apache-2.0; upstream:
|
||||
https://github.com/imLinguin/comet.
|
||||
|
||||
Build with Rust 1.90, the `aarch64-unknown-linux-gnu` target and
|
||||
`aarch64-linux-gnu-gcc`: `bash tools/comet/build.sh`.
|
||||
The APK's runtime-input manifest records the prepared binary and Windows tools.
|
||||
|
||||
The patch accepts credentials on stdin, announces readiness and accepted uploads
|
||||
without secrets, emits named local unlocks for the session notification, uses a periodic sync tick even during SDK traffic, and retains the retry flag
|
||||
when an achievement upload fails.
|
||||
The Android supervisor discards other upstream output instead of exporting
|
||||
HTTP errors or protocol payloads containing game credentials.
|
||||
|
||||
The dummy service tools are the hash-checked upstream v0.3.2 release. They are
|
||||
registered through the game's selected Proton in its own prefix. GOG overlays
|
||||
are not installed. Pending databases survive session resets and sign-out.
|
||||
|
||||
Local unlocks show a five-second DroidDeck notification without taking input focus.
|
||||
The notification queue belongs to the session, ignores duplicate SDK unlocks, and clears
|
||||
on account replacement or session stop. Upload acknowledgements refresh the achievement
|
||||
reader without replaying notifications.
|
||||
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
repo=$(cd "$(dirname "$0")/../.." && pwd)
|
||||
image=${DROIDDECK_BUILD_IMAGE:-droiddeck-local-cross:24.04-v3}
|
||||
docker run --rm --platform linux/amd64 -v "$repo:/src" \
|
||||
-v "${HOME}/.cache/droiddeck-comet-rust:/rust" -w /src \
|
||||
-e CARGO_HOME=/rust/cargo -e RUSTUP_HOME=/rust/rustup "$image" bash -lc '
|
||||
set -euo pipefail
|
||||
apt-get update -qq
|
||||
apt-get install -y -qq curl git unzip ca-certificates pkg-config >/dev/null
|
||||
export PATH=/rust/cargo/bin:$PATH
|
||||
if ! command -v cargo >/dev/null; then
|
||||
curl -fsSL https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain 1.90.0
|
||||
fi
|
||||
export RUSTUP_TOOLCHAIN=1.90.0
|
||||
rustup target add aarch64-unknown-linux-gnu
|
||||
bash tools/comet/build.sh
|
||||
'
|
||||
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
repo=$(cd "$(dirname "$0")/../.." && pwd)
|
||||
out=${1:-"$repo/app/src/main/assets/linuxfs/usr/local/lib/droiddeck-comet"}
|
||||
cache=${COMET_BUILD_DIR:-"$repo/app/build/comet"}
|
||||
commit=3d7488ee72f83b7e8462a70fd4c4638d6da71360
|
||||
mkdir -p "$cache" "$out"
|
||||
if [ ! -d "$cache/source/.git" ]; then
|
||||
git clone https://github.com/imLinguin/comet.git "$cache/source"
|
||||
fi
|
||||
git -C "$cache/source" reset --hard "$commit"
|
||||
git -C "$cache/source" submodule update --init
|
||||
git -C "$cache/source" apply "$repo/tools/comet/droiddeck.patch"
|
||||
cd "$cache/source"
|
||||
cargo build --locked --release --target aarch64-unknown-linux-gnu
|
||||
install -m644 target/aarch64-unknown-linux-gnu/release/comet "$out/comet"
|
||||
zip="$cache/dummy-service.zip"
|
||||
if ! echo "7fc5facd1fce4d516cd3ce527e7e4dbe0bfd17649cea805e8ea7c37d4ba58d9a $zip" | sha256sum -c - >/dev/null 2>&1; then
|
||||
curl -fsSL --retry 3 -o "$zip" https://github.com/imLinguin/comet/releases/download/v0.3.2/dummy-service.zip
|
||||
fi
|
||||
echo "7fc5facd1fce4d516cd3ce527e7e4dbe0bfd17649cea805e8ea7c37d4ba58d9a $zip" | sha256sum -c -
|
||||
unzip -o "$zip" GalaxyCommunication.exe update-permissions.exe -d "$out"
|
||||
install -m644 "$repo/tools/comet/LICENSE" "$out/LICENSE"
|
||||
printf '%s\n' "$commit" > "$out/version"
|
||||
@@ -0,0 +1,174 @@
|
||||
diff --git a/src/api/gog/users.rs b/src/api/gog/users.rs
|
||||
index 77d8ecf..6a6da12 100644
|
||||
--- a/src/api/gog/users.rs
|
||||
+++ b/src/api/gog/users.rs
|
||||
@@ -26,9 +26,9 @@ pub async fn get_token_for(
|
||||
.get(url)
|
||||
.timeout(time::Duration::from_secs(10))
|
||||
.send()
|
||||
- .await?;
|
||||
+ .await.map_err(reqwest::Error::without_url)?;
|
||||
|
||||
- let result = result.error_for_status()?;
|
||||
- let token: Token = result.json().await?;
|
||||
+ let result = result.error_for_status().map_err(reqwest::Error::without_url)?;
|
||||
+ let token: Token = result.json().await.map_err(reqwest::Error::without_url)?;
|
||||
Ok(token)
|
||||
}
|
||||
diff --git a/src/api/handlers.rs b/src/api/handlers.rs
|
||||
index 43a8180..fbbba1b 100644
|
||||
--- a/src/api/handlers.rs
|
||||
+++ b/src/api/handlers.rs
|
||||
@@ -59,6 +59,9 @@ pub async fn entry_point(
|
||||
let mut topic_receiver_clone = topic_receiver.resubscribe();
|
||||
let mut overlay_event_receiver_clone = overlay_event_receiver.resubscribe();
|
||||
let main_socket = tokio::spawn(async move {
|
||||
+ let mut sync_interval = time::interval(time::Duration::from_secs(10));
|
||||
+ sync_interval.set_missed_tick_behavior(time::MissedTickBehavior::Skip);
|
||||
+ sync_interval.tick().await;
|
||||
loop {
|
||||
tokio::select! {
|
||||
size_read = context_clone.socket_read_u16() => {
|
||||
@@ -101,7 +104,7 @@ pub async fn entry_point(
|
||||
}
|
||||
}
|
||||
|
||||
- _ = time::sleep(time::Duration::from_secs(10)) => {
|
||||
+ _ = sync_interval.tick() => {
|
||||
sync_routine(&context_clone, &reqwest_clone, user_clone.clone()).await
|
||||
},
|
||||
|
||||
@@ -338,6 +341,7 @@ async fn sync_routine(context: &HandlerContext, reqwest_client: &Client, user_in
|
||||
let Some(client_id) = &context.client_id().await else {
|
||||
return;
|
||||
};
|
||||
+ if !crate::client_allowed(client_id) { return; }
|
||||
let Some(client_secret) = &context.client_secret().await else {
|
||||
return;
|
||||
};
|
||||
@@ -391,6 +395,8 @@ async fn sync_routine(context: &HandlerContext, reqwest_client: &Client, user_in
|
||||
.expect("Failed to get database connection");
|
||||
let mut transaction = connection.begin().await.unwrap();
|
||||
|
||||
+ let mut pending = false;
|
||||
+ let mut uploaded = 0;
|
||||
for achievement in achievements {
|
||||
debug!("Setting achievement {}", achievement.achievement_key());
|
||||
let result = gog::achievements::set_achievement(
|
||||
@@ -409,11 +415,15 @@ async fn sync_routine(context: &HandlerContext, reqwest_client: &Client, user_in
|
||||
.execute(&mut *transaction)
|
||||
.await
|
||||
.expect("Failed to update changed status");
|
||||
+ uploaded += 1;
|
||||
+ } else {
|
||||
+ pending = true;
|
||||
}
|
||||
}
|
||||
transaction.commit().await.expect("Failed to save changes");
|
||||
- context.set_updated_achievements(false).await;
|
||||
- info!("Uploaded achievements");
|
||||
+ context.set_updated_achievements(pending).await;
|
||||
+ if uploaded > 0 { eprintln!("DROIDDECK_COMET_UPLOADED:{uploaded}"); }
|
||||
+ if pending { eprintln!("DROIDDECK_COMET_PENDING"); }
|
||||
}
|
||||
Err(err) => error!("Failed to read local database {:?}", err),
|
||||
}
|
||||
diff --git a/src/api/handlers/communication_service.rs b/src/api/handlers/communication_service.rs
|
||||
index c1bed3b..1dda644 100644
|
||||
--- a/src/api/handlers/communication_service.rs
|
||||
+++ b/src/api/handlers/communication_service.rs
|
||||
@@ -35,6 +35,9 @@ pub async fn entry_point(
|
||||
debug!("Handling in communication service");
|
||||
let header = &payload.header;
|
||||
|
||||
+ if let Some(client) = context.client_id().await {
|
||||
+ if !crate::client_allowed(&client) { return Err(MessageHandlingError::unauthorized()); }
|
||||
+ }
|
||||
let message_type: i32 = header.type_().try_into().unwrap();
|
||||
|
||||
if message_type == MessageType::LIBRARY_INFO_REQUEST.value() {
|
||||
@@ -132,6 +135,7 @@ async fn auth_info_request(
|
||||
|
||||
let client_id = request_data.client_id();
|
||||
let client_secret = request_data.client_secret();
|
||||
+ if !crate::client_allowed(client_id) { return Err(MessageHandlingError::unauthorized()); }
|
||||
let openid = request_data.openid();
|
||||
let pid = request_data.game_pid();
|
||||
|
||||
@@ -551,6 +555,14 @@ async fn unlock_user_achievement(
|
||||
.await
|
||||
.expect("Failed to write achievement to database");
|
||||
context.set_updated_achievements(true).await;
|
||||
+ eprintln!("DROIDDECK_COMET_UNLOCKED:{}", serde_json::json!({
|
||||
+ "client_id": context.client_id().await,
|
||||
+ "id": achievement.achievement_key(),
|
||||
+ "name": achievement.name(),
|
||||
+ "description": achievement.description(),
|
||||
+ "icon": achievement.image_url_unlocked(),
|
||||
+ "unlocked_at": timestamp,
|
||||
+ }));
|
||||
achievement.date_unlocked = timestamp_string;
|
||||
let pid = context.get_pid().await;
|
||||
let _ = context
|
||||
diff --git a/src/lib.rs b/src/lib.rs
|
||||
index 0c539f1..50fdd21 100644
|
||||
--- a/src/lib.rs
|
||||
+++ b/src/lib.rs
|
||||
@@ -16,3 +16,10 @@ lazy_static! {
|
||||
.and_then(|x| if !x.contains("-") { None } else { Some(x) })
|
||||
.unwrap_or_else(|| String::from("en-US"));
|
||||
}
|
||||
+
|
||||
+
|
||||
+pub fn client_allowed(client_id: &str) -> bool {
|
||||
+ let Ok(path) = std::env::var("COMET_ALLOWED_CLIENTS") else { return true; };
|
||||
+ std::fs::read(path).ok().and_then(|data| serde_json::from_slice::<Vec<String>>(&data).ok())
|
||||
+ .is_some_and(|clients| clients.iter().any(|id| id == client_id))
|
||||
+}
|
||||
diff --git a/src/main.rs b/src/main.rs
|
||||
index 109098f..8301edb 100644
|
||||
--- a/src/main.rs
|
||||
+++ b/src/main.rs
|
||||
@@ -41,11 +41,13 @@ enum SubCommand {
|
||||
struct Args {
|
||||
#[arg(long, help = "Provide access token (for getting user data)")]
|
||||
access_token: Option<String>,
|
||||
+ #[arg(long, help = "Read credentials as JSON from stdin")]
|
||||
+ credentials_stdin: bool,
|
||||
#[arg(long, help = "Provide refresh token (for creating game sessions)")]
|
||||
refresh_token: Option<String>,
|
||||
#[arg(long, help = "Galaxy user id from /userData.json")]
|
||||
user_id: Option<String>,
|
||||
- #[arg(long, help = "User name")]
|
||||
+ #[arg(long, help = "User name", default_value = "")]
|
||||
username: String,
|
||||
#[arg(
|
||||
long = "from-heroic",
|
||||
@@ -86,7 +88,18 @@ struct Args {
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
- let args = Args::parse();
|
||||
+ let mut args = Args::parse();
|
||||
+ if args.credentials_stdin {
|
||||
+ use std::io::Read;
|
||||
+ let value: serde_json::Value = serde_json::from_reader(std::io::stdin().take(32768))
|
||||
+ .expect("Invalid credential input");
|
||||
+ let field = |key: &str| value.get(key).and_then(|v| v.as_str())
|
||||
+ .filter(|v| !v.is_empty()).expect("Missing credential field").to_owned();
|
||||
+ args.access_token = Some(field("access_token"));
|
||||
+ args.refresh_token = Some(field("refresh_token"));
|
||||
+ args.user_id = Some(field("user_id"));
|
||||
+ args.username = field("username");
|
||||
+ }
|
||||
#[cfg(debug_assertions)]
|
||||
let log_level = "debug";
|
||||
#[cfg(not(debug_assertions))]
|
||||
@@ -306,6 +319,7 @@ async fn main() {
|
||||
});
|
||||
|
||||
info!("Listening on port 9977");
|
||||
+ eprintln!("DROIDDECK_COMET_READY:{}", std::process::id());
|
||||
let socket_shutdown = cloned_shutdown.clone();
|
||||
let cloned_user_info = user_info.clone();
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
#!/bin/bash
|
||||
# Build the pinned KWin executable with the nested-scale patch on native aarch64 Linux.
|
||||
# Its dependencies come from signature-checked Arch Linux ARM packages in a disposable chroot.
|
||||
set -euo pipefail
|
||||
out=$(realpath -m "${1:?out dir}")
|
||||
here=$(cd "$(dirname "$0")" && pwd)
|
||||
@@ -20,7 +18,6 @@ for repo in core extra alarm; do
|
||||
done
|
||||
touch "$work/runtime.txt"
|
||||
python3 "$here/closure.py" "$work/db" "$work/runtime.txt" "$here/kwin-build-seeds.txt" > "$work/packages.txt"
|
||||
# Refuse a repository whose KWin headers/libraries have moved beyond the pinned source.
|
||||
grep -Eq '^extra/kwin-6\.7\.5-[0-9]+-aarch64\.pkg\.tar\.' "$work/packages.txt"
|
||||
export work mirror builder here
|
||||
download() {
|
||||
@@ -56,8 +53,6 @@ sudo cp "$work/root/build/out/bin/kwin_wayland" "$out/kwin_wayland"
|
||||
sudo cp "$work/root/build/out/bin/libkwin.so.$version" "$out/libkwin.so.$version"
|
||||
sudo chown "$(id -u):$(id -g)" "$out/kwin_wayland" "$out/libkwin.so.$version"
|
||||
strip --strip-unneeded "$out/kwin_wayland" "$out/libkwin.so.$version"
|
||||
# The backend lives in libkwin, not the small launcher. Catch accidentally shipping only the
|
||||
# executable, which boots successfully but still loads the distribution's unpatched backend.
|
||||
grep -aq DROIDDECK_NESTED_SCALE "$out/libkwin.so.$version"
|
||||
{
|
||||
echo "KWin $version source sha256 $source_sha"
|
||||
|
||||
@@ -1,24 +1,4 @@
|
||||
#!/bin/bash
|
||||
# Builds the KDE Plasma desktop package for the Linux runtime: the closure of seeds.txt over Arch
|
||||
# Linux ARM's aarch64 repositories, minus what the runtime image already carries, plus overlay/,
|
||||
# as a zstd tarball that extracts over the rootfs (DesktopCatalog's "tar" kind).
|
||||
#
|
||||
# tools/desktop-kde/build.sh <out dir>
|
||||
#
|
||||
# The runtime's own packages (runtime-packages.txt, "name version" from its pacman db) are not
|
||||
# shipped again, except where something in the closure asks for a version of one the runtime does
|
||||
# not have (a versioned dependency on it, or on a library it provides): then the repository's
|
||||
# build comes along and replaces it. Nothing is deleted on extraction, so a library whose soname
|
||||
# moved keeps its old file for what the runtime linked against it.
|
||||
#
|
||||
# Every package is fetched over HTTPS and must carry a valid signature by the Arch Linux ARM Build
|
||||
# System key (archlinuxarm-builder.gpg; primary fingerprint pinned below, as archlinuxarm.org
|
||||
# publishes it and archlinuxarm-keyring trusts it) and match the sha256 the repository database
|
||||
# gives for it; anything else stops the build. The repository databases themselves are not signed
|
||||
# by Arch Linux ARM, so they decide only which signed packages are taken. desktop-kde.packages.txt
|
||||
# lists every package taken, with its sha256: what a release was built from.
|
||||
#
|
||||
# Needs curl, gpgv, tar, xz, zstd, python3.
|
||||
set -euo pipefail
|
||||
out=${1:?out dir}
|
||||
here=$(cd "$(dirname "$0")" && pwd)
|
||||
@@ -27,7 +7,6 @@ case $mirror in https://*) ;; *) echo "ALARM_MIRROR must be https" >&2; exit 1 ;
|
||||
builder=68B3537F39A313B3E574D06777193F152BDBE6A6
|
||||
fetch() { curl -fsSL --proto '=https' --proto-redir '=https' --retry 6 --retry-delay 5 --retry-all-errors -o "$1" "$2"; }
|
||||
work=$(mktemp -d); mkdir -p "$out" "$work/db" "$work/root"
|
||||
# PKG_CACHE keeps the downloaded packages between builds (a local rebuild after an overlay change).
|
||||
pkgs=${PKG_CACHE:-$work/pkgs}; mkdir -p "$pkgs"
|
||||
trap 'rm -rf "$work"' EXIT
|
||||
|
||||
@@ -56,24 +35,19 @@ done < "$work/pkglist.txt"
|
||||
|
||||
cp -a "$here/overlay/." "$work/root/"
|
||||
|
||||
# Same-version KWin, built by build-kwin.sh with the nested desktop scale patch.
|
||||
if [ -n "${KDE_KWIN_OVERRIDE:-}" ]; then
|
||||
install -m 755 "$KDE_KWIN_OVERRIDE/kwin_wayland" "$work/root/usr/bin/kwin_wayland"
|
||||
install -m 755 "$KDE_KWIN_OVERRIDE/libkwin.so.6.7.5" "$work/root/usr/lib/libkwin.so.6.7.5"
|
||||
fi
|
||||
|
||||
# Weight that no desktop on a phone reads.
|
||||
rm -rf "$work/root/usr/share/doc" "$work/root/usr/share/man" "$work/root/usr/share/info" \
|
||||
"$work/root/usr/share/gtk-doc" "$work/root/usr/include" "$work/root/usr/lib/pkgconfig" \
|
||||
"$work/root/usr/lib/cmake" "$work/root/usr/share/help"
|
||||
# English only, on purpose: the desktop session runs in C.UTF-8 and nothing hands the app's language
|
||||
# to KDE, so other translations would be weight no one sees. They come back with localizing the
|
||||
# desktop itself (LANGUAGE from the app's language at session start).
|
||||
find "$work/root/usr/share/locale" -mindepth 1 -maxdepth 1 -type d ! -name 'en*' -exec rm -rf {} + 2>/dev/null || true
|
||||
find "$work/root/usr/lib" -name '*.a' -delete
|
||||
chmod -R u+rwX "$work/root"
|
||||
|
||||
sed 's#^[a-z]*/##' "$work/pkglist.txt" > "$out/desktop-kde.packages.txt" # "file sha256", each verified above
|
||||
sed 's#^[a-z]*/##' "$work/pkglist.txt" > "$out/desktop-kde.packages.txt"
|
||||
tar -C "$work/root" --zstd -cf "$out/desktop-kde.tar.zst" .
|
||||
sha256sum "$out/desktop-kde.tar.zst" | awk '{print $1}' > "$out/desktop-kde.sha256"
|
||||
ls -l "$out/desktop-kde.tar.zst"
|
||||
@@ -15,7 +15,6 @@ REPOS = ("core", "extra", "alarm")
|
||||
|
||||
|
||||
def vercmp_part(a, b):
|
||||
# rpmvercmp, as pacman compares version strings.
|
||||
if a == b:
|
||||
return 0
|
||||
sa = re.findall(r"\d+|[a-zA-Z]+", a)
|
||||
@@ -104,14 +103,11 @@ def main():
|
||||
def resolve(dep):
|
||||
"""The package to take for a dependency string, and whether the runtime's copy serves."""
|
||||
name, op, want = parse_dep(dep)
|
||||
# A runtime package that is the dependency or provides it, at a version that serves.
|
||||
if name in runtime and satisfies(runtime[name], op, want):
|
||||
return name, True
|
||||
candidates = providers.get(name, [])
|
||||
for real, _ in candidates:
|
||||
if real in runtime:
|
||||
# A provided name (a soname, mostly): the runtime's build serves as long as it is
|
||||
# the repository's own, or nothing asks for a particular version.
|
||||
if not op or runtime[real] == pkgs[real]["version"]:
|
||||
return real, True
|
||||
if satisfies_provider(real, name, op, want):
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# Native build tools and KWin's Arch makedepends; dependencies are resolved and signature-checked.
|
||||
kwin
|
||||
base-devel
|
||||
cmake
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
# Application packages from steamdeck-desktop-r1's desktop.packages.txt.
|
||||
# Keep dependencies and shared apps/icons (Firefox, mpv, Breeze, xdg-utils and portals).
|
||||
labwc
|
||||
lxqt-panel
|
||||
lxqt-config
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
<svg id="svg2" height="64" style="" viewBox="0 0 64 64" width="64" xmlns="http://www.w3.org/2000/svg" sodipodi:docname="deck_icon.svg" inkscape:version="1.2-dev (d2dd25d878, 2022-02-01, custom)" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<path id="path42220" d="m 32 4 v 10 a 18 18 0 0 1 18 18 a 18 18 0 0 1 -18 18 v 10 a 28 28 0 0 0 28 -28 a 28 28 0 0 0 -28 -28 z" style="fill:#fff;fill-rule:evenodd"/>
|
||||
<circle id="path43518" cx="32" cy="32" r="14" style="fill:#1a9fff;fill-rule:evenodd"/>
|
||||
|
||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
-1
@@ -1,4 +1,3 @@
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
<svg id="svg2" height="64" style="" viewBox="0 0 64 64" width="64" xmlns="http://www.w3.org/2000/svg" sodipodi:docname="start.svg" inkscape:version="1.2-dev (d2dd25d878, 2022-02-01, custom)" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<style type="text/css" id="current-color-scheme">
|
||||
.ColorScheme-Text {
|
||||
|
||||
|
Before Width: | Height: | Size: 1020 B After Width: | Height: | Size: 962 B |
-3
@@ -1,5 +1,3 @@
|
||||
// The first desktop: DroidDeck's wallpaper, and SteamOS's Plasma's default bottom panel with the Steam Deck
|
||||
// launcher icon, Steam, the file manager, the browser and Konsole pinned to the task manager.
|
||||
var desktops = desktopsForActivity(currentActivity());
|
||||
for (var i = 0; i < desktops.length; i++) {
|
||||
desktops[i].wallpaperPlugin = "org.kde.image";
|
||||
@@ -36,7 +34,6 @@ if (trayId) {
|
||||
trayContainment.currentConfigGroup = ["General"];
|
||||
trayContainment.writeConfig("scaleIconsToFit", true);
|
||||
}
|
||||
// The runtime has no locale of its own (C.UTF-8), whose short date reads "9 10 2026".
|
||||
var clock = panel.addWidget("org.kde.plasma.digitalclock");
|
||||
clock.currentConfigGroup = ["Appearance"];
|
||||
clock.writeConfig("dateFormat", "isoDate");
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1920" height="1080" viewBox="0 0 1920 1080">
|
||||
<!-- DroidDeck's desktop wallpaper: the mark (artwork/droiddeck-mark.svg) on deep navy. -->
|
||||
<defs>
|
||||
<radialGradient id="bg" cx="960" cy="540" r="1150" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0" stop-color="#14213a"/>
|
||||
|
||||
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.4 KiB |
@@ -28,7 +28,7 @@
|
||||
- // intentionally ignored, as it would get overwritten
|
||||
- // with the fractional scale protocol anyways
|
||||
- // next.scale = props->scale.value_or(m_state.scale);
|
||||
+ // DroidDeck owns the outer window size; Display Settings owns the inner UI scale.
|
||||
+
|
||||
+ if (qEnvironmentVariableIsSet("DROIDDECK_NESTED_SCALE")) {
|
||||
+ next.scale = props->scale.value_or(m_state.scale);
|
||||
+ next.scaleSetting = props->scaleSetting.value_or(m_state.scaleSetting);
|
||||
@@ -53,7 +53,7 @@
|
||||
|
||||
void init(const QSize &pixelSize, qreal scale, bool fullscreen);
|
||||
|
||||
+ // The outer window scale, independent of the desktop UI scale in DroidDeck.
|
||||
+
|
||||
+ qreal presentationScale() const;
|
||||
bool isReady() const;
|
||||
KWayland::Client::Surface *surface() const;
|
||||
|
||||
@@ -68,7 +68,6 @@ def main():
|
||||
cache, out, legacy_cache = map(pathlib.Path, sys.argv[5:8])
|
||||
here = pathlib.Path(__file__).resolve().parent
|
||||
seeds = {line.strip() for line in (here / 'seeds.txt').read_text().splitlines() if line.strip() and not line.startswith('#')} - SHARED_SEEDS
|
||||
# Published source package hashes; the caller places this beside the verified cache.
|
||||
packages = dict(line.split() for line in (cache / 'desktop-kde.packages.txt').read_text().splitlines())
|
||||
selected = set()
|
||||
found = set()
|
||||
@@ -86,8 +85,6 @@ def main():
|
||||
selected.update(str(p.relative_to(here / 'overlay')) for p in (here / 'overlay').rglob('*') if p.is_file())
|
||||
inventories = [inventory(p, pin[1]) for p, pin in zip(archives, PINS)]
|
||||
out.mkdir(parents=True, exist_ok=True)
|
||||
# The old runtime's pacman database omits some gamescope dependencies (e.g. libseat).
|
||||
# Own only the LXQt application packages, never their dependency closure.
|
||||
legacy_seeds = {line.strip() for line in (here / 'lxqt-applications.txt').read_text().splitlines()
|
||||
if line.strip() and not line.startswith('#')}
|
||||
legacy_selected = set()
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
# The desktop: KDE Plasma, as SteamOS's desktop mode has it - KWin nested as a client of the app's
|
||||
# compositor, Plasma's shell on it, and the apps SteamOS puts on its desktop. One package name per
|
||||
# line; build.sh takes the closure over Arch Linux ARM at build time, minus what the runtime has.
|
||||
kwin
|
||||
plasma-workspace
|
||||
plasma-desktop
|
||||
|
||||
@@ -1,21 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
# Fetches the DirectAudio pieces DroidDeck ships from the pinned release in tools/directaudio/release.env
|
||||
# and puts them where the build reads them. Four zips, checksummed:
|
||||
# directaudio-linux-wine11.zip the game driver for Valve Proton 11 / Experimental / GE-Proton
|
||||
# directaudio-linux-wine11-systhread.zip the game driver for Proton-CachyOS (system-thread mmdevapi)
|
||||
# directaudio-linux-relay.zip the Android-side helper (speaker + microphone for games)
|
||||
# directaudio-linux-sink.zip the PulseAudio sinks; the app ships module-directaudio-native-sink
|
||||
#
|
||||
# tools/directaudio/fetch.sh <repo root> <dir to receive the sink modules>
|
||||
#
|
||||
# Driver sets -> app/src/main/assets/directaudio/<set>/ (generated, ignored by git)
|
||||
# Helper -> app/src/main/jniLibs/arm64-v8a/libdirectaudiorelay.so (generated, ignored by git)
|
||||
# Sink -> <sink dir>/module-directaudio-native-sink.so for the audio bundle, next to the
|
||||
# module-aaudio-sink.so tools/aaudio-sink builds (the fallback).
|
||||
set -euo pipefail
|
||||
repo_root=$1
|
||||
sink_out=$2
|
||||
# shellcheck source=release.env
|
||||
. "${repo_root}/tools/directaudio/release.env"
|
||||
for v in DIRECTAUDIO_REPO DIRECTAUDIO_TAG DIRECTAUDIO_WINE11_SHA256 DIRECTAUDIO_SYSTHREAD_SHA256 DIRECTAUDIO_RELAY_SHA256 DIRECTAUDIO_SINK_SHA256; do
|
||||
[[ -n "${!v:-}" && "${!v}" != TBD ]] || { echo "tools/directaudio/release.env: ${v} is not set" >&2; exit 1; }
|
||||
@@ -44,7 +30,6 @@ for set in linux-wine11 linux-wine11-systhread; do
|
||||
done
|
||||
rm -f "${assets}/${set}/README.md"
|
||||
done
|
||||
# Each set says which interface it was built for; the name must not lie.
|
||||
grep -q '^abi wine11$' "${assets}/linux-wine11/version.txt"
|
||||
grep -q '^abi systhread$' "${assets}/linux-wine11-systhread/version.txt"
|
||||
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
# The DirectAudio release this build ships, pinned: nothing compiled for audio lives in this repo.
|
||||
# Source and release notes: https://github.com/The412Banner/directaudio
|
||||
# Bump the tag and the four checksums together (sha256 of each zip, from the release's SHA256SUMS.txt).
|
||||
DIRECTAUDIO_REPO=The412Banner/directaudio
|
||||
DIRECTAUDIO_TAG=directaudio-linux-v1.1.0
|
||||
DIRECTAUDIO_WINE11_SHA256=835e6cab072f5148893c43379e60506483aeb3f1444e777b430c295cbeb472c9
|
||||
|
||||
@@ -155,7 +155,7 @@ class Runner:
|
||||
):
|
||||
try:
|
||||
found[name] = action()
|
||||
except Exception as exc: # evidence is best effort
|
||||
except Exception as exc:
|
||||
found[name] = {"ok": False, "error": str(exc)}
|
||||
write_json(folder / "evidence.json", found)
|
||||
return {k: v.get("ok", True) if isinstance(v, dict) else True for k, v in found.items()}
|
||||
|
||||
+3
-9
@@ -15,7 +15,7 @@ import time
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
from adb_device import DeviceResolutionError, resolve_serial # noqa: E402
|
||||
from adb_device import DeviceResolutionError, resolve_serial
|
||||
|
||||
|
||||
AUTHORITY = "content://com.droiddeck.launcher.agent"
|
||||
@@ -215,7 +215,6 @@ def add_serial(response: dict, serial: str) -> dict:
|
||||
return response
|
||||
|
||||
|
||||
# --- displays ------------------------------------------------------------------------------------
|
||||
|
||||
def displays(adb: str, serial: str) -> list[dict]:
|
||||
"""Logical displays with the SurfaceFlinger (physical) id screencap and screenrecord want."""
|
||||
@@ -285,7 +284,6 @@ def record(adb: str, serial: str, path: str, seconds: float, display: int | None
|
||||
return {"ok": True, "command": "record", "path": str(destination), "seconds": seconds, "display": display}
|
||||
|
||||
|
||||
# --- commands ------------------------------------------------------------------------------------
|
||||
|
||||
def start_session(adb: str, serial: str, request: dict) -> dict:
|
||||
if request.get("mode") == "run":
|
||||
@@ -300,7 +298,7 @@ def start_session(adb: str, serial: str, request: dict) -> dict:
|
||||
def require_commands(adb: str, serial: str) -> dict:
|
||||
access = checked(provider_call(adb, serial, "access"), "ACCESS_FAILED")
|
||||
if access.get("commands") is not True:
|
||||
raise ControlError("Debugging tools are off: turn on Setup > Session > Debugging tools on the device",
|
||||
raise ControlError("Debugging tools are off: turn on Setup > Diagnostics > Debugging tools on the device",
|
||||
"AGENT_COMMANDS_DISABLED")
|
||||
return access
|
||||
|
||||
@@ -341,8 +339,6 @@ def execute(args: argparse.Namespace, adb: str, serial: str) -> dict:
|
||||
raise ControlError("Steam URL must start with steam://", "INVALID_STEAM_URL")
|
||||
request["steamUrl"] = args.url
|
||||
if args.reuse:
|
||||
# A scenario's per-run "before": keep a session of this mode that is already up, so only
|
||||
# a run after one that ended (a crash, the low-memory killer) starts a new one.
|
||||
current = get_state(adb, serial)["session"]
|
||||
wanted = {"steam": "steam", "desktop": "lxqt"}[args.mode]
|
||||
if current.get("running") and current.get("mode") == wanted and current.get("phase") not in {"STOPPING", "FAILED"}:
|
||||
@@ -508,7 +504,6 @@ def execute(args: argparse.Namespace, adb: str, serial: str) -> dict:
|
||||
return add_serial(record(adb, serial, args.path, args.seconds, args.display), serial)
|
||||
|
||||
if command == "wake":
|
||||
# A sleeping device stops the session and hides the app's windows from ui dump.
|
||||
run_adb(adb, serial, "shell", "input", "keyevent", "KEYCODE_WAKEUP")
|
||||
run_adb(adb, serial, "shell", "wm", "dismiss-keyguard")
|
||||
power = run_adb(adb, serial, "shell", "dumpsys", "power").stdout.decode(errors="replace")
|
||||
@@ -549,7 +544,6 @@ def build_parser() -> argparse.ArgumentParser:
|
||||
|
||||
stop = commands.add_parser("stop", help="stop the session and wait for IDLE")
|
||||
stop.add_argument("--timeout", type=float, default=90)
|
||||
# Collecting the client's logs and redacting them took about two minutes after a Skyrim session.
|
||||
stop.add_argument("--artifact-timeout", type=float, default=300)
|
||||
commands.add_parser("resume", help="resume a suspended session")
|
||||
|
||||
@@ -711,7 +705,7 @@ def main(argv: list[str] | None = None) -> int:
|
||||
except (ControlError, DeviceResolutionError) as exc:
|
||||
error = {"code": getattr(exc, "code", "DEVICE_RESOLUTION_FAILED"), "message": str(exc)}
|
||||
code = exit_code(exc)
|
||||
except Exception as exc: # the contract is JSON on stdout, even for a bug in this tool
|
||||
except Exception as exc:
|
||||
error = {"code": "INTERNAL_ERROR", "message": f"{type(exc).__name__}: {exc}"}
|
||||
code = 2
|
||||
response = {"ok": False, "error": error}
|
||||
|
||||
@@ -44,6 +44,13 @@ library list, before anything is published.
|
||||
read the window's attributes first, it kept the window as override-redirect and left it out of
|
||||
`GAMESCOPE_FOCUSABLE_WINDOWS`, so the client kept its loading screen over the running game
|
||||
(Skyrim SE, A Plague Tale: Innocence, on the games' own Xwayland). MapNotify now refreshes the flag.
|
||||
- `0115-limiter-paces-per-window.patch` - this app: on a fixed-refresh output the frame limiter
|
||||
(Steam's Frame Limit) let a capped window's frames out only on every Nth refresh of a global grid,
|
||||
so a frame finished just after its slot waited a whole extra slot. At 30 on 60 Hz one picture was
|
||||
held for three or four refreshes - "small stops and ladders" with frame generation - where a game's
|
||||
own limiter slips such a frame by one refresh. The fixed-refresh branch now paces each window by
|
||||
time, as the VRR branch already did: its next frame goes out on the first refresh a capped interval
|
||||
after its last one, with half a refresh of tolerance so an on-time window keeps every Nth refresh.
|
||||
|
||||
Sixteen more of Armada's patches are DRM/lease/HDR-on-KMS work for a native display, which this
|
||||
app's Wayland-hosted gamescope never reaches, or need a newer gamescope than the runtime has.
|
||||
@@ -1,26 +1,15 @@
|
||||
#!/usr/bin/bash
|
||||
# Runs INSIDE an Arch Linux ARM container (menci/archlinuxarm:base-devel) on an arm64 runner.
|
||||
# Builds Arch's own gamescope package of the runtime's version with the patches in ./patches
|
||||
# added, then keeps only the gamescope binary, checks its library needs against the runtime's
|
||||
# list, and packs it as gamescope.tzst (usr/local/bin/gamescope) for the apk to stage.
|
||||
set -euxo pipefail
|
||||
VERSION=${GAMESCOPE_VERSION:-3.16.29}
|
||||
WORK=/work
|
||||
cd "$WORK"
|
||||
# pacman's download sandbox (Landlock + the alpm user) cannot be set up inside the runner's
|
||||
# container; the packages still come signed from Arch Linux ARM's mirrors.
|
||||
grep -q '^DisableSandbox' /etc/pacman.conf || sed -i 's/^\[options\]/[options]\nDisableSandbox/' /etc/pacman.conf
|
||||
# The geo-redirecting mirror answered 500s and connection resets mid-transaction; name a few
|
||||
# concrete mirrors ahead of it so pacman has somewhere to fall over to.
|
||||
{ for m in https://ca.us.mirror.archlinuxarm.org https://fl.us.mirror.archlinuxarm.org https://de3.mirror.archlinuxarm.org https://nl.mirror.archlinuxarm.org; do echo "Server = $m/\$arch/\$repo"; done; cat /etc/pacman.d/mirrorlist; } > /etc/pacman.d/mirrorlist.new
|
||||
mv /etc/pacman.d/mirrorlist.new /etc/pacman.d/mirrorlist
|
||||
pacman -Syu --noconfirm --needed git sudo zstd binutils
|
||||
# makepkg refuses root; a builder user with passwordless sudo installs the dependencies.
|
||||
id builder >/dev/null 2>&1 || useradd -m builder
|
||||
echo 'builder ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/builder
|
||||
rm -rf pkg && mkdir pkg && cp -r tools/gamescope/patches pkg/ && chown -R builder pkg
|
||||
# Arch's packaging for exactly this version: the tag is <pkgver>-<pkgrel>; the first rel is tried
|
||||
# first, later ones after it.
|
||||
sudo -u builder bash -c "
|
||||
set -euxo pipefail
|
||||
cd pkg
|
||||
@@ -31,13 +20,11 @@ test -f arch/PKGBUILD
|
||||
cd arch
|
||||
grep -q '^pkgver=${VERSION}$' PKGBUILD
|
||||
cp ../patches/*.patch .
|
||||
# Add our patches to the source list and apply them after Arch's own prepare() steps.
|
||||
PATCHES=\$(ls *.patch | sort)
|
||||
{ echo; echo 'source+=('; for p in \$PATCHES; do echo \" \$p\"; done; echo ')'; for p in \$PATCHES; do echo \"sha256sums+=('SKIP')\"; done; } >> PKGBUILD
|
||||
cat >> PKGBUILD <<'PREP'
|
||||
|
||||
_droiddeck_prepare() {
|
||||
# Arch's own prepare() leaves the shell inside the checkout; start from a known place.
|
||||
cd \"\$srcdir/gamescope\"
|
||||
for p in \$(ls \"\$srcdir\"/*.patch | sort); do
|
||||
echo \"applying \$(basename \"\$p\")\"
|
||||
@@ -51,7 +38,7 @@ else
|
||||
prepare() { _droiddeck_prepare; }
|
||||
fi
|
||||
PREP
|
||||
makepkg -A -s --noconfirm --skipchecksums --skippgpcheck # -A: the PKGBUILD lists x86_64 only; Arch Linux ARM builds the same file
|
||||
makepkg -A -s --noconfirm --skipchecksums --skippgpcheck
|
||||
ls -l *.pkg.tar.*
|
||||
"
|
||||
cd "$WORK"
|
||||
@@ -61,7 +48,6 @@ tar --use-compress-program=unzstd -xf "$PKG" -C out --strip-components=2 usr/bin
|
||||
mv out/gamescope out/usr/local/bin/gamescope
|
||||
chmod 755 out/usr/local/bin/gamescope
|
||||
strip --strip-unneeded out/usr/local/bin/gamescope || true
|
||||
# Every NEEDED library must be one the runtime ships, or the binary would not load there.
|
||||
NEEDED=$(readelf -d out/usr/local/bin/gamescope | sed -n 's/.*NEEDED.*\[\(.*\)\]/\1/p')
|
||||
echo "NEEDED: $NEEDED"
|
||||
MISSING=""
|
||||
|
||||
@@ -22,9 +22,9 @@ index e54194b..4131467 100644
|
||||
g_ColorMgmt.pending.outputVirtualWhite.x = santitize_float( bit_cast<float>( user_vec[0] ) );
|
||||
g_ColorMgmt.pending.outputVirtualWhite.y = santitize_float( bit_cast<float>( user_vec[1] ) );
|
||||
+#if defined(__aarch64__)
|
||||
+ // The ARM64 Steam client packs the pair as one 64-bit element, so only x arrives;
|
||||
+ // Steam derives the pair from the CIE daylight locus, so y follows from x.
|
||||
+ // Drop once the client sends both floats (y arrives non-zero).
|
||||
+
|
||||
+
|
||||
+
|
||||
+ float x = g_ColorMgmt.pending.outputVirtualWhite.x;
|
||||
+ if ( x >= 0.25f && x <= 0.55f && g_ColorMgmt.pending.outputVirtualWhite.y <= 0.01f )
|
||||
+ g_ColorMgmt.pending.outputVirtualWhite.y = -3.0f * x * x + 2.87f * x - 0.275f;
|
||||
|
||||
@@ -18,7 +18,7 @@ index 64430a5..f4dcd98 100644
|
||||
{
|
||||
- // Use red as a sentinal for a wide-gamut display
|
||||
- return ( nativeDisplayOutput.primaries.r.x > 0.650f && nativeDisplayOutput.primaries.r.y < 0.320f );
|
||||
+ // Use red as a sentinal for a wide-gamut display; DCI-P3 red sits exactly on the threshold
|
||||
+
|
||||
+ return ( nativeDisplayOutput.primaries.r.x > 0.650f && nativeDisplayOutput.primaries.r.y <= 0.320f );
|
||||
}
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@ index 54e4efc..024af02 100644
|
||||
}
|
||||
|
||||
float queuePriorities = 1.0f;
|
||||
+ // Without CAP_SYS_NICE gamescope never asks for realtime-priority queues. Under proot on
|
||||
+ // Android there is no capability to have; the fallback below covers a driver that refuses. KGSL
|
||||
+ // Turnip accepts but ignores it (one submit-queue priority, contexts created alike). Opt in with
|
||||
+ // GAMESCOPE_FORCE_VULKAN_REALTIME=1. (Armada's --force-vulkan-realtime, as an environment switch.)
|
||||
+
|
||||
+
|
||||
+
|
||||
+
|
||||
+ const char *pszForceRealtime = getenv( "GAMESCOPE_FORCE_VULKAN_REALTIME" );
|
||||
+ const bool useRealtimeVulkanQueue = gamescope::Process::HasCapSysNice() || ( pszForceRealtime && atoi( pszForceRealtime ) != 0 );
|
||||
+ if ( useRealtimeVulkanQueue && !gamescope::Process::HasCapSysNice() )
|
||||
@@ -67,8 +67,8 @@ index 10990b8..08afbc4 100644
|
||||
}
|
||||
- else
|
||||
+ m_bConstrained = false;
|
||||
+ // Nothing to draw (the gamepad UI, most games): the position only feeds focus and zoom, and
|
||||
+ // wlserver's copy is what stock gamescope uses for those. No round trip to X.
|
||||
+
|
||||
+
|
||||
+ if ( m_imageEmpty )
|
||||
{
|
||||
- m_bConstrained = false;
|
||||
@@ -80,12 +80,12 @@ index 10990b8..08afbc4 100644
|
||||
}
|
||||
wlserver_unlock();
|
||||
+
|
||||
+ // The gamepad-driven cursor is moved through XTest, which moves the X pointer and nothing
|
||||
+ // else: wlserver's copy of the position never changes, so the sprite sat frozen while the
|
||||
+ // pointer moved. Ask X where the pointer is. (Armada 0001, on 3.16.29.) That is a blocking
|
||||
+ // round trip to Xwayland on the paint thread, which waits while Xwayland is busy drawing the
|
||||
+ // client's interface: once per vblank only while the sprite is shown, and every 50 ms while
|
||||
+ // it is hidden for inactivity - enough to bring it back within a few frames of a move.
|
||||
+
|
||||
+
|
||||
+
|
||||
+
|
||||
+
|
||||
+
|
||||
+ if ( wlserver.bCursorHidden )
|
||||
+ {
|
||||
+ const uint64_t now = get_time_in_nanos();
|
||||
|
||||
@@ -6,8 +6,8 @@ index d74268b..bf72267 100644
|
||||
void Wayland_Keyboard_RepeatInfo( wl_keyboard *pKeyboard, int32_t nRate, int32_t nDelay );
|
||||
static const wl_keyboard_listener s_KeyboardListener;
|
||||
|
||||
+ // Touch from the host compositor (DroidDeck): each finger goes to wlserver's touch path,
|
||||
+ // the one a Steam Deck's touchscreen drives, instead of being dropped.
|
||||
+
|
||||
+
|
||||
+ void Wayland_Touch_Down( wl_touch *pTouch, uint32_t uSerial, uint32_t uTime, wl_surface *pSurface, int32_t nId, wl_fixed_t fX, wl_fixed_t fY );
|
||||
+ void Wayland_Touch_Up( wl_touch *pTouch, uint32_t uSerial, uint32_t uTime, int32_t nId );
|
||||
+ void Wayland_Touch_Motion( wl_touch *pTouch, uint32_t uTime, int32_t nId, wl_fixed_t fX, wl_fixed_t fY );
|
||||
@@ -58,7 +58,7 @@ index d74268b..bf72267 100644
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // Touch
|
||||
+
|
||||
+
|
||||
+ bool CWaylandInputThread::TouchToOutput( wl_surface *pSurface, wl_fixed_t fX, wl_fixed_t fY, double *pflX, double *pflY )
|
||||
+ {
|
||||
@@ -75,7 +75,7 @@ index d74268b..bf72267 100644
|
||||
+ *pflY = ( wl_fixed_to_double( fY ) * uScale / 120.0 + oState->nDestY ) / g_nOutputHeight;
|
||||
+ return true;
|
||||
+ }
|
||||
+ // Touch ids are offset by one: the nested pointer already moves wlserver's touch 0.
|
||||
+
|
||||
+ void CWaylandInputThread::Wayland_Touch_Down( wl_touch *pTouch, uint32_t uSerial, uint32_t uTime, wl_surface *pSurface, int32_t nId, wl_fixed_t fX, wl_fixed_t fY )
|
||||
+ {
|
||||
+ double flX, flY;
|
||||
|
||||
@@ -7,9 +7,9 @@ index bf72267..c400978 100644
|
||||
|
||||
wlserver_lock();
|
||||
- wlserver_touchmotion( flX, flY, 0, ++m_uFakeTimestamp );
|
||||
+ // Always move the real pointer too: in Passthrough (what Steam's Big Picture asks for) a
|
||||
+ // touch motion for an id that is not down moves nothing, so hover never reached the
|
||||
+ // client and a click landed wherever the pointer had last been.
|
||||
+
|
||||
+
|
||||
+
|
||||
+ wlserver_touchmotion( flX, flY, 0, ++m_uFakeTimestamp, true );
|
||||
wlserver_unlock();
|
||||
}
|
||||
|
||||
@@ -28,11 +28,11 @@ index 08afbc4..372a82c 100644
|
||||
if ( keyboardFocusWindow && ctx->currentKeyboardFocusWindow && find_win( ctx, ctx->currentKeyboardFocusWindow ) == keyboardFocusWin )
|
||||
keyboardFocusWindow = ctx->currentKeyboardFocusWindow;
|
||||
|
||||
+ // An overlay that takes input (the Steam menu) moves input away without changing the focus window, and a
|
||||
+ // fullscreen game iconifies itself when it loses input. The focus window never changed, so it is never taken
|
||||
+ // out of iconic above, and wine will not activate a window it believes iconic: the game stays minimized
|
||||
+ // (its 160x24 caption in the corner) after Resume. Put it back to NormalState before input returns to it,
|
||||
+ // then hand focus over again so wine sees the restore first and the activation after it.
|
||||
+
|
||||
+
|
||||
+
|
||||
+
|
||||
+
|
||||
+ if ( inputFocus == ctx->focus.focusWindow && ctx->focus.focusWindow->iconifyRequested )
|
||||
+ {
|
||||
+ ctx->focus.focusWindow->iconifyRequested = false;
|
||||
@@ -59,8 +59,8 @@ index 08afbc4..372a82c 100644
|
||||
}
|
||||
+ if ( ev->atom == ctx->atoms.gamescopeRestoreFocusWindow )
|
||||
+ {
|
||||
+ // Anything outside (the session's watcher) can ask for the same restore: NormalState on the focus
|
||||
+ // window and focus handed to it again. Harmless on a window that is not iconic.
|
||||
+
|
||||
+
|
||||
+ if ( ctx->focus.focusWindow && get_prop( ctx, ctx->root, ctx->atoms.gamescopeRestoreFocusWindow, 0 ) )
|
||||
+ {
|
||||
+ xwm_log.infof( "restore requested for focus window 0x%lx", ctx->focus.focusWindow->xwayland().id );
|
||||
@@ -89,7 +89,7 @@ index 66022d7..af93a23 100644
|
||||
|
||||
bool isFullscreen = false;
|
||||
bool isSysTrayIcon = false;
|
||||
+ // The client asked to be iconified (WM_CHANGE_STATE) and has not been put back to NormalState since.
|
||||
+
|
||||
+ bool iconifyRequested = false;
|
||||
bool sizeHintsSpecified = false;
|
||||
bool skipTaskbar = false;
|
||||
|
||||
@@ -26,7 +26,7 @@ index f00b62c..cb3b9c6 100644
|
||||
|
||||
if (w && w->xwayland().id == ev.xmap.window)
|
||||
+ {
|
||||
+ // Wine flips override-redirect while unmapped and the flip itself sends no event.
|
||||
+
|
||||
+ w->xwayland().a.override_redirect = ev.xmap.override_redirect;
|
||||
map_win(ctx, ev.xmap.window, ev.xmap.serial);
|
||||
+ }
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
diff --git a/src/steamcompmgr.cpp b/src/steamcompmgr.cpp
|
||||
index 5b0e300..b9b07ca 100644
|
||||
--- a/src/steamcompmgr.cpp
|
||||
+++ b/src/steamcompmgr.cpp
|
||||
@@ -6875,10 +6875,19 @@ static bool steamcompmgr_should_vblank_window( bool bShouldLimitFPS, uint64_t vb
|
||||
{
|
||||
if ( g_nSteamCompMgrTargetFPS && bShouldLimitFPS && nRefreshHz > nTargetFPS )
|
||||
{
|
||||
- int nVblankDivisor = nRefreshHz / nTargetFPS;
|
||||
+ if ( w && now )
|
||||
+ {
|
||||
+ uint64_t schedule = w->last_commit_first_latch_time + g_SteamCompMgrLimitedAppRefreshCycle;
|
||||
+ if ( now + g_SteamCompMgrAppRefreshCycle / 2 < schedule )
|
||||
+ bSendCallback = false;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ int nVblankDivisor = nRefreshHz / nTargetFPS;
|
||||
|
||||
- if ( vblank_idx % nVblankDivisor != 0 )
|
||||
- bSendCallback = false;
|
||||
+ if ( vblank_idx % nVblankDivisor != 0 )
|
||||
+ bSendCallback = false;
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
GAMESCOPE_REPO=Droid-Deck/DroidDeck-Components
|
||||
GAMESCOPE_TAG=gamescope-3.16.29-p9
|
||||
GAMESCOPE_SHA256=7123a37bdbcd0d76d4bd1d7490e5d2017221e036395fdd48c1e92458594ca769
|
||||
GAMESCOPE_TAG=gamescope-3.16.29-p10
|
||||
GAMESCOPE_SHA256=e8e2433ae618458135ec271a30af7e80b282ff41f9931286e9bbad614838eca0
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
# Shared native ABI checks for CI and local builds.
|
||||
set -euo pipefail
|
||||
D=${1:?asset directory}
|
||||
NEED=$("${READELF:-readelf}" -d "$D/libfakeinput.so" | sed -n 's/.*NEEDED.*\[\(.*\)\]/\1/p')
|
||||
@@ -13,9 +12,6 @@ FAKE=$(syms "$D/libfakeinput.so")
|
||||
for sym in open openat ioctl read close poll ppoll select stat fstat access scandir; do
|
||||
grep -qx "$sym" <<<"$FAKE" || { echo "::error::libfakeinput.so does not export $sym"; exit 1; }
|
||||
done
|
||||
# The static C++ runtime stays private: every session process preloads this library,
|
||||
# and an exported personality routine takes over other programs' unwinding (shadPS4
|
||||
# aborted in pthread_exit).
|
||||
if grep -qxE '__gxx_personality_v0|__cxa_throw|_Unwind_Resume' <<<"$FAKE"; then
|
||||
echo "::error::libfakeinput.so exports the C++ runtime"; exit 1
|
||||
fi
|
||||
@@ -23,7 +19,6 @@ SESSION=$(syms "$D/libblsession.so")
|
||||
for sym in socket bind getsockname setsockopt statfs statvfs syscall shm_open shm_unlink mmap mmap64 munmap drmPrimeFDToHandle drmCloseBufferHandle; do
|
||||
grep -qx "$sym" <<<"$SESSION" || { echo "::error::libblsession.so does not export $sym"; exit 1; }
|
||||
done
|
||||
# Zink's GEM_CLOSE is caught at ioctl(); an exported drmIoctl made NMS replay old frames.
|
||||
if grep -qx drmIoctl <<<"$SESSION"; then
|
||||
echo "::error::libblsession.so exports drmIoctl"; exit 1
|
||||
fi
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
/* Android text -> Gamescope's Xwayland selection. Gamescope's Wayland backend does not
|
||||
* relay the outer compositor's clipboard. libX11 is loaded from the guest at runtime;
|
||||
* the small stable Xlib ABI below keeps this helper independent of cross X11 headers.
|
||||
* The private host file is atomically replaced, never put in session logs. */
|
||||
#define _GNU_SOURCE
|
||||
#include <sys/inotify.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -45,12 +41,9 @@ API(int, XConnectionNumber, (Display *));
|
||||
API(int, XCloseDisplay, (Display *));
|
||||
API(void *, XSetErrorHandler, (int (*)(Display *, void *)));
|
||||
|
||||
/* Stay below X11's normal maximum property request. Never paste a truncated command. */
|
||||
#define MAX_TEXT (64 * 1024)
|
||||
static int ignore_x_error(Display *d, void *event) { (void)d; (void)event; return 0; }
|
||||
|
||||
/* The host renames complete files into place. The inode distinguishes copying the same
|
||||
* text again after a guest program has taken ownership of the clipboard. */
|
||||
static int refresh(Display *d, Window w, Atom clipboard, const char *path,
|
||||
char **text, size_t *len, ino_t *inode) {
|
||||
int fd = open(path, O_RDONLY | O_CLOEXEC | O_NOFOLLOW);
|
||||
@@ -98,7 +91,7 @@ int main(int argc, char **argv) {
|
||||
LOAD(XSetErrorHandler);
|
||||
Display *d = XOpenDisplay(NULL);
|
||||
if (!d) { fprintf(stderr, "== clipboard: cannot open Xwayland\n"); return 1; }
|
||||
XSetErrorHandler(ignore_x_error); /* A paste requester can close its window at any time. */
|
||||
XSetErrorHandler(ignore_x_error);
|
||||
Window w = XCreateSimpleWindow(d, XDefaultRootWindow(d), 0, 0, 1, 1, 0, 0, 0);
|
||||
Atom clipboard = XInternAtom(d, "CLIPBOARD", 0);
|
||||
Atom targets = XInternAtom(d, "TARGETS", 0), utf8 = XInternAtom(d, "UTF8_STRING", 0);
|
||||
@@ -117,7 +110,7 @@ int main(int argc, char **argv) {
|
||||
for (;;) {
|
||||
while (XPending(d)) {
|
||||
Event e; XNextEvent(d, &e);
|
||||
if (e.type != 30) continue; /* SelectionRequest */
|
||||
if (e.type != 30) continue;
|
||||
SelectionRequest *r = &e.request;
|
||||
Atom property = r->property ? r->property : r->target;
|
||||
Event reply = {0};
|
||||
@@ -126,14 +119,13 @@ int main(int argc, char **argv) {
|
||||
size_t ascii; for (ascii = 0; ascii < len && (unsigned char)text[ascii] < 128; ascii++) {}
|
||||
if (r->target == targets) {
|
||||
Atom supported[] = {targets, utf8, plain, text_atom, string};
|
||||
XChangeProperty(d, r->requestor, property, 4 /* XA_ATOM */, 32, 0,
|
||||
XChangeProperty(d, r->requestor, property, 4 , 32, 0,
|
||||
(const unsigned char *)supported, ascii == len ? 5 : 4);
|
||||
reply.selection.property = property;
|
||||
} else if (r->target == utf8 || r->target == plain || r->target == text_atom) {
|
||||
XChangeProperty(d, r->requestor, property, utf8, 8, 0, (const unsigned char *)text, (int)len);
|
||||
reply.selection.property = property;
|
||||
} else if (r->target == string) {
|
||||
/* STRING is Latin-1. Offer it only for ASCII rather than corrupt UTF-8. */
|
||||
if (ascii == len) {
|
||||
XChangeProperty(d, r->requestor, property, string, 8, 0, (const unsigned char *)text, (int)len);
|
||||
reply.selection.property = property;
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
# The Debian 11 image the x86 preloads are compiled in (glibc 2.31, what Steam's Linux runtime
|
||||
# has). Published once by .github/workflows/ci-debian-image.yml to a release on this repo; the
|
||||
# build downloads it from there instead of pulling from a public registry mirror, whose
|
||||
# anonymous rate limit the shared runners keep hitting. Debian 11 is frozen upstream, so a
|
||||
# refresh is only ever a new -rN release with the three lines below updated.
|
||||
DEBIAN_IMAGE_TAG=ci-debian-bullseye-r1
|
||||
DEBIAN_IMAGE_ASSET=debian-bullseye.tar.zst
|
||||
DEBIAN_IMAGE_SHA256=5ac13c6b0f2e3ab3e8acc8cadcd39ee453a51a72870645d592635e24bcb85459
|
||||
@@ -1,91 +1,39 @@
|
||||
#!/bin/bash
|
||||
# The desktop session: KDE Plasma, set up as SteamOS's desktop mode - KWin nested as a client of the
|
||||
# app's compositor, Plasma's shell on it, and Xwayland for the X11 programs (the Steam client, most
|
||||
# emulators). Run by droiddeck-session in place of gamescope for mode "lxqt" (the mode's name from
|
||||
# the LXQt desktop this replaced; it is what the app and its preferences use).
|
||||
# Staged by the app over the desktop package's copy on every launch, so a fix here reaches an
|
||||
# installed desktop without re-downloading the package.
|
||||
set -u
|
||||
export XDG_SESSION_TYPE=wayland XDG_CURRENT_DESKTOP=KDE XDG_SESSION_DESKTOP=KDE DESKTOP_SESSION=plasma
|
||||
export KDE_FULL_SESSION=true KDE_SESSION_VERSION=6 KDE_APPLICATIONS_AS_SCOPE=0
|
||||
# Qt tries Wayland and falls back to X11 (Xwayland): an AppImage that bundles only Qt's xcb
|
||||
# plugin - melonDS - exits at once on a plain "wayland" ("Could not find the Qt platform plugin").
|
||||
export QT_QPA_PLATFORM="wayland;xcb" GDK_BACKEND=wayland,x11 SDL_VIDEODRIVER=wayland,x11
|
||||
unset QT_QPA_PLATFORMTHEME
|
||||
# KDE's programs log through Qt, which writes to the journal when stderr is not a terminal; there is
|
||||
# no journal here, so their messages go to the desktop log with everything else.
|
||||
export QT_FORCE_STDERR_LOGGING=1
|
||||
# SteamOS's /etc/profile.d/kde.sh.
|
||||
export MOZ_ENABLE_WAYLAND=1 MOZ_USE_XINPUT2=1
|
||||
# Konsole's profile starts the login shell, which it finds here.
|
||||
export SHELL=/bin/bash
|
||||
# Firefox's child processes sandbox themselves with seccomp and namespaces, neither of which
|
||||
# behaves under proot: the content process ends up unable to read the font files its parent can,
|
||||
# reports "no fonts" and dies - the tab crash, with the chrome around it still drawing text.
|
||||
# The prefs for this are only advisory and a profile can override them; the environment is not.
|
||||
export MOZ_DISABLE_CONTENT_SANDBOX=1 MOZ_DISABLE_GMP_SANDBOX=1 MOZ_DISABLE_RDD_SANDBOX=1
|
||||
export MOZ_DISABLE_SOCKET_PROCESS_SANDBOX=1 MOZ_DISABLE_UTILITY_SANDBOX=1
|
||||
# Firefox seals the size of the shared memory it hands a tab; on Android 16 (Galaxy S25/S26,
|
||||
# RedMagic) adding the seal fails, Firefox only warns, and the tab refuses the unsealed memory
|
||||
# ("Shared memory PlatformHandle is not safe to map") and dies on signal 11 - every page. Firefox's
|
||||
# own switch skips the seals. (#280; the line went missing in the fontconfig move of #252.)
|
||||
export MOZ_SHM_NO_SEALS=1
|
||||
# KWin composites in software (QPainter): its GPU path allocates through gbm on a DRM render node,
|
||||
# and the KGSL stand-in is not one. Its windows get shm buffers only, so GL programs on it draw with
|
||||
# Mesa's software rasterizer, Plasma's own Qt Quick draws with Qt's software renderer (plasmashell
|
||||
# crashes on llvmpipe here), and a Vulkan program cannot draw at all: games and emulators from the
|
||||
# menu run through droiddeck-gpu (their own gamescope on the app's compositor), and Steam goes back
|
||||
# to the app as a Steam session - SteamOS's "Return to Gaming Mode". The session's own GL choice
|
||||
# (zink on Turnip, for the Steam client) is put back by droiddeck-gpu.
|
||||
export KWIN_COMPOSE=Q QT_QUICK_BACKEND=software LIBGL_ALWAYS_SOFTWARE=1 GALLIUM_DRIVER=llvmpipe
|
||||
# mpv refuses that software GL and then fails its X11 fallback (an assertion): allowed it, it plays.
|
||||
[ -e /etc/mpv/mpv.conf ] || { mkdir -p /etc/mpv && echo gpu-sw=yes >/etc/mpv/mpv.conf; } 2>/dev/null
|
||||
export DROIDDECK_NESTED_SCALE=1
|
||||
export DROIDDECK_GLTHREAD=${mesa_glthread:-}
|
||||
unset MESA_LOADER_DRIVER_OVERRIDE LIBGL_KOPPER_DRI2 mesa_glthread
|
||||
# The desktop's own log, beside the session's, so KWin and the programs on it can be read apart
|
||||
# from the session that started them. The session log keeps the milestones either way.
|
||||
if [ -n "${BL_DEBUG_DIR:-}" ]; then
|
||||
mkdir -p "$BL_DEBUG_DIR" 2>/dev/null || true
|
||||
exec >>"$BL_DEBUG_DIR/desktop.log" 2>&1
|
||||
echo "== droiddeck-desktop $(date -u '+%Y-%m-%d %H:%M:%S UTC') ${BL_WIDTH:-1280}x${BL_HEIGHT:-720}"
|
||||
fi
|
||||
# The runtime directory outlives a session. KDE's daemons are single-instance programs that leave a
|
||||
# lock and a socket there; finding last session's, they decide they are already running and exit
|
||||
# without a word. Only the app's own compositor socket (wayland-0) is kept.
|
||||
find "$XDG_RUNTIME_DIR" -mindepth 1 -maxdepth 1 ! -name 'wayland-0*' ! -name 'keymap.xkb' -exec rm -rf {} + 2>/dev/null
|
||||
chmod 700 "$XDG_RUNTIME_DIR" 2>/dev/null
|
||||
# KWin will not start Xwayland when its socket directory is not sticky, as a shared /tmp would be,
|
||||
# and Plasma's session manager cannot listen at all without the ICE directory, which only root may
|
||||
# create for it.
|
||||
mkdir -p /tmp/.X11-unix /tmp/.ICE-unix && chmod 1777 /tmp/.X11-unix /tmp/.ICE-unix 2>/dev/null
|
||||
# Fontconfig defaults and Android language fallbacks are set up by droiddeck-session before this
|
||||
# script or any desktop program starts.
|
||||
# The menu's "Steam" / "Steam Big Picture" entries and one entry per installed game: all of them
|
||||
# hand off to the app (droiddeck-steam-launch), since the client cannot draw on this desktop.
|
||||
export BL_DESKTOP=1
|
||||
ln -sf /usr/local/bin/droiddeck-steam-launch /usr/local/bin/steamdeck-steam 2>/dev/null
|
||||
ln -sf /usr/local/bin/droiddeck-steam-shim /usr/local/bin/steam 2>/dev/null
|
||||
python3 /usr/local/bin/droiddeck-desktop-games 2>&1 | sed 's/^/[games] /'
|
||||
# Player 1 on the controller in every emulator that has no profile of its own yet - now, and again
|
||||
# every half minute: an emulator started for the first time writes its own config, which is then
|
||||
# given the controller for its next start without waiting for the next desktop.
|
||||
python3 /usr/local/bin/droiddeck-pad-defaults 2>&1 | sed 's/^/[pads] /'
|
||||
( while sleep 30; do python3 /usr/local/bin/droiddeck-pad-defaults 2>&1 | sed 's/^/[pads] /'; done ) &
|
||||
# Games and emulators from the menu run through droiddeck-gpu; BL_DESKTOP_GPU=on/off overrides,
|
||||
# and each entry keeps "Run in a desktop window" either way.
|
||||
python3 /usr/local/bin/droiddeck-desktop-gpu 2>&1 | sed 's/^/[gpu] /'
|
||||
# The windowed action still opens melonDS at the size/placement the LXQt desktop used.
|
||||
/usr/local/bin/droiddeck-desktop-window-rules 2>&1 | sed 's/^/[rules] /'
|
||||
# Windows programs, Linux programs, AppImages and scripts open with droiddeck-open (Steam's Proton,
|
||||
# FEX for x86); an exec the kernel refuses is handed to it as well (libblsession's binfmt.c). An
|
||||
# AppImage run directly cannot mount itself under proot, so it unpacks itself to run.
|
||||
python3 /usr/local/bin/droiddeck-open --install 2>&1 | sed 's/^/[open] /'
|
||||
export APPIMAGE_EXTRACT_AND_RUN=1
|
||||
# A click runs an executable script or program without KIO asking first; Dolphin's settings can still ask.
|
||||
[ -e /etc/xdg/kiorc ] || printf '[Executable scripts]\nbehaviourOnLaunch=execute\n' >/etc/xdg/kiorc 2>/dev/null
|
||||
# SteamOS's desktop icons: Return to Gaming Mode and Steam, put there once - what the user moves
|
||||
# or deletes stays that way.
|
||||
desktop_dir=$(xdg-user-dir DESKTOP 2>/dev/null); [ -n "$desktop_dir" ] && [ "$desktop_dir" != "$HOME" ] || desktop_dir=$HOME/Desktop
|
||||
if [ ! -e "$HOME/.config/droiddeck-desktop-icons" ]; then
|
||||
mkdir -p "$desktop_dir" "$HOME/.config"
|
||||
@@ -94,23 +42,16 @@ if [ ! -e "$HOME/.config/droiddeck-desktop-icons" ]; then
|
||||
chmod +x "$desktop_dir"/*.desktop 2>/dev/null
|
||||
touch "$HOME/.config/droiddeck-desktop-icons"
|
||||
fi
|
||||
# A Return icon still there is kept current with the package's entry (what it runs has changed).
|
||||
[ -f "$desktop_dir/Return.desktop" ] && cp -f /usr/share/applications/droiddeck-return-gaming.desktop "$desktop_dir/Return.desktop" 2>/dev/null
|
||||
# Plasma's caches of the menu, the icons and the MIME types, which a package install never ran.
|
||||
update-mime-database /usr/share/mime >/dev/null 2>&1 &
|
||||
[ -f /usr/share/icons/hicolor/icon-theme.cache ] || gtk-update-icon-cache -q -t /usr/share/icons/hicolor 2>/dev/null &
|
||||
[ -f /usr/share/glib-2.0/schemas/gschemas.compiled ] || glib-compile-schemas /usr/share/glib-2.0/schemas 2>/dev/null
|
||||
# In debug runs Firefox (started from the panel or the menu, so it inherits this) writes its
|
||||
# own network log: name lookups, connects, HTTP transactions, the link/offline decisions.
|
||||
if [ -f "$HOME/.droiddeck-desktop-debug" ]; then
|
||||
mkdir -p "$HOME/.cache/droiddeck"
|
||||
export MOZ_LOG="nsHttp:3,nsSocketTransport:3,nsHostResolver:4,NetworkLinkService:5,NetworkConnectivityService:5,nsIOService:5"
|
||||
export MOZ_LOG_FILE="$HOME/.cache/droiddeck/firefox-net.log"
|
||||
export QT_LOGGING_RULES="kwin_*.debug=true"
|
||||
fi
|
||||
# Remote runs, for driving the desktop from a debugger: with ~/.droiddeck-remote-run present (only
|
||||
# the app or root can create it), each script dropped into ~/.cache/droiddeck/run/ is run once,
|
||||
# inside the session with its environment, its output tagged into the desktop log.
|
||||
if [ -f "$HOME/.droiddeck-remote-run" ]; then
|
||||
mkdir -p "$HOME/.cache/droiddeck/run"
|
||||
(
|
||||
@@ -123,18 +64,10 @@ if [ -f "$HOME/.droiddeck-remote-run" ]; then
|
||||
done
|
||||
) &
|
||||
fi
|
||||
# Plasma as its own login starts it: startplasma-wayland sets up the session's environment and runs
|
||||
# plasma_session, which starts KWin (through kwin_wayland_wrapper, ours first on PATH) as a client of
|
||||
# the app's compositor with its own Xwayland, then Plasma's daemons, shell and autostart entries on
|
||||
# it. The session bus is ours: Plasma, the file manager and the portal all expect one.
|
||||
echo "== droiddeck-desktop: Plasma on $WAYLAND_DISPLAY"
|
||||
dbus-run-session -- startplasma-wayland
|
||||
rc=$?
|
||||
echo "== droiddeck-desktop: Plasma ended ($rc)"
|
||||
# Plasma logged out - Log Out, or Return to Gaming Mode, which logs out the same way, so open windows
|
||||
# are asked to close (and to save) first. As on SteamOS, leaving the desktop goes to Gaming Mode: the
|
||||
# app is asked for a Steam session, and it ends this one to start it. A desktop the app stops never
|
||||
# gets here; a Plasma that failed does not count as a logout.
|
||||
if [ "$rc" -eq 0 ]; then
|
||||
/usr/local/bin/droiddeck-steam-launch bigpicture
|
||||
sleep 30
|
||||
|
||||
@@ -1,24 +1,13 @@
|
||||
#!/usr/bin/python3
|
||||
# The desktop's games and emulators, started on the GPU. Every menu entry whose categories say
|
||||
# Game or Emulator gets a copy of its own in ~/.local/share/applications (which wins over
|
||||
# /usr/share/applications) whose Exec runs it through droiddeck-gpu: full screen on the app's
|
||||
# compositor, where Vulkan and OpenGL work. The entry keeps the old way as a second action, "Run in
|
||||
# a desktop window". Run at every desktop start; copies whose original is gone, or all of them when
|
||||
# the switch is off, are removed.
|
||||
#
|
||||
# BL_DESKTOP_GPU=on (default: the desktop composites in software) | off
|
||||
import os
|
||||
import re
|
||||
|
||||
HOME = os.environ.get("HOME", "/root")
|
||||
SYSTEM_DIR = "/usr/share/applications"
|
||||
# The user's own AppImages (the front end's Add AppImage).
|
||||
LOCAL_DIR = "/usr/local/share/applications"
|
||||
# Flathub's games, as Flatpak exports them; the copies here win over these as they do over the system's.
|
||||
FLATPAK_DIR = os.path.join(HOME, ".local/share/flatpak/exports/share/applications")
|
||||
USER_DIR = os.path.join(HOME, ".local/share/applications")
|
||||
MARK = "X-DroidDeck-GPU=1"
|
||||
# The client and its games already hand themselves to the app (droiddeck-steam-launch).
|
||||
SKIP = re.compile(r"^(steam|droiddeck-game-|droiddeck-steam|steamdeck-)", re.I)
|
||||
|
||||
|
||||
@@ -76,7 +65,6 @@ def wrap(text):
|
||||
out_group.append("Actions=" + ("droiddeck-window;" + actions if actions else "droiddeck-window;"))
|
||||
out_group.append(MARK)
|
||||
window = ["", "[Desktop Action droiddeck-window]", "Name=Run in a desktop window", "Exec=" + exec_line]
|
||||
# The entry's own actions (new window, a different mode...) run on the GPU as well.
|
||||
wrapped_rest = []
|
||||
for l in rest:
|
||||
if l.startswith("Exec=") and not l[5:].startswith("droiddeck-gpu "):
|
||||
@@ -105,7 +93,6 @@ def main():
|
||||
if not name.endswith(".desktop") or SKIP.match(name):
|
||||
continue
|
||||
target = os.path.join(USER_DIR, name)
|
||||
# A copy the user made or edited themselves is theirs.
|
||||
if os.path.exists(target) and not ours(target):
|
||||
continue
|
||||
try:
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
#!/bin/bash
|
||||
# Runs a program from the desktop on the GPU: in a gamescope of its own that draws straight into
|
||||
# the app's compositor (wayland-0), not inside the desktop's KWin. KWin composites in software, and
|
||||
# gives its windows no DMA-BUFs - a Vulkan program there fails at its swapchain
|
||||
# (VK_ERROR_SURFACE_LOST, RPCS3's error). Here it gets the same path as a program started from the
|
||||
# app's rail: full screen over the desktop until it exits, then the desktop is back.
|
||||
# droiddeck-gpu <program> [args...]
|
||||
set -u
|
||||
[ $# -gt 0 ] || { echo "usage: droiddeck-gpu <program> [args...]" >&2; exit 64; }
|
||||
if [ -n "${BL_DEBUG_DIR:-}" ]; then
|
||||
@@ -20,16 +14,11 @@ elif [ "${BL_REFRESH:-0}" -gt 0 ]; then
|
||||
fi
|
||||
[ "${BL_HDR:-0}" = 1 ] && args+=(--hdr-enabled)
|
||||
echo "== droiddeck-gpu $(date -u +%H:%M:%S): $* (gamescope ${width}x${height} on wayland-0)"
|
||||
# gamescope is a client of the app's compositor, beside the desktop's KWin; the program inside it reaches it
|
||||
# through gamescope's own Xwayland, as in a Steam session.
|
||||
export WAYLAND_DISPLAY=wayland-0
|
||||
export GDK_BACKEND=x11 QT_QPA_PLATFORM=xcb SDL_VIDEODRIVER=x11
|
||||
# GL on the GPU again (zink on Turnip, as the session sets it): the desktop itself draws GL in software.
|
||||
# Qt Quick back on its GPU renderer and KWin's software compositing not passed on, too.
|
||||
unset LIBGL_ALWAYS_SOFTWARE QT_QUICK_BACKEND KWIN_COMPOSE
|
||||
export MESA_LOADER_DRIVER_OVERRIDE=zink GALLIUM_DRIVER=zink LIBGL_KOPPER_DRI2=true
|
||||
[ -n "${DROIDDECK_GLTHREAD:-}" ] && export mesa_glthread=$DROIDDECK_GLTHREAD
|
||||
# AppImages cannot mount under proot; the menu entries already say so, a hand-typed one may not.
|
||||
export APPIMAGE_EXTRACT_AND_RUN=1
|
||||
gamescope "${args[@]}" -- /usr/local/bin/droiddeck-gpu-window "$@"
|
||||
rc=$?
|
||||
|
||||
@@ -1,17 +1,9 @@
|
||||
// Firefox defaults for the DroidDeck desktop, staged by the app into
|
||||
// /usr/lib/firefox/defaults/pref/. A user's own prefs.js still wins.
|
||||
|
||||
// Firefox judges "online" by dumping the routing table over netlink, which Android denies to
|
||||
// apps; seeing no default route it switches itself to Work Offline and every page fails while
|
||||
// the network is fine. Let it just try.
|
||||
pref("network.manage-offline-status", false);
|
||||
pref("browser.offline", false);
|
||||
// No user namespaces on Android kernels and a ptrace'd process tree: the process sandboxes
|
||||
// have nothing to set up and only add failure modes.
|
||||
pref("security.sandbox.content.level", 0);
|
||||
pref("media.cubeb.sandbox", false);
|
||||
pref("security.sandbox.socket.process.level", 0);
|
||||
// Handheld-sized chrome, and nothing phoning home on first run.
|
||||
pref("browser.shell.checkDefaultBrowser", false);
|
||||
pref("datareporting.policy.dataSubmissionEnabled", false);
|
||||
pref("browser.aboutwelcome.enabled", false);
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
#!/bin/bash
|
||||
# KWin for the desktop. Plasma's session (plasma_session) starts KWin through kwin_wayland_wrapper as
|
||||
# found on PATH; this one, first on it, has KWin draw into the app's compositor (wayland-0) and serve
|
||||
# its own clients on wayland-1 - by default it takes wayland-0 and finds the app's lock on it - with
|
||||
# its nested output at the app's surface size (left alone, a 1024x768 window the desktop is scaled
|
||||
# from), and without the lock screen, which the app's own suspend stands in for. Anything else (a KWin
|
||||
# started outside DroidDeck's desktop) gets the real wrapper as it is.
|
||||
if [ "${BL_DESKTOP:-}" = 1 ]; then
|
||||
set -- --wayland-display wayland-0 --socket wayland-1 --width "${BL_WIDTH:-1280}" --height "${BL_HEIGHT:-720}" --no-lockscreen "$@"
|
||||
fi
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
#!/bin/sh
|
||||
# No Deck BIOS here. The client calls this in Deck mode; a clean exit is "nothing to do".
|
||||
exit 0
|
||||
@@ -1,3 +1,2 @@
|
||||
#!/bin/sh
|
||||
# No Deck BIOS here. The client calls this in Deck mode; a clean exit is "nothing to do".
|
||||
exit 0
|
||||
@@ -1,8 +1,4 @@
|
||||
#!/bin/sh
|
||||
# No Deck dock here. The client runs this with --check at start (systemdockmanager.txt) and reads
|
||||
# the exit code: 0 with nothing printed is taken as "an update is available" and puts a Dock
|
||||
# Firmware Update row with an Apply button in Settings > System. 7, SteamOS's "nothing to do",
|
||||
# is read as up to date (state 2 in that log, against state 4 for exit 0; both seen on device).
|
||||
case "${1:-}" in
|
||||
--check) exit 7 ;;
|
||||
esac
|
||||
|
||||
@@ -1,6 +1,2 @@
|
||||
#!/bin/sh
|
||||
# steamos-priv-write <path> <value>: how the client in Deck mode sets brightness, TDP and fan
|
||||
# controls through sysfs. None of those paths is writable from an app on Android, and the app
|
||||
# already sets the panel's mode and the game-tier power policy from the Android side. Accept
|
||||
# and do nothing, so the client never logs a failed helper.
|
||||
exit 0
|
||||
@@ -1,8 +1,4 @@
|
||||
#!/bin/sh
|
||||
# The SteamOS update-branch selector the client calls in Deck mode. The session forces the client
|
||||
# branch on the command line and keeps package/beta in step with it, so a selection here would
|
||||
# only start the restart loop the session script describes. List and report the stable branch;
|
||||
# accept and ignore a choice.
|
||||
case "${1:-}" in
|
||||
-l) printf 'rel\n' ;;
|
||||
-c) printf 'rel\n' ;;
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
#!/bin/sh
|
||||
# The session carries the device's time zone in TZ already; the client's own setter is a no-op.
|
||||
exit 0
|
||||
@@ -1,8 +1,4 @@
|
||||
#!/bin/sh
|
||||
# What the Steam client calls in Deck mode (from /usr/bin/steamos-polkit-helpers/, seen in its
|
||||
# console log on device; a copy sits in /usr/bin as well) to look for a SteamOS update. There is no SteamOS
|
||||
# here: the answer is "no update", which is exit 7 in SteamOS's convention, and the client moves
|
||||
# on. --supports-duplicate-detection is a capability probe and answers yes. Staged from the apk.
|
||||
case "${1:-}" in
|
||||
--supports-duplicate-detection) exit 0 ;;
|
||||
esac
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
#!/bin/sh
|
||||
# The SteamOS update-branch selector the client calls in Deck mode. The session forces the client
|
||||
# branch on the command line and keeps package/beta in step with it, so a selection here would
|
||||
# only start the restart loop the session script describes. List and report the stable branch;
|
||||
# accept and ignore a choice.
|
||||
case "${1:-}" in
|
||||
-l) printf 'rel\n' ;;
|
||||
-c) printf 'rel\n' ;;
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
#!/bin/sh
|
||||
# The SteamOS session switch. Big Picture's power menu runs it for "Switch to Desktop" (a Plasma
|
||||
# session: "plasma", "plasma-wayland-persistent", ...) and waits for Game Mode to end; with nothing
|
||||
# here it sat on "Switching to Desktop..." for ever. Here the desktop is DroidDeck's own: the app is
|
||||
# asked for a desktop session with Steam's desktop client open in it (the request file
|
||||
# droiddeck-steam-launch uses; the app ends this session and starts that one). Anything else -
|
||||
# "gamescope", the session Game Mode already is - has nothing to do.
|
||||
echo "steamos-session-select: $*" >&2
|
||||
case "${1:-}" in
|
||||
""|gamescope) exit 0 ;;
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
#!/bin/sh
|
||||
# What the Steam client calls in Deck mode to look for a SteamOS update. There is no SteamOS
|
||||
# here: the answer is "no update", which is exit 7 in SteamOS's convention, and the client moves
|
||||
# on. --supports-duplicate-detection is a capability probe and answers yes. Staged from the apk.
|
||||
case "${1:-}" in
|
||||
--supports-duplicate-detection) exit 0 ;;
|
||||
esac
|
||||
|
||||
@@ -68,7 +68,6 @@ class AgentError(Exception):
|
||||
self.code = code
|
||||
|
||||
|
||||
# --- X11: just enough of the protocol for root properties, the window tree and events ---------
|
||||
|
||||
class X:
|
||||
"""One connection to an Xwayland server. The rootfs has xprop but no python X library."""
|
||||
@@ -266,7 +265,7 @@ class FocusWatcher(threading.Thread):
|
||||
while True:
|
||||
self.changed.wait(timeout=5)
|
||||
self.changed.clear()
|
||||
time.sleep(0.2) # let a burst of property changes settle
|
||||
time.sleep(0.2)
|
||||
try:
|
||||
snap = focus_snapshot()
|
||||
except (OSError, AgentError) as e:
|
||||
@@ -286,9 +285,7 @@ class FocusWatcher(threading.Thread):
|
||||
try:
|
||||
x = X(os.environ["DISPLAY"])
|
||||
wanted = {x.atom(name) for name in FOCUS_PROPS}
|
||||
x.select(x.root, 0x400000) # PropertyChangeMask
|
||||
# Waits for events as long as there are none: the connect timeout left in place
|
||||
# here dropped and remade the connection, and took a snapshot, every few seconds.
|
||||
x.select(x.root, 0x400000)
|
||||
x.s.settimeout(None)
|
||||
self.changed.set()
|
||||
while True:
|
||||
@@ -300,7 +297,6 @@ class FocusWatcher(threading.Thread):
|
||||
time.sleep(2)
|
||||
|
||||
|
||||
# --- Steam client DevTools (CDP) -----------------------------------------------------------------
|
||||
|
||||
class WebSocket:
|
||||
"""A minimal RFC 6455 client: text frames out, text frames in. Enough for CDP."""
|
||||
@@ -384,7 +380,7 @@ class WebSocket:
|
||||
op = b0 & 0x0F
|
||||
if op == 8:
|
||||
raise OSError("DevTools closed the WebSocket")
|
||||
if op == 9: # ping
|
||||
if op == 9:
|
||||
continue
|
||||
if op in (0, 1, 2):
|
||||
message += data
|
||||
@@ -453,7 +449,34 @@ def cdp_eval(agent_dir, expression, target=None, await_promise=True, timeout=15)
|
||||
ws.close()
|
||||
|
||||
|
||||
# --- Game processes ------------------------------------------------------------------------------
|
||||
def steam_selection(agent_dir, timeout=5):
|
||||
result = cdp_eval(
|
||||
agent_dir,
|
||||
"""(() => {
|
||||
let node = document.activeElement;
|
||||
while (node) {
|
||||
for (const name of ["data-id", "data-appid"]) {
|
||||
const value = node.getAttribute?.(name);
|
||||
if (/^[1-9][0-9]{0,9}$/.test(value || "")) {
|
||||
const appId = Number(value);
|
||||
if (Number.isSafeInteger(appId) && appId <= 4294967295) return value;
|
||||
}
|
||||
}
|
||||
node = node.parentElement;
|
||||
}
|
||||
return null;
|
||||
})()""",
|
||||
target="Steam Big Picture Mode",
|
||||
timeout=timeout,
|
||||
)
|
||||
value = result.get("value")
|
||||
if value is None:
|
||||
return {"appId": None}
|
||||
if not isinstance(value, str) or not value.isdigit() or not 0 < int(value) <= 4294967295:
|
||||
raise AgentError("INVALID_SELECTION", "Steam returned an invalid selected app id")
|
||||
return {"appId": int(value)}
|
||||
|
||||
|
||||
|
||||
def game_pids(app_id):
|
||||
"""Our processes started for this Steam app (Steam sets SteamAppId / SteamGameId in their
|
||||
@@ -510,7 +533,38 @@ def quit_game(agent_dir, app_id, timeout):
|
||||
return {"appId": int(app_id), "steps": steps, "remaining": game_pids(app_id)}
|
||||
|
||||
|
||||
# --- Requests ------------------------------------------------------------------------------------
|
||||
|
||||
VR_HELPER = "/usr/local/bin/droiddeck-steamvr"
|
||||
VR_ACTIONS = ("status", "install", "start", "stop")
|
||||
|
||||
|
||||
def steamvr(req):
|
||||
"""Cardboard mode's SteamVR: a fixed helper with four actions, unlike exec (no command line from
|
||||
the request). install downloads 571 MB, so it runs detached and status reports it."""
|
||||
action = req.get("action", "status")
|
||||
if action not in VR_ACTIONS:
|
||||
raise AgentError("INVALID_REQUEST", "vr action must be one of " + ", ".join(VR_ACTIONS))
|
||||
helper = os.environ.get("DROIDDECK_VR_HELPER", VR_HELPER)
|
||||
if not os.path.isfile(helper):
|
||||
raise AgentError("UNAVAILABLE", "this runtime has no " + helper)
|
||||
if action == "install":
|
||||
state = Path(os.environ.get("XDG_RUNTIME_DIR", "/tmp")) / "droiddeck-steamvr"
|
||||
state.mkdir(parents=True, exist_ok=True)
|
||||
with open(state / "install.log", "ab") as log_file:
|
||||
subprocess.Popen(["sh", helper, "install"], stdin=subprocess.DEVNULL, stdout=log_file,
|
||||
stderr=subprocess.STDOUT, start_new_session=True)
|
||||
return {"action": action, "started": True}
|
||||
done = subprocess.run(["sh", helper, action], stdin=subprocess.DEVNULL, capture_output=True,
|
||||
timeout=request_timeout(req, 30))
|
||||
out = done.stdout.decode("utf-8", "replace").strip()
|
||||
result = {"action": action, "exitCode": done.returncode, "output": out[-2000:]}
|
||||
if action == "status":
|
||||
for part in out.split():
|
||||
key, _, value = part.partition("=")
|
||||
if key in ("installed", "running", "installing", "driver"):
|
||||
result[key] = value == "1"
|
||||
return result
|
||||
|
||||
|
||||
def run_exec(req):
|
||||
argv = req.get("argv")
|
||||
@@ -624,8 +678,12 @@ def handle(agent_dir, req):
|
||||
raise AgentError("INVALID_REQUEST", "cdp eval needs an expression")
|
||||
return cdp_eval(agent_dir, expression, req.get("target"), bool(req.get("awaitPromise", True)),
|
||||
request_timeout(req, 15))
|
||||
if kind == "steam-selection":
|
||||
return steam_selection(agent_dir, request_timeout(req, 5))
|
||||
if kind == "quit":
|
||||
return quit_game(agent_dir, req.get("appId"), request_timeout(req, 15))
|
||||
if kind == "vr":
|
||||
return steamvr(req)
|
||||
raise AgentError("UNKNOWN_REQUEST", "Unknown agent request '%s'" % kind)
|
||||
|
||||
|
||||
@@ -652,7 +710,7 @@ def answer(agent_dir, path):
|
||||
result = dict(handle(agent_dir, req), ok=True)
|
||||
except AgentError as e:
|
||||
result = {"ok": False, "error": {"code": e.code, "message": str(e)}}
|
||||
except Exception as e: # an answer of some kind always goes back
|
||||
except Exception as e:
|
||||
result = {"ok": False, "error": {"code": "AGENT_FAILED", "message": "%s: %s" % (type(e).__name__, e)}}
|
||||
write_json(agent_dir / "resp" / (rid + ".json"), result)
|
||||
|
||||
|
||||
@@ -1,33 +1,17 @@
|
||||
#!/bin/bash
|
||||
# An AppImage imported from the front end (AppImageManager), extracted once at import into
|
||||
# /opt/appimages/user/<id>/app
|
||||
# and started from there: proot has no FUSE to mount the image, and extracting it at every
|
||||
# start (APPIMAGE_EXTRACT_AND_RUN) would cost the whole image in /tmp each time.
|
||||
# droiddeck-appimage-run /opt/appimages/user/<id> [args...]
|
||||
set -u
|
||||
dir=${1:?usage: droiddeck-appimage-run <imported AppImage directory> [args...]}
|
||||
shift
|
||||
export APPDIR=$dir/app
|
||||
# APPIMAGE is left unset on purpose: with it an app believes it runs from an image file and offers
|
||||
# to add itself to the menu (DuckStation) or update the file in place - DroidDeck already does the
|
||||
# one, and there is no image file for the other.
|
||||
unset APPIMAGE
|
||||
export ARGV0=$(cat "$dir/name" 2>/dev/null || basename "$dir")
|
||||
if [ ! -x "$APPDIR/AppRun" ]; then
|
||||
echo "droiddeck-appimage-run: $APPDIR/AppRun is missing; import the AppImage again" >&2
|
||||
exit 127
|
||||
fi
|
||||
# Browsers sandbox their own children with namespaces and a setuid helper, neither of which proot
|
||||
# can give them (the Flatpak sandboxes get the same; see BwrapSpawner): Firefox and its forks (Zen,
|
||||
# LibreWolf) by these switches, Electron and Chromium builds by --no-sandbox. Chromium on Wayland
|
||||
# also asks the render node for a DRM version KGSL cannot give, so with an X server up it stays on
|
||||
# X11, which it picks from the session type.
|
||||
export MOZ_DISABLE_CONTENT_SANDBOX=1 MOZ_DISABLE_GMP_SANDBOX=1 MOZ_DISABLE_RDD_SANDBOX=1
|
||||
export MOZ_DISABLE_SOCKET_PROCESS_SANDBOX=1 MOZ_DISABLE_UTILITY_SANDBOX=1
|
||||
# Android 16 refuses Firefox the size seal on a tab's shared memory; see droiddeck-desktop.
|
||||
export MOZ_SHM_NO_SEALS=1
|
||||
# sharun images start the app through their own ld.so, patched not to read /etc/ld.so.preload, and
|
||||
# drop LD_PRELOAD unless allowed: without this the app never gets the session's pads.
|
||||
if [ -s /etc/ld.so.preload ]; then
|
||||
preload=$(tr -s '\n' ':' < /etc/ld.so.preload)
|
||||
export LD_PRELOAD="${preload%:}${LD_PRELOAD:+:$LD_PRELOAD}" SHARUN_ALLOW_LD_PRELOAD=1
|
||||
@@ -74,8 +58,6 @@ fi
|
||||
echo "== appimage $ARGV0 ($APPDIR) ${flags[*]} FEX $fex Qt $qt${QT_QPA_PLATFORM:+ ($QT_QPA_PLATFORM)}"
|
||||
cd "$APPDIR" || exit 1
|
||||
started=$(mktemp "${TMPDIR:-/tmp}/droiddeck-appimage.XXXXXX")
|
||||
# Apps expect a session bus; Electron's main process traps (SIGTRAP) on an address it cannot
|
||||
# parse. A run mode has none, so one is started for the app, as for Flatpak apps.
|
||||
case ${DBUS_SESSION_BUS_ADDRESS:-} in
|
||||
unix:*) "${run[@]}" "${flags[@]}" "$@" ;;
|
||||
*) unset DBUS_SESSION_BUS_ADDRESS
|
||||
@@ -100,10 +82,6 @@ if [ "$rc" -ne 0 ] && [ -n "$started" ]; then
|
||||
done
|
||||
fi
|
||||
rm -f "$started"
|
||||
# The program a session was started for may hand over to another process and exit: Electron apps
|
||||
# relaunch themselves (Obsidian on its first start), launchers fork their real program. The
|
||||
# session ends with this script, and takes the rest with it - so it waits while anything running
|
||||
# from the image is still up.
|
||||
image_running() {
|
||||
local p exe arg cwd
|
||||
for p in /proc/[0-9]*; do
|
||||
|
||||
@@ -1,17 +1,4 @@
|
||||
#!/usr/bin/python3
|
||||
# bubblewrap for Flatpak (FLATPAK_BWRAP), in a runtime that cannot have it.
|
||||
#
|
||||
# bwrap builds each sandbox from mount namespaces, which Android gives no app. proot gives the same
|
||||
# picture - Flatpak's runtime as /usr, the app as /app, host paths bound where Flatpak asks - but a
|
||||
# proot nested inside the session's proot runs every system call through two tracers, some thirty
|
||||
# times slower on a program's start. So a sandbox is described to the app instead, over a socket
|
||||
# only this app's uid may use, and the app starts it as a proot of its own beside the session's
|
||||
# (BwrapSpawner). This process stands in for the sandbox until it ends: its output, its pid for
|
||||
# --info-fd, and its exit status come back here.
|
||||
#
|
||||
# Sandboxes that remap nothing - Flatpak's install triggers (`--ro-bind / /` and the directory they
|
||||
# update) and the D-Bus proxy (every top-level directory bound onto itself) - need no proot at all
|
||||
# and run here directly, with the file descriptors Flatpak handed them.
|
||||
import base64
|
||||
import json
|
||||
import os
|
||||
@@ -20,10 +7,9 @@ import socket
|
||||
import struct
|
||||
import sys
|
||||
|
||||
SOCKET = "\0com.droiddeck.launcher.bwrap"
|
||||
SOCKET = "\0" + os.environ.get("DROIDDECK_BWRAP_SOCKET", "com.droiddeck.launcher.bwrap")
|
||||
VERSION = "bubblewrap 0.11.0 (droiddeck)"
|
||||
|
||||
# Options and how many arguments each takes; bwrap(1).
|
||||
NO_ARG = {
|
||||
"--unshare-user", "--unshare-user-try", "--unshare-ipc", "--unshare-pid", "--unshare-net",
|
||||
"--unshare-uts", "--unshare-cgroup", "--unshare-cgroup-try", "--unshare-all", "--share-net",
|
||||
@@ -68,7 +54,6 @@ def expand(argv):
|
||||
a = argv[i]
|
||||
if a == "--args" and i + 1 < len(argv):
|
||||
data = read_fd(int(argv[i + 1]))
|
||||
# Each argument ends in a NUL; an empty one (--setenv LD_LIBRARY_PATH "") is kept.
|
||||
parts = data.split(b"\0")
|
||||
if parts and parts[-1] == b"":
|
||||
parts.pop()
|
||||
@@ -155,7 +140,6 @@ def parse(argv):
|
||||
elif a == "--dev":
|
||||
s.ops.append({"t": "dev", "dest": args[0]})
|
||||
elif a in ("--seccomp", "--add-seccomp-fd"):
|
||||
# proot is the sandbox; there is no filter to install under it.
|
||||
os.close(int(args[0]))
|
||||
elif a == "--block-fd":
|
||||
read_fd(int(args[0]))
|
||||
@@ -165,8 +149,6 @@ def parse(argv):
|
||||
s.info_fds.append(int(args[0]))
|
||||
elif a == "--json-status-fd":
|
||||
s.json_fds.append(int(args[0]))
|
||||
# Everything else - namespaces, capabilities, labels, locks, --remount-ro, --chmod - has
|
||||
# nothing to act on under proot.
|
||||
if not s.command:
|
||||
sys.stderr.write("bwrap: No command specified\n")
|
||||
sys.exit(1)
|
||||
@@ -196,7 +178,6 @@ def remaps_nothing(s):
|
||||
if not os.path.islink(op["dest"]) or os.readlink(op["dest"]) != op["target"]:
|
||||
return False
|
||||
elif t == "file":
|
||||
# The D-Bus proxy's /.flatpak-info names the app to the bus; nothing here reads it.
|
||||
if op["dest"] != "/.flatpak-info":
|
||||
return False
|
||||
elif t == "dir":
|
||||
@@ -258,7 +239,6 @@ def run_by_app(s):
|
||||
for op in s.ops:
|
||||
op = dict(op)
|
||||
if op["t"] == "bind":
|
||||
# The app resolves no guest symlinks; hand it the path they lead to.
|
||||
op["src"] = real(op["src"])
|
||||
if op["t"] == "file":
|
||||
op["data"] = base64.b64encode(op["data"]).decode()
|
||||
@@ -274,7 +254,6 @@ def run_by_app(s):
|
||||
sys.stderr.write("bwrap: DroidDeck is not answering (%s); open DroidDeck and try again\n" % e)
|
||||
sys.exit(1)
|
||||
send(sock, b"R", json.dumps(request).encode())
|
||||
# This process is the sandbox as far as Flatpak is concerned: ended, it takes the sandbox down.
|
||||
for sig in (signal.SIGTERM, signal.SIGINT, signal.SIGHUP):
|
||||
signal.signal(sig, lambda *_: os._exit(128 + 15))
|
||||
status = 1
|
||||
|
||||
@@ -29,7 +29,7 @@ def steam_libraries(home, data):
|
||||
try:
|
||||
selected = {Path(e["path"]): str(e["label"]) for e in json.loads(Path(listing).read_text())}
|
||||
except (OSError, ValueError, KeyError, TypeError):
|
||||
pass # Fall back to the client's registered libraries if the app's list is unreadable.
|
||||
pass
|
||||
vdf = steam / "steamapps/libraryfolders.vdf"
|
||||
if vdf.is_file():
|
||||
parser = runpy.run_path(str(Path(__file__).with_name("droiddeck-steam-ui-scale")))
|
||||
@@ -76,7 +76,6 @@ def update_places(path, libraries):
|
||||
else:
|
||||
if not libraries:
|
||||
return
|
||||
# Leave KDE's file version unset so it still adds its normal Home/Downloads/etc. places.
|
||||
root = ET.Element("xbel", {"version": "1.0"})
|
||||
before = ET.tostring(root)
|
||||
seen = set()
|
||||
@@ -112,7 +111,6 @@ def update_places(path, libraries):
|
||||
|
||||
|
||||
def bookmarks_file(home, config):
|
||||
# libfm-qt reads GTK3 bookmarks first, falling back to the legacy file when empty.
|
||||
current = config / "gtk-3.0/bookmarks"
|
||||
legacy = home / ".gtk-bookmarks"
|
||||
if current.is_file() and current.read_text(errors="surrogateescape").strip():
|
||||
@@ -153,7 +151,6 @@ def main():
|
||||
home = Path.home()
|
||||
config = Path(os.environ.get("XDG_CONFIG_HOME") or home / ".config")
|
||||
label = os.environ.get("BL_LIBRARY_LABEL")
|
||||
# An unbound mount-point directory may remain from a previous session.
|
||||
available = bool(label) and (LIBRARY / "steamapps").is_dir()
|
||||
update_bookmark(bookmarks_file(home, config), label if available else None)
|
||||
data = Path(os.environ.get("XDG_DATA_HOME") or home / ".local/share")
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
#!/bin/bash
|
||||
# Plasma starts this after its nested Xwayland display is available. The session launcher still
|
||||
# sees the outer compositor before startplasma, so starting its X11 helper there cannot work.
|
||||
[ -n "${BL_ANDROID_CLIPBOARD:-}" ] && [ -n "${DISPLAY:-}" ] || exit 0
|
||||
# The native helper dies with its parent. Keep this shell until it exits: Plasma's autostart
|
||||
# launcher may itself exit immediately after starting us.
|
||||
/usr/local/bin/droiddeck-clipboard "$BL_ANDROID_CLIPBOARD" &
|
||||
child=$!
|
||||
trap 'kill "$child" 2>/dev/null' EXIT
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
#!/usr/bin/python3
|
||||
# The client's installed games, on the desktop. The client writes a menu entry per game itself
|
||||
# (`steam steam://rungameid/<id>`, with the game's icon), which the desktop's `steam` shim hands to
|
||||
# the app - so an entry of ours exists only for a game the client wrote none for. Plus two links in
|
||||
# the home folder to the game files. Run at every desktop start; stale entries go.
|
||||
#
|
||||
# droiddeck-desktop-games [steam root]
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
@@ -12,8 +6,6 @@ import sys
|
||||
HOME = os.environ.get("HOME", "/root")
|
||||
STEAM_ROOT = sys.argv[1] if len(sys.argv) > 1 else os.path.join(HOME, ".local/share/Steam")
|
||||
LIBRARIES = ((STEAM_ROOT, "Steam Games"), ("/mnt/droiddeck-sd", "SD Games"))
|
||||
# The client's own tools and runtimes live in steamapps beside the games; they are not titles. A
|
||||
# depot with a toolmanifest.vdf is one too (a runtime or a Proton), listed here or not.
|
||||
NOT_GAMES = {228980, 1070560, 1391110, 1493710, 1628350, 3127680, 4183110, 4185400, 4427310, 4628740}
|
||||
APPS_DIR = os.path.join(HOME, ".local/share/applications")
|
||||
PREFIX = "droiddeck-game-"
|
||||
@@ -41,7 +33,6 @@ def games(library):
|
||||
continue
|
||||
name = NAME.search(text)
|
||||
state = STATE.search(text)
|
||||
# StateFlags 4 = fully installed; anything else is downloading, updating or broken.
|
||||
if not name or not state or (int(state.group(1)) & 4) == 0:
|
||||
continue
|
||||
installdir = INSTALLDIR.search(text)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/bin/bash
|
||||
# Port the old desktop's melonDS window rule once; later window rules belong to the user.
|
||||
set -euo pipefail
|
||||
config=${XDG_CONFIG_HOME:-$HOME/.config}
|
||||
marker=$config/droiddeck-window-rules-v1
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
#!/usr/bin/python3
|
||||
# droiddeck-esync: picks and stages the esync pack for each Proton build.
|
||||
# Credit: esync and ntsync were designed by Elizabeth Figura for Wine and Proton, and fsync by Elizabeth Figura
|
||||
# and Paul Gofman; droiddeck-esync, droiddeck-ntsync and droiddeck-fsync build on that work.
|
||||
import contextlib
|
||||
import fcntl
|
||||
import hashlib
|
||||
|
||||
@@ -252,9 +252,6 @@ def install_preloads(root):
|
||||
if os.path.isfile(source):
|
||||
copy_if_changed(source, os.path.join(root, "lib/x86_64-linux-gnu/droiddeck", name))
|
||||
wanted = [name for name in host_preloads() if name in shipped]
|
||||
# The fault report is preloaded from the runtime's own list, which only x86 loaders read: through
|
||||
# LD_PRELOAD it reached FEX's own loader too, and every FEX after it, which could not open it and
|
||||
# said so at each start. Listed only with both builds, or i386 programs would say so instead.
|
||||
if len(shipped.get(FAULT_REPORT, ())) == len(GUEST_LIBDIRS):
|
||||
wanted.append(FAULT_REPORT)
|
||||
write_if_changed(os.path.join(root, "etc", "ld.so.preload"), "".join("/usr/$LIB/droiddeck/%s\n" % name for name in wanted))
|
||||
@@ -411,8 +408,6 @@ def split_paths(value):
|
||||
|
||||
|
||||
def data_dir(env):
|
||||
# FEXServer's socket lives here. Under ~/.local its host path passes sun_path's 108 bytes, and
|
||||
# proot then binds it to a temporary name only the server sees: no client ever reaches it.
|
||||
runtime = env.get("XDG_RUNTIME_DIR")
|
||||
if runtime and os.path.isdir(runtime) and os.access(runtime, os.W_OK):
|
||||
return os.path.join(runtime, "fex")
|
||||
|
||||
@@ -1,27 +1,14 @@
|
||||
#!/usr/bin/python3
|
||||
# The app's store talks to Flatpak through this: one JSON object per line on stdout, so progress
|
||||
# reaches the front end as numbers rather than a terminal's redrawn bar. Per-user installation,
|
||||
# Flathub as the remote, this device's architecture.
|
||||
#
|
||||
# droiddeck-flatpak install <app-id> the app and whatever runtimes it needs
|
||||
# droiddeck-flatpak install-bundle <file> a .flatpak file, its runtimes from Flathub
|
||||
# droiddeck-flatpak uninstall <app-id> the app, then runtimes nothing uses any more
|
||||
# droiddeck-flatpak update [<app-id>] one app, or everything with an update
|
||||
# droiddeck-flatpak updates what has one (a "updates" line)
|
||||
#
|
||||
# Lines: {"e":"op","i":1,"n":3,"kind":"install","ref":"..."} as each step starts,
|
||||
# {"e":"progress","i":1,"n":3,"percent":45,"status":"..."} while it runs,
|
||||
# {"e":"error","message":"..."} and {"e":"done"} at the end (with "id" for a bundle). Exit status 0 on success.
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
os.environ.setdefault("FLATPAK_BWRAP", "/usr/local/bin/droiddeck-bwrap")
|
||||
|
||||
import gi # noqa: E402
|
||||
import gi
|
||||
|
||||
gi.require_version("Flatpak", "1.0")
|
||||
from gi.repository import Flatpak, Gio, GLib # noqa: E402
|
||||
from gi.repository import Flatpak, Gio, GLib
|
||||
|
||||
REMOTE = "flathub"
|
||||
|
||||
@@ -82,12 +69,6 @@ def transaction(inst):
|
||||
progress.connect("changed", changed)
|
||||
|
||||
def on_operation_error(tr, op, err, details):
|
||||
# A runtime extension that fails to install (a missing translation, an unneeded GL
|
||||
# driver) is not worth losing the app over; anything else ends the transaction.
|
||||
# FLATPAK_TRANSACTION_ERROR_DETAILS_NON_FATAL is 1, but PyGObject does not always hand the
|
||||
# flags over ("g_value_get_flags: assertion ... failed" and a 0). An extension installed
|
||||
# alongside an app - its translations, debug data, a GL or codecs runtime - is what Flatpak
|
||||
# marks non-fatal, as the flatpak CLI does: its failure costs that extension, not the app.
|
||||
try:
|
||||
non_fatal = bool(int(details) & 1)
|
||||
except (TypeError, ValueError):
|
||||
@@ -108,7 +89,6 @@ def transaction(inst):
|
||||
t.connect("ready", on_ready)
|
||||
t.connect("new-operation", on_new_operation)
|
||||
t.connect("operation-error", on_operation_error)
|
||||
# A dependency found on more than one remote comes from the first (Flathub, the only one).
|
||||
t.connect("choose-remote-for-ref", lambda tr, ref, runtime_ref, remotes: 0)
|
||||
t.connect("end-of-lifed-with-rebase", lambda *a: False)
|
||||
t.connect("add-new-remote", lambda *a: False)
|
||||
@@ -135,7 +115,6 @@ def install(app_id):
|
||||
if app_ref(inst, app_id) is not None:
|
||||
emit(e="done", note="already installed")
|
||||
return 0
|
||||
# Flathub publishes apps on "stable"; libflatpak's default branch is "master".
|
||||
branch, last = None, None
|
||||
for candidate in ("stable", "master"):
|
||||
try:
|
||||
@@ -149,8 +128,6 @@ def install(app_id):
|
||||
t, state = transaction(inst)
|
||||
t.add_install(REMOTE, "app/%s/%s/%s" % (app_id, arch, branch), None)
|
||||
rc = run(t, state, report_done=False)
|
||||
# A failure the transaction did not report (an error handler that raised, say) must not read
|
||||
# as an install: the app is there, or it is not.
|
||||
if rc == 0 and app_ref(installation(), app_id) is None:
|
||||
emit(e="error", message="%s did not install; see flatpak-install.log" % app_id)
|
||||
return 1
|
||||
@@ -192,7 +169,6 @@ def uninstall(app_id):
|
||||
t.add_uninstall(ref.format_ref())
|
||||
rc = run(t, state)
|
||||
if rc == 0:
|
||||
# Runtimes only this app used; Flatpak's own `uninstall --unused`.
|
||||
try:
|
||||
unused = inst.list_unused_refs(None, None)
|
||||
except GLib.Error:
|
||||
|
||||
@@ -1,19 +1,10 @@
|
||||
#!/bin/bash
|
||||
# A Flatpak app from the front end, full screen under gamescope like an emulator:
|
||||
# droiddeck-flatpak-run <app-id> [args...]
|
||||
set -u
|
||||
export FLATPAK_BWRAP=/usr/local/bin/droiddeck-bwrap
|
||||
case ":${XDG_DATA_DIRS:-}:" in
|
||||
*"/flatpak/exports/share:"*) ;;
|
||||
*) export XDG_DATA_DIRS=$HOME/.local/share/flatpak/exports/share:${XDG_DATA_DIRS:-/usr/local/share:/usr/share} ;;
|
||||
esac
|
||||
# Under gamescope - a program's session (BL_INSIDE), or droiddeck-gpu from the desktop
|
||||
# (GAMESCOPE_WAYLAND_DISPLAY) - windows have to reach gamescope's X server. Flatpak would hand an
|
||||
# app wayland-0 (it finds it in the runtime directory even with WAYLAND_DISPLAY unset) and the
|
||||
# window would open behind gamescope. gamescope's own Wayland socket is no way out: Chromium on
|
||||
# Wayland asks the render node it names for its DRM version, which KGSL cannot answer, and exits.
|
||||
# The session is X11 as far as an app can tell; Electron picks its platform from that.
|
||||
# Its own flatpak options (--branch, --command, from a menu entry) come first, then the app id.
|
||||
socket=()
|
||||
if [ -n "${BL_INSIDE:-}" ] || [ -n "${GAMESCOPE_WAYLAND_DISPLAY:-}" ]; then
|
||||
unset WAYLAND_DISPLAY
|
||||
@@ -21,7 +12,6 @@ if [ -n "${BL_INSIDE:-}" ] || [ -n "${GAMESCOPE_WAYLAND_DISPLAY:-}" ]; then
|
||||
socket=(--nosocket=wayland --socket=x11)
|
||||
fi
|
||||
echo "== flatpak run ${socket[*]} $*"
|
||||
# Apps expect a session bus (settings, portals, single-instance checks); a run mode has none.
|
||||
if [ -z "${DBUS_SESSION_BUS_ADDRESS:-}" ] && command -v dbus-run-session >/dev/null 2>&1; then
|
||||
exec dbus-run-session -- flatpak run "${socket[@]}" "$@"
|
||||
fi
|
||||
|
||||
@@ -1,26 +1,10 @@
|
||||
#!/bin/bash
|
||||
# Puts Flatpak into the runtime, with Flathub as a per-user remote. Run by the app under proot's
|
||||
# fake root (pacman and pacman-key refuse any other uid), outside a session.
|
||||
#
|
||||
# The runtime's pacman database lists only the base image: the desktop and emulator packages were
|
||||
# unpacked over it without registering. Asked for flatpak the usual way, pacman "reinstalls" about
|
||||
# a hundred of those - Mesa among them, over the runtime's own Turnip build with its KGSL backend -
|
||||
# and then runs every hook in the image, mkinitcpio included. So pacman only fetches and checks the
|
||||
# few packages Flatpak needs on top of this image, verifying each against the Arch Linux ARM
|
||||
# keyring, and they are unpacked here without hooks or scripts, like the desktop package itself.
|
||||
#
|
||||
# droiddeck-flatpak-setup install or repair; prints "== STEP ..." milestones
|
||||
set -u
|
||||
export LANG=C.UTF-8
|
||||
step() { echo "== STEP $*"; }
|
||||
fail() { echo "== FAIL $*"; exit 1; }
|
||||
|
||||
# Flatpak, the libraries it and appstream add to this image, and the D-Bus proxy flatpak run puts
|
||||
# between an app and the session bus. bubblewrap is not among them: Android gives an app no user
|
||||
# namespaces, and droiddeck-bwrap stands in for it (FLATPAK_BWRAP).
|
||||
PACKAGES="flatpak ostree appstream libxmlb libmalcontent libfyaml accountsservice composefs xdg-dbus-proxy"
|
||||
# Libraries Flatpak and the store's helper also need, which the Desktop package brings but a
|
||||
# runtime without it may lack: each is fetched only when its file is not already there.
|
||||
while read -r pkg probe; do
|
||||
[ -n "$pkg" ] || continue
|
||||
compgen -G "$probe" >/dev/null || PACKAGES="$PACKAGES $pkg"
|
||||
@@ -41,8 +25,6 @@ WORK=/var/cache/droiddeck-flatpak
|
||||
CONF=$WORK/pacman.conf
|
||||
mkdir -p "$WORK/pkg" "$WORK/db" || fail "cannot create $WORK"
|
||||
|
||||
# The image's pacman.conf names a download user this rootfs does not have (only root exists) and a
|
||||
# sandbox proot cannot set up. Its one mirror is plain HTTP; these serve the same repos over TLS.
|
||||
{ for m in https://ca.us.mirror.archlinuxarm.org https://fl.us.mirror.archlinuxarm.org \
|
||||
https://de3.mirror.archlinuxarm.org https://nl.mirror.archlinuxarm.org; do
|
||||
echo "Server = $m/\$arch/\$repo"; done
|
||||
@@ -58,8 +40,6 @@ if [ ! -f /etc/pacman.d/gnupg/pubring.gpg ] && [ ! -f /etc/pacman.d/gnupg/pubrin
|
||||
pacman-key --populate archlinuxarm >/dev/null 2>&1 || fail "pacman-key --populate failed"
|
||||
fi
|
||||
|
||||
# A database of our own, so the image's stays exactly as it was built: -Sy on it would leave the
|
||||
# rest of the image a partial upgrade behind the repos.
|
||||
step "Reading the package lists"
|
||||
pacman --config "$CONF" --dbpath "$WORK/db" --noconfirm -Sy >/dev/null 2>&1 \
|
||||
|| pacman --config "$CONF" --dbpath "$WORK/db" --noconfirm -Sy 2>&1 | tail -3 \
|
||||
@@ -67,8 +47,6 @@ pacman --config "$CONF" --dbpath "$WORK/db" --noconfirm -Sy >/dev/null 2>&1 \
|
||||
[ -f "$WORK/db/sync/extra.db" ] || fail "could not reach the Arch Linux ARM mirrors"
|
||||
|
||||
step "Downloading Flatpak"
|
||||
# -w only downloads; pacman still checks each package's signature against the keyring. -dd: the
|
||||
# dependencies are already in the image (and checked below by what the binaries actually link).
|
||||
out=$(pacman --config "$CONF" --dbpath "$WORK/db" --cachedir "$WORK/pkg" --noconfirm -Sw -dd $PACKAGES 2>&1)
|
||||
rc=$?
|
||||
echo "$out" | grep -vE '^\s*$' | tail -4
|
||||
@@ -84,10 +62,8 @@ for name in $PACKAGES; do
|
||||
echo "$name $ver" >> "$WORK/installed.new"
|
||||
done
|
||||
mv -f "$WORK/installed.new" "$WORK/installed"
|
||||
# Only the newest file of each package is worth keeping for a repair.
|
||||
find "$WORK/pkg" -type f -mtime +1 -delete 2>/dev/null
|
||||
|
||||
# What the binaries link is the real dependency list: anything this image lacks shows here.
|
||||
missing=$(for f in /usr/bin/flatpak /usr/lib/libflatpak.so.0 /usr/lib/libostree-1.so.1 /usr/bin/xdg-dbus-proxy; do
|
||||
ldd "$f" 2>&1 | grep -E 'not found|version .* not found'
|
||||
done | sort -u)
|
||||
@@ -98,9 +74,6 @@ python3 -c 'import gi; gi.require_version("Flatpak", "1.0"); from gi.repository
|
||||
|
||||
step "Adding Flathub"
|
||||
export FLATPAK_BWRAP=/usr/local/bin/droiddeck-bwrap
|
||||
# Flathub's descriptor - its URL and the key its commits are signed with - is carried here rather
|
||||
# than fetched: adding the remote then needs no network, and a descriptor that did not arrive
|
||||
# whole cannot be what failed. Flathub's own copy: https://dl.flathub.org/repo/flathub.flatpakrepo
|
||||
cat > "$WORK/flathub.flatpakrepo" <<'REPO'
|
||||
[Flatpak Repo]
|
||||
Title=Flathub
|
||||
@@ -115,7 +88,6 @@ if ! flatpak remote-list --user --columns=name 2>/dev/null | grep -qx flathub; t
|
||||
out=$(flatpak remote-add --user --if-not-exists flathub "$WORK/flathub.flatpakrepo" 2>&1)
|
||||
rc=$?
|
||||
echo "$out"
|
||||
# What Flatpak said goes up with the failure, so the app can show it rather than a guess.
|
||||
[ $rc -eq 0 ] || fail "could not add the Flathub remote: $(echo "$out" | grep -v '^[[:space:]]*$' | tail -1)"
|
||||
fi
|
||||
echo "== DONE $(flatpak --version)"
|
||||
@@ -1,24 +1,12 @@
|
||||
#!/bin/bash
|
||||
# DroidDeck's fontconfig setup for the Linux runtime. The rootfs ships DejaVu alone and no rules
|
||||
# for a default family: applications then find fonts but no default, and Firefox logs "no fonts"
|
||||
# and draws pages without text. DejaVu also has no CJK, Thai or Arabic glyphs, so those draw as
|
||||
# tofu boxes. The app binds Android's fonts for the session, which adds language-specific fallbacks
|
||||
# separately. This script links fontconfig's default rules and writes generic DejaVu aliases to an
|
||||
# owned conf.d file. Fontconfig reads local.conf afterward, so user overrides keep precedence and
|
||||
# are never replaced.
|
||||
# The first argument is the root to set up, "/" in a session; the tests point it at a temp tree.
|
||||
set -u
|
||||
root=${1:-/}
|
||||
root=${root%/}
|
||||
# "/" strips to empty above; put it back so the paths below read as absolute and the test for a
|
||||
# real session ("/") still holds.
|
||||
[ -n "$root" ] || root=/
|
||||
conf_dir=$root/etc/fonts
|
||||
defaults_dir=$root/usr/share/fontconfig/conf.default
|
||||
mkdir -p "$conf_dir/conf.d" 2>/dev/null
|
||||
|
||||
# The default rules (sans-serif -> DejaVu Sans and the rest) live as links in /etc/fonts/conf.d,
|
||||
# and the rootfs has none. Linked by name, so a file we ship is never overwritten.
|
||||
if [ -d "$defaults_dir" ]; then
|
||||
for f in "$defaults_dir"/*.conf; do
|
||||
[ -e "$f" ] || continue
|
||||
|
||||
@@ -25,8 +25,6 @@ def game_id(env):
|
||||
return str(number % 2**32)
|
||||
|
||||
|
||||
# A .NET (CoreCLR) runtime under FEX crashes in the runtime itself unless memory ordering is fully
|
||||
# emulated and multiblock is off: the Stability preset.
|
||||
DOTNET_FEX = {
|
||||
"FEX_TSOENABLED": "1",
|
||||
"FEX_VECTORTSOENABLED": "1",
|
||||
@@ -69,8 +67,6 @@ class Game:
|
||||
return any(a == name or a.startswith(name + "=") for a in self.args)
|
||||
|
||||
|
||||
# Each fix looks at a Game and returns (environment, extra arguments, note) for the games it
|
||||
# applies to, or None. Adding one is writing a function and decorating it.
|
||||
FIXES = []
|
||||
|
||||
|
||||
@@ -91,16 +87,12 @@ def dotnet_memory_ordering(game):
|
||||
|
||||
@fix
|
||||
def godot_vulkan(game):
|
||||
# Godot 4 on Direct3D 12 through VKD3D-Proton fails to create its swap chain and runs behind a
|
||||
# black window; its own Vulkan renderer draws.
|
||||
if is_godot(game) and not game.has_arg("--rendering-driver"):
|
||||
return {}, ["--rendering-driver", "vulkan"], "Godot: Vulkan renderer"
|
||||
|
||||
|
||||
@fix
|
||||
def godot_sentry(game):
|
||||
# The Sentry GDExtension's native crash handler takes the .NET runtime down under FEX. Godot
|
||||
# loads it on demand and carries on without it.
|
||||
sentry = sorted(n[:-4] for n in game.files if n.startswith("libsentry.windows.") and n.endswith(".dll"))
|
||||
if is_godot(game) and sentry:
|
||||
return {"WINEDLLOVERRIDES": ";".join(n + "=d" for n in sentry)}, [], "Godot: Sentry crash handler off"
|
||||
@@ -166,9 +158,10 @@ def apply_config(env, config, app_id, fixes=None):
|
||||
result[name] = value
|
||||
else:
|
||||
raise ValueError("invalid environment value")
|
||||
# The app's texture filtering (Display page), as DXVK options appended after the profiles so
|
||||
# a DXVK_CONFIG entry of the user's keeps its own.
|
||||
dxvk = config.get("dxvkConfig")
|
||||
game_dxvk = config.get("dxvkConfigGames", {})
|
||||
if not isinstance(game_dxvk, dict):
|
||||
raise ValueError("invalid game dxvk configuration")
|
||||
dxvk = game_dxvk.get(app_id, config.get("dxvkConfig"))
|
||||
if dxvk is not None:
|
||||
if not isinstance(dxvk, str) or "\0" in dxvk or len(dxvk) > 8192:
|
||||
raise ValueError("invalid dxvk configuration")
|
||||
@@ -250,13 +243,44 @@ def force_ssbs(command, env):
|
||||
return env
|
||||
|
||||
|
||||
def umu_capable(proton):
|
||||
"""Whether this Proton's script has umu's launch without Steam: GE-Proton, Proton-CachyOS and
|
||||
DroidDeck-Proton run umu.exe in place of steam.exe when UMU_ID is set; Valve's Proton does not."""
|
||||
try:
|
||||
with open(proton, encoding="utf-8", errors="replace") as source:
|
||||
text = source.read()
|
||||
except OSError:
|
||||
return False
|
||||
return "UMU_ID" in text and "umu.exe" in text
|
||||
|
||||
|
||||
def start_without_steam(command, env, app_id):
|
||||
"""DROIDDECK_NO_STEAM=1 (a game's Start without Steam): launch the game without Proton's
|
||||
steam.exe, for games that close right away because of what it sets up. A Proton with umu's
|
||||
launch gets UMU_ID - Proton still sets up the prefix, and a Steam game keeps its protonfixes
|
||||
under its own id; any other Proton runs the game straight in the prefix (runinprefix)."""
|
||||
if env.get("DROIDDECK_NO_STEAM", "").lower() not in ("1", "on", "true", "yes"):
|
||||
return command, env
|
||||
if len(command) < 3 or command[1] != "waitforexitandrun":
|
||||
return command, env
|
||||
if umu_capable(command[0]):
|
||||
if not env.get("UMU_ID"):
|
||||
steam_game = app_id is not None and int(app_id) < 2**31
|
||||
env = dict(env, UMU_ID=app_id if steam_game else "0")
|
||||
print("droiddeck-game-env: starting without Steam (umu.exe in place of steam.exe, UMU_ID=%s)" % env["UMU_ID"], file=sys.stderr)
|
||||
return command, env
|
||||
print("droiddeck-game-env: starting without Steam (this Proton has no umu launch: runinprefix)", file=sys.stderr)
|
||||
return [command[0], "runinprefix"] + command[2:], env
|
||||
|
||||
|
||||
EVALUATOR_SCRIPT = re.compile(r"(?:^|[\\/])evaluatorscript_[0-9]+\.vdf$", re.IGNORECASE)
|
||||
|
||||
|
||||
def mark_install_scripts(command, env):
|
||||
"""The client is about to run a game's install scripts (iscriptevaluator.exe): mark every process
|
||||
in them as already run first, so no redistributable installer starts - on first launch the
|
||||
shared ones may still be downloading, and on ARM64 Proton the VC++ ones stop with an error."""
|
||||
in them but a Vulkan runtime installer as already run first, so no redistributable installer
|
||||
starts - on first launch the shared ones may still be downloading, and on ARM64 Proton the VC++
|
||||
ones stop with an error."""
|
||||
if not any(arg.lower().replace("\\", "/").endswith("iscriptevaluator.exe") for arg in command):
|
||||
return
|
||||
root = env.get("STEAM_COMPAT_CLIENT_INSTALL_PATH") or str(Path.home() / ".local/share/Steam")
|
||||
@@ -305,6 +329,7 @@ def main():
|
||||
except (OSError, ValueError, TypeError, AttributeError):
|
||||
print("droiddeck-game-env: invalid configuration; using inherited environment", file=sys.stderr)
|
||||
env = force_ssbs(command, env)
|
||||
command, env = start_without_steam(command, env, app_id)
|
||||
sync = load_sync()
|
||||
launch, launch_env = select_sync(command, env, sync)
|
||||
if launch[0] != command[0]:
|
||||
|
||||
@@ -8,8 +8,6 @@ import sys
|
||||
|
||||
|
||||
def advertise_compositing():
|
||||
# This is gamescope's private X server: it composites alpha buffers already, but GTK also
|
||||
# requires the compositing-manager selection and frame-extents hint before enabling CSD.
|
||||
x = c.CDLL('libX11.so.6')
|
||||
display_type, window_type = c.c_void_p, c.c_ulong
|
||||
x.XOpenDisplay.argtypes = [c.c_char_p]
|
||||
@@ -41,7 +39,6 @@ def advertise_compositing():
|
||||
x.XChangeProperty(display, root, atom('_NET_SUPPORTED'), atom('ATOM'), 32, 2, c.byref(extents), 1)
|
||||
x.XSync.argtypes = [display_type, c.c_int]
|
||||
x.XSync(display, False)
|
||||
# Keep the selection's connection alive until the program exits.
|
||||
return x, display
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,220 @@
|
||||
#!/usr/bin/python3
|
||||
"""Holds a game launcher's hidden web interface on one slow core while something else has focus.
|
||||
|
||||
Rockstar's launcher keeps drawing its Chromium interface (SocialClubHelper.exe: a renderer, and a
|
||||
GPU process compositing through DXVK) for as long as it runs, hidden behind the game too, and at a
|
||||
higher priority than the game's (Wine passes Chromium's on: the GPU process ran at nice -10). With
|
||||
Red Dead Redemption 2 in front on the RedMagic that was 1.3 to 2.5 cores under FEX, on a phone
|
||||
already held back by its temperature, for a page nobody sees. Held, riding at the throttle limit
|
||||
went from 46.5 to 48.7 fps, 1% lows from 27.5 to 32.6. So while the focused window belongs to
|
||||
anything but the launcher, every helper thread runs on one core of the slowest cluster at nice 19;
|
||||
when the launcher's own window has focus again (signing in, the game closed) each thread gets its
|
||||
own mask and priority back. Stopping the helpers instead would not hold: proot, the tracer of every
|
||||
guest process, resumes a stopped tracee.
|
||||
|
||||
Focus comes from droiddeck-agent's focus.json (the path is the argument), which the agent rewrites
|
||||
whenever gamescope's focus changes. droiddeck-session starts this for Steam sessions;
|
||||
BL_LAUNCHER_CORES=0 leaves the launchers alone."""
|
||||
import json
|
||||
import os
|
||||
import signal
|
||||
import sys
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
HELPERS = ("\\rockstar games\\social club\\socialclubhelper.exe",)
|
||||
FRONTS = HELPERS + ("\\rockstar games\\launcher\\launcher.exe",)
|
||||
NICE = 19
|
||||
POLL = 2.0
|
||||
RESCAN = 10.0
|
||||
STEAM_CLIENT = 769
|
||||
|
||||
|
||||
def log(message):
|
||||
print("droiddeck-launcher-cores: " + message, flush=True)
|
||||
|
||||
|
||||
def image(proc, pid):
|
||||
"""A process's program as Wine names it (argv[0]), lower case with backslashes, or None."""
|
||||
try:
|
||||
with open(proc / str(pid) / "cmdline", "rb") as stream:
|
||||
first = stream.read(4096).split(b"\0", 1)[0]
|
||||
except OSError:
|
||||
return None
|
||||
return first.decode("utf-8", "replace").lower().replace("/", "\\")
|
||||
|
||||
|
||||
def is_one_of(path, suffixes):
|
||||
return path is not None and path.endswith(suffixes)
|
||||
|
||||
|
||||
def tasks(proc, pid):
|
||||
try:
|
||||
return [int(tid) for tid in os.listdir(proc / str(pid) / "task") if tid.isdigit()]
|
||||
except OSError:
|
||||
return []
|
||||
|
||||
|
||||
class Cores:
|
||||
"""The kernel calls, apart so a test can stand in for them."""
|
||||
|
||||
def own(self):
|
||||
return os.sched_getaffinity(0)
|
||||
|
||||
def get(self, tid):
|
||||
return os.sched_getaffinity(tid), os.getpriority(os.PRIO_PROCESS, tid)
|
||||
|
||||
def set(self, tid, cpus, nice):
|
||||
try:
|
||||
os.sched_setaffinity(tid, cpus)
|
||||
except OSError:
|
||||
os.sched_setaffinity(tid, self.own())
|
||||
os.setpriority(os.PRIO_PROCESS, tid, nice)
|
||||
|
||||
|
||||
class Holder:
|
||||
def __init__(self, proc=Path("/proc"), cpufreq=Path("/sys/devices/system/cpu"), cores=None):
|
||||
self.proc = proc
|
||||
self.cpufreq = cpufreq
|
||||
self.cores = cores or Cores()
|
||||
self.held = {}
|
||||
self.core = None
|
||||
|
||||
def slow_core(self):
|
||||
"""The last core of the slowest cluster the session has - not of the game's cores, which
|
||||
the launcher inherits when BL_GAME_CPUS is set: the core the game misses least."""
|
||||
def top(cpu):
|
||||
try:
|
||||
return int((self.cpufreq / f"cpu{cpu}/cpufreq/cpuinfo_max_freq").read_text())
|
||||
except (OSError, ValueError):
|
||||
return 0
|
||||
cpus = self.cores.own()
|
||||
slowest = min(top(cpu) for cpu in cpus)
|
||||
return max(cpu for cpu in cpus if top(cpu) == slowest)
|
||||
|
||||
def helpers(self):
|
||||
for name in os.listdir(self.proc):
|
||||
if name.isdigit() and is_one_of(image(self.proc, name), HELPERS):
|
||||
yield int(name)
|
||||
|
||||
def hold(self):
|
||||
"""Every helper thread onto the slow core at NICE: new ones, and held ones the program has
|
||||
moved since (Chromium sets its threads' priorities, and Wine passes that on)."""
|
||||
if self.core is None:
|
||||
self.core = self.slow_core()
|
||||
hold = ({self.core}, NICE)
|
||||
for pid in self.helpers():
|
||||
before = self.held.setdefault(pid, {})
|
||||
for tid in tasks(self.proc, pid):
|
||||
try:
|
||||
now = self.cores.get(tid)
|
||||
if now != hold:
|
||||
self.cores.set(tid, *hold)
|
||||
except OSError:
|
||||
continue
|
||||
if tid not in before:
|
||||
before[tid] = now if now != hold else before.get(pid) or self.first() or now
|
||||
for pid in [pid for pid in self.held if not (self.proc / str(pid)).exists()]:
|
||||
del self.held[pid]
|
||||
|
||||
def first(self):
|
||||
for before in self.held.values():
|
||||
for state in before.values():
|
||||
if state != ({self.core}, NICE):
|
||||
return state
|
||||
return None
|
||||
|
||||
def release(self):
|
||||
"""Every held thread back to its own mask and priority; one started during the hold gets
|
||||
what its process had."""
|
||||
for pid, before in self.held.items():
|
||||
default = before.get(pid) or self.first()
|
||||
for tid in tasks(self.proc, pid):
|
||||
state = before.get(tid, default)
|
||||
if state is None:
|
||||
continue
|
||||
try:
|
||||
self.cores.set(tid, *state)
|
||||
except OSError:
|
||||
pass
|
||||
self.held.clear()
|
||||
|
||||
|
||||
def focused(snapshot):
|
||||
"""(app id, pid) of the window gamescope has focused, from droiddeck-agent's snapshot."""
|
||||
window = snapshot.get("focusedWindow")
|
||||
for entry in snapshot.get("focusableWindows") or []:
|
||||
if entry.get("window") == window:
|
||||
return snapshot.get("focusedApp"), entry.get("pid")
|
||||
return snapshot.get("focusedApp"), None
|
||||
|
||||
|
||||
class Governor:
|
||||
def __init__(self, focus_path, holder=None, clock=time.monotonic):
|
||||
self.focus_path = Path(focus_path)
|
||||
self.holder = holder or Holder()
|
||||
self.clock = clock
|
||||
self.seen = None
|
||||
self.app = self.pid = None
|
||||
self.scanned = None
|
||||
self.reported = None
|
||||
|
||||
def read_focus(self):
|
||||
try:
|
||||
stamp = self.focus_path.stat().st_mtime_ns
|
||||
except OSError:
|
||||
return False
|
||||
if stamp == self.seen:
|
||||
return False
|
||||
try:
|
||||
self.app, self.pid = focused(json.loads(self.focus_path.read_text()))
|
||||
except (OSError, ValueError, AttributeError):
|
||||
return False
|
||||
self.seen = stamp
|
||||
return True
|
||||
|
||||
def tick(self):
|
||||
changed = self.read_focus()
|
||||
if self.pid is None:
|
||||
return
|
||||
launcher_in_front = is_one_of(image(self.holder.proc, self.pid), FRONTS)
|
||||
if launcher_in_front:
|
||||
if self.holder.held:
|
||||
self.holder.release()
|
||||
self.report("released: the launcher has focus")
|
||||
return
|
||||
if self.app in (None, 0, STEAM_CLIENT) and not self.holder.held:
|
||||
return
|
||||
now = self.clock()
|
||||
if changed or self.scanned is None or now - self.scanned >= RESCAN:
|
||||
self.scanned = now
|
||||
self.holder.hold()
|
||||
if self.holder.held:
|
||||
self.report(f"{len(self.holder.held)} SocialClubHelper process(es) on core {self.holder.core} "
|
||||
f"at nice {NICE} while the launcher is hidden")
|
||||
|
||||
def report(self, message):
|
||||
if message != self.reported:
|
||||
self.reported = message
|
||||
log(message)
|
||||
|
||||
def stop(self, *_):
|
||||
self.holder.release()
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def main(argv):
|
||||
if len(argv) != 1:
|
||||
print("usage: droiddeck-launcher-cores <agent focus.json>", file=sys.stderr)
|
||||
return 2
|
||||
governor = Governor(argv[0])
|
||||
signal.signal(signal.SIGTERM, governor.stop)
|
||||
signal.signal(signal.SIGHUP, governor.stop)
|
||||
signal.signal(signal.SIGINT, governor.stop)
|
||||
while True:
|
||||
governor.tick()
|
||||
time.sleep(POLL)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main(sys.argv[1:]))
|
||||
@@ -14,7 +14,7 @@ import uuid
|
||||
import gi
|
||||
|
||||
gi.require_version("Gio", "2.0")
|
||||
from gi.repository import Gio, GLib # noqa: E402
|
||||
from gi.repository import Gio, GLib
|
||||
|
||||
NAME = "org.freedesktop.login1"
|
||||
ROOT = "/org/freedesktop/login1"
|
||||
@@ -56,8 +56,6 @@ class LoginManager:
|
||||
self.preparation = None
|
||||
info = Gio.DBusNodeInfo.new_for_xml(INTROSPECTION).interfaces[0]
|
||||
self.registration = bus.register_object(ROOT, info, self.method, self.property, None)
|
||||
# Steam can issue its suspend command through the legacy UPower service even
|
||||
# while listening to login1's sleep/resume notifications. Use one handshake.
|
||||
upower_info = Gio.DBusNodeInfo.new_for_xml(UPOWER_INTROSPECTION).interfaces[0]
|
||||
self.upower_registration = bus.register_object(UPOWER_ROOT, upower_info, self.method, None, None)
|
||||
self.monitor = Gio.File.new_for_path(str(self.directory)).monitor_directory(Gio.FileMonitorFlags.NONE, None)
|
||||
@@ -86,8 +84,6 @@ class LoginManager:
|
||||
self.pending = uuid.uuid4().hex
|
||||
self.notify(True)
|
||||
reply.return_value(None)
|
||||
# Flush the signal and method reply without blocking this D-Bus callback. Once both are
|
||||
# on the wire, publishing the request lets the host safely freeze this service.
|
||||
self.bus.flush(None, self.publish_after_flush, self.pending)
|
||||
|
||||
def publish_after_flush(self, connection, result, token):
|
||||
@@ -122,7 +118,6 @@ class LoginManager:
|
||||
return
|
||||
if not re.fullmatch(r"[a-f0-9]{32}", token) or self.pending is not None:
|
||||
return
|
||||
# Android may have returned before this helper read its request.
|
||||
if self.read_state() == token + ":awake":
|
||||
return
|
||||
self.pending = token
|
||||
@@ -138,8 +133,6 @@ class LoginManager:
|
||||
return
|
||||
self.check_state()
|
||||
if self.pending == token:
|
||||
# Keep Steam runnable while it handles the system sleep notification.
|
||||
# This is a bounded grace period, not a claim that every game has saved.
|
||||
self.preparation = GLib.timeout_add(NATIVE_PREPARE_MS, self.finish_preparation, token)
|
||||
|
||||
def finish_preparation(self, token):
|
||||
@@ -171,7 +164,6 @@ class LoginManager:
|
||||
def check_ack(self):
|
||||
self.timeout = None
|
||||
if self.pending and self.read_state() != self.pending + ":paused":
|
||||
# A missing host or a failed freeze must not strand Steam in black.
|
||||
self.request.unlink(missing_ok=True)
|
||||
self.native_ready.unlink(missing_ok=True)
|
||||
self.resume()
|
||||
@@ -180,8 +172,6 @@ class LoginManager:
|
||||
def resume(self, force=False):
|
||||
if self.pending is None:
|
||||
if force:
|
||||
# A missed suspend command leaves Steam without the first half of
|
||||
# the handshake. Replay both notifications, without pausing again.
|
||||
self.notify(True)
|
||||
self.bus.flush(None, self.finish_recovery, None)
|
||||
return
|
||||
|
||||
@@ -43,7 +43,6 @@ CABEXTRACT = os.environ.get("DROIDDECK_CABEXTRACT", str(TOOLS / "cabextract"))
|
||||
SEVENZIP = os.environ.get("DROIDDECK_7Z", str(TOOLS / "7z"))
|
||||
MSI_MAGIC = b"\xd0\xcf\x11\xe0\xa1\xb1\x1a\xe1"
|
||||
BURN_MAGIC = 0x00F14300
|
||||
# A bundle's manifest names ARM64 packages too; a game's prefix wants the x86 and x64 ones.
|
||||
SKIP_PLATFORMS = ("arm64", "arm")
|
||||
|
||||
|
||||
@@ -53,9 +52,6 @@ def tool_env():
|
||||
env["LD_LIBRARY_PATH"] = ":".join(p for p in (str(TOOLS), env.get("LD_LIBRARY_PATH", "")) if p)
|
||||
return env
|
||||
|
||||
# The folders Windows Installer knows by name, as a 64-bit Windows 10 prefix lays them out (Proton's
|
||||
# user is steamuser). None is a folder whose files a game never needs: installer temp files and
|
||||
# shortcuts.
|
||||
SKIP = None
|
||||
KNOWN_FOLDERS = {
|
||||
"TARGETDIR": "C:\\", "ROOTDRIVE": "C:\\", "WindowsVolume": "C:\\",
|
||||
@@ -78,25 +74,17 @@ for _name in ("TempFolder", "DesktopFolder", "ProgramMenuFolder", "StartMenuFold
|
||||
"TemplateFolder", "MyPicturesFolder", "AdminToolsFolder"):
|
||||
KNOWN_FOLDERS[_name] = SKIP
|
||||
|
||||
# What Wine's msi reports on a 64-bit Windows 10 prefix, for the packages' conditions.
|
||||
SYSTEM_PROPERTIES = {
|
||||
"VersionNT": "603", "VersionNT64": "603", "WindowsBuild": "9600", "ServicePackLevel": "0",
|
||||
"Msix64": "6", "ALLUSERS": "1", "Privileged": "1", "AdminUser": "1", "MsiNTProductType": "1",
|
||||
"UILevel": "2", "INSTALLLEVEL": "1", "ProgramFilesFolder": None, "VersionMsi": "5.00",
|
||||
}
|
||||
|
||||
# Win64 component (msidbComponentAttributes64bit); file attributes.
|
||||
COMPONENT_64BIT = 0x100
|
||||
FILE_NONCOMPRESSED = 0x2000
|
||||
# Custom action types that only set a property or a folder: done here, the rest are named in notes.
|
||||
SET_PROPERTY, SET_DIRECTORY, ERROR_ACTION = 51, 35, 19
|
||||
# Microsoft's "SFP CA" merge module (MDAC, MSXML): on Windows 2000 and later it parks system DLLs in a
|
||||
# cache folder and its own code copies them into the system folder past Windows File Protection.
|
||||
# Skipping the folder change puts them where that copy would. Its actions, and the side-by-side
|
||||
# merge module's (done here from MsiAssembly), are then left out of the notes.
|
||||
SFP_CACHE_ACTION = "CDirSystemSFPCacheDir"
|
||||
HANDLED_ACTIONS = ("Wdsfpca_", "SxsInstallCA", "SxsUninstallCA")
|
||||
# Tables whose work needs the package's own code or is not done here yet.
|
||||
UNSUPPORTED_TABLES = ("SelfReg", "Class", "ProgId", "TypeLib", "Extension", "Verb", "MIME", "AppId",
|
||||
"IniFile", "ServiceInstall", "MoveFile", "IsolatedComponent", "PublishComponent",
|
||||
"ODBCDriver", "ODBCDataSource")
|
||||
@@ -123,7 +111,6 @@ class Span:
|
||||
progress(text, self.lo + (self.hi - self.lo) * max(0.0, min(1.0, fraction)))
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- reading the package
|
||||
|
||||
IDT_ESCAPES = str.maketrans({"\x19": "\n", "\x11": "\r", "\x15": "\t", "\x1b": ";"})
|
||||
|
||||
@@ -182,7 +169,6 @@ def to_int(value, default=0):
|
||||
return default
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- conditions
|
||||
|
||||
TOKEN = re.compile(r'\s*(?:(?P<str>"[^"]*")|(?P<num>-?\d+)(?![\w.])|(?P<op>~?(?:<>|<=|>=|><|<<|>>|=|<|>))'
|
||||
r'|(?P<paren>[()])|(?P<word>[%$?&!]?[A-Za-z_][\w.]*))')
|
||||
@@ -330,7 +316,6 @@ class Conditions:
|
||||
return value not in ("", None)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- the install
|
||||
|
||||
def win_to_rel(path):
|
||||
"""C:\\windows\\x\\ -> drive_c/windows/x; None for a path off drive C or a folder left out."""
|
||||
@@ -375,7 +360,7 @@ class Installer:
|
||||
self.span = span or Span()
|
||||
self.notes = []
|
||||
self.registry = []
|
||||
self.files = {} # File key -> rel path it was installed to
|
||||
self.files = {}
|
||||
self.counts = {"files": 0, "assemblies": 0, "registry": 0}
|
||||
template = self.pkg.summary.get("template", "")
|
||||
self.platform = template.split(";")[0].strip().lower()
|
||||
@@ -385,7 +370,6 @@ class Installer:
|
||||
for name, path in KNOWN_FOLDERS.items():
|
||||
self.props[name] = path if path is not None else "\0skip"
|
||||
for row in self.pkg.table("Property"):
|
||||
# The package's own defaults, but never over the folders and the system it runs on.
|
||||
if row["Property"] not in self.props or row["Property"] in ("INSTALLLEVEL", "ALLUSERS", "UILevel"):
|
||||
self.props[row["Property"]] = row["Value"]
|
||||
self.props["ALLUSERS"] = "1"
|
||||
@@ -397,7 +381,6 @@ class Installer:
|
||||
self._resolving = set()
|
||||
self._set_by_action = set()
|
||||
|
||||
# -- states, folders, formatted text
|
||||
|
||||
def feature_state(self, name):
|
||||
return 3 if name in self.included_features else -1
|
||||
@@ -411,13 +394,11 @@ class Installer:
|
||||
return None
|
||||
value = self.props.get(key)
|
||||
row = self.directories.get(key)
|
||||
# A folder Windows knows by name, one a custom action set, or a property naming a path.
|
||||
if key in KNOWN_FOLDERS or key in self._set_by_action or row is None:
|
||||
return None if value in (None, "", "\0skip") else win_to_rel(value)
|
||||
parent_key = row.get("Directory_Parent", "")
|
||||
default = long_name(row.get("DefaultDir", "").split(":")[0])
|
||||
if not parent_key or parent_key == key:
|
||||
# A root: TARGETDIR (SourceDir) is drive C.
|
||||
return "drive_c"
|
||||
self._resolving.add(key)
|
||||
try:
|
||||
@@ -466,7 +447,6 @@ class Installer:
|
||||
text = re.sub(r"\[([^\[\]]*)\]", one, text)
|
||||
return text
|
||||
|
||||
# -- what gets installed
|
||||
|
||||
def run_set_actions(self):
|
||||
"""The property/folder-setting custom actions, in sequence order; the rest go to the notes."""
|
||||
@@ -581,8 +561,6 @@ class Installer:
|
||||
self.pkg.stream(cabinet[1:], cab)
|
||||
own = True
|
||||
else:
|
||||
# An external cabinet: a file beside the package, as an installer wrapper lays it out
|
||||
# (vc_red.cab beside vc_red.msi, netfx_Full.mzz beside netfx_Full_x64.msi).
|
||||
cab = sibling(Path(self.pkg.path), cabinet)
|
||||
if cab is None:
|
||||
self.notes.append("external cabinet %s is not part of the package; its files are missing" % cabinet)
|
||||
@@ -601,15 +579,17 @@ class Installer:
|
||||
|
||||
def put(self, source, rel):
|
||||
target = self.out / rel
|
||||
if target.exists() and Path(source).samefile(target):
|
||||
return False
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
shutil.copyfile(source, target)
|
||||
return True
|
||||
|
||||
def install_files(self, unpacked):
|
||||
assemblies = self.assemblies()
|
||||
files = self.pkg.table("File")
|
||||
missing = 0
|
||||
destinations = {}
|
||||
# Where each file goes: its component's folder, or the assembly store for a global assembly.
|
||||
for row in files:
|
||||
comp = row["Component_"]
|
||||
if comp not in self.included_components:
|
||||
@@ -664,16 +644,12 @@ class Installer:
|
||||
folder = self.directory(row["DestFolder"]) if row.get("DestFolder") else self.files[row["File_"]].rsplit("/", 1)[0]
|
||||
name = long_name(row.get("DestName", "")) or self.files[row["File_"]].rsplit("/", 1)[1]
|
||||
source = self.out / self.files[row["File_"]]
|
||||
if folder and source.is_file() and "/" not in name:
|
||||
self.put(source, folder + "/" + name)
|
||||
if folder and source.is_file() and "/" not in name and self.put(source, folder + "/" + name):
|
||||
self.counts["files"] += 1
|
||||
if missing:
|
||||
self.notes.append("%d file(s) were not in the package's cabinets" % missing)
|
||||
|
||||
def value(self, hive, key, name, kind, data, wow64):
|
||||
# A 32-bit component writes through the 32-bit view, as Wine's msi does: HKLM\Software is
|
||||
# Software\Wow6432Node, and the prefix's link keys there (Classes, TypeLib, Fonts...) lead
|
||||
# to the keys both views share - droiddeck-wincomponents follows them when it writes.
|
||||
lower = key.lower()
|
||||
if hive == "HKLM" and wow64 and lower.startswith("software\\") and not lower.startswith("software\\wow6432node\\"):
|
||||
key = "Software\\Wow6432Node\\" + key[len("software\\"):]
|
||||
@@ -782,7 +758,6 @@ class Installer:
|
||||
self.check()
|
||||
if not self.counts["files"] and not self.registry:
|
||||
raise MsiError("the package installs nothing here")
|
||||
# A component made of several packages (32- and 64-bit) gets them all in one registry.json.
|
||||
values = []
|
||||
try:
|
||||
with open(self.out / "registry.json", encoding="utf-8") as source:
|
||||
@@ -796,7 +771,6 @@ class Installer:
|
||||
"counts": self.counts, "notes": self.notes}
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- installer wrappers
|
||||
|
||||
def sibling(path, name):
|
||||
"""A file next to [path] called [name], whatever its case; None when there is none."""
|
||||
@@ -974,8 +948,6 @@ def install_wrapper(path, out):
|
||||
try:
|
||||
result = Installer(str(package), out, span=Span(lo, hi)).install()
|
||||
except MsiError as error:
|
||||
# A package with nothing for this prefix (a patch for another Windows) is skipped,
|
||||
# unless it is the only one; anything else is the whole installer's failure.
|
||||
if "installs nothing" in str(error) and len(packages) > 1:
|
||||
total["notes"].append("%s: %s" % (package.name, error))
|
||||
continue
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
#!/usr/bin/python3
|
||||
# Based on WinNative (maxjivi05, feature/wayland-gamescope e7a224ae), GPL-3.0.
|
||||
# Steam speaks NetworkManager; Android owns the radios, routes and connection. Export the
|
||||
# app's live snapshot through that API, including nearby Wi-Fi access points. Requests to
|
||||
# scan are handed to Android; Android settings still handle joining networks.
|
||||
import ipaddress
|
||||
import json
|
||||
import re
|
||||
@@ -16,7 +12,7 @@ from xml.sax.saxutils import escape
|
||||
import gi
|
||||
|
||||
gi.require_version("Gio", "2.0")
|
||||
from gi.repository import Gio, GLib # noqa: E402
|
||||
from gi.repository import Gio, GLib
|
||||
|
||||
NAME = "org.freedesktop.NetworkManager"
|
||||
ROOT = "/org/freedesktop/NetworkManager"
|
||||
@@ -60,7 +56,6 @@ def v(signature, value):
|
||||
|
||||
|
||||
def read_snapshot():
|
||||
# Atomic replacement by the app means we never see a partially written handover.
|
||||
try:
|
||||
state = json.loads(SNAPSHOT.read_text())
|
||||
if not isinstance(state, dict) or not isinstance(state.get("connected"), bool):
|
||||
@@ -71,7 +66,6 @@ def read_snapshot():
|
||||
|
||||
|
||||
def legacy_snapshot():
|
||||
# Older APKs do not publish transport metadata. Never guess Wi-Fi from an interface name.
|
||||
try:
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as sock:
|
||||
sock.connect(("192.0.2.1", 9))
|
||||
@@ -101,10 +95,10 @@ def connection_name(state):
|
||||
|
||||
def connectivity(state):
|
||||
if not state["connected"]:
|
||||
return 1 # NONE
|
||||
return 1
|
||||
if state.get("validated"):
|
||||
return 4 # FULL
|
||||
return 2 if state.get("captivePortal") else 3 # PORTAL / LIMITED
|
||||
return 4
|
||||
return 2 if state.get("captivePortal") else 3
|
||||
|
||||
|
||||
def metered(state):
|
||||
@@ -155,7 +149,6 @@ def active_ap(state):
|
||||
|
||||
|
||||
def ap_security(capabilities):
|
||||
# NetworkManager's cipher/key-management flags, from Android's beacon capabilities.
|
||||
wpa = rsn = 0
|
||||
for group in re.findall(r"\[([^]]+)\]", capabilities.upper()):
|
||||
flags = 0
|
||||
@@ -280,7 +273,6 @@ def objects(state):
|
||||
if present:
|
||||
found[path] = {NAME + f".IP{version}Config": ip_config(state, version)}
|
||||
if up and not wifi and state.get("wifiEnabled"):
|
||||
# Android can keep its Wi-Fi radio available while cellular/VPN is the default route.
|
||||
wireless = objects(dict(state, connected=False, transport="none",
|
||||
interface=state.get("wifiInterface", "wlan0"), metered=None))
|
||||
wifi_device = ROOT + "/Devices/Wifi"
|
||||
@@ -304,13 +296,11 @@ def settings(state):
|
||||
"ssid": v("ay", list((state.get("ssid") or "Wi-Fi").encode("utf-8"))), "mode": v("s", "infrastructure"),
|
||||
}
|
||||
elif state.get("transport") == "cellular":
|
||||
result["gsm"] = {} # Android owns the SIM/APN; no credentials are exported.
|
||||
result["gsm"] = {}
|
||||
return result
|
||||
|
||||
|
||||
def interface_info(interface, values):
|
||||
# Register properties on the actual objects as well as returning ObjectManager snapshots.
|
||||
# Steam/libnm also use Properties.Get/GetAll and introspect the wireless methods.
|
||||
props = "".join(f'<property name="{escape(key)}" type="{value.get_type_string()}" access="read"/>'
|
||||
for key, value in values.items())
|
||||
node = Gio.DBusNodeInfo.new_for_xml(f'<node><interface name="{interface}">{METHODS.get(interface, "")}{props}</interface></node>')
|
||||
@@ -372,7 +362,7 @@ class NetworkManager:
|
||||
def check(self):
|
||||
state = read_snapshot()
|
||||
if state is None:
|
||||
return True # A transient read failure must not replace a known link with Ethernet.
|
||||
return True
|
||||
if state == self.state:
|
||||
return True
|
||||
before, after = self.objects, objects(state)
|
||||
|
||||
@@ -33,9 +33,7 @@ APPIMAGE_RUN = os.path.join(BIN, "droiddeck-appimage-run")
|
||||
SCRIPT_RUN = os.path.join(BIN, "droiddeck-script-run")
|
||||
STEAM_LAUNCH = os.path.join(BIN, "droiddeck-steam-launch")
|
||||
CACHE = os.path.join(HOME, ".cache", "droiddeck")
|
||||
# Where the app adds each kind, and what an added one holds.
|
||||
IMPORTS = {"appimage": ("/opt/appimages/user", "app"), "folder": ("/opt/droiddeck-apps", "entry")}
|
||||
# Android's own folders on shared storage: never copied in whole.
|
||||
SHARED_FOLDERS = ("alarms", "android", "audiobooks", "dcim", "documents", "download", "movies", "music",
|
||||
"notifications", "pictures", "podcasts", "recordings", "ringtones")
|
||||
SCAN_LIMIT = 4000
|
||||
|
||||
@@ -36,7 +36,6 @@ def where(url):
|
||||
|
||||
def main(argv):
|
||||
url = argv[0] if argv else ""
|
||||
# The Steam client's own form (steam://openurl/<address>), in case a launcher passes it on.
|
||||
if url.startswith("steam://openurl/"):
|
||||
url = url[len("steam://openurl/"):]
|
||||
launch_dir = os.environ.get("BL_LAUNCH_DIR", "")
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
#!/usr/bin/python3
|
||||
# Player 1 on the session's controller, for every emulator that would otherwise start on the
|
||||
# keyboard. The session's pad is an Xbox 360 controller (libfakeinput's identity outside Steam) that
|
||||
# SDL maps by itself; what an emulator lacks is a profile that points Player 1 at it. One is
|
||||
# written only where the emulator has none yet - a profile the user made is never touched.
|
||||
# Run at every desktop start and before every program from the rail.
|
||||
import os
|
||||
|
||||
HOME = os.environ.get("HOME", "/root")
|
||||
@@ -21,10 +16,6 @@ def seed(path, text, what, done="Player 1 on the controller"):
|
||||
return True
|
||||
|
||||
|
||||
# RPCS3: its global input configuration (rpcs3::utils::get_input_config_dir() + "Default.yml").
|
||||
# Without one it adds the keyboard pad handler (pad_config.cpp, cfg_input::load). SDL handler
|
||||
# names from rpcs3/Input/sdl_pad_handler.cpp (button_list, init_config); the device is
|
||||
# "<SDL gamepad name> <n>" (sdl_pad_handler::enumerate_devices).
|
||||
RPCS3_PLAYER1 = """Player 1 Input:
|
||||
Handler: SDL
|
||||
Device: Xbox 360 Controller 1
|
||||
@@ -71,13 +62,8 @@ def rpcs3():
|
||||
rpcs3_shader_mode()
|
||||
|
||||
|
||||
# RPCS3's default shader mode (Async Recompiler with Shader Interpreter) builds 6650 interpreter
|
||||
# pipelines at the start of every boot, minutes on an Adreno. The async recompiler compiles only
|
||||
# what a game draws, in the background, once. A new install starts with it (a config.yml that
|
||||
# holds only this is merged over RPCS3's defaults); an existing one still on the default is moved
|
||||
# once, and a marker keeps any later choice the user makes in RPCS3's own settings.
|
||||
RPCS3_INTERPRETER = "Async Recompiler with Shader Interpreter"
|
||||
RPCS3_RECOMPILER = "Async Recompiler (multi-threaded)" # the GUI says "Async Shader Recompiler"; this is the value (system_config_types.cpp)
|
||||
RPCS3_RECOMPILER = "Async Recompiler (multi-threaded)"
|
||||
|
||||
|
||||
def rpcs3_shader_mode():
|
||||
@@ -101,7 +87,6 @@ def rpcs3_shader_mode():
|
||||
open(marker, "w").close()
|
||||
|
||||
|
||||
# ---- ini helpers (DuckStation and PCSX2 share one ini dialect, keys may repeat) -------------
|
||||
|
||||
def ini_section(lines, name):
|
||||
"""(start, end) line indices of [name]'s body, or None."""
|
||||
@@ -132,7 +117,6 @@ def patch_ini_section(path, section, body, what, needle="SDL-", require=None, do
|
||||
return
|
||||
new = body.strip("\n").splitlines()
|
||||
if span:
|
||||
# The controller type the emulator already wrote stays; only bindings are added.
|
||||
have = {l.split("=", 1)[0].strip() for l in lines[span[0]:span[1]] if "=" in l}
|
||||
new = [l for l in new if not (l.split("=", 1)[0].strip() == "Type" and "Type" in have)]
|
||||
end = span[1]
|
||||
@@ -147,8 +131,6 @@ def patch_ini_section(path, section, body, what, needle="SDL-", require=None, do
|
||||
print(f"droiddeck-pad-defaults: {what}: {done} ({path})")
|
||||
|
||||
|
||||
# DuckStation: SDL-<n>/<name>, axes signed (src/util/sdl_input_source.cpp); Pad1 keys from
|
||||
# src/core/analog_controller.cpp. Its defaults bind the keyboard only (settings.cpp).
|
||||
DUCKSTATION_PAD1 = """Type = AnalogController
|
||||
Up = SDL-0/DPadUp
|
||||
Down = SDL-0/DPadDown
|
||||
@@ -244,17 +226,12 @@ def bios_folder(base):
|
||||
d = os.path.join(base, "bios")
|
||||
if os.path.isdir(ROMS):
|
||||
try:
|
||||
os.makedirs(d, exist_ok=True) # where the user is told to put their BIOS
|
||||
os.makedirs(d, exist_ok=True)
|
||||
except OSError:
|
||||
pass
|
||||
return d
|
||||
|
||||
|
||||
# DuckStation (PS1) - set up like ARMSX2: users bring their own BIOS and games, in the ROMs folder.
|
||||
# Front-end runs use -batch -bigpicture -fullscreen, so the guide button is the pause menu
|
||||
# (Hotkeys OpenPauseMenu, src/core/hotkeys.cpp), not the analog toggle. Keys from
|
||||
# src/core/settings.cpp: [BIOS] SearchDirectory, [GPU] Renderer ("Vulkan"), [Main]
|
||||
# SetupWizardIncomplete (src/duckstation-qt/qthost.cpp).
|
||||
DUCKSTATION_PAD1_GUIDE_FREE = "\n".join(l for l in DUCKSTATION_PAD1.splitlines() if not l.startswith("Analog ")) + "\n"
|
||||
|
||||
|
||||
@@ -266,8 +243,6 @@ def duckstation():
|
||||
if not os.path.isfile(ini) and os.path.isfile(legacy):
|
||||
ini = legacy
|
||||
if not os.path.isfile(ini):
|
||||
# A new player: everything DuckStation's first-time setup asks is answered here (it finds
|
||||
# the BIOS in its folder by itself), so a game from the front end boots straight away.
|
||||
bios = bios_folder(ps1)
|
||||
seed(ini, "[Main]\nSetupWizardIncomplete = false\nInhibitScreensaver = false\n\n"
|
||||
f"[BIOS]\nSearchDirectory = {bios}\n\n"
|
||||
@@ -282,17 +257,12 @@ def duckstation():
|
||||
done="the guide button opens the pause menu")
|
||||
patch_ini_section(ini, "GameList", f"RecursivePaths = {ps1}\n", "DuckStation", needle=ROMS,
|
||||
done="games listed from the ROMs folder")
|
||||
# One set up by an earlier build still has its first-time setup pending, in the way of a game.
|
||||
if ini_get(ini, "Main", "SetupWizardIncomplete") == "true":
|
||||
ini_set(ini, "Main", "SetupWizardIncomplete", "false")
|
||||
print("droiddeck-pad-defaults: DuckStation: first-time setup already done here")
|
||||
# Keeping the screen awake goes through org.freedesktop.ScreenSaver, which nothing in the session
|
||||
# provides (Android decides when the screen sleeps): DuckStation only warns it failed, every game.
|
||||
if (ini_get(ini, "Main", "InhibitScreensaver") or "true") == "true":
|
||||
ini_set(ini, "Main", "InhibitScreensaver", "false")
|
||||
print("droiddeck-pad-defaults: DuckStation: no screensaver inhibit (no such service here)")
|
||||
# Once, for a DuckStation set up before this: its own empty BIOS folder moves to the ROMs folder,
|
||||
# and Automatic becomes Vulkan. A later choice in DuckStation's settings is kept.
|
||||
marker = os.path.join(os.path.dirname(ini), ".droiddeck-setup")
|
||||
if os.path.exists(marker):
|
||||
return
|
||||
@@ -307,8 +277,6 @@ def duckstation():
|
||||
open(marker, "w").close()
|
||||
|
||||
|
||||
# PCSX2: FaceSouth/... names (pcsx2/Input/SDLInputSource.cpp), keys from SIO/Pad/PadDualshock2.cpp.
|
||||
# An ini without [UI] SettingsVersion is thrown away and rebuilt, so only a complete one is patched.
|
||||
PCSX2_PAD1 = """Type = DualShock2
|
||||
Up = SDL-0/DPadUp
|
||||
Right = SDL-0/DPadRight
|
||||
@@ -346,8 +314,6 @@ def pcsx2():
|
||||
|
||||
|
||||
|
||||
# Dolphin: SDL/<id>/<SDL gamepad name>; control names from InputCommon/.../SDL/SDLGamepad.h (Left Y+
|
||||
# is up). A section that exists is taken whole - keys it lacks are unbound - so both are complete.
|
||||
DOLPHIN_GC = """[GCPad1]
|
||||
Device = SDL/0/Xbox 360 Controller
|
||||
Buttons/A = `Button S`
|
||||
@@ -406,11 +372,6 @@ Nunchuk/Stick/Right = `Left X+`
|
||||
"""
|
||||
|
||||
|
||||
# ARMSX2 - the PS2 emulator (PCSX2 with ARM64 recompilers; upstream PCSX2 interprets on ARM64). Its
|
||||
# files are PCSX2's under $XDG_CONFIG_HOME/ARMSX2 (pcsx2/Pcsx2Config.cpp). The user supplies the BIOS
|
||||
# and the games; they live in the ROMs folder (/root/ROMs). The guide button opens the pause menu
|
||||
# (Hotkeys OpenPauseMenu) - the way out of a game started from the front end, which runs ARMSX2
|
||||
# without its window (-batch -bigpicture) - so it is not also the analog toggle here.
|
||||
ARMSX2_PAD1 = "\n".join(l for l in PCSX2_PAD1.splitlines() if not l.startswith("Analog ")) + "\n"
|
||||
ROMS = "/root/ROMs"
|
||||
|
||||
@@ -432,7 +393,7 @@ def ps2_bios_folder():
|
||||
d = os.path.join(base, "bios")
|
||||
if os.path.isdir(ROMS):
|
||||
try:
|
||||
os.makedirs(d, exist_ok=True) # where the user is told to put their BIOS
|
||||
os.makedirs(d, exist_ok=True)
|
||||
except OSError:
|
||||
pass
|
||||
return d
|
||||
@@ -443,8 +404,6 @@ def armsx2():
|
||||
ini = os.path.join(root, "inis/PCSX2.ini")
|
||||
old = os.path.join(CONFIG, "PCSX2")
|
||||
if not os.path.isfile(ini) and os.path.isfile(os.path.join(old, "inis/PCSX2.ini")):
|
||||
# Someone who played on PCSX2 here: the same settings, BIOS choice and memory cards (the
|
||||
# saves), copied once. PCSX2's own folder is left as it was.
|
||||
import shutil
|
||||
for sub in ("inis", "memcards", "bios", "gamesettings", "cheats", "patches", "covers",
|
||||
"inputprofiles", "textures"):
|
||||
@@ -453,22 +412,16 @@ def armsx2():
|
||||
shutil.copytree(src, os.path.join(root, sub), dirs_exist_ok=True)
|
||||
print(f"droiddeck-pad-defaults: ARMSX2: settings and memory cards copied from PCSX2 ({root})")
|
||||
elif not os.path.isfile(ini):
|
||||
# A new player: everything ARMSX2's first-time setup asks is answered here - the BIOS
|
||||
# folder in the ROMs folder, the ps2 folder as its game list, the controller on Player 1 -
|
||||
# and the BIOS file itself is picked below once one is there.
|
||||
bios, games = ps2_bios_folder(), ps2_folder()
|
||||
seed(ini, "[UI]\nSettingsVersion = 1\nSetupWizardIncomplete = false\n\n"
|
||||
f"[Folders]\nBios = {bios}\n\n"
|
||||
f"[GameList]\nRecursivePaths = {games}\n\n"
|
||||
# Vulkan outright rather than Auto's pick: the renderer every other path here uses.
|
||||
"[EmuCore/GS]\nRenderer = 14\n\n"
|
||||
"[Hotkeys]\nOpenPauseMenu = Keyboard/Escape\nOpenPauseMenu = SDL-0/Guide\n\n"
|
||||
"[Pad1]\n" + ARMSX2_PAD1, "ARMSX2", "first-time setup, BIOS from " + bios)
|
||||
armsx2_bios(ini)
|
||||
return
|
||||
patch_ini_section(ini, "Pad1", ARMSX2_PAD1, "ARMSX2", require="SettingsVersion")
|
||||
# The guide button is the pause menu here; PCSX2's profile (ours, copied over) had it as the
|
||||
# analog toggle as well.
|
||||
with open(ini, encoding="utf-8", errors="replace") as f:
|
||||
lines = f.read().splitlines()
|
||||
kept = [l for l in lines if l.replace(" ", "") != "Analog=SDL-0/Guide"]
|
||||
@@ -497,7 +450,6 @@ def armsx2_bios(ini):
|
||||
if current and os.path.isfile(os.path.join(folder, current)):
|
||||
return
|
||||
try:
|
||||
# A PS2 BIOS dump is 4 MiB (a few are 8); the .nvm/.mec files beside it are not dumps.
|
||||
dumps = sorted(f for f in os.listdir(folder)
|
||||
if os.path.isfile(os.path.join(folder, f)) and 4 << 20 <= os.path.getsize(os.path.join(folder, f)) <= 8 << 20)
|
||||
except OSError:
|
||||
@@ -510,12 +462,6 @@ def armsx2_bios(ini):
|
||||
print(f"droiddeck-pad-defaults: ARMSX2: BIOS {pick}")
|
||||
|
||||
|
||||
# Dolphin (PC) has no controller menu, so the guide button is its Toggle Fullscreen hotkey: out of full
|
||||
# screen is Dolphin's own window with its Config / Graphics / Stop buttons. Hotkeys.ini is all-or-
|
||||
# nothing - a file with one line drops every other default - so a new one carries Dolphin's defaults,
|
||||
# generated from HotkeyManager.cpp's LoadDefaults (Linux branch, RetroAchievements on) plus the guide;
|
||||
# an existing one only gets the guide added to its Toggle Fullscreen. The Wii remote's Home, which
|
||||
# was on the guide button, is on the right shoulder button instead.
|
||||
DOLPHIN_GUIDE = "`SDL/0/Xbox 360 Controller:Guide`"
|
||||
DOLPHIN_HOTKEYS = """[Hotkeys]
|
||||
Device = XInput2/0/Virtual core pointer
|
||||
@@ -632,11 +578,6 @@ def dolphin():
|
||||
ini_set(hotkeys, "Hotkeys", "General/Toggle Fullscreen",
|
||||
(current + " | " if current else "") + DOLPHIN_GUIDE)
|
||||
print("droiddeck-pad-defaults: Dolphin: the guide button shows Dolphin's window (Toggle Fullscreen)")
|
||||
# Games from the ROMs folder's gamecube and wii folders, subfolders included; Vulkan; no
|
||||
# NKit warning (it will not let a game start until a box is ticked - games run either way,
|
||||
# the warning is about loading times, netplay and save states); no statistics question.
|
||||
# Names from Dolphin's MainSettings.cpp / UISettings.cpp. Only what is not set yet is added,
|
||||
# except the game folders, which are added to whatever the user has.
|
||||
ini = os.path.join(d, "Dolphin.ini")
|
||||
gc = system_folder(("gamecube", "gc", "ngc"), "gamecube")
|
||||
wii = system_folder(("wii",), "wii")
|
||||
@@ -655,9 +596,6 @@ def dolphin():
|
||||
count = 0
|
||||
paths = [ini_get(ini, "General", "ISOPath%d" % i) for i in range(count)]
|
||||
changed = []
|
||||
# The whole ROMs folder as a game folder (what Dolphin's "set a games directory" was pointed at
|
||||
# before) would, searched with its subfolders, have Dolphin open every PS2 and PS3 image too;
|
||||
# the system folders below cover it.
|
||||
if any((p or "").rstrip("/") == ROMS for p in paths):
|
||||
paths = [p for p in paths if p and p.rstrip("/") != ROMS]
|
||||
for i, p in enumerate(paths):
|
||||
@@ -680,7 +618,6 @@ def dolphin():
|
||||
changed.append("subfolders")
|
||||
if changed:
|
||||
print("droiddeck-pad-defaults: Dolphin: games from " + ", ".join(changed))
|
||||
# Once, for a Dolphin set up before this: Vulkan unless it was chosen already, and the NKit box.
|
||||
marker = os.path.join(d, ".droiddeck-setup")
|
||||
if os.path.exists(marker):
|
||||
return
|
||||
@@ -694,10 +631,6 @@ def dolphin():
|
||||
print("droiddeck-pad-defaults: Dolphin: Vulkan, no NKit warning")
|
||||
|
||||
|
||||
# Cemu: an SDLController profile for the GamePad. The uuid is "<index>_<SDL GUID>" and SDL's GUID
|
||||
# carries a CRC of the device name; this is the one SDL reports for the session's pad
|
||||
# ("Xbox 360 Controller (0)", 045e:028e - read from RPCS3's SDL log on the device). Mapping ids
|
||||
# from VPADController.h, values from Controller.h, Cemu's own SDL default layout plus Home.
|
||||
CEMU_MAP = [(1, 1), (2, 0), (3, 3), (4, 2), (5, 9), (6, 10), (7, 42), (8, 43), (9, 6), (10, 4),
|
||||
(11, 11), (12, 12), (13, 13), (14, 14), (15, 7), (16, 8), (17, 45), (18, 39), (19, 44),
|
||||
(20, 38), (21, 47), (22, 41), (23, 46), (24, 40), (27, 5)]
|
||||
@@ -717,11 +650,6 @@ CEMU_XML = """<?xml version="1.0" encoding="UTF-8"?>
|
||||
"""
|
||||
|
||||
|
||||
# Cemu's settings, so its Getting Started dialog (shown while settings.xml is missing, and whose
|
||||
# folder picker cannot reach ROMs) never blocks a launch: the Wii U games folder, Vulkan
|
||||
# (Graphic api 1), and audio through Cubeb (the only backend on Linux; api 3) on the default
|
||||
# device for both the TV and the GamePad speaker - some titles play everything through the
|
||||
# GamePad - at full volume (Cemu's own default is 20 %). Keys from config/CemuConfig.cpp.
|
||||
CEMU_SETTINGS = """<?xml version="1.0" encoding="UTF-8"?>
|
||||
<content>
|
||||
<mlc_path></mlc_path>
|
||||
@@ -749,11 +677,6 @@ def cemu():
|
||||
done=f"games in {games}, Vulkan, Cubeb audio on the default device")
|
||||
|
||||
|
||||
# melonDS 1.x: raw SDL joystick indices. The session's pad has the kernel's Xbox 360 layout
|
||||
# (buttons A B X Y LB RB Back Start Guide LS RS = 0..10, hat 0 for the d-pad); the d-pad values
|
||||
# also take the left stick (EmuInstanceInput.cpp; encoding InputConfig/MapButton.h). The guide
|
||||
# button toggles full screen (HK_FullscreenToggle), as it does in Dolphin: the front end starts
|
||||
# melonDS full screen (-f), and leaving it shows the window's menus for settings.
|
||||
MELONDS_GUIDE = 8
|
||||
MELONDS_JOY = f"""[Instance0.Joystick]
|
||||
A = 1
|
||||
@@ -771,28 +694,15 @@ Right = 65794
|
||||
HK_FullscreenToggle = {MELONDS_GUIDE}
|
||||
"""
|
||||
|
||||
# The screen a handheld's wide panel suits best: the top screen as big as the panel's height allows
|
||||
# with the bottom screen alone beside it, centred (ScreenLayout.h: Horizontal = 2, EmphTop = 1;
|
||||
# melonDS's Hybrid shows the big screen a second time, small, above the bottom one; nobody needs
|
||||
# it twice). Sharp pixels: no filtering, and no integer steps that leave the panel half used. Keys as
|
||||
# melonDS writes them (Window.cpp windowCfg).
|
||||
MELONDS_WINDOW = """[Instance0.Window0]
|
||||
ScreenLayout = 2
|
||||
ScreenSizing = 1
|
||||
IntegerScaling = false
|
||||
ScreenFilter = false
|
||||
"""
|
||||
# melonDS's own defaults for those, which an existing install is moved off once. Hybrid (3) was
|
||||
# this preset's first layout, and moves on too.
|
||||
MELONDS_WINDOW_DEFAULTS = {"ScreenLayout": ("0", "3"), "ScreenSizing": ("0",), "ScreenFilter": ("true",)}
|
||||
|
||||
|
||||
# The window melonDS returns to when the guide button leaves full screen: 1x wide (the width of
|
||||
# two DS screens side by side, Screen.cpp screenGetMinSize) and 16:9, so gamescope stretches it to
|
||||
# fill the panel and the menu bar and cursor come out large enough to use. A bigger window keeps
|
||||
# its menus at their real size, tiny on a handheld. Qt's saveGeometry() v3 blob: magic, version,
|
||||
# frame and normal rects (x, y, right, bottom), screen, maximized, full screen, screen width, and
|
||||
# the normal rect again (QWidget::restoreGeometry).
|
||||
def melonds_geometry():
|
||||
import base64, struct
|
||||
w, h = 512, 288
|
||||
@@ -845,11 +755,6 @@ def toml_str(path):
|
||||
return '"' + path.replace("\\", "\\\\").replace('"', '\\"') + '"'
|
||||
|
||||
|
||||
# The user's own BIOS, firmware and DSi NAND, found in the ROMs folder's nds/bios (or firmware)
|
||||
# folder by what each file is: the DS BIOSes by size and checksum (the GBA BIOS is also 16 KB),
|
||||
# firmware and NAND by size, the DSi boot ROMs (both 64 KB) by the 7 or 9 in their names. A path
|
||||
# is only filled where melonDS has none, and external files are only switched on when a whole set
|
||||
# was found - without them melonDS runs DS games on its built-in free BIOS.
|
||||
DS_BIOS7_MD5 = "df692a80a5b1bc90728bc3dfc76cd948"
|
||||
DS_BIOS9_MD5 = "a392174eb3e572fed6447e956bde4b25"
|
||||
|
||||
@@ -924,7 +829,6 @@ def melonds():
|
||||
lines = text.splitlines()
|
||||
done = []
|
||||
if not any(isinstance(v, int) and v != -1 and k != "HK_FullscreenToggle" for k, v in joy.items()):
|
||||
# Replace melonDS's own all-unbound table with ours (a TOML table can be defined only once).
|
||||
out, skipping = [], False
|
||||
for line in lines:
|
||||
t = line.strip()
|
||||
@@ -937,8 +841,6 @@ def melonds():
|
||||
elif joy.get("HK_FullscreenToggle", -1) == -1 and MELONDS_GUIDE not in joy.values():
|
||||
toml_set(lines, "Instance0.Joystick", "HK_FullscreenToggle", str(MELONDS_GUIDE))
|
||||
done.append("guide button toggles full screen")
|
||||
# Once, for a melonDS set up before this: the big top screen, where it is still on its own
|
||||
# defaults. The marker keeps whatever the user picks in melonDS's View menu afterwards.
|
||||
if not os.path.exists(marker):
|
||||
for l in MELONDS_WINDOW.splitlines()[1:]:
|
||||
k, v = (x.strip() for x in l.split("=", 1))
|
||||
@@ -957,9 +859,6 @@ def melonds():
|
||||
print(f"droiddeck-pad-defaults: melonDS: {'; '.join(done)} ({path})")
|
||||
|
||||
|
||||
# PPSSPP (SDL): its pad defaults leave the shoulders, the right stick and the triggers unbound on
|
||||
# SDL builds (SDLJoystick.cpp codes vs KeyMapDefaults.cpp); a [ControlMapping] that exists replaces
|
||||
# every default, so this one is complete, keyboard included (device 1 keyboard, 10 pad).
|
||||
PPSSPP_CONTROLS = """[ControlMapping]
|
||||
Up = 1-19,10-19
|
||||
Down = 1-20,10-20
|
||||
@@ -989,8 +888,6 @@ def ppsspp():
|
||||
seed(os.path.join(CONFIG, "ppsspp/PSP/SYSTEM/controls.ini"), PPSSPP_CONTROLS, "PPSSPP")
|
||||
|
||||
|
||||
# RetroArch: the udev joypad driver finds nothing here (no udev database in the runtime); sdl2
|
||||
# does, and matches this profile by vendor/product (task_autodetect.c).
|
||||
RETROARCH_PROFILE = """input_driver = "sdl2"
|
||||
input_device = "Xbox 360 Controller"
|
||||
input_vendor_id = "1118"
|
||||
@@ -1044,11 +941,6 @@ def retroarch():
|
||||
print(f"droiddeck-pad-defaults: RetroArch: joypad driver udev -> sdl2 ({cfg})")
|
||||
|
||||
|
||||
# yuzu and its forks: Player 1 in [Controls] of <name>/qt-config.ini, which each writes at its first
|
||||
# start with the keyboard bound. Bindings are input_common ParamPackages, laid out by position as the
|
||||
# frontend's own auto-map does (sdl_driver.cpp GetDefaultButtonBinding); the guid is SDL's with the
|
||||
# name CRC cleared (GetGUID). A key is only read while its \default is false. Done once per emulator,
|
||||
# and only while Player 1 is still on the keyboard.
|
||||
SWITCH_PAD = "engine:sdl,port:0,guid:030000005e0400008e02000010010000,"
|
||||
SWITCH_PLAYER1 = {
|
||||
"button_a": "button:1", "button_b": "button:0", "button_x": "button:3", "button_y": "button:2",
|
||||
|
||||
@@ -1,23 +1,4 @@
|
||||
#!/usr/bin/python3
|
||||
# Installs a third-party Proton build into the client's compatibilitytools.d, so it appears in the
|
||||
# Compatibility dropdown beside our own Proton ARM64 and can be picked per game.
|
||||
#
|
||||
# droiddeck-proton-extra <steam root> ge [--tag GE-Proton11-7]
|
||||
# droiddeck-proton-extra <steam root> cachyos [--tag cachyos-11.0-20260703-slr]
|
||||
# droiddeck-proton-extra <steam root> <url of an aarch64 tarball>
|
||||
# droiddeck-proton-extra <steam root> /path/to/an/aarch64/tarball
|
||||
# droiddeck-proton-extra <steam root> --list what is installed now
|
||||
#
|
||||
# Both projects publish native ARM64 builds - GloriousEggroll as "*-aarch64.tar.gz", CachyOS as
|
||||
# "*-arm64.tar.xz" - and both are ordinary Proton trees: a python entry point beside a files/
|
||||
# directory holding Wine, DXVK and VKD3D. That is the same shape as the depot the Steam client
|
||||
# downloads, so the runtime can run them the same way.
|
||||
#
|
||||
# What it cannot use is their toolmanifest. Like Valve's ARM64 depot they declare
|
||||
# require_tool_appid, which makes Steam stack pressure-vessel underneath - and pressure-vessel
|
||||
# needs unprivileged user namespaces, which an Android app does not get. Patching that out is
|
||||
# steam-compatibility's job (adopt_extras); this script only puts the tree in place and then
|
||||
# calls it, so an install is usable without restarting the client.
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
@@ -29,16 +10,12 @@ import urllib.error
|
||||
import urllib.request
|
||||
|
||||
RELEASES = "https://api.github.com/repos/%s/releases"
|
||||
# Each source: the GitHub repo, and how its ARM64 asset is named. Ordered newest-release-first by
|
||||
# the API, so "latest usable" is the first release that actually carries an ARM64 asset - the
|
||||
# projects do not build one for every tag.
|
||||
SOURCES = {
|
||||
"ge": ("GloriousEggroll/proton-ge-custom", re.compile(r"aarch64\.tar\.(gz|xz)$")),
|
||||
"cachyos": ("CachyOS/proton-cachyos", re.compile(r"arm64\.tar\.(gz|xz)$")),
|
||||
"droiddeck": ("The412Banner/DroidDeck-Proton", re.compile(r"aarch64\.tar\.(gz|xz)$")),
|
||||
}
|
||||
USER_AGENT = "droiddeck-proton-extra"
|
||||
# Room for the tarball and the tree it unpacks to. GE-Proton's aarch64 build is ~650 MB packed and
|
||||
# unpacks to about three times that; refusing early beats a half-written tool directory.
|
||||
NEED_BYTES = 4 * 1024 * 1024 * 1024
|
||||
|
||||
|
||||
@@ -54,10 +31,10 @@ def fetch_json(url):
|
||||
|
||||
|
||||
def pick_asset(source):
|
||||
"""(release tag, asset url, sha512 url or None) for the newest release with an ARM64 build."""
|
||||
"""(release tag, asset url, sha512 url or None) for the newest full release with an ARM64 build."""
|
||||
repo, pattern = SOURCES[source]
|
||||
for release in fetch_json(RELEASES % repo + "?per_page=15"):
|
||||
if release.get("draft"):
|
||||
if release.get("draft") or release.get("prerelease"):
|
||||
continue
|
||||
assets = {a["name"]: a["browser_download_url"] for a in release.get("assets", ())}
|
||||
for name in sorted(assets):
|
||||
@@ -119,8 +96,6 @@ def extract(tarball, into):
|
||||
rc = subprocess.call(["tar", "-xf", tarball, "-C", into])
|
||||
if rc != 0:
|
||||
raise SystemExit("droiddeck-proton-extra: tar failed (%d)" % rc)
|
||||
# A Proton tarball holds one top-level directory. Take whichever entry has the entry point so a
|
||||
# stray ._ file or a nested layout does not decide it.
|
||||
entries = [e for e in sorted(os.listdir(into)) if not e.startswith(".")]
|
||||
for entry in entries:
|
||||
path = os.path.join(into, entry)
|
||||
@@ -144,7 +119,7 @@ def installed(tools):
|
||||
def main():
|
||||
argv = sys.argv[1:]
|
||||
if not argv:
|
||||
raise SystemExit(__doc__ or "usage: droiddeck-proton-extra <steam root> ge|cachyos|<url>")
|
||||
raise SystemExit(__doc__ or "usage: droiddeck-proton-extra <steam root> ge|cachyos|droiddeck|<url>")
|
||||
steam_root = argv.pop(0)
|
||||
tools = os.path.join(steam_root, "compatibilitytools.d")
|
||||
os.makedirs(tools, exist_ok=True)
|
||||
@@ -160,9 +135,6 @@ def main():
|
||||
argv.pop(0)
|
||||
tag = argv.pop(0) if argv else None
|
||||
|
||||
# A tarball already on the device is used as it is: a session that has to pull 650 MB down
|
||||
# first shows nothing on screen for ten minutes, so the download can be done ahead of time and
|
||||
# handed over by path.
|
||||
local = None
|
||||
if what in SOURCES:
|
||||
tag, url, sums = release_asset(what, tag) if tag else pick_asset(what)
|
||||
@@ -176,7 +148,7 @@ def main():
|
||||
log("using %s" % what)
|
||||
else:
|
||||
raise SystemExit(
|
||||
"droiddeck-proton-extra: expected ge, cachyos, a URL or a tarball path, got %r" % what)
|
||||
"droiddeck-proton-extra: expected ge, cachyos, droiddeck, a URL or a tarball path, got %r" % what)
|
||||
|
||||
free = shutil.disk_usage(tools).free
|
||||
if free < NEED_BYTES:
|
||||
@@ -198,8 +170,6 @@ def main():
|
||||
tree = extract(tarball, unpacked)
|
||||
name = os.path.basename(tree)
|
||||
final = os.path.join(tools, name)
|
||||
# Replaced rather than merged: a half-written tree from an interrupted run would otherwise
|
||||
# leave stale files behind that Proton would load.
|
||||
if os.path.exists(final):
|
||||
shutil.rmtree(final, ignore_errors=True)
|
||||
os.rename(tree, final)
|
||||
@@ -209,8 +179,6 @@ def main():
|
||||
shutil.rmtree(staging, ignore_errors=True)
|
||||
log("installed %s" % name)
|
||||
|
||||
# Patches out require_tool_appid and wraps the entry point, which is what makes it launchable
|
||||
# here. Doing it now means the client picks the tool up on its next restart with no extra step.
|
||||
subprocess.call(["steam-compatibility", steam_root])
|
||||
|
||||
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
#!/bin/bash
|
||||
# A script added on the Desktop page (UserApps), run from its own folder:
|
||||
# droiddeck-script-run /opt/droiddeck-apps/<id> [args...]
|
||||
set -u
|
||||
dir=${1:?usage: droiddeck-script-run <added app directory> [args...]}
|
||||
shift
|
||||
entry=$(cat "$dir/entry" 2>/dev/null) || { echo "droiddeck-script-run: $dir has no entry" >&2; exit 127; }
|
||||
cd -P "$dir/files" 2>/dev/null || { echo "droiddeck-script-run: $dir/files is missing; add the script again" >&2; exit 127; }
|
||||
folder=$PWD
|
||||
# Shared storage is noexec, so the script is handed to its interpreter rather than executed.
|
||||
first=
|
||||
IFS= read -r first < "$entry"
|
||||
first=${first%$'\r'}
|
||||
interp=(/bin/bash)
|
||||
# A program as the entry (the desktop's copy of a game's folder) runs itself.
|
||||
case $first in '#!'*) read -r -a interp <<< "${first#'#!'}" ;; $'\x7f'ELF*) interp=() ;; esac
|
||||
fex=$(cat "$dir/fex" 2>/dev/null)
|
||||
case $fex in on|off) ;; *) fex=auto ;; esac
|
||||
@@ -31,7 +27,6 @@ case ${DBUS_SESSION_BUS_ADDRESS:-} in
|
||||
fi ;;
|
||||
esac
|
||||
rc=$?
|
||||
# A launcher script often starts the game and returns; the session lasts while it runs.
|
||||
running() {
|
||||
local p exe arg cwd
|
||||
for p in /proc/[0-9]*; do
|
||||
|
||||
@@ -1,38 +1,15 @@
|
||||
#!/bin/bash
|
||||
# Marks Steam's shared redistributables as already run in every Proton prefix, and in the
|
||||
# template Proton makes new prefixes from.
|
||||
#
|
||||
# A game whose depot lists _CommonRedist makes the client run the real installer inside the
|
||||
# prefix on first launch. Those are x86 bundles, so they run under FEX, and the 2019 one leaves
|
||||
# a task behind every time: its main thread exits while a helper stays blocked reading a pipe it
|
||||
# also holds the write end of, so the process never reaps and the client keeps waiting on it.
|
||||
#
|
||||
# The client skips a "Run Process" block whose HasRunKey is already set, which is the same escape
|
||||
# WineUtils.seedVcRedistRegistryIfDllsPresent() takes for the app's own containers. The names and
|
||||
# versions come out of the install scripts rather than a list kept here, because Valve revises
|
||||
# them; a prefix already carrying the same set is left alone.
|
||||
#
|
||||
# Games also carry install scripts of their own (<game>/_CommonRedist/vcredist/2022/installscript.vdf
|
||||
# and the like), often with another version in the value name; those are read too. And the VC++
|
||||
# 2015-2022 runtime is recorded as installed the way Microsoft's installers look for it: on ARM64
|
||||
# Proton the x64 bundle otherwise stops with "Microsoft Visual C++ 2015-2022 Redistributable (arm64)
|
||||
# is required", while Proton's own msvcp140/vcruntime140 already serve the game.
|
||||
set -u
|
||||
steam_root=${1:?steam root}
|
||||
LIBRARIES=${DROIDDECK_LIBRARIES-/mnt/droiddeck /mnt/droiddeck-sd}
|
||||
|
||||
redist="$steam_root/steamapps/common/Steamworks Shared/_CommonRedist"
|
||||
|
||||
# Every process an install script would run, as the registry key and value the client writes once
|
||||
# it has run it. Names sit one level inside "Run Process", the key they share a level further in.
|
||||
read_scripts() { xargs -0 -r awk '
|
||||
# A block whose HasRunKey is set is one process; its name is the key the block opened under, at
|
||||
# whatever depth - an install script nests it under "Run Process", the client'"'"'s evaluator script
|
||||
# for a game wraps the same blocks once more.
|
||||
read_scripts() { xargs -0 -r awk -v want="${1:-redists}" '
|
||||
FNR == 1 { depth = 0; pending = "" }
|
||||
/^[[:space:]]*\{/ { depth++; name[depth] = pending; key[depth] = ""; pending = ""; next }
|
||||
/^[[:space:]]*\{/ { depth++; name[depth] = pending; key[depth] = ""; vulkan[depth] = 0; pending = ""; next }
|
||||
/^[[:space:]]*\}/ {
|
||||
if (depth > 0 && key[depth] != "" && name[depth] != "")
|
||||
if (depth > 0 && key[depth] != "" && name[depth] != "" && vulkan[depth] == (want == "vulkan"))
|
||||
printf "%s\t%s\n", key[depth], name[depth]
|
||||
if (depth > 0) depth--
|
||||
next
|
||||
@@ -40,12 +17,16 @@ read_scripts() { xargs -0 -r awk '
|
||||
{
|
||||
n = split($0, part, "\"")
|
||||
if (n >= 5 && tolower(part[2]) == "hasrunkey") { key[depth] = part[4]; next }
|
||||
if (n >= 5 && tolower(part[2]) ~ /^process [0-9]+$/) {
|
||||
program = tolower(part[4])
|
||||
sub(/.*[\\\/]/, "", program)
|
||||
if (program ~ /vulkan/) vulkan[depth] = 1
|
||||
next
|
||||
}
|
||||
if (n == 3) pending = part[2]
|
||||
}
|
||||
'; }
|
||||
pairs=$(find "$redist" -name installscript.vdf -print0 2>/dev/null | sort -z | read_scripts)
|
||||
# The client downloads the scripts with the first game that wants them, which is too late for that
|
||||
# game; until then the set they held when this was written stands in. (WinNative's list.)
|
||||
[ -n "$pairs" ] || pairs=$(sed 's/^\([^ ]*\) /HKEY_LOCAL_MACHINE\\\\Software\\\\Valve\\\\Steam\\\\Apps\\\\CommonRedist\\\\\1\t/' <<'KNOWN'
|
||||
DirectX\\Jun2010 dxsetup
|
||||
.NET\\4.8 4.8
|
||||
@@ -66,8 +47,6 @@ vcredist\\2022 x64 14.51.36247.0
|
||||
KNOWN
|
||||
)
|
||||
|
||||
# The games' own scripts. Finding them walks every game folder, so the list is kept until a game is
|
||||
# installed, updated or removed (its appmanifest changes) - this runs every quarter minute.
|
||||
cache="$steam_root/.droiddeck-game-scripts"
|
||||
libraries="$steam_root"
|
||||
for library in $LIBRARIES; do libraries="$libraries
|
||||
@@ -84,17 +63,14 @@ if [ "$(head -n 1 "$cache" 2>/dev/null)" != "$sig" ]; then
|
||||
done <<<"$libraries" | sort -u
|
||||
} >"$cache.tmp" && mv -f "$cache.tmp" "$cache"
|
||||
fi
|
||||
game_pairs=$(tail -n +2 "$cache" 2>/dev/null | tr '\n' '\0' | read_scripts)
|
||||
# DROIDDECK_SEED_SCRIPTS: more scripts, one path a line - droiddeck-game-env passes the client's
|
||||
# evaluator script for the game about to run its installers, read before the client looks.
|
||||
if [ -n "${DROIDDECK_SEED_SCRIPTS:-}" ]; then
|
||||
game_pairs=$(printf '%s\n%s\n' "$game_pairs" "$(printf '%s\n' "$DROIDDECK_SEED_SCRIPTS" | tr '\n' '\0' | read_scripts)")
|
||||
fi
|
||||
game_scripts() { { tail -n +2 "$cache" 2>/dev/null; printf '%s\n' "${DROIDDECK_SEED_SCRIPTS:-}"; } | sed '/^$/d' | tr '\n' '\0'; }
|
||||
game_pairs=$(game_scripts | read_scripts)
|
||||
[ -n "$(printf '%s' "$game_pairs" | tr -d '[:space:]')" ] && pairs=$(printf '%s\n%s\n' "$pairs" "$game_pairs" | sort -u | sed '/^$/d')
|
||||
declare -A vulkan=()
|
||||
while IFS= read -r line; do
|
||||
[[ $line == *$'\t'* ]] && vulkan[$line]=1
|
||||
done < <(game_scripts | read_scripts vulkan)
|
||||
|
||||
# The VC++ 2015-2022 runtime as its installers check for it, for each architecture and both registry
|
||||
# views. The version is the newest the scripts above know, so any 2015-2022 bundle finds itself
|
||||
# already installed and exits without asking for anything.
|
||||
VCRT_MAJOR=14 VCRT_MINOR=51 VCRT_BUILD=36247
|
||||
vcrt() {
|
||||
local view arch
|
||||
@@ -108,9 +84,6 @@ vcrt() {
|
||||
done
|
||||
}
|
||||
|
||||
# Each prefix's marker lists the names it was given, so it is handed only what it lacks. One stamp
|
||||
# for the whole set flipped between the session's set and the evaluator's (which adds the game's
|
||||
# own names) on every launch, and every prefix was appended to again, inside the launch.
|
||||
want=()
|
||||
declare -A wanted=()
|
||||
while IFS= read -r line; do
|
||||
@@ -126,9 +99,6 @@ block_for() { printf '%s\n' "$@" | awk -F'\t' -v now="$now" '
|
||||
if (path == $1)
|
||||
next
|
||||
printf "\n[%s] %d\n\"%s\"=dword:00000001\n", path, now, $2
|
||||
# The client writes these from 32-bit steam.exe, so its own copy lands under Wow6432Node;
|
||||
# both spellings are seeded because the reader picks by its own word size.
|
||||
# Joined rather than sub()stituted: gawk and mawk read backslashes in a replacement differently.
|
||||
if (substr(path, 1, 10) != "Software\\\\")
|
||||
next
|
||||
printf "\n[%s] %d\n\"%s\"=dword:00000001\n", "Software\\\\Wow6432Node\\\\" substr(path, 11), now, $2
|
||||
@@ -138,9 +108,37 @@ block_for() { printf '%s\n' "$@" | awk -F'\t' -v now="$now" '
|
||||
for line; do [[ $line == vcrt$'\t'* ]] && vcrt "$now"; done
|
||||
}
|
||||
|
||||
# Proton builds a new prefix from its template, and the client runs the install scripts in that
|
||||
# prefix moments later, so the template carries the markers too. Its date is kept: Proton reads a
|
||||
# changed one as a new template and upgrades every prefix made from the old.
|
||||
unseed() {
|
||||
local reg=$1 out
|
||||
shift
|
||||
out=$(mktemp "${reg%/*}/.system.reg.XXXXXX") || return 1
|
||||
if printf '%s\n' "$@" | awk -F'\t' '
|
||||
NR == FNR {
|
||||
path = $1
|
||||
sub(/^HKEY_LOCAL_MACHINE\\\\/, "", path)
|
||||
if (path == $1)
|
||||
next
|
||||
path = tolower(path)
|
||||
drop["[" path "]" SUBSEP tolower($2)] = 1
|
||||
if (substr(path, 1, 10) == "software\\\\")
|
||||
drop["[software\\\\wow6432node\\\\" substr(path, 11) "]" SUBSEP tolower($2)] = 1
|
||||
next
|
||||
}
|
||||
/^\[/ { section = tolower(substr($0, 1, index($0, "]"))) }
|
||||
/^"/ {
|
||||
value = substr($0, 2)
|
||||
value = tolower(substr(value, 1, index(value, "\"=") - 1))
|
||||
if ((section SUBSEP value) in drop)
|
||||
next
|
||||
}
|
||||
{ print }
|
||||
' - "$reg" >"$out" && touch -r "$reg" "$out" && mv -f "$out" "$reg"; then
|
||||
return 0
|
||||
fi
|
||||
rm -f "$out"
|
||||
return 1
|
||||
}
|
||||
|
||||
for reg in "$steam_root"/steamapps/common/Proton*/files/share/default_pfx*/system.reg \
|
||||
/mnt/droiddeck-sd/steamapps/common/Proton*/files/share/default_pfx*/system.reg \
|
||||
/root/Games/*/steamapps/common/Proton*/files/share/default_pfx*/system.reg \
|
||||
@@ -158,6 +156,16 @@ for reg in "$steam_root"/steamapps/common/Proton*/files/share/default_pfx*/syste
|
||||
if [ -f "$seeded" ]; then
|
||||
while IFS= read -r line; do [[ $line == *$'\t'* ]] && had[$line]=1; done <"$seeded"
|
||||
fi
|
||||
stale=() kept=()
|
||||
for line in "${!had[@]}"; do
|
||||
if [ -n "${vulkan[$line]:-}" ]; then stale+=("$line"); else kept+=("$line"); fi
|
||||
done
|
||||
if [ ${#stale[@]} -gt 0 ] && unseed "$reg" "${stale[@]}"; then
|
||||
had=()
|
||||
for line in "${kept[@]}"; do had[$line]=1; done
|
||||
printf '%s\n' "${kept[@]}" >"$seeded"
|
||||
echo "== took Vulkan runtime markers out of $reg"
|
||||
fi
|
||||
missing=()
|
||||
for line in "${want[@]}"; do [ -n "${had[$line]:-}" ] || missing+=("$line"); done
|
||||
[ ${#missing[@]} -eq 0 ] && continue
|
||||
|
||||
@@ -1,27 +1,14 @@
|
||||
#!/bin/bash
|
||||
# The Linux runtime's session. DroidDeck execs this under proot with the output size and mode;
|
||||
# the first pass starts gamescope, which execs this script again inside it for the program:
|
||||
# droiddeck-session desktop the file manager
|
||||
# droiddeck-session run <path> a Linux program (AppImage, script or ELF)
|
||||
# droiddeck-session steam [steam-url] the native Steam client
|
||||
# droiddeck-session lxqt the KDE Plasma desktop (DroidDeck's desktop package)
|
||||
# BL_WIDTH / BL_HEIGHT size the output, BL_FPS limits it, BL_LOG collects everything said here.
|
||||
set -u
|
||||
export HOME=${HOME:-/root}
|
||||
mode=${1:-desktop}
|
||||
shift || true
|
||||
# One line per milestone, greppable as "== STEP", so a first run reads as a narrative rather than
|
||||
# something to be reconstructed from Steam's own chatter. The app shows these while it waits.
|
||||
step() { echo "== STEP $(date -u +%H:%M:%S) $*"; }
|
||||
if [ -n "${BL_LOG:-}" ] && [ -z "${BL_INSIDE:-}" ]; then
|
||||
mkdir -p "$(dirname "$BL_LOG")" 2>/dev/null
|
||||
# The client alone writes megabytes an hour; one earlier log is kept, not every session's.
|
||||
if [ "$(stat -c %s "$BL_LOG" 2>/dev/null || echo 0)" -gt 8388608 ]; then
|
||||
mv -f "$BL_LOG" "$BL_LOG.1"
|
||||
fi
|
||||
# A guest looping on an error writes gigabytes in minutes (an Xwayland proot had lost track of
|
||||
# managed 9 GB of one line in 19 min): the log keeps its first BL_LOG_CAP bytes and the rest is
|
||||
# drained, not refused - a writer that filled it must not die of SIGPIPE.
|
||||
exec > >({ dd of="$BL_LOG" oflag=append conv=notrunc iflag=count_bytes count="${BL_LOG_CAP:-268435456}" bs=65536 status=none; cat >/dev/null; }) 2>&1
|
||||
echo "== droiddeck-session $(date) mode=$mode $*"
|
||||
echo "== uid=$(id -u) size=${BL_WIDTH:-?}x${BL_HEIGHT:-?} fps=${BL_FPS:-0} icd=${VK_ICD_FILENAMES:-none}"
|
||||
@@ -29,11 +16,6 @@ if [ -n "${BL_LOG:-}" ] && [ -z "${BL_INSIDE:-}" ]; then
|
||||
echo "== rootfs: $(cat /.version 2>/dev/null || echo unversioned)"
|
||||
fi
|
||||
|
||||
# Every program loads the locale LANG names (C.UTF-8) before main(). glibc ships it as a directory,
|
||||
# which it looks for once per category under two spellings before reading gconv's module lists:
|
||||
# about 30 opens, each a stop in proot, for every process in the session, a script's dirname or cat
|
||||
# included. An archive holding it (and gconv's cache) makes that one open. Built again when the
|
||||
# glibc package changes, or when the archive does (locale-gen rewrites it).
|
||||
prepare_locale() {
|
||||
local dir=/usr/lib/locale stamp=/usr/lib/locale/.droiddeck-archive want have= pkg
|
||||
pkg=(/var/lib/pacman/local/glibc-[0-9]*)
|
||||
@@ -41,7 +23,6 @@ prepare_locale() {
|
||||
[ -f "$stamp" ] && read -r have < "$stamp"
|
||||
[ "$have" = "$want" ] && [ -f "$dir/locale-archive" ] && [ ! "$dir/locale-archive" -nt "$stamp" ] && return 0
|
||||
[ -d "$dir/C.utf8" ] && command -v localedef >/dev/null 2>&1 || return 0
|
||||
# localedef names a new archive by hard link, which Android refuses; libblsession renames it.
|
||||
DROIDDECK_LINK_RENAME=1 localedef --add-to-archive --replace "$dir/C.utf8" >/dev/null 2>&1 || return 0
|
||||
rm -f /usr/lib/gconv/gconv-modules.cache
|
||||
command -v iconvconfig >/dev/null 2>&1 && iconvconfig >/dev/null 2>&1
|
||||
@@ -50,22 +31,38 @@ prepare_locale() {
|
||||
}
|
||||
[ -z "${BL_INSIDE:-}" ] && prepare_locale
|
||||
|
||||
# Until the runtime is stable, Steam's own logs are copied beside the session log at exit so a
|
||||
# failed launch can be handed over as one folder.
|
||||
clear_stale_tmp() {
|
||||
local running names=() n
|
||||
running=$(pgrep -af 'steamwebhelper|steamrtarm64/steam|--type=|droiddeck-appimage-run|dbus-run-session|dbus-daemon.*--session|dbus-launch|kwin|plasmashell' 2>/dev/null)
|
||||
case $running in
|
||||
*steamwebhelper* | *steamrtarm64/steam*) ;;
|
||||
*) names+=(-o -name 'mangohud.????????' -o -name '.com.valvesoftware.Steam.??????'
|
||||
-o -name 'steam_chrome_shmem_uid*' -o \( -type d -empty -name 'steam??????' \)) ;;
|
||||
esac
|
||||
case $running in *--type=*) ;; *) names+=(-o \( -type d -name 'scoped_dir??????' \)) ;; esac
|
||||
case $running in *droiddeck-appimage-run*) ;; *) names+=(-o -name 'droiddeck-appimage.??????') ;; esac
|
||||
case $running in
|
||||
*dbus-run-session* | *dbus-daemon*--session* | *dbus-launch*) ;;
|
||||
*) names+=(-o \( -type s -name 'dbus-??????????' \)) ;;
|
||||
esac
|
||||
case $running in
|
||||
*kwin* | *plasmashell*) ;;
|
||||
*) names+=(-o \( -type d -empty -name 'plasma-csd-generator.??????' \)) ;;
|
||||
esac
|
||||
[ ${#names[@]} -gt 0 ] || return 0
|
||||
n=$(find /tmp -mindepth 1 -maxdepth 1 \( "${names[@]:1}" \) -print -exec rm -rf {} + 2>/dev/null | wc -l)
|
||||
[ "$n" -gt 0 ] && echo "== /tmp: cleared $n entries earlier sessions left"
|
||||
return 0
|
||||
}
|
||||
[ -z "${BL_INSIDE:-}" ] && clear_stale_tmp
|
||||
|
||||
collect_steam_logs() {
|
||||
[ -n "${BL_DEBUG_DIR:-}" ] || return 0
|
||||
local steam_root=${XDG_DATA_HOME:-$HOME/.local/share}/Steam
|
||||
mkdir -p "$BL_DEBUG_DIR/steam" 2>/dev/null || return 0
|
||||
# Into steam/ beside this session's own logs. The app scrubs these line by line after the
|
||||
# session ends - they carry the account's session token and id - so nothing here is the last
|
||||
# word on what the user ends up sharing; this is just the copy that survives the runtime.
|
||||
# Up to 8 MB each, as the app's own copy takes them: the client's CEF and *.previous.txt logs
|
||||
# reach 17 MB and say little about this session, and every share scrubs whatever is here.
|
||||
[ -d "$steam_root/logs" ] && find "$steam_root/logs" -maxdepth 1 -type f -size -8192k \
|
||||
-exec cp {} "$BL_DEBUG_DIR/steam/" \; 2>/dev/null
|
||||
[ -f "$HOME/.steam/steam/logs/steamwebhelper.log" ] && cp "$HOME/.steam/steam/logs/steamwebhelper.log" "$BL_DEBUG_DIR/steam/" 2>/dev/null
|
||||
# NOT copied, ever: loginusers.vdf, config.vdf and the ssfn* files, which hold the credentials
|
||||
# themselves rather than a mention of them.
|
||||
local sync_store=$HOME/.local/share/droiddeck-esync sync_file
|
||||
if [ -d "$sync_store" ] && mkdir -p "$BL_DEBUG_DIR/droiddeck-esync" 2>/dev/null; then
|
||||
for sync_file in launches.log tools.tsv wanted.tsv prefixes.json; do
|
||||
@@ -78,20 +75,9 @@ collect_steam_logs() {
|
||||
fi
|
||||
echo "== steam logs copied to $BL_DEBUG_DIR/steam"
|
||||
}
|
||||
# A session that is killed never reaches the copy below, and those are the sessions worth reading.
|
||||
trap 'collect_steam_logs 2>/dev/null || true' TERM INT HUP
|
||||
# The driver everything in this session draws with: gamescope's compositing, the client's UI
|
||||
# (OpenGL through Zink), every game Proton launches, and in desktop mode every program on it.
|
||||
# BL_VK_DRIVER names an imported driver's ICD manifest on the Android side, which is bound into the
|
||||
# session at its own path; unset means the runtime keeps the Turnip it was built with.
|
||||
# VK_DRIVER_FILES REPLACES the loader's search, so a manifest whose library is unreadable would
|
||||
# leave the session with no Vulkan at all - check both before setting it, and say so in the log
|
||||
# rather than fail silently half a minute later.
|
||||
if [ -n "${BL_VK_DRIVER:-}" ]; then
|
||||
bl_icd_lib=$(sed -n 's/.*"library_path"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "$BL_VK_DRIVER" 2>/dev/null | head -1)
|
||||
# JSON may escape the separator: org.json writes "\/data\/user\/0\/...". The Vulkan loader
|
||||
# parses that correctly; this check has to as well, or an absolute path looks relative and gets
|
||||
# glued onto the manifest's directory - which is exactly what happened the first time.
|
||||
bl_icd_lib=$(printf '%s' "$bl_icd_lib" | sed 's|\\/|/|g')
|
||||
case $bl_icd_lib in
|
||||
/*) ;;
|
||||
@@ -99,7 +85,6 @@ if [ -n "${BL_VK_DRIVER:-}" ]; then
|
||||
esac
|
||||
if [ -r "$BL_VK_DRIVER" ] && [ -n "$bl_icd_lib" ] && [ -r "$bl_icd_lib" ]; then
|
||||
export VK_DRIVER_FILES="$BL_VK_DRIVER"
|
||||
# Loaders older than 1.3.207 only know the old name; both are harmless together.
|
||||
export VK_ICD_FILENAMES="$BL_VK_DRIVER"
|
||||
echo "== vulkan driver: imported $bl_icd_lib (via $BL_VK_DRIVER)"
|
||||
else
|
||||
@@ -107,21 +92,9 @@ if [ -n "${BL_VK_DRIVER:-}" ]; then
|
||||
fi
|
||||
unset bl_icd_lib
|
||||
fi
|
||||
# The app's gamescope build (tools/gamescope) asks for realtime-priority Vulkan queues on this
|
||||
# switch instead of on CAP_SYS_NICE, which proot never has; it falls back to normal priority
|
||||
# where the driver refuses, and the runtime's own build ignores it. On KGSL Turnip (Mesa 26.2) it
|
||||
# changes nothing yet: the driver reports one submit-queue priority and creates every KGSL context
|
||||
# with the same flags, so no priority reaches the GPU. Kept for a driver that maps it, and off
|
||||
# unless the app's Performance page turns it on (BL_GAMESCOPE_REALTIME=1).
|
||||
export GAMESCOPE_FORCE_VULKAN_REALTIME=${BL_GAMESCOPE_REALTIME:-0}
|
||||
rm -rf /tmp/.droiddeck-rx
|
||||
|
||||
# A sleep that starts no process. Under proot every exec is a traced execve plus the loader's
|
||||
# opens and maps, and the watchers below poll for the whole session: `sleep 1` in a loop was 60
|
||||
# execs a minute each. read -t on a pipe nothing ever writes to waits in bash itself.
|
||||
# The agent bridge's guest side (docs/agent-control.md): runs what the app's agent provider asks
|
||||
# for inside this session and publishes gamescope's focus. Its files live under the session root
|
||||
# ($BL_LAUNCH_DIR/agent), which the app empties before each session.
|
||||
start_agent() {
|
||||
[ -n "${BL_LAUNCH_DIR:-}" ] && [ -x /usr/local/bin/droiddeck-agent ] || return 0
|
||||
mkdir -p "$BL_LAUNCH_DIR/agent"
|
||||
@@ -135,18 +108,28 @@ export XDG_DATA_HOME=${XDG_DATA_HOME:-$HOME/.local/share}
|
||||
export XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config}
|
||||
export XDG_CACHE_HOME=${XDG_CACHE_HOME:-$HOME/.cache}
|
||||
mkdir -p "$XDG_DATA_HOME" "$XDG_CONFIG_HOME" "$XDG_CACHE_HOME"
|
||||
rm -f "${XDG_RUNTIME_DIR:-/run/droiddeck}/droiddeck-steamvr/active"
|
||||
if [ "$mode" = lxqt ] || [ "$mode" = desktop ]; then
|
||||
/usr/local/bin/droiddeck-desktop-bookmarks || true
|
||||
fi
|
||||
# Flatpak (the store's apps): its sandboxes through the app instead of bubblewrap, which needs the
|
||||
# user namespaces Android keeps from apps, and its apps' menu entries and icons on the desktop.
|
||||
export FLATPAK_BWRAP=/usr/local/bin/droiddeck-bwrap
|
||||
export XDG_DATA_DIRS=$XDG_DATA_HOME/flatpak/exports/share:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}
|
||||
|
||||
# The cores a program runs on outside Steam (the desktop and everything started from it, a
|
||||
# program from the rail): the user's game cores when set (BL_GAME_CPUS), else every core but the
|
||||
# slowest cluster - Android is free to park an emulator's threads on the little cores, and those
|
||||
# are what compile shaders and recompile PPU/SPU code. BL_PIN_CORES=0 leaves the scheduler alone.
|
||||
client_single_core_matches() {
|
||||
local wanted=$1 task key cpus
|
||||
shift
|
||||
[[ $wanted =~ ^[0-9]+$ ]] || return 0
|
||||
for task in "$@"; do
|
||||
[ -r "$task/status" ] || continue
|
||||
while read -r key cpus; do
|
||||
[ "$key" = Cpus_allowed_list: ] || continue
|
||||
[ "$cpus" = "$wanted" ] || return 1
|
||||
break
|
||||
done < "$task/status" 2>/dev/null
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
program_cores() {
|
||||
[ "${BL_PIN_CORES:-1}" = 0 ] && return 0
|
||||
command -v taskset >/dev/null 2>&1 || return 0
|
||||
@@ -166,9 +149,7 @@ program_cores() {
|
||||
}
|
||||
|
||||
if [ -z "${BL_INSIDE:-}" ]; then
|
||||
# Install the shared default-family aliases before Steam, gamescope or the desktop queries fonts.
|
||||
/usr/local/bin/droiddeck-fonts 2>&1 | sed 's/^/[fonts] /'
|
||||
# Android's directory binding and language-specific family matches handle CJK and Thai fonts.
|
||||
device_fonts=/usr/local/share/fonts/android
|
||||
if [ -d "$device_fonts" ] && [ -d /etc/fonts/conf.d ] && command -v fc-cache >/dev/null 2>&1; then
|
||||
fonts_rules=$(
|
||||
@@ -189,14 +170,10 @@ if [ -z "${BL_INSIDE:-}" ]; then
|
||||
echo "== fontconfig: indexed $(ls "$device_fonts" | wc -l) device fonts, zh falls back to $(fc-match -f '%{family[0]}' ':lang=zh-cn' 2>/dev/null)"
|
||||
fi
|
||||
fi
|
||||
# The compositor may still be starting, and a socket left by an earlier session is not
|
||||
# a compositor: probe until a connection succeeds.
|
||||
for _ in $(seq 1 100); do
|
||||
wayland-info >/dev/null 2>&1 && break
|
||||
sleep 0.1
|
||||
done
|
||||
# The desktop (DroidDeck's hosted package) is its own nested compositor, KWin, drawing straight
|
||||
# into the app's: no gamescope in between.
|
||||
if [ "$mode" = lxqt ]; then
|
||||
step "starting the desktop"
|
||||
start_agent --no-focus
|
||||
@@ -204,9 +181,6 @@ if [ -z "${BL_INSIDE:-}" ]; then
|
||||
cores=$(program_cores)
|
||||
if [ -n "$cores" ]; then
|
||||
echo "== desktop cores: $cores (the desktop and every program started from it)"
|
||||
# Pin this shell and let exec carry the mask. Android keeps the app on a smaller cpuset
|
||||
# until its activity is on top (foreground 0-5, background fewer), and a mask with no core
|
||||
# of that set is EINVAL: taskset -c then exits 1 and takes the whole session with it.
|
||||
taskset -cp "$cores" $$ >/dev/null 2>&1 || echo "== desktop cores: not allowed right now, every core"
|
||||
fi
|
||||
exec /usr/local/bin/droiddeck-desktop
|
||||
@@ -214,9 +188,6 @@ if [ -z "${BL_INSIDE:-}" ]; then
|
||||
width=${BL_WIDTH:-1280}
|
||||
height=${BL_HEIGHT:-720}
|
||||
nested=$width
|
||||
# Follow screen (BL_FOLLOW_OUTPUT=1): the app resizes gamescope's output when a foldable opens or
|
||||
# closes, and with Steam on its own Xwayland gamescope resizes Steam's X screen with it, as on a
|
||||
# Steam Deck docking. A stretched 16:9 nested size would pin it, so the two are exclusive.
|
||||
if [ "${BL_FOLLOW_OUTPUT:-0}" = 1 ]; then
|
||||
echo "== gamescope: the output follows the screen (${width}x${height} to start)"
|
||||
elif [ "$mode" = steam ] && [ "${BL_GAMESCOPE_STRETCH_16X9:-0}" = 1 ]; then
|
||||
@@ -228,51 +199,22 @@ if [ -z "${BL_INSIDE:-}" ]; then
|
||||
fi
|
||||
args=(--backend wayland --expose-wayland -f -W "$width" -H "$height" -w "$nested" -h "$height")
|
||||
[ "$nested" != "$width" ] && args+=(-S stretch) && export BL_STRETCHED=1
|
||||
# -r is what gamescope advertises as the refresh rate, and what a game reads as the display's.
|
||||
# Left unset it defaults to 60, so a 120 Hz panel offers only 60 Hz in game settings. The FPS
|
||||
# limiter wins when it is on (it is a deliberate cap); otherwise use the panel's own rate.
|
||||
if [ "${BL_FPS:-0}" -gt 0 ]; then
|
||||
args+=(-r "$BL_FPS")
|
||||
elif [ "${BL_REFRESH:-0}" -gt 0 ]; then
|
||||
args+=(-r "$BL_REFRESH")
|
||||
fi
|
||||
# Steam integration advertises a Deck session and makes the client select Big Picture even
|
||||
# without -gamepadui. The desktop UI uses ordinary gamescope window management instead.
|
||||
[ "$mode" = steam ] && [ "${BL_STEAM_UI:-}" != desktop ] && args+=(-e)
|
||||
# Two Xwayland servers, as SteamOS runs Steam: the client on the first, games on the second
|
||||
# (STEAM_GAME_DISPLAY_0). The client then sizes the games' server to each game's Game Resolution
|
||||
# (GAMESCOPE_XWAYLAND_MODE_CONTROL; native unless one is set), and gamescope scales it to the
|
||||
# output. With one server the client and its games share the output's size, so a game's own Game
|
||||
# Resolution never reaches its display (docs/development/steam-display-scaling.md). The client's
|
||||
# overlay is also on another server than the game, so opening it no longer takes the game's X
|
||||
# keyboard focus, which made games like FlatOut shrink their window.
|
||||
# BL_XWAYLAND_COUNT=1 in Download/droiddeck-env goes back to one.
|
||||
if [ "$mode" = steam ] && [ "${BL_XWAYLAND_COUNT:-2}" -gt 1 ]; then
|
||||
args+=(--xwayland-count "${BL_XWAYLAND_COUNT:-2}")
|
||||
export STEAM_MULTIPLE_XWAYLANDS=1
|
||||
fi
|
||||
# Touch passes through to the client as touch until the client says otherwise, as SteamOS's
|
||||
# gamescope-session starts it (TOUCH_MODE=4). The client sets the mode itself (STEAM_TOUCH_CLICK_MODE)
|
||||
# only once it has a controller; until then gamescope's own default made a finger a left-click
|
||||
# mouse, so the Steam interface took taps but would not scroll on a phone with no pad attached.
|
||||
[ "$mode" = steam ] && args+=(--default-touch-mode 4)
|
||||
# No --force-windows-fullscreen: it was for games that shrink their window when the Steam menu
|
||||
# opens over them (FlatOut), which no longer happens with the games on their own Xwayland server
|
||||
# (above), and it made any game drawing at another size than its display fight it. An experiment
|
||||
# can still pass it with BL_GAMESCOPE_ARGS.
|
||||
# HDR10: the app opened its compositor's colour-management gate for this session (BL_HDR=1);
|
||||
# gamescope then offers HDR to its clients through the same wp_color_manager_v1 it binds on ours.
|
||||
[ "${BL_HDR:-0}" = 1 ] && args+=(--hdr-enabled)
|
||||
# Extra gamescope arguments for an experiment (--debug-focus, say), from Download/droiddeck-env.
|
||||
[ -n "${BL_GAMESCOPE_ARGS:-}" ] && read -r -a _bl_extra <<<"$BL_GAMESCOPE_ARGS" && args+=("${_bl_extra[@]}")
|
||||
# The performance overlay (Quick Access Menu → Performance → Overlay Level) is drawn by
|
||||
# mangoapp, which gamescope starts beside the client; the client sets the level by rewriting
|
||||
# MANGOHUD_CONFIGFILE. The apk stages Valve's aarch64 build (tools/mangoapp) - without it the menu
|
||||
# still offers the levels and nothing appears. Starts hidden until the client writes a level.
|
||||
# BL_MANGOAPP=0 turns it off (one community build found Valve's mangoapp crashing on Turnip).
|
||||
if [ "$mode" = steam ] && [ "${BL_MANGOAPP:-1}" = 1 ] \
|
||||
&& [ "${BL_STEAM_UI:-}" != desktop ] && command -v mangoapp >/dev/null 2>&1; then
|
||||
MANGOHUD_CONFIGFILE=$(mktemp /tmp/mangohud.XXXXXXXX)
|
||||
MANGOHUD_CONFIGFILE=/tmp/droiddeck-mangohud.conf
|
||||
echo no_display > "$MANGOHUD_CONFIGFILE"
|
||||
export MANGOHUD_CONFIGFILE STEAM_USE_MANGOAPP=1 STEAM_MANGOAPP_PRESETS_SUPPORTED=1 STEAM_MANGOAPP_HORIZONTAL_SUPPORTED=1
|
||||
args+=(--mangoapp)
|
||||
@@ -282,10 +224,6 @@ if [ -z "${BL_INSIDE:-}" ]; then
|
||||
exec gamescope "${args[@]}" -- "$0" "$mode" "$@"
|
||||
fi
|
||||
|
||||
# gamescope manages X windows: toolkits go through Xwayland, not gamescope's own Wayland socket.
|
||||
# Root-window requests for the game (restore) go to every display gamescope gave us:
|
||||
# the client's ($DISPLAY) and, with two servers, the games' (STEAM_GAME_DISPLAY_0); gamescope reads
|
||||
# them per server.
|
||||
bl_displays() {
|
||||
printf '%s\n' "$DISPLAY"
|
||||
[ -n "${STEAM_GAME_DISPLAY_0:-}" ] && [ "$STEAM_GAME_DISPLAY_0" != "$DISPLAY" ] && printf '%s\n' "$STEAM_GAME_DISPLAY_0"
|
||||
@@ -299,10 +237,6 @@ bl_xprop_set_all() {
|
||||
[ "$ok" = 1 ]
|
||||
}
|
||||
export GDK_BACKEND=x11 QT_QPA_PLATFORM=xcb SDL_VIDEODRIVER=x11
|
||||
# gamescope's reaper waits for every process left under it before the compositor comes down. A
|
||||
# process a game left behind - a Wine service blocked on a server that is already gone - is
|
||||
# reparented there when the client exits, and the screen stays black on it for good. Nothing of
|
||||
# the session outlives the program it was started for.
|
||||
reap_orphans() {
|
||||
local round p stat pid left
|
||||
for round in 1 2 3 4 5; do
|
||||
@@ -322,13 +256,11 @@ reap_orphans() {
|
||||
done
|
||||
}
|
||||
|
||||
# Gamescope's Wayland backend does not forward the outer clipboard into Xwayland.
|
||||
# This helper owns only Android text selections and exits with this guest session.
|
||||
if [ -n "${BL_ANDROID_CLIPBOARD:-}" ] && [ -x /usr/local/bin/droiddeck-clipboard ]; then
|
||||
if [ "${BL_DESKTOP:-}" != 1 ] && [ -n "${BL_ANDROID_CLIPBOARD:-}" ] && [ -x /usr/local/bin/droiddeck-clipboard ]; then
|
||||
/usr/local/bin/droiddeck-clipboard "$BL_ANDROID_CLIPBOARD" &
|
||||
fi
|
||||
|
||||
start_agent
|
||||
[ "${BL_DESKTOP:-}" = 1 ] || start_agent
|
||||
|
||||
case $mode in
|
||||
desktop)
|
||||
@@ -342,7 +274,6 @@ case $mode in
|
||||
echo "== program cores: $cores"
|
||||
taskset -cp "$cores" $$ >/dev/null 2>&1 || true
|
||||
fi
|
||||
# Player 1 on the controller in an emulator that has no profile of its own yet.
|
||||
python3 /usr/local/bin/droiddeck-pad-defaults 2>&1 || true
|
||||
fex=()
|
||||
if [ -x /usr/local/bin/droiddeck-fex ]; then
|
||||
@@ -373,13 +304,6 @@ case $mode in
|
||||
droiddeck-steam-install || exit $?
|
||||
step "Steam client ready"
|
||||
steam_root=$XDG_DATA_HOME/Steam
|
||||
# Register the card library (bound at /mnt/droiddeck-sd) with the client - internal storage is
|
||||
# its main library already - and the ARM64 Proton that lets it launch the Windows ones.
|
||||
# A request left in ~/.bl-proton-extra installs a third-party Proton before the client starts,
|
||||
# so it is in the Compatibility dropdown the first time the user looks. One per line, each the
|
||||
# arguments to droiddeck-proton-extra: "ge", "cachyos", "ge --tag GE-Proton11-7", or a URL.
|
||||
# Hundreds of megabytes each, so it is only ever done on request, and the line is dropped once
|
||||
# it has succeeded - a failed download stays and is retried next session.
|
||||
if [ -s "$HOME/.bl-proton-extra" ]; then
|
||||
_bl_left=$HOME/.bl-proton-extra.left
|
||||
: > "$_bl_left"
|
||||
@@ -395,11 +319,6 @@ case $mode in
|
||||
done < "$HOME/.bl-proton-extra"
|
||||
mv -f "$_bl_left" "$HOME/.bl-proton-extra"
|
||||
fi
|
||||
# steam:// URLs left in ~/.bl-steam-urls are handed to the client on its command line. The app
|
||||
# writes one when the user asks for a Proton that is one of Valve's own depots rather than a
|
||||
# tarball: those are not files anywhere, the client fetches them like any other app. One per
|
||||
# line, and the file is cleared once they have been passed on - the client either acts on a URL
|
||||
# or it does not, and repeating it every session would re-ask forever.
|
||||
if [ -s "$HOME/.bl-steam-urls" ]; then
|
||||
while read -r _bl_url || [ -n "$_bl_url" ]; do
|
||||
case ${_bl_url# } in steam://*) ;; *) continue ;; esac
|
||||
@@ -408,15 +327,6 @@ case $mode in
|
||||
done < "$HOME/.bl-steam-urls"
|
||||
rm -f "$HOME/.bl-steam-urls"
|
||||
fi
|
||||
# Cores for the client itself. Steam pins its own interface renderer to a subset - on the
|
||||
# device it took 5 of 8, leaving out both little cores and the fastest one - which is a
|
||||
# reasonable thing to do while a game is running and the wrong thing when the client is all
|
||||
# there is. BL_CLIENT_CPUS overrides it. Re-applied on a beat because steamwebhelper spawns
|
||||
# children continuously and each one inherits Steam's choice, not ours. The beat reads /proc
|
||||
# itself instead of running pgrep, and only runs taskset for a process that is new or has
|
||||
# grown threads since it was last pinned: every fork is a round of traced syscalls, and a
|
||||
# beat that forked a taskset per process every 5 s did that for an hour. taskset -a, because
|
||||
# without it only a process's main thread moves and the renderer's workers stay where they were.
|
||||
if [ -n "${BL_CLIENT_CPUS:-}" ]; then
|
||||
step "client cores: $BL_CLIENT_CPUS"
|
||||
(
|
||||
@@ -427,7 +337,9 @@ case $mode in
|
||||
case $_c in *steamwebhelper*|*steamrtarm64/steam|*gamescope*) ;; *) continue ;; esac
|
||||
_t=("$_d"/task/*)
|
||||
_p=${_d#/proc/}
|
||||
[ "${_bl_pinned[$_p]:-}" = "${#_t[@]}" ] && continue
|
||||
if [ "${_bl_pinned[$_p]:-}" = "${#_t[@]}" ] && client_single_core_matches "$BL_CLIENT_CPUS" "${_t[@]}"; then
|
||||
continue
|
||||
fi
|
||||
taskset -a -cp "$BL_CLIENT_CPUS" "$_p" >/dev/null 2>&1 || true
|
||||
_bl_pinned[$_p]=${#_t[@]}
|
||||
done
|
||||
@@ -435,6 +347,61 @@ case $mode in
|
||||
done
|
||||
) &
|
||||
fi
|
||||
if [ "${BL_ZRAM:-0}" = 1 ]; then
|
||||
printf 0 > /tmp/.bl-zram
|
||||
step "zRAM compression: on"
|
||||
(
|
||||
bl_zram_scan() {
|
||||
_bl_game=0 _bl_pids=()
|
||||
for _d in /proc/[0-9]*; do
|
||||
IFS= read -r -d '' _c 2>/dev/null < "$_d/cmdline" || continue
|
||||
case ${_c##*/} in
|
||||
reaper) _bl_game=1 ;;
|
||||
steam|steamwebhelper) _bl_pids+=("${_d#/proc/}") ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
bl_zram_usage() {
|
||||
local _p _k _v _u _rss=0 _swap=0
|
||||
for _p in "${_bl_pids[@]}"; do
|
||||
while read -r _k _v _u; do
|
||||
case $_k in VmRSS:) _rss=$((_rss + _v)) ;; VmSwap:) _swap=$((_swap + _v)) ;; esac
|
||||
done 2>/dev/null < "/proc/$_p/status"
|
||||
done
|
||||
echo "${#_bl_pids[@]} processes, resident $((_rss / 1024)) MB, in zram $((_swap / 1024)) MB"
|
||||
}
|
||||
bl_zram_send() {
|
||||
step "zRAM: $2 ($(bl_zram_usage))"
|
||||
printf '%s' "$1" > /tmp/.bl-zram
|
||||
[ "${#_bl_pids[@]}" = 0 ] || kill -URG "${_bl_pids[@]}" 2>/dev/null
|
||||
nap 5
|
||||
bl_zram_scan
|
||||
step "zRAM: done ($(bl_zram_usage))"
|
||||
}
|
||||
_bl_since=-1 _bl_packed=-1
|
||||
while kill -0 $$ 2>/dev/null; do
|
||||
bl_zram_scan
|
||||
if [ "$_bl_game" = 1 ]; then
|
||||
[ "$_bl_since" -ge 0 ] || _bl_since=$SECONDS
|
||||
if [ $((SECONDS - _bl_since)) -ge 20 ] && [ "${#_bl_pids[@]}" -gt 0 ] &&
|
||||
{ [ "$_bl_packed" -lt 0 ] || [ $((SECONDS - _bl_packed)) -ge 300 ]; }; then
|
||||
bl_zram_send 1 "compressing the client"
|
||||
_bl_packed=$SECONDS
|
||||
fi
|
||||
elif [ "$_bl_since" -ge 0 ]; then
|
||||
[ "$_bl_packed" -lt 0 ] || bl_zram_send 0 "game closed, reading the client back"
|
||||
_bl_since=-1 _bl_packed=-1
|
||||
fi
|
||||
nap 5
|
||||
done
|
||||
) &
|
||||
else
|
||||
rm -f /tmp/.bl-zram
|
||||
fi
|
||||
if [ "${BL_LAUNCHER_CORES:-1}" != 0 ] && [ -n "${BL_LAUNCH_DIR:-}" ] && [ -z "${BL_DESKTOP:-}" ] \
|
||||
&& [ "${BL_STEAM_UI:-}" != desktop ] && [ -x /usr/local/bin/droiddeck-launcher-cores ]; then
|
||||
/usr/local/bin/droiddeck-launcher-cores "$BL_LAUNCH_DIR/agent/focus.json" 2>&1 &
|
||||
fi
|
||||
|
||||
step "registering the app's game library with Steam"
|
||||
droiddeck-steam-library "$steam_root" || true
|
||||
@@ -443,32 +410,18 @@ case $mode in
|
||||
if [ -z "${BL_DESKTOP:-}" ] && [ "${BL_STEAM_UI:-}" != desktop ]; then
|
||||
droiddeck-steam-ui-scale "$steam_root" "${BL_WIDTH:-1280}" "${BL_HEIGHT:-720}" || true
|
||||
fi
|
||||
# The user's own games, as non-Steam shortcuts under that tool; the list is written by the app
|
||||
# each session (empty = the app's earlier entries are removed, the client's own are kept).
|
||||
if [ -n "${BL_ADDED_GAMES:-}" ]; then
|
||||
step "adding the app's own games to the client's library"
|
||||
droiddeck-steam-shortcuts "$steam_root" "$BL_ADDED_GAMES" || true
|
||||
fi
|
||||
# Steam runs a game's shared redistributables inside its prefix on first launch; marking
|
||||
# them as already run keeps those x86 installers from starting under emulation at all.
|
||||
droiddeck-seed-redists "$steam_root" || true
|
||||
# The compatibility tool runs Valve's arm64 Proton, which the client fetches like any depot.
|
||||
# Asked for on the command line the first time, so a Windows title has it before it is needed.
|
||||
if [ ! -f "$steam_root/steamapps/appmanifest_4427310.acf" ]; then
|
||||
step "asking the client to fetch the ARM64 Proton"
|
||||
set -- "$@" steam://install/4427310
|
||||
# Ported from Bannerlator's session script (device-proven 2026-09-22). The client decides
|
||||
# a title's compatibility tool when the title is installed and keeps that decision for the
|
||||
# rest of its run, and the tool is set up before the client comes up. So once the depot has
|
||||
# fully landed, restart the client once - its own -shutdown, then the loop below, which knows
|
||||
# the marker - and every title installed from then on runs through the tool, with the
|
||||
# refreshed tool list and defaults, and no second launch by the user. A first run only: with
|
||||
# the depot present at session start nothing here is armed.
|
||||
(
|
||||
_bl_acf="$steam_root/steamapps/appmanifest_4427310.acf"
|
||||
for _ in $(seq 1 360); do
|
||||
sleep 10
|
||||
# StateFlags 4 = fully installed; a moment more for the client to finish its bookkeeping.
|
||||
if grep -q '"StateFlags"[[:space:]]*"4"' "$_bl_acf" 2>/dev/null; then
|
||||
sleep 10
|
||||
steam-compatibility "$steam_root" >/dev/null 2>&1 || true
|
||||
@@ -479,17 +432,6 @@ case $mode in
|
||||
fi
|
||||
done
|
||||
) &
|
||||
# A client that starts signed out drops that request - on a fresh install nobody has signed
|
||||
# in yet - so the install dialog only appeared after the user restarted the client by hand.
|
||||
# With no remembered sign-in, ask again once the sign-in has happened: the client binary
|
||||
# started a second time with a URL hands it to the running instance and exits.
|
||||
#
|
||||
# The request is also dropped while the client is still in its post-logon compat phase (it
|
||||
# probes every registered tool then): with publicbeta 1790380355 that phase took 27 s and a
|
||||
# request sent 15 s after sign-in vanished (2026-09-26, no dialog; 1790121765 was done in
|
||||
# time). So wait for the client to say the phase is over ("Waiting for compat in post-logon
|
||||
# took" in its console log; at most 90 s if it never does), then ask - and ask again, twice
|
||||
# at most, if no install has started a minute later.
|
||||
if ! grep -q '"RememberPassword"[[:space:]]*"1"' "$steam_root/config/loginusers.vdf" 2>/dev/null; then
|
||||
(
|
||||
_bl_acf="$steam_root/steamapps/appmanifest_4427310.acf"
|
||||
@@ -518,26 +460,6 @@ case $mode in
|
||||
) &
|
||||
fi
|
||||
fi
|
||||
# The tool is registered before the client starts and finds the depot at launch time, so
|
||||
# nothing here waits for a download. What can still change under a running client is which
|
||||
# titles are installed: a title installed this session gets the client's own per-app Proton
|
||||
# choice, which it cannot start. Refresh the per-app entries every so often; the registrar is
|
||||
# idempotent, so a repeat costs nothing.
|
||||
# The seeder has the same problem and a worse consequence. It marks the shared redistributables
|
||||
# as already run in each prefix that exists, and a game's prefix is not created until the
|
||||
# client launches it - so a title played for the first time this session was never covered, and
|
||||
# its install scripts run for real. That is exactly the hang the seeder exists to prevent: Need
|
||||
# for Speed Payback sat on "Running install script" with vcredist_x86.exe blocked in pipe_read,
|
||||
# holding both ends of a pipe nobody would write to, while the client waited for it to exit.
|
||||
# Seeding again on the same beat covers a prefix the moment it appears.
|
||||
# The seeder runs on a shorter beat than the registrar because it is racing something. The
|
||||
# client creates a prefix when it launches a title and runs that title's install scripts
|
||||
# moments later, so the seeder has only that gap to mark the redistributables as already run.
|
||||
# It stamps each prefix it has covered and skips it thereafter, so the extra passes cost
|
||||
# almost nothing.
|
||||
# With the 16:9 stretch on, the client's own scaler must not undo it: in Deck mode it sets
|
||||
# GAMESCOPE_NEW_SCALING_SCALER to Auto (0), which fits the 16:9 picture with bars and outranks -S.
|
||||
# Auto is put back to Stretch (4); a mode picked in the QAM (Integer, Fit, Fill) is kept.
|
||||
[ -z "${BL_DESKTOP:-}" ] && [ "${BL_STRETCHED:-0}" = 1 ] && (
|
||||
while :; do
|
||||
nap 1
|
||||
@@ -548,13 +470,6 @@ case $mode in
|
||||
&& echo "== stretch 16:9 to panel: the client's scaler was Auto, set to Stretch"
|
||||
done
|
||||
) &
|
||||
# Resume from the Steam menu. The menu is an overlay that takes input, and a fullscreen game that
|
||||
# loses input minimizes itself; gamescope only takes a window out of that state when the focused
|
||||
# window changes, which the menu never does, so the game stayed minimized after Resume (a black
|
||||
# screen with its small caption in the top-left corner). gamescope-3.16.29-p4 restores it itself;
|
||||
# this asks it again a moment after input comes back from the client (app 769) to anything else,
|
||||
# which covers a game that minimizes late. Harmless when nothing is minimized.
|
||||
# BL_RESTORE_ON_RESUME=0 turns it off.
|
||||
[ -z "${BL_DESKTOP:-}" ] && [ "${BL_RESTORE_ON_RESUME:-1}" = 1 ] && (
|
||||
prev=
|
||||
xprop -spy -root GAMESCOPE_FOCUSED_APP 2>/dev/null | while read -r line; do
|
||||
@@ -568,13 +483,7 @@ case $mode in
|
||||
prev=$app
|
||||
done
|
||||
) &
|
||||
# Evidence for touch reports: the touch mode the client asks gamescope for (STEAM_TOUCH_CLICK_MODE,
|
||||
# set once it has a controller, per focused app) and which app has focus, logged as they change.
|
||||
# A finger that clicks but won't scroll, or touch that stops once a pad is used, shows here as
|
||||
# the mode in force at that moment. 4 is touch passed through, 1 a left-click mouse.
|
||||
[ -z "${BL_DESKTOP:-}" ] && (
|
||||
# What follows "=" in an xprop line, or $2 for a property that is missing or has no value
|
||||
# yet ("NAME(CARDINAL) =", which read leaves with nothing after the "=").
|
||||
xprop_value() {
|
||||
case $1 in *'not found'*|*=) echo "$2"; return ;; esac
|
||||
local v=${1#*=}
|
||||
@@ -599,13 +508,6 @@ case $mode in
|
||||
esac
|
||||
done
|
||||
) &
|
||||
# The library beat. Both helpers are whole programs under proot (the seeder some forty of them,
|
||||
# the compat one a python start and a parse of the client's config), and nearly every beat has
|
||||
# nothing new for them: a burst of thousands of proot stops every quarter minute, game loads
|
||||
# included. Each runs only when what it reads has changed, which bash answers without starting
|
||||
# anything ([ -nt ], globs), and every five minutes regardless. The seeder acts on a prefix (or
|
||||
# Proton's template for them) it has not marked, and on new install scripts, which arrive with a
|
||||
# manifest; the compat pass on a new manifest, depot or tool, or the client rewriting config.vdf.
|
||||
(
|
||||
beat=0
|
||||
compat_stamp=$HOME/.bl-compat-beat
|
||||
@@ -647,8 +549,6 @@ case $mode in
|
||||
seed_due && seed=1
|
||||
compat_due && compat=1
|
||||
[ -n "$seed$compat" ] || continue
|
||||
# Not beside a running game: the client rewrites its manifest at each launch, which made both
|
||||
# due while it loaded. Its own launch seeds its prefix (droiddeck-game-env) regardless.
|
||||
pgrep -x wineserver >/dev/null 2>&1 && continue
|
||||
if [ -n "$seed" ]; then
|
||||
: > "$seed_stamp"
|
||||
@@ -660,12 +560,6 @@ case $mode in
|
||||
fi
|
||||
done
|
||||
) &
|
||||
# A game the app asked to launch on a cold start is not put on the client's command line: the
|
||||
# client takes it before its interface is up, its launch stops at "waiting for user response to
|
||||
# ShowInterstitials" with nobody to answer, and the game page reads Launching for ever (device,
|
||||
# 2026-10-09, and 2026-10-08 before it). It is handed over once the interface has focus
|
||||
# (gamescope's focused app 769) and has had a moment, through the same steam-game request an
|
||||
# in-session launch uses; after two minutes it goes anyway.
|
||||
if [ -n "${BL_LAUNCH_DIR:-}" ] && [ -z "${BL_DESKTOP:-}" ]; then
|
||||
_bl_held=
|
||||
_bl_rest=()
|
||||
@@ -688,13 +582,8 @@ case $mode in
|
||||
) &
|
||||
fi
|
||||
fi
|
||||
# Debug aid while the runtime is being brought up: an app id dropped in ~/.bl-autolaunch is
|
||||
# handed to the client as a rungameid URL, so a launch can be reproduced without touching the
|
||||
# screen. Removed once the runtime is stable.
|
||||
if [ -s "$HOME/.bl-autolaunch" ]; then
|
||||
_bl_app=$(cat "$HOME/.bl-autolaunch")
|
||||
# A bare app id runs the game; a full steam:// URL is passed through, which is how a
|
||||
# validate or an install is driven without touching the screen.
|
||||
case $_bl_app in
|
||||
steam://*) _bl_url=$_bl_app ;;
|
||||
*) _bl_url=steam://rungameid/$_bl_app ;;
|
||||
@@ -702,13 +591,6 @@ case $mode in
|
||||
echo "== autolaunch $_bl_url"
|
||||
set -- "$@" "$_bl_url"
|
||||
fi
|
||||
# The client builds Settings > Internet and its connection indicator on NetworkManager, which
|
||||
# it looks for on the SYSTEM bus as it starts. This runtime has neither, so the page failed
|
||||
# ("StartScanningForNetworks is not a function") under a header that showed no connection even
|
||||
# while downloads ran. A system bus and a stand-in that reports Android's connection - and
|
||||
# refuses what it cannot do, since the app has no say over Wi-Fi - answer what the client asks.
|
||||
# The bus config is written here rather than shipped, so a runtime installed earlier gets this
|
||||
# from the app's copy of the session scripts without a re-host. (WinNative, maxjivi05, e7a224ae.)
|
||||
if command -v dbus-daemon >/dev/null 2>&1 && command -v droiddeck-netmanager >/dev/null 2>&1; then
|
||||
mkdir -p /run/dbus /usr/local/share/droiddeck
|
||||
cat > /usr/local/share/droiddeck/system-bus.conf <<'BUSCONF'
|
||||
@@ -737,9 +619,6 @@ BUSCONF
|
||||
droiddeck-netmanager &
|
||||
netmanager=$!
|
||||
echo "== network: system bus up, NetworkManager stand-in running"
|
||||
# Steam blanks its main UI before calling login1.Suspend. Without the
|
||||
# matching resume notification it stays black although the menus work.
|
||||
# Own the name before Steam constructs its login1 proxy at startup.
|
||||
rm -f "$BL_LAUNCH_DIR/steam-sleep-ready"
|
||||
droiddeck-login1 &
|
||||
login_manager=$!
|
||||
@@ -765,9 +644,6 @@ BUSCONF
|
||||
export STEAM_RUNTIME=1
|
||||
export LD_LIBRARY_PATH=$steam_root/steamrtarm64:$steam_root/steamrtarm64/panorama${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
|
||||
export SDL_VIDEO_X11_DGAMOUSE=0
|
||||
# Decky is optional and session scoped: the app's marker opts in, and this supervisor is
|
||||
# reaped with the client session. Native ARM64 runs directly. A legacy x86_64 asset is used
|
||||
# only when its recorded architecture says so and droiddeck-fex has FEX and its runtime ready.
|
||||
decky_loader=$HOME/homebrew/services/PluginLoader
|
||||
if [ -f "$HOME/.droiddeck-decky-enabled" ] && [ -x "$decky_loader" ]; then
|
||||
decky_arch=$(cat "$HOME/homebrew/services/.droiddeck-decky-arch" 2>/dev/null || echo unknown)
|
||||
@@ -814,34 +690,23 @@ BUSCONF
|
||||
export BL_CDP_GUARD=$BL_CDP_PORT
|
||||
echo "== steam: devtools port $BL_CDP_PORT, guest processes only"
|
||||
fi
|
||||
# The agent bridge drives the client through it (droiddeck-agent's cdp requests).
|
||||
[ -n "${BL_LAUNCH_DIR:-}" ] && mkdir -p "$BL_LAUNCH_DIR/agent" && echo "$BL_CDP_PORT" > "$BL_LAUNCH_DIR/agent/cdp-port"
|
||||
droiddeck-steam-compat "$steam_root" 2>&1 &
|
||||
# The client exits 42 when it has updated itself and wants a fresh start (steam.sh does this).
|
||||
# BL_STEAM_UI=desktop = the client's desktop UI (a window, the library as a list), which the
|
||||
# desktop's launchers ask for; gamescope shows one window at a time and the game takes over.
|
||||
_bl_ui=(-gamepadui)
|
||||
[ "${BL_STEAM_UI:-}" = desktop ] && _bl_ui=()
|
||||
# Deck mode, always outside the desktop UI: -steamdeck is the flag that puts
|
||||
# the Quick Access Menu and the Deck settings pages on screen; the QAM's performance overlay
|
||||
# controls stay greyed out without -steamos3, as SteamOS and Armada launch it. -steamos3 makes
|
||||
# the client manage itself as SteamOS does - it calls steamos-select-branch and writes
|
||||
# steamdeck_stable to package/beta, and a branch on disk that loses to the -clientbeta below
|
||||
# is an update that never installs: exit 42, a restart, for ever (Bannerlator 38996ea1). The
|
||||
# loop below puts package/beta back before every start. The SteamOS helpers the client calls
|
||||
# in this mode are staged as no-op stubs under /usr/bin.
|
||||
_bl_cef=(-cef-force-gpu -cef-use-gl=angle -cef-use-angle=vulkan)
|
||||
if [ "${BL_DESKTOP:-}" = 1 ] && [ "${BL_STEAM_UI:-}" = desktop ]; then
|
||||
_bl_cef=(-cef-disable-gpu)
|
||||
_bl_ui=(-nobigpicture)
|
||||
fi
|
||||
if [ "${BL_STEAM_UI:-}" != desktop ]; then
|
||||
_bl_ui+=(-steamdeck -steamos3)
|
||||
# The QAM's Scaling Filter lists NVIDIA Image Scaling only when told gamescope has it (it does).
|
||||
export STEAM_GAMESCOPE_NIS_SUPPORTED=1
|
||||
# And shows its Scaling Mode and Scaling Filter only when told gamescope takes them.
|
||||
export STEAM_GAMESCOPE_FANCY_SCALING_SUPPORT=1
|
||||
echo "== steam: Deck mode on (-steamdeck -steamos3)"
|
||||
fi
|
||||
# What a killed session leaves behind. Android ends sessions without warning (backgrounding, the
|
||||
# low-memory killer), and the client then finds .crash - opening its update UI on the spinner -
|
||||
# and the web helper's Singleton* locks in htmlcache, owned by a process that is gone, which can
|
||||
# leave the Gamepad UI blank. No client or helper is running at this point in a session.
|
||||
export STEAMOS_STEAM_SHUTDOWN_SENTINEL="$HOME/.bl-steam-shutdown"
|
||||
export STEAMOS_STEAM_REBOOT_SENTINEL="$HOME/.bl-steam-reboot"
|
||||
if ! pgrep -f 'steamwebhelper|steamrtarm64/steam' >/dev/null 2>&1; then
|
||||
_stale=""
|
||||
for _f in "$steam_root/.crash" "$steam_root/steam.pid" \
|
||||
@@ -852,18 +717,7 @@ BUSCONF
|
||||
[ -n "$_stale" ] && echo "== steam: cleared what an earlier session left:$_stale"
|
||||
unset _stale _f
|
||||
fi
|
||||
# The Deck's beta branch, the one the first-run download takes: with -steamos3 on publicbeta
|
||||
# the client settled on steamdeck_stable, an older client it then offered as a "Software
|
||||
# Update" every session (2026-09-30); on steamdeck_publicbeta it finds no update. Whatever
|
||||
# wrote package/beta, the branch on disk has to agree with the one forced here - a
|
||||
# disagreement is the restart loop above, and it is silent apart from rc=42 in this log. A
|
||||
# client installed from publicbeta by an older app moves over this way at its next start.
|
||||
# Checked before every start, not once: the client rewrites package/beta during its own run,
|
||||
# and a restart below (rc=42, or the one after the ARM64 Proton lands) would otherwise start it
|
||||
# again on the branch it just wrote.
|
||||
steam_channel=steamdeck_publicbeta
|
||||
# The app's language (Setup, or the system's): the client's interface takes -language over its
|
||||
# registry, and the registry is rewritten before each start below for its update window.
|
||||
_bl_lang=()
|
||||
[ -n "${BL_STEAM_LANGUAGE:-}" ] && _bl_lang=(-language "$BL_STEAM_LANGUAGE")
|
||||
steam_beta=$steam_root/package/beta
|
||||
@@ -871,16 +725,12 @@ BUSCONF
|
||||
droiddeck-steam-games watch "$steam_root" "$BL_ADDED_GAMES" &
|
||||
games_watcher=$!
|
||||
fi
|
||||
# Lossless Scaling (Steam app 993090): whether this account owns it, asked of the signed-in
|
||||
# client once a session until the answer is yes. From then on the app offers importing
|
||||
# Lossless.dll and passes BL_LOSSLESS_OWNED=1, so the question is never asked again.
|
||||
if [ "${BL_LOSSLESS_OWNED:-0}" != 1 ]; then
|
||||
(
|
||||
owned=$HOME/.config/droiddeck/lossless-owned
|
||||
for ((_i = 0; _i < 60; _i++)); do
|
||||
nap 30
|
||||
[ -e "$owned" ] && exit 0
|
||||
# Loading steamclient.so under proot takes seconds of CPU: not while a game loads or runs.
|
||||
pgrep -x wineserver >/dev/null 2>&1 && continue
|
||||
answer=$(droiddeck-steam-games probe "$steam_root" 993090 2>/dev/null) || continue
|
||||
case $answer in
|
||||
@@ -891,16 +741,9 @@ BUSCONF
|
||||
done
|
||||
) &
|
||||
fi
|
||||
echo "== steam args: ${_bl_ui[*]} ${_bl_cdp[*]} ${_bl_lang[*]} -clientbeta $steam_channel -no-cef-sandbox -cef-force-gpu -cef-ozone-platform=x11 -cef-use-gl=angle -cef-use-angle=vulkan $*"
|
||||
# An update that cannot install asks for a restart (rc=42) every time; the count is capped so a
|
||||
# session can never again loop in silence, which reads as a menu opening and closing by itself.
|
||||
echo "== steam args: ${_bl_ui[*]} ${_bl_cdp[*]} ${_bl_lang[*]} -clientbeta $steam_channel -no-cef-sandbox -cef-ozone-platform=x11 ${_bl_cef[*]} $*"
|
||||
steam_updates=0
|
||||
rm -f "$HOME/.bl-stop-requested"
|
||||
# The client brings a game it launched to the front only while it counts someone as present,
|
||||
# which it reads from gamescope's input counter. A game the app launches after a few minutes
|
||||
# with no touch starts behind the library page and stays there until the next input (device,
|
||||
# 2026-10-09). The game's window turning up behind the interface is counted as one input, as
|
||||
# gamescope counts a key.
|
||||
rm -f "$HOME/.bl-stop-requested" "$STEAMOS_STEAM_SHUTDOWN_SENTINEL" "$STEAMOS_STEAM_REBOOT_SENTINEL"
|
||||
steam_bring_forward() {
|
||||
local end=$((SECONDS + 600)) behind=0 line name value focused other n
|
||||
while [ "$SECONDS" -lt "$end" ]; do
|
||||
@@ -971,7 +814,6 @@ BUSCONF
|
||||
echo start >> "$steam_root/package/droiddeck-unconfirmed"
|
||||
_bl_counted=1
|
||||
fi
|
||||
# Between starts only: the client holds registry.vdf in memory and writes it back on exit.
|
||||
if [ -n "${BL_STEAM_LANGUAGE:-}" ]; then
|
||||
droiddeck-steam-language "$HOME" "$BL_STEAM_LANGUAGE" || true
|
||||
fi
|
||||
@@ -982,8 +824,7 @@ BUSCONF
|
||||
desktop_ui_pid=$!
|
||||
fi
|
||||
"$steam_root/steamrtarm64/steam" "${_bl_ui[@]}" "${_bl_cdp[@]}" "${_bl_lang[@]}" -clientbeta "$steam_channel" \
|
||||
-no-cef-sandbox -cef-force-gpu -cef-ozone-platform=x11 \
|
||||
-cef-use-gl=angle -cef-use-angle=vulkan "$@"
|
||||
-no-cef-sandbox -cef-ozone-platform=x11 "${_bl_cef[@]}" "$@"
|
||||
rc=$?
|
||||
if [ -n "$desktop_ui_pid" ]; then
|
||||
kill "$desktop_ui_pid" 2>/dev/null || true
|
||||
@@ -1001,8 +842,18 @@ BUSCONF
|
||||
rm -f "$HOME/.bl-stop-requested" "$HOME/.bl-restart-once"
|
||||
break
|
||||
fi
|
||||
# The session asked for this exit (the ARM64 Proton landed): start again, without the URL
|
||||
# arguments, which were acted on. Not counted against the update cap.
|
||||
if [ -e "$STEAMOS_STEAM_SHUTDOWN_SENTINEL" ]; then
|
||||
rm -f "$STEAMOS_STEAM_SHUTDOWN_SENTINEL" "$STEAMOS_STEAM_REBOOT_SENTINEL"
|
||||
echo "== steam: Shut Down from the power menu; ending the session"
|
||||
rc=0
|
||||
break
|
||||
fi
|
||||
if [ -e "$STEAMOS_STEAM_REBOOT_SENTINEL" ]; then
|
||||
rm -f "$STEAMOS_STEAM_REBOOT_SENTINEL"
|
||||
echo "== steam: Restart from the power menu; starting the client again"
|
||||
set --
|
||||
continue
|
||||
fi
|
||||
if [ -f "$HOME/.bl-restart-once" ]; then
|
||||
echo "== steam: restarting once so the new compatibility layer is in the client's lists"
|
||||
set --
|
||||
@@ -1014,7 +865,6 @@ BUSCONF
|
||||
echo "== steam: asked to restart for an update $steam_updates times and it is not installing; the session stops here rather than loop"
|
||||
break
|
||||
fi
|
||||
# The URL arguments were acted on the first time; a restart must not repeat them.
|
||||
set --
|
||||
done
|
||||
if [ -n "${stop_watcher:-}" ]; then
|
||||
@@ -1026,10 +876,6 @@ BUSCONF
|
||||
wait "$games_watcher" 2>/dev/null || true
|
||||
fi
|
||||
if [ -n "${BL_DESKTOP:-}" ]; then
|
||||
# Started from the desktop (droiddeck-steam-launch): the desktop's own programs share this
|
||||
# script's parent, so reap_orphans - right under gamescope, where everything is the client's -
|
||||
# is not for here. The helpers this run started (the cores and redistributables beats, the
|
||||
# system bus and the NetworkManager stand-in) go with the client instead.
|
||||
if [ -n "${decky_supervisor:-}" ]; then
|
||||
kill "$decky_supervisor" 2>/dev/null || true
|
||||
wait "$decky_supervisor" 2>/dev/null || true
|
||||
|
||||
@@ -126,10 +126,6 @@ INSTALL_JS = r"""
|
||||
return "installed";
|
||||
})()
|
||||
""".replace("__BINDING__", BINDING)
|
||||
# Big Picture's "Switch to Desktop" asks the client's SteamOS manager, which the client has only when it
|
||||
# runs as SteamOS (-steamos3, Deck mode); otherwise the request fails and the screen stays on "Switching
|
||||
# to Desktop..." for good. The request is caught on its way to the client and answered as SteamOS's
|
||||
# own path does, with steamos-session-select.
|
||||
SWITCH_BINDING = "droiddeckSwitchToDesktop"
|
||||
SWITCH_JS = r"""
|
||||
(() => {
|
||||
@@ -447,10 +443,15 @@ class Helper:
|
||||
self.installed = installed
|
||||
picks = COMPAT["valve_picks"](self.steam_root)
|
||||
apps = sorted(set(installed) | set(picks) | set(state.get("auto", {})), key=COMPAT["app_order"])
|
||||
overrides = COMPAT["requested_games"](
|
||||
COMPAT["game_requests"](), catalog, [t["name"] for t in live])
|
||||
apps = sorted(set(apps) | set(overrides), key=COMPAT["app_order"])
|
||||
current = dict(page.compat("many(%s)" % json.dumps(apps)) or {})
|
||||
current["0"] = top["selected"]
|
||||
native = COMPAT["native_targets"](self.steam_root, installed)
|
||||
changes, auto = COMPAT["plan_mapping"](current, installed, [t["name"] for t in live], default, COMPAT["followers"](state, current), native, picks)
|
||||
changes, auto = COMPAT["plan_mapping"](
|
||||
current, installed, [t["name"] for t in live], default,
|
||||
COMPAT["followers"](state, current), native, picks, overrides)
|
||||
for app, tool in sorted(changes.items(), key=lambda item: COMPAT["app_order"](item[0])):
|
||||
page.compat("set(%d, %s)" % (int(app), json.dumps(tool)))
|
||||
say("%s -> %s" % ("default" if app == "0" else "app %s" % app, tool))
|
||||
@@ -489,7 +490,7 @@ class Helper:
|
||||
if self.page.ws in ready:
|
||||
due = any(called(e, BINDING) for e in self.drain())
|
||||
if (watcher in ready or watcher.fileno() < 0) and watcher.changed():
|
||||
due = self.installed != COMPAT["installed_apps"](self.steam_root) or self.request_waiting()
|
||||
due = True
|
||||
if due:
|
||||
time.sleep(0.3)
|
||||
if watcher.fileno() >= 0 and select.select([watcher], [], [], 0)[0]:
|
||||
@@ -519,8 +520,8 @@ def main():
|
||||
say("no devtools port for this session; the client's mapping is kept through config.vdf")
|
||||
return 0
|
||||
os.makedirs(COMPAT["COMPAT_DIR"], exist_ok=True)
|
||||
watcher = Watcher([COMPAT["state_path"]("request.json")] + [os.path.join(lib, "steamapps", "libraryfolders.vdf") for lib in (steam_root, COMPAT["LIBRARY"] + "-sd")])
|
||||
# The client has its own SteamOS manager when started as SteamOS (droiddeck-session's Deck mode).
|
||||
watcher = Watcher([COMPAT["state_path"]("request.json"), COMPAT["state_path"]("games.json")] +
|
||||
[os.path.join(lib, "steamapps", "libraryfolders.vdf") for lib in (steam_root, COMPAT["LIBRARY"] + "-sd")])
|
||||
steamos = os.environ.get("BL_STEAMDECK") == "1" and os.environ.get("BL_STEAM_UI") != "desktop"
|
||||
helper = Helper(steam_root, port, steamos)
|
||||
failures = 0
|
||||
|
||||
@@ -16,7 +16,6 @@ def select_desktop(evaluate, timeout=90):
|
||||
if result.get('value') is True:
|
||||
return True
|
||||
except Exception:
|
||||
# CEF and SharedJSContext are not ready during the client's initial startup/update.
|
||||
pass
|
||||
time.sleep(1)
|
||||
return False
|
||||
|
||||
@@ -113,7 +113,6 @@ def method(obj, slot, result, *args):
|
||||
|
||||
|
||||
def probe(steam_root, ids):
|
||||
# Slots belong to Valve's SteamClient020, SteamUser021 and STEAMAPPS_INTERFACE_VERSION008.
|
||||
library = C.CDLL(str(Path(steam_root) / "steamrtarm64/steamclient.so"))
|
||||
library.CreateInterface.argtypes = [C.c_char_p, C.c_void_p]
|
||||
library.CreateInterface.restype = C.c_void_p
|
||||
@@ -185,12 +184,6 @@ def watch(steam_root, listing):
|
||||
candidates, sources = {}, {}
|
||||
next_lookup = 0
|
||||
last_status = None
|
||||
# The probe is a fresh python that loads steamclient.so, seconds of CPU under proot. Ownership
|
||||
# only moves with a purchase or a new match, so it runs when the matches or their sources
|
||||
# change, after a failed probe, and otherwise every five minutes - not on every 30 s beat.
|
||||
# A failed probe is retried on a doubling delay up to those five minutes rather than on every
|
||||
# beat (a client that is not logged on fails it for as long as it stays that way), and none
|
||||
# starts while a game is running: the answer can wait, the game's cores cannot.
|
||||
probed, next_probe, failures = None, 0, 0
|
||||
pending, requested = [], []
|
||||
while True:
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
#!/bin/bash
|
||||
# Fetches the native arm64 Steam client from Valve's client-update CDN into ~/.local/share/Steam.
|
||||
# The client is not redistributable, so the runtime ships this script instead of the client.
|
||||
set -eu
|
||||
cdn=https://client-update.fastly.steamstatic.com
|
||||
# The Deck's beta branch, which droiddeck-session forces on the command line too. A client already
|
||||
# on disk from another branch is left for the client to move (droiddeck-session's package/beta).
|
||||
steam_channel=steamdeck_publicbeta
|
||||
manifest=steam_client_${steam_channel}_linuxarm64
|
||||
steam_root=${XDG_DATA_HOME:-$HOME/.local/share}/Steam
|
||||
@@ -43,7 +39,6 @@ work=$(mktemp -d)
|
||||
trap 'rm -rf "$work"' EXIT
|
||||
curl -fsSL "$cdn/$manifest" -o "$work/manifest"
|
||||
version=$(awk -F'"' '$2 == "version" { print $4; exit }' "$work/manifest")
|
||||
# Every component block: its name, then the plain zip's file name and sha256.
|
||||
awk -F'"' '
|
||||
/^\t"/ && NF >= 3 && $4 == "" { block = $2 }
|
||||
$2 == "file" { file[block] = $4 }
|
||||
@@ -62,7 +57,6 @@ while read -r block file sum; do
|
||||
unzip -qo "$work/$file" -d "$steam_root"
|
||||
rm -f "$work/$file"
|
||||
done < "$work/parts"
|
||||
# Some entries are zipped with Windows separators; unzip keeps the backslash in the file name.
|
||||
find "$steam_root" -depth -name '*\\*' | while read -r odd; do
|
||||
fixed=${odd//\\//}
|
||||
mkdir -p "$(dirname "$fixed")"
|
||||
@@ -75,17 +69,11 @@ done
|
||||
echo "$steam_channel" > "$steam_root/package/beta"
|
||||
ln -sfn "$steam_root/steamrtarm64" "$steam_root/steamrtarm32"
|
||||
chmod +x "$steam_root/steamrtarm64/steam" 2>/dev/null || true
|
||||
# What Valve's steam.sh sets up before it runs the client (it has no arm64 branch itself).
|
||||
mkdir -p "$HOME/.steam"
|
||||
ln -sfn "$steam_root" "$HOME/.steam/root"
|
||||
ln -sfn "$steam_root" "$HOME/.steam/steam"
|
||||
ln -sfn "$steam_root/steamrtarm64" "$HOME/.steam/bin64"
|
||||
ln -sfn "$steam_root/linuxarm64" "$HOME/.steam/sdk64"
|
||||
# The arm64 client runs every game through $HOME/.steam/sdkarm64/steam-launch-wrapper. Valve's
|
||||
# steam.sh has no arm64 branch to create it, and without it a launch dies in /bin/sh before Proton
|
||||
# is ever invoked - "No such file or directory", no Proton log, and the only other clue is an
|
||||
# unrelated-looking installscript assertion. Same target as sdk64; the client picks the name by
|
||||
# architecture.
|
||||
ln -sfn "$steam_root/linuxarm64" "$HOME/.steam/sdkarm64"
|
||||
ln -sfn "$steam_root/steamrtarm64" "$HOME/.steam/binarm64"
|
||||
ln -sfn "$steam_root/linux32" "$HOME/.steam/sdk32"
|
||||
|
||||
@@ -122,7 +122,6 @@ def set_value(tokens, opening, key, value):
|
||||
def with_language(text, language):
|
||||
tokens = tokenize(text)
|
||||
if child(tokens, 0, len(tokens), "Registry") is None:
|
||||
# Not a registry the client wrote (or none at all): start one it will read.
|
||||
tokens = []
|
||||
for path in KEYS:
|
||||
set_value(tokens, ensure_block(tokens, path), "language", language)
|
||||
|
||||
@@ -1,13 +1,4 @@
|
||||
#!/bin/bash
|
||||
# Starts the Steam client from inside a session (the desktop's menu entries and the per-game
|
||||
# launchers droiddeck-desktop-games writes):
|
||||
# droiddeck-steam-launch desktop [appid|steam-url] Steam's desktop UI, optionally a game
|
||||
# droiddeck-steam-launch bigpicture [appid|steam-url] Big Picture
|
||||
#
|
||||
# The desktop (KDE Plasma) composites in software and has no dma-buf, so the client's own Vulkan
|
||||
# window - and any game it starts - would die at its first frame there. The request goes to the app
|
||||
# instead, which ends the desktop and starts a Steam session under gamescope in its place, as
|
||||
# SteamOS's desktop hands Steam back to Gaming Mode.
|
||||
set -u
|
||||
ui=${1:-desktop}
|
||||
target=${2:-}
|
||||
@@ -20,12 +11,31 @@ case $target in
|
||||
*) url=steam://rungameid/$target ;;
|
||||
esac
|
||||
|
||||
# Ask the app for a Steam session.
|
||||
if [ "$ui" = desktop ] && [ "${BL_DESKTOP:-}" = 1 ]; then
|
||||
steam_root=${XDG_DATA_HOME:-${HOME:-/root}/.local/share}/Steam
|
||||
export LD_LIBRARY_PATH=$steam_root/steamrtarm64:$steam_root/steamrtarm64/panorama${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
|
||||
mkdir -p "${XDG_CACHE_HOME:-$HOME/.cache}/droiddeck"
|
||||
exec 9>"${XDG_CACHE_HOME:-$HOME/.cache}/droiddeck/steam-desktop.lock"
|
||||
if ! flock -n 9; then
|
||||
for ((attempt = 0; attempt < 180; attempt++)); do
|
||||
pid=$(cat "$HOME/.steam/steam.pid" 2>/dev/null || true)
|
||||
if [ -p "$HOME/.steam/steam.pipe" ] && [[ "$pid" =~ ^[0-9]+$ ]] && kill -0 "$pid" 2>/dev/null; then
|
||||
exec "$steam_root/steamrtarm64/steam" -nobigpicture -no-cef-sandbox \
|
||||
-cef-ozone-platform=x11 -cef-disable-gpu "${url:-steam://open/library}"
|
||||
fi
|
||||
sleep 0.5
|
||||
done
|
||||
echo "droiddeck-steam-launch: the desktop client did not become ready" >&2
|
||||
exit 69
|
||||
fi
|
||||
export BL_INSIDE=1 BL_STEAM_UI=desktop
|
||||
exec /usr/local/bin/droiddeck-session steam "${url:-steam://open/library}"
|
||||
fi
|
||||
|
||||
dir=${BL_LAUNCH_DIR:-}
|
||||
if [ -z "$dir" ] || [ ! -d "$dir" ]; then
|
||||
echo "droiddeck-steam-launch: not inside a DroidDeck session (BL_LAUNCH_DIR unset)" >&2
|
||||
exit 69
|
||||
fi
|
||||
# Written whole, then renamed: the app reads it on close, never half-written.
|
||||
printf 'ui=%s\nurl=%s\n' "$ui" "$url" > "$dir/steam-launch.tmp" && mv -f "$dir/steam-launch.tmp" "$dir/steam-launch"
|
||||
echo "droiddeck-steam-launch: asked the app for Steam ($ui${url:+, $url})"
|
||||
@@ -1,23 +1,10 @@
|
||||
#!/usr/bin/python3
|
||||
# Registers the card the app installs to (bound at /mnt/droiddeck-sd) as a library folder of the
|
||||
# native Steam client, so they show as installed there instead of being downloaded a second time.
|
||||
#
|
||||
# droiddeck-steam-library <steam root>
|
||||
#
|
||||
# Ported from WinNative's gamescope runtime (GPL-3.0).
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
# The client's own library is internal storage (its steamapps/common is bound to the app's root);
|
||||
# the card is the one extra library folder.
|
||||
# The app binds the storage the user chose (Steam cog -> Game storage) at this path and names it
|
||||
# in BL_LIBRARY_LABEL; nothing bound = internal only, and the entry is removed so the client does
|
||||
# not keep offering a place that is not there.
|
||||
LIBRARIES = (("/mnt/droiddeck-sd", os.environ.get("BL_LIBRARY_LABEL", "SD Card")),)
|
||||
# The client calls its own library "Local Drive (/)", which says nothing about where that is.
|
||||
# It is the phone's internal storage, so say so.
|
||||
MAIN_LABEL = "Internal Storage"
|
||||
|
||||
|
||||
@@ -153,10 +140,6 @@ def relabel(steam_root, target, label):
|
||||
with open(path, "w", encoding="utf-8") as f:
|
||||
f.write("\n".join(out))
|
||||
print("droiddeck-steam-library: labelled %s %r" % (target, label))
|
||||
# A library also carries its own libraryfolder.vdf, and the client takes the label from there
|
||||
# back into the list above - so editing the list alone is undone on the next start. The
|
||||
# client's own library has no such file, which is why that one kept the new name and the card
|
||||
# went back to the name it was first registered with.
|
||||
marker = os.path.join(target, "libraryfolder.vdf")
|
||||
if not os.path.isfile(marker):
|
||||
return
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
#!/bin/bash
|
||||
# `steam` on the desktop. The client writes a menu entry per installed game that runs
|
||||
# `steam steam://rungameid/<id>`, and its own launchers say `steam`. On the desktop that goes
|
||||
# through droiddeck-steam-launch - which runs the client on the desktop itself when it draws with
|
||||
# the GPU, hands the URL to a client already running there, and asks the app for a Steam session
|
||||
# on a software desktop. Anywhere else it is the client itself.
|
||||
set -u
|
||||
if [ "${BL_DESKTOP:-}" = 1 ]; then
|
||||
url=
|
||||
|
||||
@@ -29,7 +29,6 @@ def account_dir(steam_root):
|
||||
pass
|
||||
userdata = os.path.join(steam_root, "userdata")
|
||||
if recent is not None:
|
||||
# loginusers holds the 64-bit id; userdata folders use the 32-bit account id.
|
||||
acct = recent - 76561197960265728
|
||||
return os.path.join(userdata, str(acct))
|
||||
try:
|
||||
@@ -39,7 +38,6 @@ def account_dir(steam_root):
|
||||
return os.path.join(userdata, dirs[0]) if len(dirs) == 1 else None
|
||||
|
||||
|
||||
# ---- binary VDF: 0x00 map, 0x01 string, 0x02 int32, 0x08 end ----
|
||||
|
||||
def parse(data):
|
||||
pos = [0]
|
||||
@@ -123,8 +121,6 @@ def shortcut(game, launch_options=None):
|
||||
RECORD = ".droiddeck-shortcuts.json"
|
||||
AWAY_LIMIT = 256
|
||||
FIELDS = ("AppName", "Exe", "StartDir", "icon", "LaunchOptions")
|
||||
# What the app may change after the shortcut exists. Each follows the app only while Steam still
|
||||
# has what the app last asked for; a value the user set in Steam's Properties stays.
|
||||
FOLLOWED = ("StartDir", "LaunchOptions")
|
||||
|
||||
|
||||
@@ -164,9 +160,6 @@ def merge(fresh, current, state, seen):
|
||||
for field in ("AppName", "icon"):
|
||||
if current.get(field) == base.get(field):
|
||||
entry[field] = fresh[field]
|
||||
# Start in and launch options the app sets: only once there is a record of what it asked for
|
||||
# before (a first run keeps whatever the shortcut already had), and an older record that did
|
||||
# not keep launch options means the app asked for none.
|
||||
if isinstance(state.get("app"), dict):
|
||||
for field in FOLLOWED:
|
||||
was = base.get(field, "" if field == "LaunchOptions" else current.get(field))
|
||||
@@ -240,8 +233,6 @@ def save_record(path, record):
|
||||
|
||||
|
||||
ART_MANIFEST = ".droiddeck-art.json"
|
||||
# listing key -> the client's grid file suffix: <appid>p = portrait capsule, <appid> = header,
|
||||
# <appid>_hero, <appid>_logo.
|
||||
ART_SLOTS = (("p", "p"), ("header", ""), ("hero", "_hero"), ("logo", "_logo"))
|
||||
|
||||
|
||||
@@ -273,7 +264,7 @@ def install_art(acct, games):
|
||||
dst = os.path.join(grid, name)
|
||||
size = os.path.getsize(src)
|
||||
if os.path.exists(dst) and name not in manifest:
|
||||
continue # the user's own choice inside the client; never ours to touch
|
||||
continue
|
||||
wanted[name] = size
|
||||
if os.path.exists(dst) and manifest.get(name) == size:
|
||||
continue
|
||||
@@ -344,9 +335,7 @@ def main():
|
||||
save_record(record_path, record)
|
||||
print("droiddeck-steam-shortcuts: %d added game(s) written, %d of the client's own kept" % (len(ours), len(kept)))
|
||||
install_art(acct, [g for g in games if g.get("exe") and g.get("name")])
|
||||
# Each added game runs under the ARM64 Proton: the compat registrar's own mapping writer.
|
||||
try:
|
||||
# No .py suffix on the registrar, so the loader has to be named.
|
||||
compat_path = "/usr/local/bin/steam-compatibility"
|
||||
spec = importlib.util.spec_from_file_location("compat", compat_path, loader=importlib.machinery.SourceFileLoader("compat", compat_path))
|
||||
compat = importlib.util.module_from_spec(spec)
|
||||
@@ -356,7 +345,7 @@ def main():
|
||||
compat.register_default(cfg, apps=[str(int(g["appid"]) & 0xFFFFFFFF) for g in games if g.get("exe")] + [str(appid) for appid in set(routes.values())],
|
||||
protect=compat.adopt_extras(os.path.join(steam_root, "compatibilitytools.d")))
|
||||
print("droiddeck-steam-shortcuts: mapped them to %s" % compat.TOOL)
|
||||
except Exception as e: # noqa: BLE001 - the games still show; the client falls back to the default tool
|
||||
except Exception as e:
|
||||
print("droiddeck-steam-shortcuts: compat mapping skipped (%s)" % e)
|
||||
return 0
|
||||
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
#!/usr/bin/python3
|
||||
"""Initialize Steam's own Gamescope display settings once; subsequent choices belong to Steam.
|
||||
"""Initialize Steam's own display settings once; subsequent choices belong to Steam.
|
||||
|
||||
The UI scale, and native resolution: the client treats our gamescope as an external display and,
|
||||
unless "Enable Native Resolution on External Displays" is on, draws itself at 1920x1080 on any
|
||||
larger output - a 2340x1080 session came up as 16:9 with bars. The session's size is already the
|
||||
user's Resolution choice, so the client should use all of it."""
|
||||
user's Resolution choice, so the client should use all of it.
|
||||
|
||||
And the screensaver over a running game. The client's defaults (steamui.so's settings descriptor)
|
||||
show screensavers while a game runs, after 300 s on AC power with no button pressed - and a stick or
|
||||
trigger held is no press. Red Dead Redemption 2's cutscenes run longer than that: the slideshow
|
||||
covered the game, and the button that woke it reached the game as well (B asked to quit to the
|
||||
desktop). Customization > Screensaver > "Show screensavers when playing a game" still turns it on."""
|
||||
import math
|
||||
import os
|
||||
from pathlib import Path
|
||||
@@ -15,6 +21,7 @@ import tempfile
|
||||
|
||||
DISPLAY = "External: gamescope|||Windowed"
|
||||
NATIVE_RESOLUTION = "EnableSteamNativeExternalResolution"
|
||||
SCREENSAVER_IN_GAME = ("Customization", "Screensaver", "WhileInGame")
|
||||
TOKEN = re.compile(r'\s+|//[^\n]*|"(?:\\.|[^"\\])*"|[{}]')
|
||||
|
||||
|
||||
@@ -71,8 +78,6 @@ def parse(text):
|
||||
|
||||
|
||||
def initial_scale(width, height):
|
||||
# The Thor setting chosen on device at 1280x720 was 140% of its automatic scale.
|
||||
# Adjust with canvas area so choosing a different session resolution keeps the UI usable.
|
||||
if not 320 <= width <= 16384 or not 320 <= height <= 16384:
|
||||
raise ValueError("invalid session size")
|
||||
return 1.3281567096710205 * math.sqrt(width * height / (1280 * 720))
|
||||
@@ -89,8 +94,6 @@ def seed_text(text, scale):
|
||||
if display is not None and not isinstance(display, Block):
|
||||
raise ValueError("invalid display settings")
|
||||
if display is not None:
|
||||
# Current describes the active display and is written even with automatic scaling.
|
||||
# Named display entries are the user's saved choices, including a return to Auto.
|
||||
if any(name.lower() != 'current' and isinstance(value, Block)
|
||||
and value.get('ScaleFactor') is not None for name, value in display.pairs):
|
||||
return text, False
|
||||
@@ -103,28 +106,44 @@ def seed_text(text, scale):
|
||||
else:
|
||||
entry = '"UI"\n{\n"display"\n{\n' + entry + '}\n}\n'
|
||||
at, indent = root.end, 1
|
||||
# Insert only the new block; leave every existing byte, comment and credential untouched.
|
||||
insertion = '\n' + '\n'.join('\t' * indent + line for line in entry.splitlines()) + '\n'
|
||||
return text[:at] + insertion + text[at:], True
|
||||
|
||||
|
||||
def seed_value(text, path, value):
|
||||
"""InstallConfigStore/<path> = value, unless the client already has a value there (the
|
||||
user's), adding only the blocks that are missing."""
|
||||
root = parse(text).get('InstallConfigStore')
|
||||
if not isinstance(root, Block):
|
||||
raise ValueError("missing InstallConfigStore")
|
||||
*sections, name = path
|
||||
block, depth = root, 1
|
||||
while sections:
|
||||
child = block.get(sections[0])
|
||||
if child is None:
|
||||
break
|
||||
if not isinstance(child, Block):
|
||||
raise ValueError(f"invalid {sections[0]} settings")
|
||||
block, depth = child, depth + 1
|
||||
sections.pop(0)
|
||||
if not sections and block.get(name) is not None:
|
||||
return text, False
|
||||
lines = [(len(sections), f'"{name}"\t\t"{value}"')]
|
||||
for level, section in reversed(list(enumerate(sections))):
|
||||
lines = [(level, f'"{section}"'), (level, '{')] + lines + [(level, '}')]
|
||||
insertion = ''.join('\t' * (depth + level) + line + '\n' for level, line in lines)
|
||||
at = text.rfind('\n', 0, block.end) + 1
|
||||
if text[at:block.end].strip():
|
||||
at, insertion = block.end, '\n' + insertion
|
||||
return text[:at] + insertion + text[at:], True
|
||||
|
||||
|
||||
def seed_native_resolution(text):
|
||||
root = parse(text).get('InstallConfigStore')
|
||||
if not isinstance(root, Block):
|
||||
raise ValueError("missing InstallConfigStore")
|
||||
gamescope = root.get('Gamescope')
|
||||
if gamescope is not None and not isinstance(gamescope, Block):
|
||||
raise ValueError("invalid Gamescope settings")
|
||||
if gamescope is not None and gamescope.get(NATIVE_RESOLUTION) is not None:
|
||||
return text, False
|
||||
entry = f'"{NATIVE_RESOLUTION}" "1"'
|
||||
if gamescope is not None:
|
||||
at, indent = gamescope.end, 2
|
||||
else:
|
||||
entry = '"Gamescope"\n{\n' + entry + '\n}'
|
||||
at, indent = root.end, 1
|
||||
insertion = '\n' + '\n'.join('\t' * indent + line for line in entry.splitlines()) + '\n'
|
||||
return text[:at] + insertion + text[at:], True
|
||||
return seed_value(text, ('Gamescope', NATIVE_RESOLUTION), '1')
|
||||
|
||||
|
||||
def seed_no_screensaver_in_game(text):
|
||||
return seed_value(text, SCREENSAVER_IN_GAME, '0')
|
||||
|
||||
|
||||
def atomic_write(path, text):
|
||||
@@ -140,31 +159,36 @@ def atomic_write(path, text):
|
||||
|
||||
|
||||
def initialize(steam_root, width, height):
|
||||
scale = initial_scale(width, height)
|
||||
return seed_once(steam_root, 'droiddeck-ui-scale-initialized', lambda text: seed_text(text, scale),
|
||||
f'== steam: initial handheld UI scale {scale:.3f}')
|
||||
|
||||
|
||||
def seed_once(steam_root, marker_name, seed, message):
|
||||
"""Applies seed to config.vdf the first time only: the marker keeps a later choice - including
|
||||
a return to the client's own default, which the client may store by dropping the key - the
|
||||
user's."""
|
||||
config = Path(steam_root) / 'config/config.vdf'
|
||||
marker = config.with_name('droiddeck-ui-scale-initialized')
|
||||
marker = config.with_name(marker_name)
|
||||
if marker.exists():
|
||||
return False
|
||||
text = config.read_text() if config.exists() else '"InstallConfigStore"\n{\n}\n'
|
||||
updated, changed = seed_text(text, initial_scale(width, height))
|
||||
updated, changed = seed(text)
|
||||
if changed:
|
||||
atomic_write(config, updated)
|
||||
print(f'== steam: initial handheld UI scale {initial_scale(width, height):.3f}')
|
||||
print(message)
|
||||
atomic_write(marker, '1\n')
|
||||
return changed
|
||||
|
||||
|
||||
def initialize_native_resolution(steam_root):
|
||||
config = Path(steam_root) / 'config/config.vdf'
|
||||
marker = config.with_name('droiddeck-native-resolution-initialized')
|
||||
if marker.exists():
|
||||
return False
|
||||
text = config.read_text() if config.exists() else '"InstallConfigStore"\n{\n}\n'
|
||||
updated, changed = seed_native_resolution(text)
|
||||
if changed:
|
||||
atomic_write(config, updated)
|
||||
print('== steam: native resolution on the session display')
|
||||
atomic_write(marker, '1\n')
|
||||
return changed
|
||||
return seed_once(steam_root, 'droiddeck-native-resolution-initialized', seed_native_resolution,
|
||||
'== steam: native resolution on the session display')
|
||||
|
||||
|
||||
def initialize_screensaver(steam_root):
|
||||
return seed_once(steam_root, 'droiddeck-screensaver-initialized', seed_no_screensaver_in_game,
|
||||
'== steam: no screensaver over a running game')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
@@ -174,9 +198,10 @@ if __name__ == '__main__':
|
||||
except (OSError, ValueError, RecursionError) as error:
|
||||
print('== steam: left UI scale unchanged: ' + str(error), file=sys.stderr)
|
||||
status = 1
|
||||
try:
|
||||
initialize_native_resolution(sys.argv[1])
|
||||
except (OSError, ValueError, RecursionError) as error:
|
||||
print('== steam: left native resolution unchanged: ' + str(error), file=sys.stderr)
|
||||
status = 1
|
||||
for what, step in (('native resolution', initialize_native_resolution), ('screensaver', initialize_screensaver)):
|
||||
try:
|
||||
step(sys.argv[1])
|
||||
except (OSError, ValueError, RecursionError) as error:
|
||||
print(f'== steam: left {what} unchanged: {error}', file=sys.stderr)
|
||||
status = 1
|
||||
sys.exit(status)
|
||||
@@ -0,0 +1,96 @@
|
||||
#!/bin/sh
|
||||
set -u
|
||||
|
||||
steamvr=${STEAMVR:-/opt/steamvr}
|
||||
vrdir=${DROIDDECK_VR_DIR:-/usr/local/lib/droiddeck-vr}
|
||||
driver=$vrdir/droiddeck
|
||||
layer=$vrdir/layer
|
||||
logs=$HOME/.local/share/Steam/logs
|
||||
state=${XDG_RUNTIME_DIR:-/tmp}/droiddeck-steamvr
|
||||
mkdir -p "$state"
|
||||
|
||||
PKG_URL=https://steamdeck-packages.steamos.cloud/archlinux-deckard-hotfixes/release/0.3.x/deckard-steamvr-rel-r25358740%2B28b72a4f-1-aarch64.pkg.tar.zst
|
||||
PKG_SHA256=90a600775eb3e8856dc475f83166a93a290a0b1f3b4e82a69c8e2a8f06b9ddc9
|
||||
|
||||
running() { pgrep -x vrserver >/dev/null 2>&1; }
|
||||
installed() { [ -x "$steamvr/bin/linuxarm64/vrstartup" ]; }
|
||||
|
||||
stop() {
|
||||
rm -f "$state/active"
|
||||
for n in vrcompositor vrserver vrmonitor vrdashboard vrstartup vrwebhelper; do
|
||||
for p in $(pgrep -x "$n"); do kill "$p" 2>/dev/null; done
|
||||
done
|
||||
for p in $(pgrep -f "$steamvr/bin/linuxarm64/vrcompositor-launcher"); do kill "$p" 2>/dev/null; done
|
||||
return 0
|
||||
}
|
||||
|
||||
case "${1:-status}" in
|
||||
status)
|
||||
i=0; installed && i=1
|
||||
r=0; running && r=1
|
||||
if [ "$r" = 0 ] && [ -n "$(find "$state/active" -mmin +2 2>/dev/null)" ]; then rm -f "$state/active"; fi
|
||||
n=0; [ -f "$state/installing" ] && n=1
|
||||
d=0; [ -f "$driver/bin/linuxarm64/driver_droiddeck.so" ] && [ -f "$layer/libVkLayer_droiddeck_vr.so" ] && d=1
|
||||
echo "installed=$i running=$r installing=$n driver=$d"
|
||||
;;
|
||||
install)
|
||||
installed && { echo "SteamVR is already in $steamvr"; exit 0; }
|
||||
[ -f "$state/installing" ] && { echo "already installing"; exit 0; }
|
||||
: > "$state/installing"
|
||||
trap 'rm -f "$state/installing"' EXIT
|
||||
cache=$HOME/.cache/droiddeck-vr
|
||||
mkdir -p "$cache"
|
||||
pkg=$cache/steamvr.pkg.tar.zst
|
||||
echo "downloading SteamVR (571 MB) from Valve's package server"
|
||||
curl -fsSL --retry 5 -C - -o "$pkg" "$PKG_URL" || { echo "download failed"; exit 1; }
|
||||
echo "$PKG_SHA256 $pkg" | sha256sum -c - >/dev/null 2>&1 || { echo "checksum mismatch: removing the download"; rm -f "$pkg"; exit 1; }
|
||||
tmp=$cache/extract
|
||||
rm -rf "$tmp" && mkdir -p "$tmp"
|
||||
zstd -dc "$pkg" | tar -x -C "$tmp" opt/steamvr || { echo "extract failed"; rm -rf "$tmp"; exit 1; }
|
||||
mkdir -p "$(dirname "$steamvr")"
|
||||
rm -rf "$steamvr" && mv "$tmp/opt/steamvr" "$steamvr" && rm -rf "$tmp" "$pkg"
|
||||
echo "SteamVR installed in $steamvr"
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
start)
|
||||
installed || { echo "SteamVR is not installed (droiddeck-steamvr install)"; exit 1; }
|
||||
[ -f "$driver/bin/linuxarm64/driver_droiddeck.so" ] || { echo "the Cardboard driver is missing from $driver"; exit 1; }
|
||||
stop
|
||||
sleep 1
|
||||
mkdir -p "$HOME/.config/openvr" "$HOME/.config/openxr/1" "$logs" "$HOME/.local/share/Steam/config"
|
||||
cat > "$HOME/.config/openvr/openvrpaths.vrpath" <<JSON
|
||||
{
|
||||
"config": ["$HOME/.local/share/Steam/config"],
|
||||
"external_drivers": ["$driver"],
|
||||
"jsonid": "vrpathreg",
|
||||
"log": ["$logs"],
|
||||
"runtime": ["$steamvr"],
|
||||
"version": 1
|
||||
}
|
||||
JSON
|
||||
ln -sf "$steamvr/steamxr_linuxarm64.json" "$HOME/.config/openxr/1/active_runtime.json"
|
||||
|
||||
export VK_LAYER_PATH="$layer${VK_LAYER_PATH:+:$VK_LAYER_PATH}"
|
||||
export VK_INSTANCE_LAYERS="VK_LAYER_DROIDDECK_vr${VK_INSTANCE_LAYERS:+:$VK_INSTANCE_LAYERS}"
|
||||
export VK_LOADER_LAYERS_DISABLE="${VK_LOADER_LAYERS_DISABLE:-~implicit~}"
|
||||
|
||||
shims=$state/shims
|
||||
mkdir -p "$shims"
|
||||
if ! command -v xset >/dev/null 2>&1; then
|
||||
printf '#!/bin/sh\n# xset stand-in for vrwebhelper.sh: "q" only checks the display answers.\nexec xprop -root -display "${DISPLAY:-:0}" _NET_SUPPORTED >/dev/null 2>&1\n' > "$shims/xset"
|
||||
chmod +x "$shims/xset"
|
||||
export PATH="$shims:$PATH"
|
||||
fi
|
||||
|
||||
: > "$state/active"
|
||||
cd "$steamvr/bin/linuxarm64" || exit 1
|
||||
setsid ./vrstartup > "$state/vrstartup.log" 2>&1 < /dev/null &
|
||||
echo "SteamVR starting; logs in $logs and $state/vrstartup.log"
|
||||
;;
|
||||
*)
|
||||
echo "usage: droiddeck-steamvr status|install|start|stop" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
@@ -30,6 +30,9 @@ import json
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import subprocess
|
||||
import tempfile
|
||||
import hashlib
|
||||
from pathlib import Path
|
||||
|
||||
LAUNCHER = ".droiddeck-launch.bat"
|
||||
@@ -113,7 +116,6 @@ def ask(channel, request, timeout=TIMEOUT):
|
||||
return value
|
||||
except (OSError, ValueError):
|
||||
time.sleep(0.05)
|
||||
# Not answered: the request is withdrawn so a late app does not mint a code nobody reads.
|
||||
try:
|
||||
(req_dir / (rid + ".json")).unlink()
|
||||
except OSError:
|
||||
@@ -226,10 +228,7 @@ def provision_prefix(compat_data, wait=SERVER_WAIT):
|
||||
reg = pfx / "user.reg"
|
||||
if not reg.is_file():
|
||||
return "prefix-not-created"
|
||||
# A wineserver still up for this prefix would write its own copy of user.reg over these lines.
|
||||
busy = not wait_for_server(pfx, wait)
|
||||
# winebrowser starts the first entry it can; an absolute path does not depend on the PATH Wine
|
||||
# hands it.
|
||||
set_value(reg, BROWSER_KEY, "Browsers", BROWSER + ",xdg-open")
|
||||
removed = remove_value(reg, EOS_KEY, "OverlayPath")
|
||||
state = "browser-set" if has_value(reg, BROWSER_KEY, "Browsers", BROWSER + ",xdg-open") else "browser-not-written"
|
||||
@@ -240,8 +239,6 @@ def provision_prefix(compat_data, wait=SERVER_WAIT):
|
||||
|
||||
CLOUD_TIMEOUT = 15.0
|
||||
CLOUD_STORES = ("gog", "epic")
|
||||
# Exit status that tells droiddeck-proton this was a store game with cloud saves: it then waits for
|
||||
# Proton instead of exec'ing it, and runs `droiddeck-store-launch --exited` after.
|
||||
STORE_GAME = 10
|
||||
|
||||
|
||||
@@ -262,6 +259,74 @@ def exited(argv):
|
||||
return 0
|
||||
|
||||
|
||||
COMET_DIR = Path("/usr/local/lib/droiddeck-comet")
|
||||
|
||||
|
||||
def provision_galaxy(compat_data, proton, timeout=90):
|
||||
"""Proton creates the prefix and registers Galaxy before the first game runs."""
|
||||
if not compat_data or not proton or not Path(proton).is_file():
|
||||
return "no-proton"
|
||||
data = Path(compat_data)
|
||||
data.mkdir(parents=True, exist_ok=True)
|
||||
marker = data / "pfx/.droiddeck-comet-service"
|
||||
try:
|
||||
version = (COMET_DIR / "version").read_text().strip()
|
||||
tools = [COMET_DIR / "GalaxyCommunication.exe", COMET_DIR / "update-permissions.exe"]
|
||||
if not all(p.is_file() for p in tools):
|
||||
return "not-installed"
|
||||
stamp = version + " " + " ".join(hashlib.sha256(p.read_bytes()).hexdigest() for p in tools)
|
||||
if marker.is_file() and marker.read_text() == stamp and (data / "pfx/system.reg").is_file():
|
||||
return "ready"
|
||||
with tempfile.TemporaryDirectory(prefix="droiddeck-galaxy-") as tmp:
|
||||
folder = Path(tmp)
|
||||
result = folder / "result"
|
||||
bat = folder / "install.bat"
|
||||
src = windows_path(str(COMET_DIR))
|
||||
answer = windows_path(str(result))
|
||||
target = r"C:\ProgramData\GOG.com\Galaxy\redists"
|
||||
lines = ["@echo off", "setlocal", 'set "DD_DIR=%s"' % target,
|
||||
"sc query GalaxyCommunication >nul 2>&1",
|
||||
'if not errorlevel 1 if not exist "%DD_DIR%\\droiddeck-comet" goto existing',
|
||||
'if not exist "%DD_DIR%" mkdir "%DD_DIR%"',
|
||||
'copy /y "%s\\GalaxyCommunication.exe" "%s\\GalaxyCommunication.exe" >nul' % (src, target),
|
||||
'if errorlevel 1 exit /b 1',
|
||||
'sc query GalaxyCommunication >nul 2>&1',
|
||||
'if errorlevel 1 sc create GalaxyCommunication binpath= "%s\\GalaxyCommunication.exe"' % target,
|
||||
'if errorlevel 1 exit /b 1',
|
||||
'"%s\\update-permissions.exe"' % src,
|
||||
'if errorlevel 1 exit /b 1',
|
||||
'sc query GalaxyCommunication >nul 2>&1',
|
||||
'if errorlevel 1 exit /b 1',
|
||||
'echo managed>"%s\\droiddeck-comet"' % target,
|
||||
':existing', 'echo ready>"%s"' % answer, 'exit /b 0']
|
||||
bat.write_bytes(("\r\n".join(lines) + "\r\n").encode())
|
||||
env = os.environ.copy()
|
||||
env["BL_COMET_BOOTSTRAP"] = "1"
|
||||
run = subprocess.run([proton, "run", "cmd.exe", "/d", "/c", windows_path(str(bat))],
|
||||
env=env, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, timeout=timeout)
|
||||
if run.returncode or not result.is_file() or result.read_text().strip() != "ready":
|
||||
return "service-unavailable"
|
||||
marker.write_text(stamp)
|
||||
return "ready"
|
||||
except subprocess.TimeoutExpired:
|
||||
return "timeout"
|
||||
except (OSError, ValueError):
|
||||
return "service-unavailable"
|
||||
|
||||
|
||||
def prepare_gog(sidecar, compat_data, launch_dir):
|
||||
if not launch_dir:
|
||||
log("gog achievements unavailable: no-channel")
|
||||
return False
|
||||
answer = ask(Path(launch_dir) / "stores", {"op": "gog-achievements", "store": "gog", "id": str(sidecar.get("id"))}, timeout=25.0)
|
||||
if not isinstance(answer, dict) or not answer.get("ready"):
|
||||
log("gog achievements: " + (str(answer.get("reason", "unavailable")) if isinstance(answer, dict) else "timeout"))
|
||||
return False
|
||||
state = provision_galaxy(compat_data, os.environ.get("BL_STORE_PROTON", ""))
|
||||
log("gog achievements prefix: " + state)
|
||||
return state == "ready"
|
||||
|
||||
|
||||
def main(argv):
|
||||
if argv and argv[0] == "--exited":
|
||||
return exited(argv[1:])
|
||||
@@ -273,11 +338,12 @@ def main(argv):
|
||||
compat_data = os.environ.get("STEAM_COMPAT_DATA_PATH", "").rstrip("/")
|
||||
prefix_id = os.path.basename(compat_data) if compat_data else ""
|
||||
launch_dir = os.environ.get("BL_LAUNCH_DIR", "")
|
||||
if store == "gog":
|
||||
prepare_gog(sidecar, compat_data, launch_dir)
|
||||
if store == "epic":
|
||||
drop_stale(folder)
|
||||
choice = options(sidecar)
|
||||
if not (choice["eos"] and not choice["offline"]):
|
||||
# Sign-in off, or offline: no code, and none left over from before.
|
||||
try:
|
||||
(folder / EPIC_CODE).unlink()
|
||||
except OSError:
|
||||
@@ -298,7 +364,6 @@ def main(argv):
|
||||
log("cloud %s %s down result=skipped reason=off" % (store, game))
|
||||
return 0
|
||||
if launch_dir:
|
||||
# The cloud copy where it is newer, before the game reads its saves; bounded, then on regardless.
|
||||
answer = ask(Path(launch_dir) / "stores", {"op": "cloud-down", "store": store, "id": game}, timeout=CLOUD_TIMEOUT)
|
||||
if answer is None:
|
||||
log("cloud %s %s down result=timeout" % (store, game))
|
||||
@@ -312,6 +377,6 @@ def main(argv):
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
sys.exit(main(sys.argv[1:]))
|
||||
except Exception as e: # never in the way of the launch
|
||||
except Exception as e:
|
||||
log("skipped: %s" % type(e).__name__)
|
||||
sys.exit(0)
|
||||
@@ -32,20 +32,13 @@ from pathlib import Path
|
||||
|
||||
STORE = Path("/opt/droiddeck/wincomponents")
|
||||
SELECTION = Path.home() / ".config/droiddeck/wincomponents.json"
|
||||
# Components the app is still downloading for a game Steam installed during this session:
|
||||
# {"games": {"<appid>": ["vcredist2019_dll", ...]}}. A launch waits a little for them.
|
||||
PENDING = Path.home() / ".config/droiddeck/wincomponents-pending.json"
|
||||
PENDING_WAIT = 10.0
|
||||
# What this prefix holds from us, so a component the user turns off is taken out again.
|
||||
STATE = ".droiddeck-wincomponents.json"
|
||||
# A file ours replaced that was not Proton's (a real installer's, the user's own), put back when the
|
||||
# component is turned off. Proton's builtins need no copy: it restores those itself.
|
||||
BACKUP = ".droiddeck-wincomponents-backup"
|
||||
BUILTIN_MARKS = (b"Wine builtin DLL", b"Wine placeholder DLL")
|
||||
ARCH_DIRS = ("system32", "syswow64")
|
||||
ID = re.compile(r"[A-Za-z0-9][A-Za-z0-9._-]{0,63}")
|
||||
# The registry file of each hive in a prefix, and the kinds of value registry.json holds: "key"
|
||||
# makes a key, "append"/"prepend" add to a list such as PATH unless it is already there.
|
||||
HIVES = {"HKLM": "system.reg", "HKCU": "user.reg"}
|
||||
VALUE_TYPES = {"key", "sz", "expand_sz", "multi_sz", "dword", "binary", "append", "prepend"}
|
||||
|
||||
@@ -80,7 +73,6 @@ def component(store, cid):
|
||||
for arch in ARCH_DIRS:
|
||||
folder = root / arch
|
||||
if folder.is_dir():
|
||||
# A few go one level down (gmdls: system32/drivers/gm.dls).
|
||||
for entry in sorted(folder.rglob("*")):
|
||||
if entry.is_file() and not entry.is_symlink():
|
||||
rel = entry.relative_to(folder).as_posix().lower()
|
||||
@@ -195,12 +187,10 @@ def place(src, target, backup=None):
|
||||
final = found or target
|
||||
temp = final.with_name(".%s.droiddeck" % final.name)
|
||||
shutil.copy2(src, temp)
|
||||
# Over a Proton builtin this swaps its symlink for our file.
|
||||
os.replace(temp, final)
|
||||
return True
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- the prefix's registry files
|
||||
|
||||
def reg_escape(text, extra=""):
|
||||
"""A string as Wine's registry files write it."""
|
||||
@@ -556,7 +546,6 @@ def apply(compat_path, app_id, selection=SELECTION, store=STORE, pending=PENDING
|
||||
"""Brings the prefix in line with the game's picks. Returns (overrides, notes)."""
|
||||
compat = Path(compat_path)
|
||||
pfx = compat / "pfx"
|
||||
# A game Steam installed during this session may have components still on their way.
|
||||
waited = wait(app_id, pending, store) if wait else None
|
||||
ids = wanted(app_id, selection)
|
||||
state = load_state(compat)
|
||||
@@ -576,7 +565,6 @@ def apply(compat_path, app_id, selection=SELECTION, store=STORE, pending=PENDING
|
||||
overrides += names
|
||||
values += [(cid, value) for value in registry]
|
||||
for rel, src in files:
|
||||
# A file this prefix already has from us is ours to replace; anything else is kept.
|
||||
if place(src, pfx / rel, None if rel in state["files"] else compat / BACKUP / rel):
|
||||
copied += 1
|
||||
keep[rel] = cid
|
||||
@@ -594,8 +582,6 @@ def apply(compat_path, app_id, selection=SELECTION, store=STORE, pending=PENDING
|
||||
path.unlink()
|
||||
removed += 1
|
||||
if removed:
|
||||
# Proton refreshes its builtins only when its config changes; forgetting the config puts
|
||||
# its own DLLs back where ours were on the next launch - this one.
|
||||
try:
|
||||
(compat / "config_info").unlink()
|
||||
except FileNotFoundError:
|
||||
@@ -627,7 +613,6 @@ def overrides_value(names):
|
||||
|
||||
|
||||
def main():
|
||||
# droiddeck-wincomponents <compatdata dir> <appid>: what a launch would do, for a shell.
|
||||
if len(sys.argv) != 3:
|
||||
print("usage: droiddeck-wincomponents <compatdata dir> <appid>", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
@@ -1,20 +1,4 @@
|
||||
#!/usr/bin/python3
|
||||
# Makes the ARM64 Proton the client already downloaded usable here, and sets it as the default tool
|
||||
# for Windows titles (CompatToolMapping "0" in config.vdf) when the user has not chosen one. Run
|
||||
# before the client starts; it rewrites config.vdf on exit.
|
||||
#
|
||||
# steam-compatibility <steam root>
|
||||
#
|
||||
# Valve ships a native aarch64 Proton (arm64ec Wine with FEX as the x86 layer) as an ordinary depot,
|
||||
# which is exactly what this runtime wants. Its toolmanifest declares require_tool_appid 4185400 -
|
||||
# Steam Linux Runtime 4 for arm64 - so Steam stacks pressure-vessel underneath it, and
|
||||
# pressure-vessel needs unprivileged user namespaces, which an Android app does not get. Steam then
|
||||
# drops the launch on the floor: no window, no log, straight back to the library.
|
||||
#
|
||||
# So the depot is re-registered here as a compatibility tool of our own: every entry symlinked so
|
||||
# nothing is copied and Steam still updates the real depot, but with a toolmanifest that leaves out
|
||||
# require_tool_appid. Proton takes its base directory from dirname(sys.argv[0]) without resolving
|
||||
# it, so it reads files/ through those symlinks and runs directly on this rootfs.
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
@@ -26,22 +10,10 @@ TOOL = "droiddeck-proton-arm64"
|
||||
TOOL_11 = "droiddeck-proton-11-arm64"
|
||||
LEGACY_TOOL = "bannerlator-proton-arm64"
|
||||
LABEL_FILE = "/etc/steam-compatibility-label"
|
||||
# The ARM64 Proton depot the client downloads for itself, as a compatibility-tool appid.
|
||||
# The session asks the client to install it on the command line the first time (steam://install),
|
||||
# so a new client has it before a Windows title is first launched. It is deliberately NOT named as
|
||||
# this tool's dependency: a dependency is composed with its own dependencies, and this depot
|
||||
# requires 4185400, the arm64 Steam Linux Runtime, whose container needs user namespaces Android
|
||||
# does not give - the launch would be wrapped in it and die before this tool ever ran.
|
||||
PROTON_ARM64_APPID = "4427310"
|
||||
LAUNCHER = "droiddeck-proton"
|
||||
LEGACY_LAUNCHER = "bannerlator-proton"
|
||||
# The extra Steam library the app mounts the installed games into (see droiddeck-steam-library).
|
||||
# installed_apps() scans it too; it lives only in the sibling script, so define it here as well.
|
||||
LIBRARY = "/mnt/droiddeck" # the card library is LIBRARY + "-sd"; internal storage is steam_root itself
|
||||
# The client lists its own "Proton Experimental (ARM64)" and "Proton 11.0 (ARM64)" in the same
|
||||
# Compatibility dropdown, and those are the two that cannot start a game here. Ours has to be
|
||||
# unmistakable at a glance, or a user picks a neighbour and gets a launch that fails silently.
|
||||
# Newest first: whichever the client has downloaded is used.
|
||||
LIBRARY = "/mnt/droiddeck"
|
||||
SOURCES = ("Proton Experimental (ARM64)", "Proton 11.0 (ARM64)")
|
||||
OWN_TOOLS = ((TOOL, SOURCES), (TOOL_11, ("Proton 11.0 (ARM64)",)))
|
||||
FEX_TOOL = "droiddeck-fex"
|
||||
@@ -53,13 +25,7 @@ FEX_DEPENDENCIES = (FEX_APPID, SNIPER_APPID)
|
||||
REQUEST_HANDOFF_SECONDS = 30
|
||||
PLAYABLE_TYPES = frozenset(("game", "demo", "application", "beta"))
|
||||
COMPAT_DIR = os.path.join(os.environ.get("HOME", "/root"), ".local", "share", "droiddeck-compat")
|
||||
# Written by us; everything else in the depot is symlinked through.
|
||||
OWN_FILES = ("toolmanifest.vdf", "compatibilitytool.vdf", LAUNCHER)
|
||||
# The client assigns a Proton to a Windows title by itself, as a per-app CompatToolMapping entry at
|
||||
# priority 250 - which outranks the "0" default, so setting that default alone changes nothing. Every
|
||||
# Proton it can pick is one this runtime cannot start: the ARM64 ones want pressure-vessel (see
|
||||
# above) and the x86_64 ones want pressure-vessel and FEX on top. Ours is the only one that runs
|
||||
# here, so every Proton mapping is repointed at it. Tools that are not Proton are left alone.
|
||||
COMPAT_TOOL_VDF = """"compatibilitytools"
|
||||
{
|
||||
"compat_tools"
|
||||
@@ -84,47 +50,25 @@ TOOL_MANIFEST_VDF = """"manifest"
|
||||
""" % LAUNCHER
|
||||
|
||||
|
||||
# Steam runs its own graphics probe through EVERY registered tool at once, ~40 s after logging in,
|
||||
# all with STEAM_COMPAT_DATA_PATH=.../compatdata/0, and those concurrent Protons can write their
|
||||
# builtin DLLs through each other's prefix links into each other's trees (seen: GE's FEX DLLs became
|
||||
# Proton Experimental's). Moving those runs to a prefix per tool was tried and crashed the Steam
|
||||
# client right after the probe started (segfault, rc 139, first ever in 25 sessions), so the client
|
||||
# relies on compatdata/0 itself. The launch-time check below is the protection instead.
|
||||
|
||||
# The Components page's choices, enforced in the one place every game launch passes: the app keeps
|
||||
# desired.tsv (tool dir, Proton build, component, file, sha256, source copy) and an unpacked copy of
|
||||
# each package in use. A file that no longer matches - whatever changed it - is put back before
|
||||
# Proton starts. Only for the Proton build the choice was made for: after a Steam update the build
|
||||
# differs and the Proton's own new files are left alone until the user chooses again.
|
||||
# A store game (GOG, Epic, Amazon) is started through the launcher .bat DroidDeck wrote beside it.
|
||||
# An Epic game needs a fresh sign-in code, which only the app can mint: droiddeck-store-launch asks
|
||||
# for it and the app writes it into the game's folder, so a launch from the client's own Play
|
||||
# button signs in just as one from the app does. A real launch only; never in the way of it.
|
||||
BL_STORE_SETUP = """
|
||||
bl_store_launch() {
|
||||
[ "${verb:-}" = waitforexitandrun ] || return 0
|
||||
# A web address the game opens (Wine's winebrowser runs xdg-open) goes to Android's browser:
|
||||
# droiddeck-open-url as xdg-open, first on the game's PATH, with the session channel left in a
|
||||
# file in case Wine does not pass BL_LAUNCH_DIR on. (The prefix also names it as Wine's browser.)
|
||||
if [ -x /usr/local/bin/droiddeck-open-url ]; then
|
||||
mkdir -p /tmp/droiddeck-browser
|
||||
ln -sfn /usr/local/bin/droiddeck-open-url /tmp/droiddeck-browser/xdg-open
|
||||
[ -n "${BL_LAUNCH_DIR:-}" ] && printf '%s\n' "$BL_LAUNCH_DIR" > /tmp/droiddeck-browser/launch-dir
|
||||
[ -n "${BL_LAUNCH_DIR:-}" ] && printf '%s
|
||||
' "$BL_LAUNCH_DIR" > /tmp/droiddeck-browser/launch-dir
|
||||
PATH="/tmp/droiddeck-browser:$PATH"; export PATH
|
||||
fi
|
||||
# BL_DEBUG_BROWSER=1 (droiddeck-env): Wine traces how the game opens a web address.
|
||||
if [ "${BL_DEBUG_BROWSER:-}" = 1 ]; then
|
||||
WINEDEBUG="${WINEDEBUG:+$WINEDEBUG,}+shell,+winebrowser"; export WINEDEBUG
|
||||
fi
|
||||
[ -x /usr/local/bin/droiddeck-store-launch ] || return 0
|
||||
/usr/local/bin/droiddeck-store-launch "$@"
|
||||
# 10: a store game with cloud saves - the launch waits for Proton and uploads after (bl_run).
|
||||
[ $? -eq 10 ] && BL_STORE_EXIT=1
|
||||
return 0
|
||||
}
|
||||
|
||||
# Runs Proton: exec'd as always, except for a store game with cloud saves, where the wrapper stays
|
||||
# to tell the app the game has exited so it can upload what changed.
|
||||
bl_run() {
|
||||
if [ -n "${BL_STORE_EXIT:-}" ]; then
|
||||
"$@"
|
||||
@@ -141,29 +85,57 @@ bl_components() {
|
||||
base=$1
|
||||
cm_dir="${HOME:-/root}/.local/share/droiddeck-components"
|
||||
cm_list="$cm_dir/desired.tsv"
|
||||
# A real game launch only: the verb the client starts a game with and the game's own prefix. Every
|
||||
# other run - above all the client's own probes right after login, which all share compatdata/0 -
|
||||
# is left exactly as it was: with this check running through them, the client segfaulted (rc 139)
|
||||
# within seconds of starting its probes, four sessions out of four. The prefix decides rather than
|
||||
# the app id because a non-Steam shortcut launches with app id 0 but still gets a prefix of its own.
|
||||
[ "${verb:-}" = waitforexitandrun ] || return 0
|
||||
case "${STEAM_COMPAT_DATA_PATH:-}" in ''|*/compatdata/0|*/compatdata/0/|*/compatdata/0-*) return 0 ;; esac
|
||||
[ -f "$cm_list" ] || return 0
|
||||
cm_app=${STEAM_COMPAT_DATA_PATH%/}
|
||||
cm_app=${STEAM_COMPAT_DATA_PATH}
|
||||
while [[ "$cm_app" == */ ]]; do cm_app=${cm_app%/}; done
|
||||
cm_app=${cm_app##*/}
|
||||
if [[ "$cm_app" =~ ^(-?)([0-9]+)$ ]]; then
|
||||
cm_sign=${BASH_REMATCH[1]}
|
||||
cm_digits=${BASH_REMATCH[2]}
|
||||
while [[ ${#cm_digits} -gt 1 && "$cm_digits" == 0* ]]; do cm_digits=${cm_digits#0}; done
|
||||
if [[ ${#cm_digits} -le 10 ]]; then
|
||||
cm_app=$((10#$cm_digits))
|
||||
[ "$cm_sign" = "-" ] && cm_app=$((-cm_app))
|
||||
if (( cm_app >= -2147483648 && cm_app <= 4294967295 && cm_app != 0 )); then
|
||||
(( cm_app < 0 )) && cm_app=$((cm_app + 4294967296))
|
||||
else
|
||||
cm_app=""
|
||||
fi
|
||||
else
|
||||
cm_app=""
|
||||
fi
|
||||
else
|
||||
cm_app=""
|
||||
fi
|
||||
if [ -z "$cm_app" ]; then
|
||||
echo "droiddeck-proton: components: invalid game prefix, left as it is" >&2
|
||||
return 0
|
||||
fi
|
||||
cm_tool=${base##*/}
|
||||
cm_build=$(awk 'NR == 1 { print $2 }' "$base/version" 2>/dev/null)
|
||||
cm_fixed=0
|
||||
cm_checked=0
|
||||
# One sha256sum for every file: each program started here pays a dozen traced library lookups
|
||||
# under the game's search path before it does anything.
|
||||
cm_selected=$(awk -F '\\t' -v app="$cm_app" -v tool="$cm_tool" -v build="$cm_build" '
|
||||
$2 == tool && $3 == build {
|
||||
rows[++count] = $0
|
||||
scopes[count] = $1
|
||||
comps[count] = $4
|
||||
if ($1 == app) specific[$4] = 1
|
||||
}
|
||||
END {
|
||||
for (i = 1; i <= count; i++)
|
||||
if (scopes[i] == app || (scopes[i] == "*" && !specific[comps[i]])) print rows[i]
|
||||
}
|
||||
' "$cm_list")
|
||||
local cm_rows=() cm_files=() row h p
|
||||
local -A cm_sums=()
|
||||
while IFS=$'\\t' read -r t want comp rel sum src; do
|
||||
[ "$t" = "$cm_tool" ] && [ "$want" = "$cm_build" ] || continue
|
||||
while IFS=$'\\t' read -r scope t want comp rel sum src; do
|
||||
[ -n "$scope" ] || continue
|
||||
cm_rows+=("$comp"$'\\t'"$rel"$'\\t'"$sum"$'\\t'"$src")
|
||||
[ -f "$base/$rel" ] && cm_files+=("$base/$rel")
|
||||
done < "$cm_list"
|
||||
[ "$src" != "-" ] && [ -f "$base/$rel" ] && cm_files+=("$base/$rel")
|
||||
done <<< "$cm_selected"
|
||||
if [ ${#cm_files[@]} -gt 0 ]; then
|
||||
while read -r h p; do cm_sums["$p"]=$h; done < <(sha256sum -- "${cm_files[@]}" 2>/dev/null)
|
||||
fi
|
||||
@@ -171,6 +143,10 @@ bl_components() {
|
||||
IFS=$'\\t' read -r comp rel sum src <<< "$row"
|
||||
cm_checked=$((cm_checked + 1))
|
||||
f="$base/$rel"
|
||||
if [ "$src" = "-" ]; then
|
||||
if [ -e "$f" ]; then rm -f "$f" && cm_fixed=$((cm_fixed + 1)); fi
|
||||
continue
|
||||
fi
|
||||
if [ -f "$f" ] && [ "${cm_sums[$f]:-}" = "$sum" ]; then continue; fi
|
||||
if [ ! -f "$src" ]; then
|
||||
echo "droiddeck-proton: components: $comp source missing ($src), left as it is" >&2
|
||||
@@ -189,36 +165,17 @@ bl_components() {
|
||||
}
|
||||
"""
|
||||
|
||||
# Resolves the depot at launch time, so the tool can be registered before the depot exists and
|
||||
# survives the client updating or replacing it. Proton takes its base directory from
|
||||
# dirname(sys.argv[0]) without resolving it, so it is run from the depot itself.
|
||||
# Cores for a game the client launches, kept separate from the client's own. One mask suits the
|
||||
# client's menus and another suits a game, and they are wanted at the same time - so the game's is
|
||||
# applied here, in the launch path every game goes through, rather than to the session as a whole.
|
||||
BL_GAME_CPUS_SETUP = """
|
||||
bl_game_cpus() {
|
||||
[ -n "${BL_GAME_CPUS:-}" ] || return 0
|
||||
command -v taskset >/dev/null 2>&1 || return 0
|
||||
# exec'd through taskset rather than set afterwards: a mask applied to a pid races the process
|
||||
# into spawning its own threads, and this way every thread inherits it from the first instruction.
|
||||
BL_TASKSET="taskset -c $BL_GAME_CPUS"
|
||||
echo "droiddeck-proton: game cores $BL_GAME_CPUS" >&2
|
||||
}
|
||||
"""
|
||||
|
||||
# Quake III engine games (id Tech 3) set their own resolution and switch the display to it. Under
|
||||
# gamescope with the ARM64 Proton that switch is refused ("calling CDS: failed, bad mode") and the
|
||||
# game never gets OpenGL; left at its own size in a window, it draws small in a corner. So these
|
||||
# titles are told to stay windowed at the session's own size - unless the user's launch options
|
||||
# already say something about the video mode, which are left as they are.
|
||||
# The session puts the client's own libraries (steamrtarm64, its panorama/) ahead of everything for
|
||||
# the client, and a game inherits that: Wine then resolved gnutls, SDL, FFmpeg and the rest against
|
||||
# the client's private copies instead of the rootfs it was built for. Inside Steam's runtime
|
||||
# container that path never reaches Proton either. (WinNative's winnative-proton-launch.)
|
||||
BL_LIBPATH_SETUP = """
|
||||
bl_libpath() {
|
||||
# A Proton built to prefer PipeWire (CachyOS's among the adopted ones) hung its audio thread
|
||||
# here, where only PulseAudio answers. (WinNative, winnative-proton-launch.)
|
||||
export PROTON_USE_PIPEWIRE=${PROTON_USE_PIPEWIRE:-0}
|
||||
[ -n "${LD_LIBRARY_PATH:-}" ] || return 0
|
||||
local kept= dir old_ifs=$IFS
|
||||
@@ -238,7 +195,6 @@ BL_IDTECH3_SETUP = """
|
||||
bl_idtech3() {
|
||||
BL_EXTRA_ARGS=()
|
||||
case "${SteamAppId:-${STEAM_COMPAT_APP_ID:-}}" in
|
||||
# Quake III Arena, Quake III: Team Arena, Return to Castle Wolfenstein, Jedi Academy.
|
||||
2200|2350|9010|6020) ;;
|
||||
*) return 0 ;;
|
||||
esac
|
||||
@@ -266,10 +222,6 @@ bl_directaudio() {
|
||||
echo "droiddeck-proton: DirectAudio left off - it is built for Wine 11 and this Proton is '${version:-unknown}'. Pairing them would be silent rather than broken, so it is not worth guessing." >&2
|
||||
return 0
|
||||
fi
|
||||
# Two builds of the driver ship, one per Wine audio interface, and both Wines call themselves
|
||||
# 11.0: the private mmdevapi table is not versioned, and the wrong set plays silence, not an
|
||||
# error. Proton's own winepulse.so tells them apart - it imports PsCreateSystemThread only on
|
||||
# the system-thread table (Proton-CachyOS), never on the classic one (Valve, GE-Proton).
|
||||
winepulse="$base/files/lib/wine/aarch64-unix/winepulse.so"
|
||||
if [ ! -f "$winepulse" ]; then
|
||||
echo "droiddeck-proton: DirectAudio left off - no winepulse.so to read this Proton's audio interface from" >&2
|
||||
@@ -281,20 +233,10 @@ bl_directaudio() {
|
||||
echo "droiddeck-proton: DirectAudio left off - no driver set for the $set interface is staged" >&2
|
||||
return 0
|
||||
fi
|
||||
# Wine appends the per-architecture subdirectory to each entry, so the directory holding
|
||||
# aarch64-unix/ and aarch64-windows/ is what goes here.
|
||||
WINEDLLPATH="$da/lib/wine${WINEDLLPATH:+:$WINEDLLPATH}"
|
||||
export WINEDLLPATH
|
||||
# Proton-CachyOS's launcher sets WINE_AUDIO_DRIVER=pulse,alsa (setdefault, so an existing value
|
||||
# wins), and its mmdevapi reads that variable BEFORE the registry - so the selection below was
|
||||
# being overridden to pulse on every CachyOS game. Valve's and GE's mmdevapi do not read the
|
||||
# variable at all and take the registry, which is why both are done. A value the user set for
|
||||
# the game still wins: the per-game environment is applied after this.
|
||||
WINE_AUDIO_DRIVER="directaudio,pulse"
|
||||
export WINE_AUDIO_DRIVER
|
||||
# mmdevapi only tries the drivers named in the registry; its built-in list is pulse, alsa, oss and
|
||||
# coreaudio and knows nothing about this one. The key is appended to the prefix's user.reg rather
|
||||
# than written with `wine reg`, which would start a wineserver here just to set one value.
|
||||
pfx="${STEAM_COMPAT_DATA_PATH:-}/pfx"
|
||||
reg="$pfx/user.reg"
|
||||
if [ -f "$reg" ]; then
|
||||
@@ -311,46 +253,21 @@ bl_directaudio() {
|
||||
elif ! BL_KEY="$key" awk 'index($0, "[") == 1 { inside = index($0, ENVIRON["BL_KEY"] " ") == 1 } inside && index($0, "\\"Audio\\"=") == 1 { last = $0 } END { exit last != "\\"Audio\\"=\\"directaudio,pulse\\"" }' "$reg" 2>/dev/null; then
|
||||
printf '\\n%s %s\\n"Audio"="directaudio,pulse"\\n' "$key" "$(date +%s)" >> "$reg"
|
||||
echo "droiddeck-proton: DirectAudio selected in the prefix" >&2
|
||||
# Steam runs this tool several times per launch (getcompatpath, run, waitforexitandrun); a
|
||||
# wineserver from an earlier verb that still holds the registry saves its own copy on exit
|
||||
# and drops this line. Said out loud so a game that stays on pulse once is explained; it
|
||||
# takes on the next launch. (Writing through the live server with a bare `wine reg add` was
|
||||
# tried and withdrawn: a second Wine invocation inside Steam's launch sequence is not safe.)
|
||||
srv="${BL_WINE_SERVER_BASE:-/tmp/.wine-$(id -u)}/server-$(printf '%x-%x' $(stat -c '%d %i' "$pfx" 2>/dev/null || echo 0 0))/socket"
|
||||
if [ -S "$srv" ]; then
|
||||
echo "droiddeck-proton: a wineserver is already running for this prefix; DirectAudio may only engage on the next launch" >&2
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# A prefix that does not exist yet is created by Proton moments from now, after this runs, so
|
||||
# the value lands on the NEXT launch of that game. Said out loud so a first launch on Proton's
|
||||
# own audio does not look like a fault. (Having Proton create the prefix from here first was
|
||||
# tried and withdrawn: a second Proton run inside Steam's launch sequence got the launch
|
||||
# aborted - Steam games bounced back to their page with a half-made prefix.)
|
||||
echo "droiddeck-proton: no prefix yet - DirectAudio takes effect the next time this game starts" >&2
|
||||
fi
|
||||
echo "droiddeck-proton: DirectAudio ready (Wine $major, $set)" >&2
|
||||
}
|
||||
"""
|
||||
|
||||
# Resolves the depot at launch time, so the tool can be registered before the depot exists and
|
||||
# survives the client updating or replacing it. Proton takes its base directory from
|
||||
# dirname(sys.argv[0]) without resolving it, so it is run from the depot itself.
|
||||
LAUNCHER_SH = """#!/bin/bash
|
||||
# DroidDeck's Proton ARM64: runs the ARM64 Proton the Steam client downloaded, without the
|
||||
# Steam Linux Runtime container its own manifest asks for (no user namespaces on Android).
|
||||
verb=$1; shift
|
||||
steam_root=${STEAM_COMPAT_CLIENT_INSTALL_PATH:-${XDG_DATA_HOME:-$HOME/.local/share}/Steam}
|
||||
# Steam's overlay is preloaded into every game Valve launches, and used to be dropped here: it was
|
||||
# landing in front of open() and read() on /dev/input, letting Wine open the session's pad and
|
||||
# answering every read of it with nothing - a controller that never reports, and Wine's HID thread
|
||||
# spinning a core on it.
|
||||
#
|
||||
# Removing it was the wrong cure for an ordering problem. glibc processes LD_PRELOAD BEFORE
|
||||
# /etc/ld.so.preload, and the interposer lives in the latter, so the overlay was simply ahead of it.
|
||||
# Naming the interposer first in LD_PRELOAD puts it back in front and the overlay loads as Valve
|
||||
# intends. That matters beyond the overlay itself: every deviation from the launch Valve ships is a
|
||||
# difference this runtime would otherwise have to justify.
|
||||
for fake in /usr/local/lib/libfakeinput.so /usr/local/lib/libblsession.so; do
|
||||
if [ -f "$fake" ]; then
|
||||
case ":${LD_PRELOAD:-}:" in
|
||||
@@ -359,9 +276,6 @@ for fake in /usr/local/lib/libfakeinput.so /usr/local/lib/libblsession.so; do
|
||||
esac
|
||||
fi
|
||||
done
|
||||
# ld.so looks every library up along the game's search path (its own directory, Steam's runtime
|
||||
# and video directories, Proton's), and under proot each miss is a round trip to the tracer. With
|
||||
# the fast path, the audit module skips the misses it can prove (tools/proot/fastpath/audit.c).
|
||||
audit=/usr/local/lib/libblaudit.so
|
||||
if [ -n "${PROOT_FP_KEY:-}" ] && [ -f "$audit" ]; then
|
||||
case ":${LD_AUDIT:-}:" in
|
||||
@@ -369,8 +283,6 @@ if [ -n "${PROOT_FP_KEY:-}" ] && [ -f "$audit" ]; then
|
||||
*) LD_AUDIT="$audit${LD_AUDIT:+:$LD_AUDIT}"; export LD_AUDIT ;;
|
||||
esac
|
||||
fi
|
||||
# The depot this tool is named after, newest across the libraries that hold it; the others in the
|
||||
# list stand in only when it is missing.
|
||||
depot=
|
||||
libraries=$(printf '%%s\\n' "$steam_root" /mnt/droiddeck-sd; sed -n 's/^[[:space:]]*"path"[[:space:]]*"\\(.*\\)"[[:space:]]*$/\\1/p' "$steam_root/steamapps/libraryfolders.vdf" 2>/dev/null)
|
||||
for name in %s; do
|
||||
@@ -394,6 +306,7 @@ if [ -n "$depot" ]; then
|
||||
bl_game_cpus
|
||||
bl_idtech3 "$@"
|
||||
bl_libpath
|
||||
BL_STORE_PROTON="$depot/proton"; export BL_STORE_PROTON
|
||||
bl_store_launch "$@"
|
||||
BL_STORE_ARGS=("$@")
|
||||
bl_run ${BL_TASKSET:-} /usr/local/bin/droiddeck-game-env "$depot/proton" "$verb" "$@" "${BL_EXTRA_ARGS[@]}"
|
||||
@@ -405,9 +318,6 @@ LAUNCHER_TEMPLATE = LAUNCHER_SH
|
||||
|
||||
|
||||
def launcher_sh(sources=SOURCES):
|
||||
# Spliced in after the formatting, never through it: the function body contains ${major%%.*}
|
||||
# and a % format would eat that into a single %, leaving a shell expansion that silently does
|
||||
# something else.
|
||||
return (LAUNCHER_TEMPLATE % " ".join('"%s"' % n for n in sources)).replace(
|
||||
"verb=$1; shift", "verb=$1; shift\n" + BL_DIRECTAUDIO_SETUP + BL_GAME_CPUS_SETUP + BL_IDTECH3_SETUP
|
||||
+ BL_COMPONENTS_SETUP + BL_LIBPATH_SETUP + BL_STORE_SETUP, 1)
|
||||
@@ -415,10 +325,6 @@ def launcher_sh(sources=SOURCES):
|
||||
|
||||
LAUNCHER_SH = launcher_sh()
|
||||
|
||||
# A third-party Proton dropped into compatibilitytools.d - GE-Proton, proton-cachyos, anything of
|
||||
# that shape - is adopted rather than used as shipped, for the same two reasons Valve's ARM64 depot
|
||||
# is: its manifest declares require_tool_appid, and the client's overlay library has to come out of
|
||||
# LD_PRELOAD. Its own entry point is left untouched and called through this wrapper.
|
||||
EXTRA_WRAPPER = "droiddeck-proton-wrap"
|
||||
LEGACY_EXTRA_WRAPPER = "bannerlator-proton-wrap"
|
||||
ORIGINAL_SUFFIX = ".droiddeck-orig"
|
||||
@@ -431,16 +337,9 @@ EXTRA_MANIFEST_VDF = """"manifest"
|
||||
"compatmanager_layer_name" "proton"
|
||||
}
|
||||
""" % EXTRA_WRAPPER
|
||||
# %s is the tool's own entry point, read out of the manifest it shipped with.
|
||||
EXTRA_WRAPPER_SH = """#!/bin/bash
|
||||
# DroidDeck: runs a Proton installed into compatibilitytools.d without the Steam Linux Runtime
|
||||
# container its own manifest asks for - pressure-vessel needs unprivileged user namespaces, which
|
||||
# an Android app does not get, and the launch dies before Proton is reached.
|
||||
verb=$1; shift
|
||||
here=$(dirname "$0")
|
||||
# See droiddeck-proton: the interposer goes first in LD_PRELOAD rather than the overlay being
|
||||
# removed, because glibc reads LD_PRELOAD before /etc/ld.so.preload and the overlay was simply
|
||||
# ahead of it on /dev/input.
|
||||
for fake in /usr/local/lib/libfakeinput.so /usr/local/lib/libblsession.so; do
|
||||
if [ -f "$fake" ]; then
|
||||
case ":${LD_PRELOAD:-}:" in
|
||||
@@ -449,7 +348,6 @@ for fake in /usr/local/lib/libfakeinput.so /usr/local/lib/libblsession.so; do
|
||||
esac
|
||||
fi
|
||||
done
|
||||
# See droiddeck-proton: library lookups that cannot succeed are skipped with the fast path.
|
||||
audit=/usr/local/lib/libblaudit.so
|
||||
if [ -n "${PROOT_FP_KEY:-}" ] && [ -f "$audit" ]; then
|
||||
case ":${LD_AUDIT:-}:" in
|
||||
@@ -462,11 +360,10 @@ bl_directaudio "$here"
|
||||
bl_game_cpus
|
||||
bl_idtech3 "$@"
|
||||
bl_libpath
|
||||
BL_STORE_PROTON="$here/%s"; export BL_STORE_PROTON
|
||||
bl_store_launch "$@"
|
||||
BL_STORE_ARGS=("$@")
|
||||
# Proton takes its base directory from dirname(sys.argv[0]) without resolving it, so it has to be
|
||||
# started from its own tree.
|
||||
bl_run ${BL_TASKSET:-} /usr/local/bin/droiddeck-game-env "$here/%s" "$verb" "$@" "${BL_EXTRA_ARGS[@]}"
|
||||
bl_run ${BL_TASKSET:-} /usr/local/bin/droiddeck-game-env "$BL_STORE_PROTON" "$verb" "$@" "${BL_EXTRA_ARGS[@]}"
|
||||
"""
|
||||
EXTRA_COMPAT_TOOL_VDF = """"compatibilitytools"
|
||||
{
|
||||
@@ -664,8 +561,6 @@ def adopt_extras(tools):
|
||||
manifest = os.path.join(tool_dir, "toolmanifest.vdf")
|
||||
if not os.path.isdir(tool_dir) or not os.path.isfile(manifest):
|
||||
continue
|
||||
# The shipped manifest is kept, once, and stays the source of the entry point: re-running
|
||||
# must not read back our own rewritten commandline and wrap the wrapper.
|
||||
original = manifest + ORIGINAL_SUFFIX
|
||||
legacy = manifest + LEGACY_ORIGINAL_SUFFIX
|
||||
if not os.path.isfile(original) and os.path.isfile(legacy):
|
||||
@@ -688,8 +583,6 @@ def adopt_extras(tools):
|
||||
name = first_key(compat_vdf, ["compatibilitytools", "compat_tools"]) or entry
|
||||
wrapper = os.path.join(tool_dir, EXTRA_WRAPPER)
|
||||
try:
|
||||
# Formatted first, spliced second: the function carries a printf %s and a
|
||||
# ${major%%.*} of its own, and putting it through the format would eat both.
|
||||
body = (EXTRA_WRAPPER_SH % entry_point).replace(
|
||||
'here=$(dirname "$0")',
|
||||
'here=$(dirname "$0")\n' + BL_DIRECTAUDIO_SETUP + BL_GAME_CPUS_SETUP + BL_IDTECH3_SETUP
|
||||
@@ -707,19 +600,17 @@ def adopt_extras(tools):
|
||||
return adopted
|
||||
|
||||
|
||||
# Steam's own tools and runtimes live in steamapps beside the games; they are not titles and must
|
||||
# not be mapped to a compatibility tool.
|
||||
NOT_GAMES = frozenset((
|
||||
"228980", # Steamworks Common Redistributables
|
||||
"1070560", # Steam Linux Runtime 1.0 (scout)
|
||||
"1391110", # Steam Linux Runtime 2.0 (soldier)
|
||||
"1628350", # Steam Linux Runtime 3.0 (sniper)
|
||||
"1493710", # Proton Experimental
|
||||
"3127680", # FEX
|
||||
"4183110", # Steam Linux Runtime 4.0
|
||||
"4185400", # Steam Linux Runtime 4.0 - Arm64
|
||||
"4427310", # Proton Experimental (ARM64)
|
||||
"4628740", # Proton 11.0 (ARM64)
|
||||
"228980",
|
||||
"1070560",
|
||||
"1391110",
|
||||
"1628350",
|
||||
"1493710",
|
||||
"3127680",
|
||||
"4183110",
|
||||
"4185400",
|
||||
"4427310",
|
||||
"4628740",
|
||||
))
|
||||
|
||||
|
||||
@@ -985,16 +876,30 @@ def app_order(app):
|
||||
return (len(app), app)
|
||||
|
||||
|
||||
def plan_mapping(current, installed, runnable, default, auto, native=None, picks=()):
|
||||
DEFERRED_GAME_TOOL = object()
|
||||
|
||||
|
||||
def plan_mapping(current, installed, runnable, default, auto, native=None, picks=(), overrides=None):
|
||||
runnable = {n.lower() for n in runnable}
|
||||
installed = set(installed)
|
||||
picks = set(picks)
|
||||
native = native or {}
|
||||
overrides = overrides or {}
|
||||
changes, kept = {}, {}
|
||||
if current.get("0", "") != default:
|
||||
changes["0"] = default
|
||||
for app in sorted((set(current) | installed | picks | set(auto)) - {"0"}, key=app_order):
|
||||
for app in sorted((set(current) | installed | picks | set(auto) | set(overrides)) - {"0"}, key=app_order):
|
||||
name = current.get(app, "")
|
||||
if app in overrides:
|
||||
target = overrides[app]
|
||||
if target is DEFERRED_GAME_TOOL:
|
||||
continue
|
||||
target = target or default
|
||||
if name != target:
|
||||
changes[app] = target
|
||||
if overrides[app] is None:
|
||||
kept[app] = target
|
||||
continue
|
||||
mine = auto.get(app)
|
||||
target = native.get(app, default)
|
||||
stale = unrunnable(name, runnable) or (app in native and linux_runtime_tool(name))
|
||||
@@ -1053,6 +958,34 @@ def requested_tool(request, catalog):
|
||||
return None
|
||||
|
||||
|
||||
def game_requests(directory=None):
|
||||
value = read_json(state_path("games.json", directory))
|
||||
if value.get("version") != 1 or not isinstance(value.get("games"), dict):
|
||||
return {}
|
||||
return value["games"]
|
||||
|
||||
|
||||
def requested_games(requests, catalog, runnable=None):
|
||||
"""App id -> requested tool, None for inherit, or DEFERRED_GAME_TOOL while unavailable."""
|
||||
runnable = None if runnable is None else set(runnable)
|
||||
resolved = {}
|
||||
for app, request in requests.items():
|
||||
if not isinstance(app, str) or not re.fullmatch(r"[1-9][0-9]*", app) or int(app) > 0xFFFFFFFF:
|
||||
continue
|
||||
if request is None:
|
||||
resolved[app] = None
|
||||
continue
|
||||
if (not isinstance(request, dict) or not isinstance(request.get("dir"), str) or
|
||||
not request["dir"] or not isinstance(request.get("valve"), bool)):
|
||||
continue
|
||||
tool = requested_tool(request, catalog)
|
||||
if tool is None or runnable is not None and tool not in runnable:
|
||||
resolved[app] = DEFERRED_GAME_TOOL
|
||||
else:
|
||||
resolved[app] = tool
|
||||
return resolved
|
||||
|
||||
|
||||
def now_ms():
|
||||
import time
|
||||
return int(time.time() * 1000)
|
||||
@@ -1174,7 +1107,9 @@ def register_default(config_path, apps=(), protect=(), default=None, catalog=Non
|
||||
else:
|
||||
default = state.get("default") if state.get("default") in names else TOOL
|
||||
steam_root = os.path.dirname(os.path.dirname(os.path.abspath(config_path)))
|
||||
changes, auto = plan_mapping(current, apps, names, default, followers(state, current), native_targets(steam_root, apps), picks)
|
||||
overrides = requested_games(game_requests(directory), catalog)
|
||||
changes, auto = plan_mapping(
|
||||
current, apps, names, default, followers(state, current), native_targets(steam_root, apps), picks, overrides)
|
||||
for app, tool in changes.items():
|
||||
set_mapping(tokens, mapping, app, tool)
|
||||
text = serialize(tokens)
|
||||
@@ -1212,8 +1147,6 @@ def build_tool(tool_dir, depot, sources=SOURCES, name=TOOL):
|
||||
if os.path.islink(tool_dir):
|
||||
os.unlink(tool_dir)
|
||||
elif os.path.isdir(tool_dir) and set(os.listdir(tool_dir)) - set(OWN_FILES):
|
||||
# Earlier versions mirrored the depot in here as symlinks; start clean. A directory holding
|
||||
# only our own files is kept, and each file rewritten only when it changed.
|
||||
shutil.rmtree(tool_dir)
|
||||
os.makedirs(tool_dir, exist_ok=True)
|
||||
write_changed(os.path.join(tool_dir, "toolmanifest.vdf"), TOOL_MANIFEST_VDF)
|
||||
|
||||
@@ -1,11 +1,3 @@
|
||||
/*
|
||||
* binfmt_misc for the desktop, which proot does not have: an exec of an x86 Linux program, a Windows
|
||||
* program, or a program or script on noexec shared storage goes to droiddeck-open --exec, which runs
|
||||
* it under FEX, Proton or its interpreter. x86 and Windows programs are caught before the exec: proot
|
||||
* loads a static x86 program as a native one, which dies on its first instruction, and execvp runs a
|
||||
* Windows program as a shell script. A program on noexec storage also passes access(X_OK), which KIO
|
||||
* and Qt ask before they start one. Only in the desktop session.
|
||||
*/
|
||||
#define _GNU_SOURCE
|
||||
#include <dlfcn.h>
|
||||
#include <elf.h>
|
||||
@@ -27,7 +19,6 @@
|
||||
typedef int (*spawn_fn)(pid_t *, const char *, const posix_spawn_file_actions_t *, const posix_spawnattr_t *,
|
||||
char *const[], char *const[]);
|
||||
|
||||
/* BINFMT_TEST: tools/tests builds it for the host, whose own x86 programs stand in for foreign ones. */
|
||||
#if defined(__aarch64__) || defined(BINFMT_TEST)
|
||||
|
||||
static int desktop(void) {
|
||||
@@ -35,7 +26,6 @@ static int desktop(void) {
|
||||
return value && value[0] == '1' && value[1] == 0;
|
||||
}
|
||||
|
||||
/* 1: x86 program or noexec storage, 2: Windows program, 3: script; 0 for anything else. */
|
||||
static int foreign(const char *path, int error) {
|
||||
if (!path || !strcmp(path, BINFMT_HANDLER)) return 0;
|
||||
int fd = open(path, O_RDONLY | O_CLOEXEC);
|
||||
@@ -52,7 +42,6 @@ static int foreign(const char *path, int error) {
|
||||
} else if (n >= 2 && head[0] == '#' && head[1] == '!' && error == EACCES) {
|
||||
kind = 3;
|
||||
}
|
||||
/* What the kernel refuses for its permissions stays refused; noexec storage has no execute bits to give. */
|
||||
struct statvfs vfs;
|
||||
int allowed = kind && (((st.st_mode & 0111) && error != EACCES) || (fstatvfs(fd, &vfs) == 0 && (vfs.f_flag & ST_NOEXEC)));
|
||||
close(fd);
|
||||
@@ -63,7 +52,6 @@ static int wanted(const char *path, int error) {
|
||||
return (error == ENOEXEC || error == ENOENT || error == EACCES) && desktop() && foreign(path, error);
|
||||
}
|
||||
|
||||
/* The program on PATH as execvp would find it, into [out]. */
|
||||
static int lookup(const char *file, char *out, size_t size) {
|
||||
if (!file || !*file) return 0;
|
||||
if (strchr(file, '/')) return snprintf(out, size, "%s", file) < (int)size;
|
||||
@@ -111,19 +99,16 @@ static int spawn_handler(pid_t *pid, const char *path, const posix_spawn_file_ac
|
||||
return real(pid, BINFMT_HANDLER, fa, attr, args, envp);
|
||||
}
|
||||
|
||||
/* Before an exec of [path]: an x86 or Windows program goes to the handler instead. */
|
||||
__attribute__((visibility("hidden"))) void bl_binfmt_before(const char *path, char *const argv[], char *const envp[]) {
|
||||
if (desktop() && foreign(path, ENOEXEC)) hand_off(path, argv, envp);
|
||||
}
|
||||
|
||||
/* After a failed exec of [path]: the handler takes it over, or the exec's own error stands. */
|
||||
__attribute__((visibility("hidden"))) int bl_binfmt_retry(const char *path, char *const argv[], char *const envp[], int error) {
|
||||
if (wanted(path, error)) hand_off(path, argv, envp);
|
||||
errno = error;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* The same around execvp, for the program it finds on PATH. */
|
||||
__attribute__((visibility("hidden"))) void bl_binfmt_before_search(const char *file, char *const argv[], char *const envp[]) {
|
||||
char path[PATH_MAX];
|
||||
if (desktop() && lookup(file, path, sizeof path)) bl_binfmt_before(path, argv, envp);
|
||||
@@ -136,7 +121,6 @@ __attribute__((visibility("hidden"))) int bl_binfmt_after_search(const char *fil
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* After access(X_OK) of [path] was refused (pathcache.c): a program on noexec storage runs all the same. */
|
||||
__attribute__((visibility("hidden"))) int bl_binfmt_runnable(const char *path, int mode) {
|
||||
if (mode != X_OK || !desktop()) return 0;
|
||||
int runs = foreign(path, EACCES) != 0;
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
/*
|
||||
* The Steam client lists a whole content directory about ten times per file it creates, moves or
|
||||
* deletes, to match names case-insensitively. On Android's FUSE storage that made reserving space
|
||||
* quadratic. Listings under steamapps/ on FUSE are kept for at most DIR_TTL_NS and dropped on any
|
||||
* inotify event the client's own patched changes don't account for; directory timestamps alone
|
||||
* can't be trusted, as NTFS volumes report whole seconds. BL_NO_DIR_CACHE=1 turns it off.
|
||||
*/
|
||||
#define _GNU_SOURCE
|
||||
#include <dirent.h>
|
||||
#include <dlfcn.h>
|
||||
@@ -32,7 +25,6 @@
|
||||
#define FUSE_MAGIC 0x65735546
|
||||
#define WATCHED (IN_CREATE | IN_DELETE | IN_MOVED_FROM | IN_MOVED_TO | IN_DELETE_SELF | IN_MOVE_SELF | IN_ONLYDIR)
|
||||
|
||||
/* The client is 64-bit; 32-bit builds only pass creates through. */
|
||||
#if __SIZEOF_POINTER__ == 8
|
||||
|
||||
_Static_assert(sizeof(struct dirent) == sizeof(struct dirent64), "dirent layouts differ");
|
||||
@@ -88,7 +80,6 @@ static long long now_ns(void) {
|
||||
return (long long)t.tv_sec * 1000000000LL + t.tv_nsec;
|
||||
}
|
||||
|
||||
/* A child shares the parent's inotify queue, so it stops keeping listings. */
|
||||
static void after_fork(void) {
|
||||
pthread_mutex_init(&lock, NULL);
|
||||
pthread_mutex_init(&oplock, NULL);
|
||||
@@ -162,7 +153,6 @@ static void unref(struct listing *l) {
|
||||
if (--l->refs == 0 && l->detached) destroy(l);
|
||||
}
|
||||
|
||||
/* The rest is called with lock held. */
|
||||
|
||||
static void release(int wd) {
|
||||
if (wd < 0 || notify < 0) return;
|
||||
@@ -179,7 +169,6 @@ static void detach(struct listing *l) {
|
||||
if (l->refs == 0) destroy(l);
|
||||
}
|
||||
|
||||
/* Takes the listing out of the table; freed now or when its last reader closes. */
|
||||
static void drop(int slot) {
|
||||
struct listing *l = table[slot];
|
||||
int wd = l->wd;
|
||||
@@ -195,7 +184,6 @@ static void changed(int wd) {
|
||||
if (handles[i] && (handles[i]->wd == wd || wd < 0)) __atomic_store_n(&handles[i]->dirty, 1, __ATOMIC_RELAXED);
|
||||
}
|
||||
|
||||
/* Applies queued events; the expected ones are the client's own changes, already patched in. */
|
||||
static void pump(struct expect *x, int nx) {
|
||||
char buf[4096] __attribute__((aligned(__alignof__(struct inotify_event))));
|
||||
if (notify < 0 || forked) return;
|
||||
@@ -302,7 +290,6 @@ static DIR *wrap(struct handle *h) {
|
||||
|
||||
#define RECLEN(namelen) ((offsetof(struct dirent64, d_name) + (namelen) + 1 + 7) & ~(size_t)7)
|
||||
|
||||
/* The listing as packed dirent64 records, built once per version. */
|
||||
static int records(struct listing *l) {
|
||||
if (l->recs) return 0;
|
||||
size_t len = 0;
|
||||
@@ -326,7 +313,6 @@ static int records(struct listing *l) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Lock-free from here on unless noted: a stream is only ever used by one thread at a time. */
|
||||
|
||||
static struct handle *lookup(DIR *d) {
|
||||
return registered(d) >= 0 ? (struct handle *)d : NULL;
|
||||
@@ -356,7 +342,6 @@ REAL(symlink);
|
||||
REAL(readdir64_r);
|
||||
REAL(readdir_r);
|
||||
|
||||
/* Resolved before the client starts threads; the calls below only fill gaps for earlier callers. */
|
||||
__attribute__((constructor)) static void resolve(void) {
|
||||
NEXT(opendir);
|
||||
NEXT(readdir64);
|
||||
@@ -378,7 +363,6 @@ __attribute__((constructor)) static void resolve(void) {
|
||||
}
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
/* A reader of the kept listing when it is still current. */
|
||||
static DIR *hit(const struct stat *st, struct handle *h, long long now) {
|
||||
pthread_mutex_lock(&lock);
|
||||
if (!changing) pump(NULL, 0);
|
||||
@@ -401,7 +385,6 @@ static DIR *hit(const struct stat *st, struct handle *h, long long now) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Registers the stream and its watch before anything is read, so no change goes unseen. */
|
||||
static int track(struct handle *h, const char *path) {
|
||||
pthread_mutex_lock(&lock);
|
||||
h->wd = watch(path);
|
||||
@@ -411,7 +394,6 @@ static int track(struct handle *h, const char *path) {
|
||||
return d != NULL;
|
||||
}
|
||||
|
||||
/* Reads through the real stream, keeping what it returns. */
|
||||
static void filling(struct handle *h, DIR *real, const struct stat *st, long long now) {
|
||||
h->real = real;
|
||||
h->fill = calloc(1, sizeof(*h->fill));
|
||||
@@ -625,7 +607,6 @@ static int watching(const char *path) {
|
||||
return eligible(path) && __atomic_load_n(&cached_listings, __ATOMIC_ACQUIRE) > 0;
|
||||
}
|
||||
|
||||
/* Called with oplock held: the client's tracked changes happen one at a time. */
|
||||
static void begin(void) {
|
||||
pthread_mutex_lock(&lock);
|
||||
pump(NULL, 0);
|
||||
@@ -639,7 +620,6 @@ static void before(struct side *s) {
|
||||
|
||||
enum { ADDED, REMOVED };
|
||||
|
||||
/* Patches the listing after the client's own change, or drops it when unsure. Called with lock held. */
|
||||
static int patch(struct side *s, int what, uint32_t event, int ok, int error, const char *target, struct expect *x) {
|
||||
struct stat now;
|
||||
if (!s->known) return 0;
|
||||
@@ -795,7 +775,6 @@ ONE_PATH(remove, REMOVED, IN_DELETE, next_remove(path))
|
||||
return r; \
|
||||
}
|
||||
|
||||
/* A refused hard link to a lock file is taken as a symlink (links.c). */
|
||||
int bl_link_lock(const char *oldpath, const char *newpath, int result) __attribute__((visibility("hidden")));
|
||||
static int link_or_lock(const char *from, const char *to) { return bl_link_lock(from, to, next_link(from, to)); }
|
||||
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
/*
|
||||
* GEM handle emulation for the KGSL device presented as a DRM render node.
|
||||
*
|
||||
* Compositors and Mesa validate or convert dma-bufs with PRIME ioctls on the render node; KGSL
|
||||
* has no GEM. Handles only serve as tokens to these callers, so a table of duplicated dma-buf
|
||||
* descriptors stands in for the kernel's, and every other device is left to libdrm.
|
||||
*/
|
||||
#define _GNU_SOURCE
|
||||
#include <dlfcn.h>
|
||||
#include <errno.h>
|
||||
@@ -19,7 +12,6 @@
|
||||
|
||||
#define MAX_HANDLES 4096
|
||||
|
||||
/* DRM_IOCTL_GEM_CLOSE from drm.h: _IOW('d', 0x09, struct drm_gem_close { u32 handle, pad; }). */
|
||||
struct gem_close {
|
||||
uint32_t handle;
|
||||
uint32_t pad;
|
||||
@@ -36,7 +28,7 @@ static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
static struct handle_entry handle_entries[MAX_HANDLES];
|
||||
static uint32_t next_handle = 1;
|
||||
static dev_t kgsl_dev;
|
||||
static int kgsl_state; /* 0 unknown, 1 known, -1 absent */
|
||||
static int kgsl_state;
|
||||
|
||||
static int is_kgsl(int fd) {
|
||||
struct stat st;
|
||||
@@ -63,7 +55,7 @@ static int same_file_description(int a, int b) {
|
||||
}
|
||||
#ifdef SYS_kcmp
|
||||
int saved_errno = errno;
|
||||
long ret = syscall(SYS_kcmp, getpid(), getpid(), 0 /* KCMP_FILE */, a, b);
|
||||
long ret = syscall(SYS_kcmp, getpid(), getpid(), 0 , a, b);
|
||||
errno = saved_errno;
|
||||
return ret == 0;
|
||||
#else
|
||||
@@ -81,11 +73,6 @@ static int find_handle_locked(int fd, uint32_t handle) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* The old table used its slot index as the public handle. Once #275 started freeing slots,
|
||||
* rapidly recreated swapchains immediately reused those numbers. Keep storage slots reusable but
|
||||
* make the public token monotonic so a stale handle can fail instead of aliasing a newer buffer.
|
||||
*/
|
||||
static uint32_t alloc_handle_locked(void) {
|
||||
for (int tries = 0; tries <= MAX_HANDLES; tries++) {
|
||||
uint32_t candidate = next_handle++;
|
||||
@@ -157,7 +144,6 @@ int drmPrimeHandleToFD(int fd, uint32_t handle, uint32_t flags, int *prime_fd) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Drops only a handle belonging to this KGSL file description. */
|
||||
static int release_handle(int fd, uint32_t handle) {
|
||||
int found = 0;
|
||||
pthread_mutex_lock(&lock);
|
||||
@@ -179,16 +165,6 @@ int drmCloseBufferHandle(int fd, uint32_t handle) {
|
||||
return release_handle(fd, handle) ? 0 : -EINVAL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Zink gives its handles back with the GEM_CLOSE ioctl itself, not drmCloseBufferHandle
|
||||
* (zink_bo.c, bo_destroy). KGSL refuses the ioctl, so the duplicated descriptor stayed open and
|
||||
* kept the whole buffer alive. Preserve #275's reclamation without letting another KGSL file
|
||||
* description release the token or making a new buffer immediately inherit a retired token.
|
||||
*
|
||||
* Caught at ioctl() (netif.c), which libdrm's drmIoctl calls, rather than by exporting drmIoctl:
|
||||
* every session process preloads this library, and exporting drmIoctl from it brought on a
|
||||
* judder replaying old frames in No Man's Sky on an Adreno 840 even with no handle released.
|
||||
*/
|
||||
__attribute__((visibility("hidden"))) int bl_drm_gem_close(int fd, unsigned long request, void *arg, int *rc) {
|
||||
if (request != GEM_CLOSE || !arg || !is_kgsl(fd)) {
|
||||
return 0;
|
||||
@@ -202,12 +178,6 @@ __attribute__((visibility("hidden"))) int bl_drm_gem_close(int fd, unsigned long
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* fork() carries over only the calling thread, so a lock another thread was holding at that
|
||||
* instant stays held in the child by a thread that is not there to release it. Taking it before
|
||||
* the fork makes the copy consistent; the parent then unlocks it and the child, whose one thread
|
||||
* never locked it, gets a fresh one. (WinNative 79aa7f68.)
|
||||
*/
|
||||
static void drm_lock_before_fork(void) { pthread_mutex_lock(&lock); }
|
||||
static void drm_unlock_after_fork(void) { pthread_mutex_unlock(&lock); }
|
||||
static void drm_reset_after_fork(void) { pthread_mutex_init(&lock, NULL); }
|
||||
|
||||
Loaded 100 of 980 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user