Merge remote-tracking branch 'origin/main' into review/malibridge-1950

This commit is contained in:
Kurt Himebauch committed 2026-11-02 18:14:00 -05:00
commit f05e0df39e
135 files changed
+5415 -979

No files matched your search

+7
View File
@@ -31,6 +31,13 @@ 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] /'
# startplasma applies this file over the session environment, and keeps what an earlier session wrote.
kwriteconfig6 --file plasma-localerc --group Formats --key LANG "${LANG:-C.UTF-8}"
if [ -n "${LANGUAGE:-}" ]; then
kwriteconfig6 --file plasma-localerc --group Translations --key LANGUAGE "$LANGUAGE"
else
kwriteconfig6 --file plasma-localerc --group Translations --key LANGUAGE --delete
fi
cat > /usr/share/applications/droiddeck-steam-x64.desktop <<'ENTRY'
[Desktop Entry]
Type=Application
@@ -357,6 +357,27 @@ GOG_ROOTS = {"HKEY_LOCAL_MACHINE": "HKEY_LOCAL_MACHINE", "HKLM": "HKEY_LOCAL_MAC
"HKEY_CLASSES_ROOT": "HKEY_CLASSES_ROOT", "HKCR": "HKEY_CLASSES_ROOT"}
WINE_USER = "C:\\users\\steamuser"
# GOG completes some installs by running a support installer from the game folder (the
# goggame-<id>.script "Execute" action). Under ARM64 FEX that 32-bit self-extractor stops at
# "Path not found", so the values it would write are applied here instead. Only products GOG
# ships no setRegistry action for are listed; a script's own entries always win.
# The Witcher: Enhanced Edition (#694) exits during startup unless the installer's
# HKLM\Software\CD Projekt Red\The Witcher keys exist - the same ones The Witcher's own
# setup writes (InstallFolder, RegionVersion, IsDjinniInstalled) plus its language.
GOG_INSTALL_REGISTRY = {
"1207658924": [
("HKLM", "Software\\CD Projekt Red\\The Witcher", "InstallFolder", "string", "{app}\\"),
("HKLM", "Software\\CD Projekt Red\\The Witcher", "RegionVersion", "string", "US"),
("HKLM", "Software\\CD Projekt Red\\The Witcher", "IsDjinniInstalled", "dword", 1),
("HKLM", "Software\\CD Projekt Red\\The Witcher", "Language", "string", "{language}"),
("HKCU", "Software\\CD Projekt RED\\Witcher\\Settings", "TextLanguage", "string", "{language}"),
("HKCU", "Software\\CD Projekt RED\\Witcher\\Settings", "VoiceLanguage", "string", "{language}"),
],
}
# The Witcher's text and voice language IDs, from its installer's registry data.
GOG_LANGUAGE_IDS = {"en": 3, "fr": 11, "de": 10, "es": 12, "it": 13, "ru": 14, "cs": 15, "hu": 16,
"zh": 21, "pl": 5}
def gog_paths(folder, product):
app = windows_path(str(folder))
@@ -416,8 +437,94 @@ def gog_entry(arguments, paths):
return None
def gog_registry(folder):
entries, skipped = [], 0
def gog_installed_products(folder):
products = {}
for info in sorted(Path(folder).glob("goggame-*.info")):
product = info.name[len("goggame-"):-len(".info")]
if not product.isdigit():
continue
try:
products[product] = json.loads(info.read_text(encoding="utf-8-sig"))
except (OSError, ValueError):
products[product] = {}
return products
def gog_language_id(info):
languages = info.get("languages") if isinstance(info, dict) else None
if isinstance(languages, str):
languages = [languages]
code = str(languages[0]).lower()[:2] if isinstance(languages, list) and languages else ""
return GOG_LANGUAGE_IDS.get(code, GOG_LANGUAGE_IDS["en"])
GOG_VALUE_HIVES = {"hklm": "local_machine", "hkey_local_machine": "local_machine",
"hkcu": "current_user", "hkey_current_user": "current_user",
"hkcr": "classes_root", "hkey_classes_root": "classes_root"}
def gog_value_key(root, section, name, view32=True):
"""A registry value's identity, keeping the root and the 32-bit view apart.
The fallback import always targets the 32-bit view (`/reg:32`), which Wine keeps under
`Software\\Wow6432Node` for HKLM: a native HKLM value must not pass for the 32-bit one.
HKCU\\Software is shared by both views, so its values read the same either way.
"""
text = section.replace("\\\\", "\\").strip("\\").lower()
hive = GOG_VALUE_HIVES.get(root.lower(), root.lower())
if text.startswith("software\\wow6432node\\"):
text = text[len("software\\wow6432node\\"):]
elif hive == "local_machine" and not view32 and text.startswith("software\\"):
text = "native\\" + text
elif text.startswith("software\\"):
text = text[len("software\\"):]
return "%s|%s|%s" % (hive, text, name.lower())
def gog_registry_values(pfx):
"""Values already in the prefix, so install defaults never overwrite a player's choice."""
values = set()
for file, root in (("system.reg", "hklm"), ("user.reg", "hkcu")):
try:
lines = (pfx / file).read_text(encoding="utf-8", errors="ignore").splitlines()
except OSError:
continue
section = ""
for line in lines:
if line.startswith("["):
end = line.find("]")
section = line[1:end] if end > 0 else line[1:]
continue
match = re.match(r'^"([^"]+)"=', line)
if match and section:
values.add(gog_value_key(root, section, match.group(1), view32=False))
return values
def gog_scripted_products(folder):
products = set()
for script in sorted(Path(folder).glob(GOG_SCRIPTS)):
try:
actions = json.loads(script.read_text(encoding="utf-8-sig")).get("actions")
except (OSError, ValueError, AttributeError):
continue
if isinstance(actions, list) and any(
isinstance(action, dict) and isinstance(action.get("install"), dict)
and action["install"].get("action") == "setRegistry" for action in actions):
products.add(script.name[len("goggame-"):-len(".script")])
return products
def gog_expected_values(folder):
"""The fallback values a launch must find, so the marker never hides one that was deleted."""
scripted = gog_scripted_products(folder)
return [gog_value_key(root, subkey, name) for product in gog_installed_products(folder)
if product in GOG_INSTALL_REGISTRY and product not in scripted
for root, subkey, name, _kind, _value in GOG_INSTALL_REGISTRY[product]]
def gog_registry(folder, existing=()):
entries, skipped, scripted = [], 0, set()
for script in sorted(Path(folder).glob(GOG_SCRIPTS)):
product = script.name[len("goggame-"):-len(".script")]
try:
@@ -434,11 +541,28 @@ def gog_registry(folder):
skipped += 1
else:
entries.append(entry)
scripted.add(product)
for product, info in gog_installed_products(folder).items():
if product in scripted or product not in GOG_INSTALL_REGISTRY:
continue
paths = dict(gog_paths(folder, product), language=str(gog_language_id(info)))
for root, subkey, name, kind, value in GOG_INSTALL_REGISTRY[product]:
if gog_value_key(root, subkey, name) in existing:
continue
entry = gog_entry({"root": root, "subkey": subkey, "valueName": name,
"valueType": kind, "valueData": value}, paths)
if entry is None:
skipped += 1
else:
entries.append(entry)
return entries, skipped
def apply_gog_registry(folder, compat_data, proton, timeout=90, installation=None):
entries, skipped = gog_registry(folder)
pfx = Path(compat_data) / "pfx" if compat_data else None
existing = gog_registry_values(pfx) if pfx else set()
entries, skipped = gog_registry(folder, existing)
expected = gog_expected_values(folder)
if installation:
product = str(installation["id"])
if not product.isdigit():
@@ -465,10 +589,10 @@ def apply_gog_registry(folder, compat_data, proton, timeout=90, installation=Non
return "no-proton" + note
text = "Windows Registry Editor Version 5.00\r\n\r\n" + "".join(entry + "\r\n\r\n" for entry in entries)
stamp = hashlib.sha256(text.encode("utf-8")).hexdigest()
pfx = Path(compat_data) / "pfx"
marker = pfx / GOG_REGISTRY_MARK
try:
if marker.is_file() and marker.read_text() == stamp and (pfx / "system.reg").is_file():
if (marker.is_file() and marker.read_text() == stamp and (pfx / "system.reg").is_file()
and set(expected) <= existing):
return "ready" + note
Path(compat_data).mkdir(parents=True, exist_ok=True)
with tempfile.TemporaryDirectory(prefix="droiddeck-gog-") as tmp:
+57
View File
@@ -3,6 +3,7 @@
#include <string.h>
#include "kgsl_busy.h"
#include "kgsl_layout.h"
#define ENTRIES 819
@@ -52,5 +53,61 @@ int main(void) {
assert(moved == 0);
puts("PASS: kgsl memstore busy");
// Hardware-scheduled kernels: ringbuffer entries stay 0, contexts carry the stamps.
memset(memstore, 0, sizeof(memstore));
static uint32_t seen[ENTRIES], ctx_last[ENTRIES];
int live[KGSL_BUSY_MAX_LIVE];
stamp(3, 50, 50);
stamp(9, 21, 20);
stamp(first - 1, 4, 4);
int count = kgsl_busy_scan_contexts(memstore, first, seen, live, KGSL_BUSY_MAX_LIVE);
assert(count == 3 && live[0] == 3 && live[1] == 9 && live[2] == first - 1);
moved = 0;
assert(kgsl_busy_sample_contexts(memstore, live, count, ctx_last, &moved) == 1);
assert(moved == 1 && ctx_last[9] == 21);
// Busy or newly started contexts come first; idle ones that have run work stay in the list.
stamp(9, 21, 21);
stamp(5, 2, 1);
count = kgsl_busy_scan_contexts(memstore, first, seen, live, KGSL_BUSY_MAX_LIVE);
assert(count == 4 && live[0] == 5 && live[1] == 3 && live[2] == 9 && live[3] == first - 1);
moved = 0;
assert(kgsl_busy_sample_contexts(memstore, live, count, ctx_last, &moved) == 1);
assert(moved == 1);
moved = 0;
assert(kgsl_busy_sample_contexts(memstore, live, count, ctx_last, &moved) == 1);
assert(moved == 0);
stamp(5, 2, 2);
assert(kgsl_busy_sample_contexts(memstore, live, count, ctx_last, &moved) == 0);
// Entry 0 (global) and the ringbuffer entries are not contexts; the live list is capped.
memset(memstore, 0, sizeof(memstore));
memset(seen, 0, sizeof(seen));
stamp(0, 8, 7);
stamp(first, 8, 7);
assert(kgsl_busy_scan_contexts(memstore, first, seen, live, KGSL_BUSY_MAX_LIVE) == 0);
for (int id = 1; id <= KGSL_BUSY_MAX_LIVE + 10; id++) stamp(id, 1, 1);
assert(kgsl_busy_scan_contexts(memstore, first, seen, live, KGSL_BUSY_MAX_LIVE) == KGSL_BUSY_MAX_LIVE);
assert(kgsl_busy_scan_contexts(memstore, first, seen, live, KGSL_BUSY_MAX_LIVE) == KGSL_BUSY_MAX_LIVE);
stamp(KGSL_BUSY_MAX_LIVE + 5, 2, 1);
assert(kgsl_busy_scan_contexts(memstore, first, seen, live, KGSL_BUSY_MAX_LIVE) == KGSL_BUSY_MAX_LIVE);
assert(live[0] == KGSL_BUSY_MAX_LIVE + 5);
stamp(KGSL_BUSY_MAX_LIVE + 5, 0, 0);
count = kgsl_busy_scan_contexts(memstore, first, seen, live, KGSL_BUSY_MAX_LIVE);
count = kgsl_busy_scan_contexts(memstore, first, seen, live, KGSL_BUSY_MAX_LIVE);
for (int i = 0; i < count; i++) assert(live[i] != KGSL_BUSY_MAX_LIVE + 5);
puts("PASS: kgsl memstore contexts");
assert(kgsl_layout_for(0x44050001u) == &KGSL_LAYOUT_A8XX); // Adreno 830
assert(kgsl_layout_for(0x44030a20u) == &KGSL_LAYOUT_A8XX); // Adreno 829
assert(kgsl_layout_for(0x43020100u) == &KGSL_LAYOUT_A7XX); // Adreno 722
assert(kgsl_layout_for(0x43050a01u) == &KGSL_LAYOUT_A7XX); // Adreno 740
assert(kgsl_layout_for(0x07010000u) == &KGSL_LAYOUT_A7XX); // Adreno 710
assert(kgsl_layout_for(0x06030001u) == &KGSL_LAYOUT_A7XX); // Adreno 630
assert(kgsl_layout_for(0x45000000u) == NULL);
assert(KGSL_LAYOUT_A8XX.always_on == 0x8e7u && KGSL_LAYOUT_A8XX.cycles == 1u);
assert(KGSL_LAYOUT_A7XX.always_on == 0x980u && KGSL_LAYOUT_A7XX.cycles == 0u);
puts("PASS: kgsl counter layout");
return 0;
}
+3 -1
View File
@@ -1,4 +1,4 @@
"""Exercise the HUD's kgsl memstore busy sampling (app/src/main/cpp/gpuclock/kgsl_busy.h)."""
"""Exercise the HUD's kgsl memstore busy sampling and counter layout (app/src/main/cpp/gpuclock)."""
import os
from pathlib import Path
import shutil
@@ -27,6 +27,8 @@ class KgslBusyTest(unittest.TestCase):
result = subprocess.run([str(self.binary)], capture_output=True, text=True)
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
self.assertIn('PASS: kgsl memstore busy', result.stdout)
self.assertIn('PASS: kgsl memstore contexts', result.stdout)
self.assertIn('PASS: kgsl counter layout', result.stdout)
if __name__ == '__main__':
+114
View File
@@ -438,6 +438,120 @@ class GogRegistry(unittest.TestCase):
], entries)
self.assertEqual(3, skipped)
def test_a_game_whose_support_installer_cannot_run_gets_the_install_registry(self):
with tempfile.TemporaryDirectory() as root:
folder = game(root, store_id='gog', ident='1207658924')
(folder / 'goggame-1207658924.info').write_text(json.dumps({'language': 'English', 'languages': ['en-US']}))
gog_script(folder, '1207658924', [
{'install': {'action': 'Execute', 'arguments': {'executable': 'galaxy_the_witcher_enhanced_edition_2.1.0.15.exe'}}},
])
entries, skipped = store.gog_registry(folder)
app = store.windows_path(str(folder)).replace('\\', '\\\\')
self.assertEqual([
'[HKEY_LOCAL_MACHINE\\Software\\CD Projekt Red\\The Witcher]\r\n"InstallFolder"="%s\\\\"' % app,
'[HKEY_LOCAL_MACHINE\\Software\\CD Projekt Red\\The Witcher]\r\n"RegionVersion"="US"',
'[HKEY_LOCAL_MACHINE\\Software\\CD Projekt Red\\The Witcher]\r\n"IsDjinniInstalled"=dword:00000001',
'[HKEY_LOCAL_MACHINE\\Software\\CD Projekt Red\\The Witcher]\r\n"Language"="3"',
'[HKEY_CURRENT_USER\\Software\\CD Projekt RED\\Witcher\\Settings]\r\n"TextLanguage"="3"',
'[HKEY_CURRENT_USER\\Software\\CD Projekt RED\\Witcher\\Settings]\r\n"VoiceLanguage"="3"',
], entries)
self.assertEqual(0, skipped)
def test_a_players_language_choice_is_not_overwritten(self):
with tempfile.TemporaryDirectory() as root:
folder = game(root, store_id='gog', ident='1207658924')
(folder / 'goggame-1207658924.info').write_text(json.dumps({'languages': ['en-US']}))
proton = Path(root) / 'proton'
proton.write_text('selected Proton')
data = Path(root) / 'compat'
(data / 'pfx').mkdir(parents=True)
(data / 'pfx/user.reg').write_text(
'[Software\\\\OtherApp] 1\n"InstallFolder"="C:\\\\Other"\n\n'
'[Software\\\\CD Projekt RED\\\\Witcher\\\\Settings] 1\n"TextLanguage"="5"\n')
imported = []
def run(argv, **kwargs):
imported.append(Path(argv[4][2:].replace('\\', '/')).read_bytes()[2:].decode('utf-16-le'))
(data / 'pfx/system.reg').write_text('Wine registry')
return __import__('subprocess').CompletedProcess(argv, 0)
with patch.object(store.subprocess, 'run', side_effect=run):
store.apply_gog_registry(folder, str(data), str(proton))
text = imported[0]
self.assertNotIn('"TextLanguage"', text)
self.assertIn('"VoiceLanguage"', text)
self.assertIn('"InstallFolder"', text)
def test_malformed_language_metadata_falls_back_to_english(self):
with tempfile.TemporaryDirectory() as root:
folder = game(root, store_id='gog', ident='1207658924')
(folder / 'goggame-1207658924.info').write_text(json.dumps({'languages': 3}))
entries, _ = store.gog_registry(folder)
self.assertIn('"Language"="3"', entries[3])
def test_a_native_hklm_value_does_not_replace_the_32_bit_fallback(self):
with tempfile.TemporaryDirectory() as root:
folder = game(root, store_id='gog', ident='1207658924')
(folder / 'goggame-1207658924.info').write_text(json.dumps({'languages': ['en-US']}))
pfx = Path(root) / 'pfx'
pfx.mkdir()
(pfx / 'system.reg').write_text(
'[Software\\\\CD Projekt Red\\\\The Witcher] 1\n"InstallFolder"="C:\\\\Native"\n')
entries, _ = store.gog_registry(folder, store.gog_registry_values(pfx))
self.assertTrue(any('"InstallFolder"' in entry for entry in entries))
(pfx / 'system.reg').write_text(
'[Software\\\\Wow6432Node\\\\CD Projekt Red\\\\The Witcher] 1\n"InstallFolder"="C:\\\\32bit"\n')
entries, _ = store.gog_registry(folder, store.gog_registry_values(pfx))
self.assertFalse(any('"InstallFolder"' in entry for entry in entries))
def test_a_deleted_fallback_value_is_imported_again(self):
with tempfile.TemporaryDirectory() as root:
folder = game(root, store_id='gog', ident='1207658924')
(folder / 'goggame-1207658924.info').write_text(json.dumps({'languages': ['en-US']}))
proton = Path(root) / 'proton'
proton.write_text('selected Proton')
data = Path(root) / 'compat'
pfx = data / 'pfx'
pfx.mkdir(parents=True)
imported = []
def run(argv, **kwargs):
imported.append(argv)
(pfx / 'system.reg').write_text(
'[Software\\\\Wow6432Node\\\\CD Projekt Red\\\\The Witcher] 1\n'
'"InstallFolder"="C:\\\\Game"\n"RegionVersion"="US"\n'
'"IsDjinniInstalled"=dword:00000001\n"Language"="3"\n')
(pfx / 'user.reg').write_text(
'[Software\\\\CD Projekt RED\\\\Witcher\\\\Settings] 1\n'
'"TextLanguage"="3"\n"VoiceLanguage"="3"\n')
return __import__('subprocess').CompletedProcess(argv, 0)
with patch.object(store.subprocess, 'run', side_effect=run):
self.assertEqual('written=6', store.apply_gog_registry(folder, str(data), str(proton)))
self.assertEqual('none', store.apply_gog_registry(folder, str(data), str(proton)))
(pfx / 'system.reg').write_text(
'[Software\\\\Wow6432Node\\\\CD Projekt Red\\\\The Witcher] 1\n'
'"RegionVersion"="US"\n"IsDjinniInstalled"=dword:00000001\n"Language"="3"\n')
self.assertEqual('written=1', store.apply_gog_registry(folder, str(data), str(proton)))
self.assertEqual(2, len(imported))
def test_the_install_language_selects_the_titles_language_id(self):
with tempfile.TemporaryDirectory() as root:
folder = game(root, store_id='gog', ident='1207658924')
(folder / 'goggame-1207658924.info').write_text(json.dumps({'languages': ['pl-PL']}))
entries, _ = store.gog_registry(folder)
self.assertIn('"Language"="5"', entries[3])
def test_a_script_that_sets_registry_keeps_its_own_values(self):
with tempfile.TemporaryDirectory() as root:
folder = game(root, store_id='gog', ident='1207658924')
(folder / 'goggame-1207658924.info').write_text(json.dumps({'languages': ['en-US']}))
gog_script(folder, '1207658924', [
set_registry(root='HKLM', subkey='Software\\CD Projekt Red\\The Witcher',
valueName='InstallFolder', valueData='{app}\\', valueType='string'),
])
entries, _ = store.gog_registry(folder)
app = store.windows_path(str(folder)).replace('\\', '\\\\')
self.assertEqual([
'[HKEY_LOCAL_MACHINE\\Software\\CD Projekt Red\\The Witcher]\r\n"InstallFolder"="%s\\\\"' % app,
], entries)
def test_a_game_without_a_script_starts_without_proton(self):
with tempfile.TemporaryDirectory() as root:
folder = game(root, store_id='gog')