Skip to content

Give identical connected controllers distinct GameInput device IDs - #1054

Merged
ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
nschlaepfer:codex/identify-simultaneous-gamepads
Nov 22, 2026
Merged

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
nschlaepfer:codex/identify-simultaneous-gamepads

Conversation

@nschlaepfer

Copy link
Copy Markdown
Contributor

ASSET-68. On Windows, SDL enumerated two identical virtual controllers as distinct devices, but a lookup using the second controller’s application-local ID returned the first controller. This broke input routing for callers that saved the ID for player two. Coordination

The first controller retains its existing ID. Simultaneous controllers with the same reported identity now get separate IDs. Reconnecting one reuses its disconnected device object and ID. If multiple indistinguishable controllers disconnect, their reassignment follows arrival order because SDL supplies no distinguishing serial or path.

On native Windows 11 with SDL 3.4.20, the regression suite passed all 145 checks. Seven of those checks failed with the parent shim. The standalone two-controller probe also verified that each saved ID retrieved its own device and that player two’s button arrived through the second device. The suite covers a third controller, reconnects and the existing keyboard controller. This CPU input test used synthetic controllers.

AI-assisted implementation and review.

@whattheflop

Copy link
Copy Markdown
Contributor

Independent Windows test (AI-assisted) for 9eaf37e96f362d39ddb5a96e6660b37972839153. Windows 11 Pro x64 (build 26200.9974), VS 2022 MSVC 19.38.33145.0, Windows SDK 10.0.26100.0, CMake 4.4.4 / Ninja 1.13.2, and SDL 3.4.20 from the repo's SHA-256-pinned fetch.

  • Stock PR gameinput_test: 145 checks, 0 failures on each of two runs. Two and three identical virtual pads got their expected distinct IDs, the first retained its legacy ID, and lookup routed the second ID to the second pad's input. Reconnecting one, two, or all three reused the expected objects and IDs in arrival order.
  • Parent 43d470316ec6cbcd64002bc3792998d9f5745dac: its own stock fixture passed 131 checks with 0 failures. The unmodified PR fixture with the parent shim produced 7 failures in 145 checks, all in the identical-pad cases.

Only the stock synthetic test was run. Physical hardware (including startup enumeration order and physical rumble/lightbar behavior), GPU behavior, and game integration were outside this run.

@kapitche

Copy link
Copy Markdown
Contributor

Tested 9eaf37e on Windows 11, MSVC 14.51: pass

  • Without SDL3 installed, gameinput_test isn't built at all, so a plain ctest (47/47 here) says nothing about this change. I configured with -DLEONIDA_SDL3_FETCH=ON so the shim and its test build.
  • gameinput_test: all PASS, including the new twins: two identical pads are two device objects and twins: the device found from the second id reads the second pad. The existing connect/disconnect/history/keyboard-pad cases are unchanged.
  • Negative control: with runtime/shims/gameinput.cpp from main, exactly the two twin checks fail (the second gets twin id 1, same GUID bytes, different from the first and FindDeviceFromId returns each twin for its own id).

For other testers: this needs SDL3, so either set SDL3_DIR or pass -DLEONIDA_SDL3_FETCH=ON.

@quackottu quackottu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested 9eaf37e on NVIDIA GeForce RTX 5070, driver 621.24, Windows 11 Pro (26300), VS 2022 Build Tools, Vulkan SDK 1.4.363.0, with LEONIDA_VK_VALIDATION=1: builds with no regressions, but gameinput_test did not run.

  • ctest: 47/47 pass. My build has no SDL3, so gameinput_test is disabled and this run does not cover the change itself.
  • The other test programs give the same results as main (d3d12_clear_test NVIDIA tie rounding; the 3 VUID-...-01387 that #1027 fixes; vk_binary_occlusion_test needs an input file).

@ItsNotRexed
ItsNotRexed merged commit 78f80b7 into ItsNotRexed:main Nov 22, 2026
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants