Skip to content

gameinput: preserve controller transitions between polls (OLD-9966, carries #233) - #1831

Open
potatoe0100 wants to merge 4 commits into
ProjectLeonida:mainfrom
potatoe0100:carry/old-9966
Open

potatoe0100 wants to merge 4 commits into
ProjectLeonida:mainfrom
potatoe0100:carry/old-9966

Conversation

@potatoe0100

@potatoe0100 potatoe0100 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: OLD-9966 (#1608 (comment))

What and why

Carries forward old-pr/9966 (draft #233) by @tedin7, rebased on main 0d80bc5df with the author's commit. A press and release that both land between two polls used to be lost, because each poll only compared the latest snapshot. Pads that were already open replay their SDL button and axis events in timestamp groups, publishing one reading per group, so the title sees each transition.

Rebase notes: runtime/shims/gameinput.cpp conflicted in poll_once(), where main added the LEONIDA_INPUT_LOG press log. The branch moves reading publication into publish_pad_sample(); the press log moved there with it (before last_snap is updated), so replayed transitions are logged too.

Supersedes draft #233 (its branch can be deleted once this lands).

Tested

VS 2022 (MSVC 19.44) RelWithDebInfo + Ninja with -DLEONIDA_SDL3_FETCH=ON (so gameinput and gameinput_script are built and run, not Disabled).

  • gameinput and gameinput_script pass.
  • Full ctest -j 6: 440 of 440 passed.

GPUs tested: NVIDIA GeForce RTX 4060, driver 621.14, Windows 11 Pro 26H2 (build 26300) (no GPU-specific code here)

AI-assisted: yes (Claude Code), by a non-developer tester.

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • 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. (n/a: no translator change)

🤖 Generated with Claude Code

@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 28, 2026
MoonEyes and others added 2 commits November 28, 2026 21:15
…-hardening

bcpack_tool: single-pass profile, history overwrite guard, and atomic output (BCPACK-TOOL-HARDENING)
…input_test.cpp)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@OreoFR

OreoFR commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Verified by OreoFR

Run 1 (nat04)

Run 2 (lot 4)

  • Base: main 09c153948 + PR head 9a96b8ba6 (tested at 9a96b8ba6, head is now 2f99fd2ca); integration package 2 of 6 (4 PRs, merged without conflict)
  • Test: full runtime build; ctest -j 6 without the 28 tests that launch gta6rt; the PRs' Python tests
  • Red on main: n/a (integration test; main baseline: xbox_present and d3d12_set_descriptor_heaps)
  • Green with the PR: ctest: only xbox_present and d3d12_set_descriptor_heaps fail, as on main
  • Verdict: CLEAN PACKAGE (no new failure vs main)

Run 3 (lot 4 bis)

  • Base: main 33db04a70 + PR head 9a96b8ba6 (tested at 9a96b8ba6, head is now 2f99fd2ca); integration package of 15 PRs
  • Test: full runtime build; ctest -j 6 without the 28 tests that launch gta6rt; the PRs' Python tests; translator suite
  • Red on main: n/a (integration test; main baseline: xbox_present, and flaky xmem)
  • Green with the PR: ctest: only xbox_present fails as on main (xs_proxy_mock failed once, flaky: passes on rerun and 5/5 direct runs); Python: same failures as main, the PRs' tests pass; translator: 507 files, 6405 tests, 0 failures
  • Verdict: CLEAN PACKAGE (no new failure vs main)

All runs

  • Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11

AI-assisted (Claude Code, Claude Opus 5.5).

@zmasi

zmasi commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Windows 11 Native Verification Report (2f99fd2cae merged onto origin/main adfb3821a2)

  • Merge Status: Clean merge onto origin/main (adfb3821a2) and clean 3-way runtime/shims/gameinput.cpp merge alongside #1790 and #1528.
  • Environment: Windows 11 (10.0.26200, x64), MSVC 19.44.35228, prebuilt SDL 3.4.20 (SDL3-static.lib), Python 3.12.10.

Diff Audit (3 files, +154/-66)

  • runtime/shims/gameinput.cpp:
    • After SDL_InitSubSystem(SDL_INIT_GAMEPAD) and SDL_SetGamepadEventsEnabled(false), re-enables SDL_EVENT_GAMEPAD_AXIS_MOTION, SDL_EVENT_GAMEPAD_BUTTON_DOWN, and SDL_EVENT_GAMEPAD_BUTTON_UP.
    • take_pad_events() flushes SDL_EVENT_JOYSTICK_AXIS_MOTION..SDL_EVENT_JOYSTICK_UPDATE_COMPLETE (0x600..0x608) and SDL_EVENT_GAMEPAD_ADDED..SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED (0x653..0x65B) before draining 0x650..0x652 with SDL_PeepEvents. Audited against SDL 3.4.20's SDL_gamepad.c and SDL_events.h: flushing 0x653..0x65B also drains SDL_EVENT_GAMEPAD_UPDATE_COMPLETE (0x65A) and SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED (0x65B), which SDL3 omits from SDL_SetGamepadEventsEnabled(false)'s SDL_gamepad_event_list, preventing unbounded accumulation toward SDL_MAX_QUEUED_EVENTS (65535).
    • replay_pad_events() groups intermediate samples per previously open pad by e.common.timestamp, publishes them to the reading history and reading/Guide callbacks, and preserves last_reading_us before replaying so the ~125 Hz idle motion_tick cadence on sensor-equipped pads remains unchanged.
  • runtime/test/gameinput_test.cpp & docs/gameinput.md: adds test_buffered_gamepad_input and documents intermediate SDL sample grouping.

Red -> Green Verification

  1. Red (origin/main adfb3821a2):
    • #1831's runtime/test/gameinput_test.cpp compiled against origin/main gameinput.cpp exited 1:
      • FAIL buffered input: history delivers both the short A/trigger press and its release
      • FAIL buffered input: two callbacks fire and the current reading stays released
  2. Green (#1831 + origin/main):
    • gameinput_test.exe (/O2 /MD /EHsc /W4 /permissive- /utf-8, SDL 3.4.20, 0 new warnings): 392 checks, 0 failures (4.20 s, rc=0), passing all three buffered input assertions.
    • Combined merge (#1790 + #1528 + #1831 + origin/main) gameinput_test.exe: 393 checks, 0 failures (4.06 s, rc=0).
    • Documentation gates: tests/test_docs_links.py, tests/test_docs_table_rows.py, and tests/test_docs_encoding.py all passed (OK, rc=0).

Verdict: PASS — ready to merge.

AI-assisted.

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.

6 participants