Skip to content

gameinput: GetCurrentReading with no device filters by the requested kind - #5019

Closed
tupacfan04 wants to merge 1 commit into
ItsNotRexed:mainfrom
tupacfan04:fix/gameinput-current-reading-kind
Closed

tupacfan04 wants to merge 1 commit into
ItsNotRexed:mainfrom
tupacfan04:fix/gameinput-current-reading-kind

Conversation

@tupacfan04

@tupacfan04 tupacfan04 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue: #4933 (comment)

Depends on: none. This shares the null-device loop with #4924 (which changes its tie-break to Reading::order()); whichever lands second rebases. #4553 already added the analogous supportedInput filter for reading callbacks, and this applies the same rule to GetCurrentReading.

What and why

IGameInput::GetCurrentReading(kind, nullptr, out) returned the newest reading from any connected device, even when that device cannot produce the requested kind. On a plain pad, GetCurrentReading(GameInputKindMotion, nullptr) returned S_OK with a gamepad reading. The explicit-device branch and the aggregate-device branch already return GAMEINPUT_E_READING_NOT_FOUND in that case.

The null-device branch now skips devices whose supportedInput does not intersect the requested kind. GameInputKindUnknown still means any kind, as in the other branches.

Tested

  • Windows 11 (10.0.26300), MSVC 19.51.36260, CMake/Ninja RelWithDebInfo, CPU-only SDL3 3.4.20 virtual joysticks. No GPU or driver used.
  • gameinput_test.exe: 332 checks, 0 failures (329 before the change, plus 3 new checks).
  • Negative control: the same test against origin/main 3faac55 with the old shim gives 332 checks, 2 failures - the two new null-device checks. The motion positive check passes on both.
  • ctest --test-dir runtime/build-gi -C RelWithDebInfo -R "^(gameinput|active_input)$" --repeat until-fail:5 --output-on-failure: 2/2 tests passed with 5 repeats each (10 runs).
  • git diff --check: clean.

AI-assisted: yes (OpenCode).

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (no translator change)

The null-device branch returned the newest reading from any connected device, even when that device cannot produce the requested kind. On a plain pad, GetCurrentReading(GameInputKindMotion, nullptr) returned S_OK with a gamepad reading, while the explicit-device and aggregate branches already return GAMEINPUT_E_READING_NOT_FOUND. Skip devices whose supportedInput does not intersect the requested kind; GameInputKindUnknown still means any.
@Atomic258

Copy link
Copy Markdown
Contributor

Independent check — pass on Windows.

Environment: Windows 11, MSVC 19.44 (RelWithDebInfo, Ninja), CPU only. Built gameinput_test with -DLEONIDA_SDL3_FETCH=ON (pinned SDL3, hash-checked, static) — SDL virtual joysticks, no real controller or game files.

  • PR head → 332 checks, 0 failures
  • Negative control: same binary against main's gameinput.cpp → 332 checks, 2 failures — GetCurrentReading with no device returns unfiltered readings on the parent; the head filters by the requested kind

Playability-relevant: games routinely call GetCurrentReading(null, kind, ...) to poll a specific input kind — unfiltered results would feed them wrong data.

AI-assisted (Devin).

@tupacfan04

Copy link
Copy Markdown
Contributor Author

Closing as a duplicate: #2612 already adds the same null-device \supportedInput\ filter and a \GetCurrentReading(GameInputKindMotion, nullptr) == GAMEINPUT_E_READING_NOT_FOUND\ regression. My claim missed that overlap; maintainers should not spend review time on a second implementation. The test/build evidence here (332 checks, 2 failures on main without the filter) still stands if a clean extraction is ever wanted.

@tupacfan04 tupacfan04 closed this Nov 23, 2026

@kacper-serewis kacper-serewis 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.

At 51b1a60 all 332 original checks passed. Combining the change with #4924, retaining both kind filtering and reading-order comparison, passed 337 checks. A separate virtual-device diagnostic found that before its first HID report a raw-capable pad can return S_OK for RawDeviceReport with the requested bit absent from the actual reading. This affects both null-device and explicit-device lookup. AI-assisted Windows CPU verification using SDL 3.4.20.

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.

3 participants