|
1 | 1 | import os |
| 2 | +import re |
| 3 | +import shlex |
2 | 4 | import shutil |
3 | 5 | import stat |
4 | 6 | import subprocess |
5 | 7 | import tempfile |
6 | | -import shlex |
7 | 8 | from typing import Optional |
8 | 9 |
|
9 | 10 | from bottles.backend.globals import ( |
|
23 | 24 | from bottles.backend.utils.generic import detect_encoding |
24 | 25 | from bottles.backend.utils.gpu import GPUUtils |
25 | 26 | from bottles.backend.utils.manager import ManagerUtils |
26 | | -from bottles.backend.utils.terminal import TerminalUtils |
27 | 27 | from bottles.backend.utils.steam import SteamUtils |
| 28 | +from bottles.backend.utils.terminal import TerminalUtils |
28 | 29 |
|
29 | 30 | logging = Logger() |
30 | 31 |
|
@@ -93,6 +94,30 @@ def apply_wayland_preferences(env: "WineEnv", params) -> None: |
93 | 94 | env.remove("DISPLAY") |
94 | 95 |
|
95 | 96 |
|
| 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 | + |
96 | 121 | class WineCommand: |
97 | 122 | """ |
98 | 123 | This class is used to run a wine command with a custom environment. |
@@ -127,7 +152,12 @@ def __init__( |
127 | 152 | else self.config.Parameters.gamescope |
128 | 153 | ) |
129 | 154 | 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, |
131 | 161 | ) |
132 | 162 | self.terminal = terminal |
133 | 163 | self.env = self.get_env(_environment) |
@@ -208,6 +238,11 @@ def get_env( |
208 | 238 | ld = [] |
209 | 239 |
|
210 | 240 | # 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 | + |
211 | 246 | if config.Environment_Variables: |
212 | 247 | for key, value in config.Environment_Variables.items(): |
213 | 248 | env.add(key, value, override=True) |
|
0 commit comments