diff options
| author | kotorvr <332716892+kotorvr@users.noreply.github.com> | 2026-11-22 02:58:46 +0000 |
|---|---|---|
| committer | kotorvr <332716892+kotorvr@users.noreply.github.com> | 2026-11-22 02:58:46 +0000 |
| commit | 71812aac055097df5a633f90984655d7bb2fe155 (patch) | |
| tree | 4fed2c942dd88ef651483c747c35e61180a99824 /runtime/shims/gameinput.cpp | |
| parent | 0e59c75b7ba15013b5939b9177bfd2aa93c8f155 (diff) | |
GameInput shim: download SDL3 only when asked (LEONIDA_SDL3_FETCH)
The shim is built with an installed SDL3 (find_package) or with
-DLEONIDA_SDL3_FETCH=ON / FETCHCONTENT_SOURCE_DIR_SDL3; otherwise configure
prints a message, gta6rt builds without it, and CTest lists gameinput as
disabled. build_runtime.ps1 gains -FetchSdl3 and warns that its cl.exe
fallback never builds the shim. Review nits: delivering_thread is atomic,
and SDL's own GameInput joystick driver is pinned off.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/shims/gameinput.cpp')
| -rw-r--r-- | runtime/shims/gameinput.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/runtime/shims/gameinput.cpp b/runtime/shims/gameinput.cpp index 9595f59dd..4b5d693ce 100644 --- a/runtime/shims/gameinput.cpp +++ b/runtime/shims/gameinput.cpp | |||
| @@ -341,7 +341,7 @@ struct State { | |||
| 341 | bool config_read = false; | 341 | bool config_read = false; |
| 342 | bool sdl_ready = false, sdl_failed = false; | 342 | bool sdl_ready = false, sdl_failed = false; |
| 343 | bool thread_started = false; | 343 | bool thread_started = false; |
| 344 | DWORD delivering_thread = 0; | 344 | std::atomic<DWORD> delivering_thread{0}; // written by the delivering thread, read unlocked by UnregisterCallback |
| 345 | }; | 345 | }; |
| 346 | 346 | ||
| 347 | // Never destroyed: the poll thread may still run while the process exits. | 347 | // Never destroyed: the poll thread may still run while the process exits. |
| @@ -722,6 +722,11 @@ bool init_sdl() { | |||
| 722 | if (s.sdl_failed) return false; | 722 | if (s.sdl_failed) return false; |
| 723 | // No window: keep reading pads when another application has focus. | 723 | // No window: keep reading pads when another application has focus. |
| 724 | SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1"); | 724 | SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1"); |
| 725 | // Never read pads through the host's GameInput underneath this GameInput shim (SDL's default is already off | ||
| 726 | // outside the GDK; this keeps it off if that default changes). | ||
| 727 | #ifdef SDL_HINT_JOYSTICK_GAMEINPUT | ||
| 728 | SDL_SetHint(SDL_HINT_JOYSTICK_GAMEINPUT, "0"); | ||
| 729 | #endif | ||
| 725 | SDL_SetGamepadEventsEnabled(false); // the shim reads state directly; nothing drains an event queue | 730 | SDL_SetGamepadEventsEnabled(false); // the shim reads state directly; nothing drains an event queue |
| 726 | if (!SDL_InitSubSystem(SDL_INIT_GAMEPAD)) { | 731 | if (!SDL_InitSubSystem(SDL_INIT_GAMEPAD)) { |
| 727 | std::fprintf(stderr, "[rt] gameinput: SDL gamepad init failed: %s; no controllers\n", SDL_GetError()); | 732 | std::fprintf(stderr, "[rt] gameinput: SDL gamepad init failed: %s; no controllers\n", SDL_GetError()); |