mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-25 22:15:57 +00:00
The gamepad pauses while the window has no focus in a game Steam started, so Steam's overlay and menus get its presses alone (#1462)
Since #971, SDL passes gamepad events to the game while its window has no focus (SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS). On Linux the window is SDL's, and under Steam the focus goes to Steam's overlay and menus while they are open (the Quick Access menu in SteamOS's Game Mode): the game took the presses meant for them too, which 0.4.1 did not. The new setting pad_background (auto, 1, 0; read at start) decides the hint. auto, the default, keeps it on unless Steam started the game (SteamGameId or SteamOverlayGameId in the environment, set for Steam games and non-Steam shortcuts alike); 1 keeps the gamepad playing behind other windows under Steam too, 0 pauses it everywhere. input_map.c input_pad_background_pick holds the decision and cfg_probe checks it. On Windows the game window is not SDL's, and nothing changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6205940caf
commit
58fd4f6f68
7 files changed
+44
-5
No files matched your search
+12
-3
@@ -671,9 +671,18 @@ static void start(void) {
|
||||
// window lacks keyboard focus (SDL_PrivateJoystickShouldIgnoreEvent in SDL_joystick.c; centring and releases
|
||||
// pass). That applies where the window is SDL's (Linux); the Win32 window on Windows is not an SDL window. The
|
||||
// game keeps running out of focus by default (TOTK_ASSUME_FOCUS, ov_system.c oe_set_focus), so the gamepad has to
|
||||
// keep working there. With the setting off the game's main thread waits while unfocused and reads no input, so
|
||||
// the hint can stay on for the whole run.
|
||||
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
|
||||
// keep working there (#971). With the setting off the game's main thread waits while unfocused and reads no input,
|
||||
// so the hint can stay on for the whole run. A game Steam started is the exception (input_pad_background_pick):
|
||||
// Steam's overlay and menus take the focus while they are open, and the presses meant for them reached the game
|
||||
// too (#1462). Steam sets SteamGameId for its own games and for non-Steam shortcuts, SteamOverlayGameId with the
|
||||
// overlay. TOTK_PAD_BACKGROUND = 1 or 0 decides it either way.
|
||||
const char *gid = getenv("SteamGameId"), *ogid = getenv("SteamOverlayGameId");
|
||||
int under_steam = (gid && *gid) || (ogid && *ogid);
|
||||
const char *bg = cfg_value("TOTK_PAD_BACKGROUND");
|
||||
if (input_pad_background_pick(bg, under_steam)) SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
|
||||
else
|
||||
rt_log("input: the gamepad pauses while the window has no focus (%s)",
|
||||
strcmp(bg, "0") ? "Steam started the game; pad_background = 1 keeps it" : "pad_background = 0");
|
||||
if (!SDL_Init(SDL_INIT_GAMEPAD)) { state = -1; rt_log("input: SDL gamepad init failed (%s), keyboard only", SDL_GetError()); }
|
||||
else state = 1;
|
||||
if (state == 1) test_pad_attach();
|
||||
|
||||
Reference in new issue
Block a user