Skip to content

Commit b4b308b

Browse files
committed
fix[close #4007]: Steam Deck Controls Don't Work in Gaming Mode
1 parent 3a1ac88 commit b4b308b

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

bottles/backend/wine/winecommand.py

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import os
2+
import re
3+
import shlex
24
import shutil
35
import stat
46
import subprocess
57
import tempfile
6-
import shlex
78
from typing import Optional
89

910
from bottles.backend.globals import (
@@ -23,8 +24,8 @@
2324
from bottles.backend.utils.generic import detect_encoding
2425
from bottles.backend.utils.gpu import GPUUtils
2526
from bottles.backend.utils.manager import ManagerUtils
26-
from bottles.backend.utils.terminal import TerminalUtils
2727
from bottles.backend.utils.steam import SteamUtils
28+
from bottles.backend.utils.terminal import TerminalUtils
2829

2930
logging = Logger()
3031

@@ -93,6 +94,30 @@ def apply_wayland_preferences(env: "WineEnv", params) -> None:
9394
env.remove("DISPLAY")
9495

9596

97+
def _needs_steam_virtual_gamepad_workaround(runner_name: Optional[str]) -> bool:
98+
"""Return True if the runner should force SteamVirtualGamepadInfo."""
99+
100+
if not runner_name:
101+
return False
102+
103+
normalized = runner_name.lower()
104+
if not any(
105+
prefix in normalized for prefix in ("ge-proton", "proton-ge", "wine-ge", "soda")
106+
):
107+
return False
108+
109+
match = re.search(r"(\d+)", normalized)
110+
if not match:
111+
return False
112+
113+
try:
114+
major = int(match.group(1))
115+
except ValueError:
116+
return False
117+
118+
return major <= 8
119+
120+
96121
class WineCommand:
97122
"""
98123
This class is used to run a wine command with a custom environment.
@@ -127,7 +152,12 @@ def __init__(
127152
else self.config.Parameters.gamescope
128153
)
129154
self.command = self.get_cmd(
130-
command, pre_script, post_script, pre_script_args, post_script_args, environment=_environment
155+
command,
156+
pre_script,
157+
post_script,
158+
pre_script_args,
159+
post_script_args,
160+
environment=_environment,
131161
)
132162
self.terminal = terminal
133163
self.env = self.get_env(_environment)
@@ -208,6 +238,11 @@ def get_env(
208238
ld = []
209239

210240
# Bottle environment variables
241+
if _needs_steam_virtual_gamepad_workaround(config.Runner) and not env.has(
242+
"SteamVirtualGamepadInfo"
243+
):
244+
env.add("SteamVirtualGamepadInfo", "", override=True)
245+
211246
if config.Environment_Variables:
212247
for key, value in config.Environment_Variables.items():
213248
env.add(key, value, override=True)

0 commit comments

Comments
 (0)