Run the gamepad update on a thread of its own, so a controller that comes or goes no longer stalls the game.

When a device came or went, SDL's gamepad update first found every device again, 100 ms and more, on the game's
polling thread with the input lock held: a controller disconnecting gave five frames of 120 to 240 ms in a row, with
the game's other pollers queued on the lock. The pad thread now makes SDL's initialisation and every update. A poll
asks for an update and waits at most 2 ms for it; an ordinary one is done in microseconds and the poll reads fresh
state as before, and during a device search the poll goes on with the state it read last. Rumble, the motion samples
and the menu's stick reading skip a beat then instead of waiting.
--probe-input checks it on a virtual gamepad, with an update made to take 300 ms.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-09 23:51:58 -05:00
parent 9728424aec
commit be8c2620e5
3 changed files with 204 additions and 23 deletions

View File

@@ -22,6 +22,7 @@
// --probe-nvn, --probe-nvn-tex, --probe-window, --probe-shader, --probe-vkmem, --probe-vkexec graphics probes
// --probe-astc the compute ASTC decoder against astc_decode_ldr; needs no game files
// --probe-zstd host zstd streams (ov_zstd.c) on frames made here; needs no game files
// --probe-input gamepad polls on a virtual gamepad, also while SDL's update takes long; needs no game files
// --probe-movie host VP9 movie::Decoder on one RomFS movie; skips without game data
// --boot run the game to the first NVN call
// --seconds S run the game (implies --boot's start-up) until the world clock (game time since the loaded
@@ -493,7 +494,7 @@ static int usage(const char *argv0) {
fprintf(stderr, "usage: %s [--exefs DIR] [--romfs DIR] [--profile DIR] [--audio-device VALUE] [--monitor VALUE] [--list-audio-devices | --list-monitors | --selftest | --probe-loader | "
"--probe-cfg | --probe-dpi | --probe-mods | --probe-kernel | --probe-ipc | --probe-services | --probe-fs | --probe-gfx-abi | "
"--probe-nvn | --probe-nvn-tex | --probe-window | --probe-shader | --probe-vkmem | "
"--probe-vkexec | --probe-astc | --probe-zstd | --probe-movie | --probe-crash-call | --probe-crash-null | --probe-discord | "
"--probe-vkexec | --probe-astc | --probe-zstd | --probe-input | --probe-movie | --probe-crash-call | --probe-crash-null | --probe-discord | "
"--prepare-shaders | --warm-shaders | --boot |--seconds S [--shot PNG]]\n", argv0);
return 2;
}
@@ -630,6 +631,7 @@ int main(int argc, char **argv) {
if (!strcmp(mode, "--probe-vkexec")) return probe_vkexec();
if (!strcmp(mode, "--probe-astc")) return probe_astc();
if (!strcmp(mode, "--probe-zstd")) return probe_zstd();
if (!strcmp(mode, "--probe-input")) return probe_input();
if (!strcmp(mode, "--probe-vkdevice")) return probe_vkdevice();
if (!strcmp(mode, "--probe-movie")) return probe_movie();
if (!strcmp(mode, "--prepare-shaders")) return vk_pipeline_prepare_shaders();