Add opt-in GOG achievements through Comet (#651)

This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-10-12 16:40:06 -04:00
1 parent 3ed756b067
commit 8f36eb7f54
35 files changed
+1364 -45

No files matched your search

+1
View File
@@ -320,6 +320,7 @@ else
fi
cd "${repo_root}"
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"
+202
View File
@@ -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.
+24
View File
@@ -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.
+18
View File
@@ -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
'
+24
View File
@@ -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"
+174
View File
@@ -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"));
}
+
+/// A launcher may restrict Galaxy to explicitly enabled SDK clients in its private policy file.
+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();
@@ -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"
@@ -262,6 +265,76 @@ 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"
# cmd/sc run through this title's selected Proton. The run verb bypasses the managed
# wrapper, so this cannot recursively request credentials or sync cloud saves.
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,6 +346,8 @@ 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)
@@ -435,6 +435,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[@]}"
@@ -503,11 +504,12 @@ 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"
{
+3 -1
View File
@@ -15,7 +15,7 @@ MANIFEST = Path('app/build/runtime-inputs.json')
SOURCE_PATHS = ['app/build.gradle', 'app/src/main/cpp/fakeinput_steam.cpp', 'app/src/main/assets/pulseaudio.tzst',
'tools/linuxfs', 'tools/proot', 'tools/aaudio-sink', 'tools/directaudio',
'tools/gamescope/release.env', 'tools/droiddeck-esync/release.env',
'tools/mangoapp', 'tools/msitools', 'tools/build_local.sh',
'tools/mangoapp', 'tools/msitools', 'tools/comet', 'tools/build_local.sh',
'tools/release/runtime_inputs.py', 'app/src/main/assets/desktop-removal']
@@ -64,6 +64,8 @@ def required():
['msiinfo', 'cabextract', '7z', '7z.so', 'libmsi-1.0.so.0', 'libgsf-1.so.114', 'libgcab-1.0.so.0']]
paths += ['assets/linuxfs/usr/local/lib/mangoapp/' + name for name in
['mangoapp', 'libfmt.so.10', 'libspdlog.so.1.13', 'libglfw.so.3', 'libtraceevent.so.1', 'libtracefs.so.1']]
paths += ['assets/linuxfs/usr/local/lib/droiddeck-comet/' + name for name in
['comet', 'GalaxyCommunication.exe', 'update-permissions.exe', 'LICENSE', 'version']]
for driver in ['linux-wine11', 'linux-wine11-systhread']:
paths += ['assets/directaudio/' + driver + '/' + name for name in
['aarch64-unix/winedirectaudio.so', 'aarch64-windows/winedirectaudio.drv',
+68 -6
View File
@@ -10,6 +10,7 @@ import tempfile
import threading
import time
import unittest
from unittest.mock import patch
BIN = Path(__file__).resolve().parents[1] / 'linuxfs/overlay/usr/local/bin'
@@ -64,15 +65,17 @@ class Detection(unittest.TestCase):
def test_only_epic_asks_for_a_code(self):
with tempfile.TemporaryDirectory() as root:
folder = game(root, store_id='gog')
# Cloud saves off: nothing else to ask for either.
# Cloud saves off: GOG still prepares achievements, never an Epic exchange code.
sc = json.loads((folder / '.droiddeck-store.json').read_text()); sc['cloud'] = False
(folder / '.droiddeck-store.json').write_text(json.dumps(sc))
os.environ['BL_LAUNCH_DIR'] = str(Path(root) / 'session')
try:
self.assertEqual(0, store.main([str(folder / '.droiddeck-launch.bat')]))
with patch.object(store, 'ask', return_value={'ready': False, 'reason': 'off'}) as ask:
self.assertEqual(0, store.main([str(folder / '.droiddeck-launch.bat')]))
self.assertEqual('gog-achievements', ask.call_args.args[1]['op'])
finally:
del os.environ['BL_LAUNCH_DIR']
self.assertFalse((Path(root) / 'session/stores').exists())
class Asking(unittest.TestCase):
@@ -225,9 +228,10 @@ class CloudHooks(unittest.TestCase):
finally:
store.ask = original
del os.environ['BL_LAUNCH_DIR']
self.assertEqual({'op': 'cloud-down', 'store': 'gog', 'id': '1207664643'}, asked[0][0])
self.assertEqual(store.CLOUD_TIMEOUT, asked[0][1])
self.assertEqual('cloud-up', asked[1][0]['op'])
self.assertEqual('gog-achievements', asked[0][0]['op'])
self.assertEqual({'op': 'cloud-down', 'store': 'gog', 'id': '1207664643'}, asked[1][0])
self.assertEqual(store.CLOUD_TIMEOUT, asked[1][1])
self.assertEqual('cloud-up', asked[2][0]['op'])
def test_cloud_off_or_amazon_runs_proton_as_before(self):
with tempfile.TemporaryDirectory() as root:
@@ -260,3 +264,61 @@ class Launchers(unittest.TestCase):
if __name__ == '__main__':
unittest.main()
class GogAchievements(unittest.TestCase):
def test_cloud_off_still_prepares_the_gog_companion(self):
with tempfile.TemporaryDirectory() as root:
folder = game(root, store_id='gog')
sidecar = json.loads((folder / store.SIDECAR).read_text())
sidecar['cloud'] = False
(folder / store.SIDECAR).write_text(json.dumps(sidecar))
with patch.dict(os.environ, {'BL_LAUNCH_DIR': root, 'STEAM_COMPAT_DATA_PATH': root + '/compat', 'BL_STORE_PROTON': '/chosen/proton'}), patch.object(store, 'ask', return_value={'ready': True}) as ask, patch.object(store, 'provision_galaxy', return_value='ready') as provision:
self.assertEqual(0, store.main([str(folder / store.LAUNCHER)]))
ask.assert_called_once()
provision.assert_called_once_with(root + '/compat', '/chosen/proton')
def test_unavailable_companion_does_not_provision_or_block_the_game(self):
with patch.object(store, 'ask', return_value=None), patch.object(store, 'provision_galaxy') as provision:
self.assertFalse(store.prepare_gog({'id': '1', 'achievements': False}, '/pfx', '/session'))
provision.assert_not_called()
def test_a_fresh_prefix_is_bootstrapped_before_marking_success(self):
with tempfile.TemporaryDirectory() as root:
base = Path(root)
tools = base / 'tools'; tools.mkdir()
for name in ('GalaxyCommunication.exe', 'update-permissions.exe', 'version'):
(tools / name).write_text(name)
proton = base / 'proton'; proton.write_text('selected Proton')
data = base / 'compat'
seen = []
def run(argv, **kwargs):
self.assertEqual([str(proton), 'run', 'cmd.exe', '/d', '/c'], argv[:5])
bat = Path(argv[5][2:].replace('\\', '/'))
text = bat.read_text()
seen.append(text)
self.assertIn('goto existing', text)
self.assertIn('update-permissions.exe', text)
result = text.split('echo ready>"')[1].split('"')[0]
Path(result[2:].replace('\\', '/')).write_text('ready')
(data / 'pfx').mkdir(parents=True)
(data / 'pfx/system.reg').write_text('Wine registry')
return __import__('subprocess').CompletedProcess(argv, 0)
with patch.object(store, 'COMET_DIR', tools), patch.object(store.subprocess, 'run', side_effect=run):
self.assertEqual('ready', store.provision_galaxy(str(data), str(proton)))
self.assertTrue((data / 'pfx/.droiddeck-comet-service').is_file())
self.assertEqual('ready', store.provision_galaxy(str(data), str(proton)))
self.assertEqual(1, len(seen))
# A recreated prefix must be provisioned again, even with the same Proton.
__import__('shutil').rmtree(data / 'pfx')
self.assertEqual('ready', store.provision_galaxy(str(data), str(proton)))
self.assertEqual(2, len(seen))
def test_failed_service_install_is_not_marked_done(self):
with tempfile.TemporaryDirectory() as root:
base = Path(root)
for name in ('GalaxyCommunication.exe', 'update-permissions.exe', 'version', 'proton'):
(base / name).write_text(name)
with patch.object(store, 'COMET_DIR', base), patch.object(store.subprocess, 'run', return_value=__import__('subprocess').CompletedProcess([], 1)):
self.assertEqual('service-unavailable', store.provision_galaxy(str(base / 'compat'), str(base / 'proton')))
self.assertFalse((base / 'compat/pfx/.droiddeck-comet-service').exists())