WIP: gameinput: a pressed button the title has not read stays pressed until it does (RT-GAMEINPUT-BUTTON-HOLD) #944

Closed
leonida/mandy
DesertGamer wants to merge 0 commits from feat/gameinput-button-hold into main

Pull request closed

This pull request cannot be reopened because the branch was deleted.

DesertGamer commented 2026-11-24 15:25:53 +00:00

Claimed in the coordination issue as: RT-GAMEINPUT-BUTTON-HOLD (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135924581)

Draft until it has been tried with a real pad against the game. The first version of this pull request held a released button as pressed for a fixed time, which turns a tap into a long press in the title's eyes and breaks anything that tells the two apart (auto-repeat in menus, hold-to-confirm, double-tap). That version is replaced by the second commit below; this text describes the current code.

What and why

The title reads input with GetCurrentReading, which returns the newest state. On the retail boot it runs at about one frame a second, so a normal tap (50 to 150 ms) starts and ends between two reads and the title never sees it. Holding the button for about two seconds works; I saw that by hand on an RTX 5070 (a held A moves the first-run screen on, a tap mostly does not). It was not a timed measurement. LEONIDA_AUTOPRESS has the same problem, since it holds Enter for 250 ms.

LEONIDA_BUTTON_HOLD_MS (0 to 5000, default 0) is the longest time a press the title has not read yet is kept. A rising edge of a gamepad button is remembered; GetGamepadState on a reading that holds that button clears it. So:

  • a tap the title reads in time, or a press that is held while the title reads it, is released exactly when the player releases it;
  • only a press that falls between two reads is stretched, and no longer than the value;
  • with the default of 0 the whole block in poll_once is skipped and every reading is built as before. The one change that is always there is an atomic fetch_and on a per-device field in GetGamepadState, which leaves that field at 0 when the setting is off.

The raw per-button array, the sticks and the triggers are not touched, and neither is the UI navigation state: it is derived from the buttons inside read_pad, before this change, so a stretched press shows in GetGamepadState but not as GameInputUiNavigationAccept. If the title reads menus through the UI navigation state, this change does not help it; I have not checked which of the two the first-run screen uses. Only GetGamepadState counts as a read; readings taken through other calls (for example GetRawReport or the raw button array) do not clear a pending press, so such a press is kept for the full value. The variable is not documented in docs/gameinput.md here; the line belongs next to the other LEONIDA_* switches there.

The claim comment above says the by-hand observation was "measured"; it was not, and the claim comment cannot be edited without voiding it, so this text is the correction.

Tested

ctest -R "gameinput|active_input" (gameinput, gameinput_host, active_input): 3 of 3 pass, MSVC + Ninja, Windows 11, SDL3 3.4.20 built from source. gameinput_test has eight new checks: the value clamps to 5000, 300 is read, an unread tap still reads as pressed, it is released once read, a press read while held, a press already read is not stretched after release, an unread tap is released after the time, and with the variable unset a released button reads as released at once. With the read-clearing line made a no-op, "once the title has read it, it is released" and "a press already read is not stretched" fail; restored, all pass. Not run: the rest of the runtime tests, a real pad, and the game with this change.

GPUs tested: n/a (no GPU involved; the test uses SDL virtual pads and a fake keyboard source)

AI-assisted: yes (Claude Code, Sonnet 5.5)

Checklist

  • Based on current main (a28927849) 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. (Not applicable: no translator rule.)
Claimed in the coordination issue as: RT-GAMEINPUT-BUTTON-HOLD (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135924581) **Draft until it has been tried with a real pad against the game.** The first version of this pull request held a released button as pressed for a fixed time, which turns a tap into a long press in the title's eyes and breaks anything that tells the two apart (auto-repeat in menus, hold-to-confirm, double-tap). That version is replaced by the second commit below; this text describes the current code. ### What and why The title reads input with `GetCurrentReading`, which returns the newest state. On the retail boot it runs at about one frame a second, so a normal tap (50 to 150 ms) starts and ends between two reads and the title never sees it. Holding the button for about two seconds works; I saw that by hand on an RTX 5070 (a held A moves the first-run screen on, a tap mostly does not). It was not a timed measurement. `LEONIDA_AUTOPRESS` has the same problem, since it holds Enter for 250 ms. `LEONIDA_BUTTON_HOLD_MS` (0 to 5000, default 0) is the longest time a press the title has not read yet is kept. A rising edge of a gamepad button is remembered; `GetGamepadState` on a reading that holds that button clears it. So: - a tap the title reads in time, or a press that is held while the title reads it, is released exactly when the player releases it; - only a press that falls between two reads is stretched, and no longer than the value; - with the default of 0 the whole block in `poll_once` is skipped and every reading is built as before. The one change that is always there is an atomic `fetch_and` on a per-device field in `GetGamepadState`, which leaves that field at 0 when the setting is off. The raw per-button array, the sticks and the triggers are not touched, and neither is the UI navigation state: it is derived from the buttons inside `read_pad`, before this change, so a stretched press shows in `GetGamepadState` but not as `GameInputUiNavigationAccept`. If the title reads menus through the UI navigation state, this change does not help it; I have not checked which of the two the first-run screen uses. Only `GetGamepadState` counts as a read; readings taken through other calls (for example `GetRawReport` or the raw button array) do not clear a pending press, so such a press is kept for the full value. The variable is not documented in `docs/gameinput.md` here; the line belongs next to the other `LEONIDA_*` switches there. The claim comment above says the by-hand observation was "measured"; it was not, and the claim comment cannot be edited without voiding it, so this text is the correction. ### Tested `ctest -R "gameinput|active_input"` (`gameinput`, `gameinput_host`, `active_input`): 3 of 3 pass, MSVC + Ninja, Windows 11, SDL3 3.4.20 built from source. `gameinput_test` has eight new checks: the value clamps to 5000, 300 is read, an unread tap still reads as pressed, it is released once read, a press read while held, a press already read is not stretched after release, an unread tap is released after the time, and with the variable unset a released button reads as released at once. With the read-clearing line made a no-op, "once the title has read it, it is released" and "a press already read is not stretched" fail; restored, all pass. Not run: the rest of the runtime tests, a real pad, and the game with this change. GPUs tested: n/a (no GPU involved; the test uses SDL virtual pads and a fake keyboard source) AI-assisted: yes (Claude Code, Sonnet 5.5) ### Checklist - [x] Based on current `main` (`a28927849`) and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (Not applicable: no translator rule.)
DesertGamer commented 2026-11-24 15:30:53 +00:00

Closing this: the behaviour it adds (a button the title has not read stays pressed) changes what the title sees from a pad, and I have not shown it is safe for anything but this one first-run screen. It stays a local aid on my machine and is not proposed for the repository. Nothing else depends on it.

Closing this: the behaviour it adds (a button the title has not read stays pressed) changes what the title sees from a pad, and I have not shown it is safe for anything but this one first-run screen. It stays a local aid on my machine and is not proposed for the repository. Nothing else depends on it.
Sign in to join this conversation.
No description provided.