Repository navigation
Runtime: GameInput shim on SDL3 (any controller; DualSense trigger effects, lightbar) - #680
Conversation
|
Code review at |
|
Thanks, this covers #660. One change before I can merge it: the build shouldn't download anything unless asked. Right now
The pinned hash is good; keep it for the fetch path. |
|
Tested 08ac01e on Windows 10 Home 22H2 (19045), MSVC 19.39, Windows SDK 10.0.26100, Ninja RelWithDebInfo, with the pinned SDL3 3.4.20 fetched by the CMake script (hash check passed, built static): pass. (RT-19.)
Code read, mostly the threading and object lifetimes:
The AI-assisted (Claude Code); repository tests only, no game files, no controller. |
…fects, lightbar) GameInputCreate and the v0 IGameInput/IGameInputDevice/IGameInputReading/IGameInputDispatcher surface a title uses for gamepads, served from SDL3 gamepads so DualSense, DualShock 4, Switch Pro and Xbox pads all work. Rumble goes to SDL_RumbleGamepad, impulse-trigger rumble to SDL_RumbleGamepadTriggers, and on a DualSense to adaptive-trigger effects through SDL_SendGamepadEffect (LEONIDA_DS_TRIGGERS=off|rumble|resistance). Lightbar via LEONIDA_DS_LIGHTBAR. SDL3 (zlib) comes from an installed package or a pinned, hash-checked release tarball via FetchContent; -DLEONIDA_SDL3=OFF skips the shim. gameinput_test covers the shim on SDL virtual joysticks; gameinput_probe is the manual check on a real pad. docs/gameinput.md has the mapping, settings and VERIFY list. AI-assisted (Claude Code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
08ac01e to
71812aa
Compare
|
Thanks for the review. Pushed 71812aa, rebased on main at 67204bf. @ItsNotRexed: the build now downloads nothing unless asked, as you suggested:
@matheuskshn: @Derpbeat: thanks for the Windows 10 / MSVC 19.39 run and the careful read. I took both nits. Tested on Windows 11 26200, MSVC 19.44, Ninja, RelWithDebInfo:
AI-assisted (Claude Code). No controller, no game files. |
|
Tested 71812aa with a physical controller on Windows 11 Pro (10.0.26200), MSVC 19.51 (VS 2026 Build Tools), built with Controller: 8BitDo Ultimate 3-mode, 2.4 GHz dongle in Xbox mode. The shim enumerated it as Rumble, checked by hand with the step names on screen, the same on both commits:
That matches motors=0x3: over XInput this pad exposes only the two body motors, and the shim's trigger steps leave it alone. No game files. AI-assisted (Claude). |
|
Tested 71812aa on NVIDIA GeForce RTX 5070, driver 621.24, Windows 11 Pro (26300), VS 2022 Build Tools, Vulkan SDK 1.4.363.0, with
Implicit Vulkan layers (overlays) were off through an empty |
|
Thanks, both. @VeTkN: that's the real-pad run this PR was missing, and with VS 2026 and @quackottu: thanks for the RTX 5070 run with validation on. Your AI-assisted (Claude Code). |
- PE loader and import shims: the GameInput shim on SDL3 (#680) and gta6rt --trace-d3d12 (#701) are on main; neither was mentioned. - Xbox D3D12 -> Vulkan: 3D render targets and texture views, depth- and stencil-plane views, packed formats (B5G6R5, B4G4R4A4, R9G9B9E5), predication and CPU-side texture reads and writes are on main. The "not yet" list now also names placed resources and 1D textures, which are still missing. Each point checked against the code on main (b0befb4). (cherry picked from commit 4f5559d)
Item: RT: GameInput shim on SDL3 (new, claimed in #634).
The Xbox build reads controllers through GameInput. Nothing in the runtime covered input yet (#279 noted the host
GameInput.dllmight bind, but that is unverified and gives no DualSense features). This adds aGameInputCreateshim backed by SDL3 gamepads, so any controller SDL knows works as an Xbox pad would.What it does
runtime/shims/gameinput.cpp:GameInputCreate(registered undergameinput.dllandxgameruntime.dll) and the v0IGameInput/IGameInputDevice/IGameInputReading/IGameInputDispatchersurface a title uses for gamepads:UnregisterCallback,FindDeviceFromId, and a dispatcher (Dispatch,OpenWaitHandle)GetCurrentReading/GetNextReading,GetGamepadState(buttons, sticks, triggers),GetUiNavigationState, controller axes and buttons, batterySetRumbleState: body motors throughSDL_RumbleGamepad, impulse-trigger motors throughSDL_RumbleGamepadTriggers(Xbox pads)SDL_SendGamepadEffect, set byLEONIDA_DS_TRIGGERS=off|rumble|resistance(plusLEONIDA_DS_TRIGGER_GAIN,LEONIDA_DS_TRIGGER_FREQ). The docs say plainly that this approximates the Xbox impulse-trigger signal and is not the PS5 version's authored effects.SDL_SetGamepadLED(LEONIDA_DS_LIGHTBAR=RRGGBB|off), and player LEDs by connection order. I left gyro out.rt::gameinput::poll()withLEONIDA_GAMEINPUT_THREAD=0). Title calls only read snapshots or queue rumble requests.runtime/shims/gameinput_abi.h: Leonida's own declarations of the v0 ABI, written against Microsoft's public v0 GameInput header (NuGetMicrosoft.GameInput0.2303.22621.3038). That header is not committed. I compiled the struct offsets side by side with it (offsetofasserts for every field the shim fills) and they match.docs/gameinput.md: button mapping (positional: A = Cross / Switch B), rumble and trigger behaviour, DualSense effect bytes, environment variables, threading, the API coverage table, and the VERIFY list.SDL3 dependency
SDL3 is zlib-licensed. It is too big to copy in like
third_party/xtaskqueue, and the build downloads nothing unless asked. CMake builds the shim with an installed SDL3 (3.2+) thatfind_packagefinds.-DLEONIDA_SDL3_FETCH=ON(orscripts/build_runtime.ps1 -FetchSdl3) fetches the pinnedSDL3-3.4.20.tar.gzrelease (SHA-256 checked) and builds a static library with only the gamepad parts;-DFETCHCONTENT_SOURCE_DIR_SDL3=<dir>builds a local copy of that tarball without downloading. Without SDL3, or with-DLEONIDA_SDL3=OFF, configure prints a message,gta6rtbuilds without the shim as before, and CTest listsgameinputas not run (disabled).build_runtime.ps1's direct-cl.exefallback never builds the shim and warns about it. The whole block is insideif(WIN32), so the Linux CI is untouched.Tested
gameinput_test(new CTest, no controller): it turns SDL's real backends off and drives the shim throughrt::shims::findwith SDL virtual joysticks: an Xbox-style pad with trigger motors, a DualSense (054c:0ce6) and a pad without trigger motors. It covers enumeration, device/reading/guide callbacks, the button/stick/trigger/UI-navigation mapping, sequence numbers, motor and trigger rumble as SDL receives them, the DualSense effect bytes in each mode, the lightbar, the dispatcher, async and blocking enumeration, unregistering, and unplug/replug (same device object back). 77/77 checks pass.ctest, rebased on main at 67204bf: default configure (no SDL3 installed, no fetch) 29/29 pass withgameinputlisted as disabled, and nothing downloaded; with-DLEONIDA_SDL3_FETCH=ON30/30 pass.python -m compileall -q make_game.py tools testsis clean.build_runtime.ps1 -FetchSdl3. The pad was an 8BitDo Ultimate 3-mode in Xbox mode, enumerated as045e:02ffwith motors=0x3, player 1.gameinput_proberead both triggers 0..1, both sticks -1..+1, all face buttons, shoulders, stick clicks, Menu/View and the UI navigation state; the d-pad was read on 08ac01e. Both body motors rumble as expected, and the trigger steps correctly do nothing on a pad without trigger motors. Not yet tried on hardware: a DualSense (adaptive-trigger effects, lightbar) and Xbox impulse triggers.gameinput_probe --rumbleis the tool for that.d3d12_clear_testfailure is the same as on main and unrelated (Runtime: clears match WARP on every format class: tie rounding, and the SNORM/SINT/R8/R16 formats (D3D-45) #521).VERIFY
gameinput.dllandxgameruntime.dll. GameInput v1 and later changed the interfaces.GetNextReadingreturns the newest reading if it is newer than the reference, andGetPreviousReading/GetTemporalReadingfind nothing.UnregisterCallbacktimeout is not honoured. Every pad reports familyXboxOne.06(vibration) /01(resistance) parameter meanings follow SDL'stestcontroller.c; strength and frequency need tuning on a real pad.No game data, nothing online.
AI-assisted (Claude Code). Built and tested on Windows 11 26200, MSVC 19.44, RTX 4090 (the tests use no GPU), no controller attached here; real-pad results above are from @VeTkN.
🤖 Generated with Claude Code