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

Closed
github-bot wants to merge 2 commits from gh-pr/944/head into gh-pr/944/base
Owner

@⁠DesertGamer on GitHub · 2026-11-24 15:25 UTC · original
DesertGamer:feat/gameinput-button-hold → main · +59 −0 · 3 files · 2 commits · closed without merging

Claimed in the coordination issue as: RT-GAMEINPUT-BUTTON-HOLD (#14)

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.)
**@⁠DesertGamer** on GitHub · 2026-11-24 15:25 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/944) `DesertGamer:feat/gameinput-button-hold` → `main` · +59 −0 · 3 files · 2 commits · closed without merging Claimed in the coordination issue as: RT-GAMEINPUT-BUTTON-HOLD (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) **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.)
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 of 50 to 150 ms starts and ends between two reads and the title never sees it. Holding the button for about two seconds works. LEONIDA_AUTOPRESS has the same problem: it holds Enter for 250 ms.

LEONIDA_BUTTON_HOLD_MS (0 to 5000, default 0) keeps each gamepad button in the reading as pressed for at least that long after it was last seen pressed, in poll_once, for every pad. With the default of 0 nothing changes: the loop is skipped and every reading is built as before. The raw per-button array and the sticks and triggers are not touched.
LEONIDA_BUTTON_HOLD_MS used to keep a released button pressed for a fixed time. That turns a tap into a long press in the title's eyes. It is now the longest time a press the title has not yet read is kept: a rising edge is remembered, and GetGamepadState on a reading that holds that button clears it. A tap read 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 (0 to 5000, default 0, which changes nothing).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:29:42 +00:00
github-bot closed this pull request 2026-11-26 09:29:42 +00:00
Author
Owner

@⁠DesertGamer on GitHub · 2026-11-24 15:30 UTC · original

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.

**@⁠DesertGamer** on GitHub · 2026-11-24 15:30 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/944#issuecomment-7136156396) 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.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.