mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
fix(game-env): turn off Proton's tabtip unless the Steam keyboard is enabled (#2595)
* fix(game-env): turn off Proton's tabtip unless the Steam keyboard is enabled Proton's tabtip only opens Steam's keyboard with SteamDeck=1, but it always runs UI Automation queries inside the focused game, and those calls crash games that answer them (Godot 4.5 AccessKit). Game launches now add tabtip.exe=d unless SteamDeck=1 or the user's overrides name tabtip. * fix(game-env): match WINEDLLOVERRIDES modules split by spaces and tabs * fix(game-env): count only tabtip.exe entries with a load order as the user's own setting * fix(game-env): count *tabtip.exe and tabtip.exe.dll overrides as the user's own setting * test(game-env): cover keyboard overrides during sync fallback
This commit is contained in:
1 parent
fdf3d98c36
commit
7254a88391
4 files changed
+107
-19
No files matched your search
@@ -283,7 +283,12 @@ DroidDeck instead publishes an atomic JSON snapshot at
|
||||
`/root/.config/droiddeck/game-environment.json`. Both its Valve ARM64 Proton
|
||||
wrapper and adopted third-party Proton wrappers execute `droiddeck-game-env`,
|
||||
which reads that snapshot for each real game launch and uses `execvpe` to start
|
||||
Proton. Probe prefix `compatdata/0` and non-launch verbs are unchanged. Malformed
|
||||
Proton. Probe prefix `compatdata/0` and non-launch verbs are unchanged. A game launch
|
||||
adds `tabtip.exe=d` to `WINEDLLOVERRIDES` unless the launch has `SteamDeck=1`
|
||||
or the overrides already set `tabtip.exe` (also as `*tabtip.exe` or
|
||||
`tabtip.exe.dll`): Proton's tabtip only opens Steam's
|
||||
keyboard with `SteamDeck=1`, but it always runs UI Automation queries inside the
|
||||
focused game, which crash games that answer them (Godot 4.5 AccessKit). Malformed
|
||||
configuration falls back to the inherited environment without evaluating its
|
||||
contents. Both component and environment selection normalize signed non-Steam
|
||||
prefix IDs to unsigned IDs.
|
||||
|
||||
@@ -188,6 +188,21 @@ def little_nightmares_threads(game):
|
||||
return {"PROTONFIXES_DISABLE": "1"}, [], "Little Nightmares: umu-protonfixes off (its -onethread puts the game and renderer on one thread)"
|
||||
|
||||
|
||||
def names_module(overrides, names):
|
||||
for entry in (overrides or "").split(";"):
|
||||
if "=" in entry and names & {re.sub(r"^\*|\.dll$", "", name.lower()) for name in re.split(r"[, \t]", entry.split("=", 1)[0])}:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def keyboard_helper_off(env):
|
||||
if env.get("SteamDeck") == "1" or names_module(env.get("WINEDLLOVERRIDES"), {"tabtip.exe"}):
|
||||
return None
|
||||
own = env.get("WINEDLLOVERRIDES")
|
||||
env["WINEDLLOVERRIDES"] = own + ";tabtip.exe=d" if own else "tabtip.exe=d"
|
||||
return "tabtip.exe off (it only opens Steam's keyboard with SteamDeck=1, and its UI Automation calls crash games)"
|
||||
|
||||
|
||||
def skip_red_launcher(command):
|
||||
if len(command) > 2 and os.path.basename(command[2]).lower() == "redprelauncher.exe":
|
||||
game = os.path.join(os.path.dirname(command[2]), "bin", "x64", "Cyberpunk2077.exe")
|
||||
@@ -1352,6 +1367,9 @@ def main():
|
||||
if "vblank_mode" in config.get("shared", {}):
|
||||
fixes.pop("vblank_mode", None)
|
||||
env = apply_config(env, launch_config, app_id, fixes)
|
||||
note = keyboard_helper_off(env)
|
||||
if note:
|
||||
print("droiddeck-game-env: " + note, file=sys.stderr)
|
||||
else:
|
||||
path = Path.home() / ".config/droiddeck/game-environment.json"
|
||||
try:
|
||||
|
||||
@@ -1069,26 +1069,36 @@ class LauncherTest(SyncTestCase):
|
||||
dist = self.dist_of(pack["id"], tool)
|
||||
game_env = runpy.run_path(str(BIN / "droiddeck-game-env"))
|
||||
command = [str(tool / "proton"), "waitforexitandrun", "game.exe"]
|
||||
env = self.env(STEAM_COMPAT_APP_ID="2630", PROTON_NO_NTSYNC="1", BL_SYNC="1", WINEESYNC="1")
|
||||
calls = []
|
||||
cases = (
|
||||
({}, {"WINEDLLOVERRIDES": "tabtip.exe=d"}),
|
||||
({"WINEDLLOVERRIDES": "dxgi=n"}, {"WINEDLLOVERRIDES": "dxgi=n;tabtip.exe=d"}),
|
||||
({"WINEDLLOVERRIDES": "dxgi=n;tabtip.exe=b"}, {"WINEDLLOVERRIDES": "dxgi=n;tabtip.exe=b"}),
|
||||
({"SteamDeck": "1"}, {"SteamDeck": "1"}),
|
||||
)
|
||||
for inherited, expected in cases:
|
||||
with self.subTest(inherited=inherited):
|
||||
env = self.env(STEAM_COMPAT_APP_ID="2630", PROTON_NO_NTSYNC="1", BL_SYNC="1", WINEESYNC="1", **inherited)
|
||||
calls = []
|
||||
|
||||
def execvpe(path, args, environment):
|
||||
calls.append((path, list(args), dict(environment)))
|
||||
if len(calls) == 1:
|
||||
raise PermissionError("denied")
|
||||
raise SystemExit(0)
|
||||
def execvpe(path, args, environment):
|
||||
calls.append((path, list(args), dict(environment)))
|
||||
if len(calls) == 1:
|
||||
raise PermissionError("denied")
|
||||
raise SystemExit(0)
|
||||
|
||||
with mock.patch.dict(os.environ, env, clear=True), mock.patch.object(sys, "argv", ["droiddeck-game-env"] + command), \
|
||||
mock.patch("os.execvpe", execvpe), contextlib.redirect_stderr(io.StringIO()) as said:
|
||||
with self.assertRaises(SystemExit):
|
||||
game_env["main"]()
|
||||
self.assertEqual([call[:2] for call in calls], [(str(dist / "proton"), [str(dist / "proton")] + command[1:]),
|
||||
(str(tool / "proton"), command)])
|
||||
self.assertEqual((calls[0][2]["WINEESYNC"], calls[0][2]["PROTON_NO_ESYNC"], calls[0][2]["BL_SYNC_PACK"]), ("0", "1", pack["id"]))
|
||||
self.assertEqual(calls[1][2], self.env(STEAM_COMPAT_APP_ID="2630", PROTON_NO_NTSYNC="1", BL_SYNC="0", WINEESYNC="1",
|
||||
vblank_mode="0", GAMESCOPE_WSI_MIN_IMAGE_COUNT="8",
|
||||
GAMESCOPE_WSI_ENSURE_MIN_IMAGE_COUNT="1"))
|
||||
self.assertIn("could not start (", said.getvalue())
|
||||
with mock.patch.dict(os.environ, env, clear=True), mock.patch.object(sys, "argv", ["droiddeck-game-env"] + command), \
|
||||
mock.patch("os.execvpe", execvpe), contextlib.redirect_stderr(io.StringIO()) as said:
|
||||
with self.assertRaises(SystemExit):
|
||||
game_env["main"]()
|
||||
self.assertEqual([call[:2] for call in calls], [(str(dist / "proton"), [str(dist / "proton")] + command[1:]),
|
||||
(str(tool / "proton"), command)])
|
||||
self.assertEqual((calls[0][2]["WINEESYNC"], calls[0][2]["PROTON_NO_ESYNC"], calls[0][2]["BL_SYNC_PACK"]), ("0", "1", pack["id"]))
|
||||
self.assertEqual(calls[1][2], self.env(STEAM_COMPAT_APP_ID="2630", PROTON_NO_NTSYNC="1", BL_SYNC="0", WINEESYNC="1",
|
||||
vblank_mode="0", GAMESCOPE_WSI_MIN_IMAGE_COUNT="8",
|
||||
GAMESCOPE_WSI_ENSURE_MIN_IMAGE_COUNT="1", **expected))
|
||||
self.assertEqual(calls[0][2].get("WINEDLLOVERRIDES"), expected.get("WINEDLLOVERRIDES"))
|
||||
self.assertEqual(calls[0][2].get("SteamDeck"), expected.get("SteamDeck"))
|
||||
self.assertIn("could not start (", said.getvalue())
|
||||
|
||||
def test_generated_launchers_run_the_dist_proton(self):
|
||||
root = self.store()
|
||||
|
||||
@@ -844,6 +844,61 @@ class GameEnvironmentTest(unittest.TestCase):
|
||||
self.assertEqual(["0"], [env["PROTON_USE_ARM64"] for env in seen_repair])
|
||||
self.assertEqual(["0"], [env["PROTON_USE_ARM64"] for env in seen_start])
|
||||
|
||||
def test_keyboard_helper_is_off_unless_steam_keyboard_or_the_user_wants_it(self):
|
||||
cases = (
|
||||
({}, "tabtip.exe=d"),
|
||||
({"WINEDLLOVERRIDES": "dxgi=n"}, "dxgi=n;tabtip.exe=d"),
|
||||
({"WINEDLLOVERRIDES": "tabtipx=d"}, "tabtipx=d;tabtip.exe=d"),
|
||||
({"SteamDeck": "0"}, "tabtip.exe=d"),
|
||||
({"SteamDeck": "1"}, None),
|
||||
({"SteamDeck": "1", "WINEDLLOVERRIDES": "dxgi=n"}, "dxgi=n"),
|
||||
({"WINEDLLOVERRIDES": "tabtip.exe=b"}, "tabtip.exe=b"),
|
||||
({"WINEDLLOVERRIDES": "dxgi=n; TabTip.EXE=n,b"}, "dxgi=n; TabTip.EXE=n,b"),
|
||||
({"WINEDLLOVERRIDES": "dxgi=n; TabTip=n,b"}, "dxgi=n; TabTip=n,b;tabtip.exe=d"),
|
||||
({"WINEDLLOVERRIDES": "d3d11 tabtip.exe"}, "d3d11 tabtip.exe;tabtip.exe=d"),
|
||||
({"WINEDLLOVERRIDES": "tabtip.exe;dxgi=n"}, "tabtip.exe;dxgi=n;tabtip.exe=d"),
|
||||
({"WINEDLLOVERRIDES": "d3d11,tabtip.exe=b"}, "d3d11,tabtip.exe=b"),
|
||||
({"WINEDLLOVERRIDES": "d3d11 tabtip.exe=b"}, "d3d11 tabtip.exe=b"),
|
||||
({"WINEDLLOVERRIDES": "d3d11\ttabtip.exe=b"}, "d3d11\ttabtip.exe=b"),
|
||||
({"WINEDLLOVERRIDES": "d3d11\ttabtip=b"}, "d3d11\ttabtip=b;tabtip.exe=d"),
|
||||
({"WINEDLLOVERRIDES": "d3d11 dxgi=n"}, "d3d11 dxgi=n;tabtip.exe=d"),
|
||||
({"WINEDLLOVERRIDES": "*tabtip.exe=b"}, "*tabtip.exe=b"),
|
||||
({"WINEDLLOVERRIDES": "TabTip.exe.DLL=b"}, "TabTip.exe.DLL=b"),
|
||||
({"WINEDLLOVERRIDES": "d3d11,*tabtip.exe.dll=n"}, "d3d11,*tabtip.exe.dll=n"),
|
||||
({"WINEDLLOVERRIDES": "*tabtip=b"}, "*tabtip=b;tabtip.exe=d"),
|
||||
({"WINEDLLOVERRIDES": "tabtip.dll=b"}, "tabtip.dll=b;tabtip.exe=d"),
|
||||
)
|
||||
for before, overrides in cases:
|
||||
with self.subTest(env=before):
|
||||
env = dict(before)
|
||||
note = MODULE["keyboard_helper_off"](env)
|
||||
self.assertEqual(env.get("WINEDLLOVERRIDES"), overrides)
|
||||
self.assertEqual(note is not None, overrides != before.get("WINEDLLOVERRIDES"))
|
||||
|
||||
def test_game_launch_turns_the_keyboard_helper_off_and_keeps_user_choices(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
home = Path(tmp)
|
||||
probe = home / "probe"
|
||||
probe.write_text("#!" + sys.executable + "\nimport os\nprint(os.environ.get('WINEDLLOVERRIDES', 'unset'))\n")
|
||||
probe.chmod(0o755)
|
||||
config = home / ".config/droiddeck/game-environment.json"
|
||||
config.parent.mkdir(parents=True)
|
||||
cases = (
|
||||
("waitforexitandrun", {}, "tabtip.exe=d"),
|
||||
("waitforexitandrun", {"WINEDLLOVERRIDES": "dxgi=n"}, "dxgi=n;tabtip.exe=d"),
|
||||
("waitforexitandrun", {"SteamDeck": "1"}, "unset"),
|
||||
("waitforexitandrun", {"WINEDLLOVERRIDES": "tabtip.exe=b"}, "tabtip.exe=b"),
|
||||
("run", {}, "unset"),
|
||||
)
|
||||
for verb, profile, expected in cases:
|
||||
with self.subTest(verb=verb, profile=profile):
|
||||
config.write_text(json.dumps({"version": 1, "games": {"42": profile}}))
|
||||
env = {k: v for k, v in os.environ.items() if k not in ("SteamDeck", "WINEDLLOVERRIDES")}
|
||||
env.update(HOME=tmp, STEAM_COMPAT_DATA_PATH="/compatdata/42")
|
||||
result = subprocess.run([sys.executable, str(BIN / "droiddeck-game-env"), str(probe), verb],
|
||||
env=env, text=True, capture_output=True, check=True)
|
||||
self.assertEqual(result.stdout.strip().splitlines()[-1], expected)
|
||||
|
||||
def test_optional_xbox_loader_failure_keeps_stock_launch(self):
|
||||
from unittest.mock import patch
|
||||
for error in (FileNotFoundError('missing'), RuntimeError('module initialization failed')):
|
||||
|
||||
Reference in new issue
Block a user