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

Closed
opened 2026-11-26 20:19:41 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/944
Author: @DesertGamer
Created: 11/24/2026
Status: ❌ Closed

Base: main ← Head: feat/gameinput-button-hold


📝 Commits (2)

  • a5cc2af gameinput: LEONIDA_BUTTON_HOLD_MS keeps a pressed button reading as pressed
  • 003c7ec gameinput: a pressed button the title has not read stays pressed until it does

📊 Changes

3 files changed (+59 additions, -0 deletions)

View changed files

📝 runtime/shims/gameinput.cpp (+22 -0)
📝 runtime/shims/gameinput.h (+1 -0)
📝 runtime/test/gameinput_test.cpp (+36 -0)

📄 Description

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.)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/944 **Author:** [@DesertGamer](https://github.com/DesertGamer) **Created:** 11/24/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/gameinput-button-hold` --- ### 📝 Commits (2) - [`a5cc2af`](https://github.com/ubiquitarianism/leonida/commit/a5cc2af6b7bb087b51e968293a2f413de1cc94df) gameinput: LEONIDA_BUTTON_HOLD_MS keeps a pressed button reading as pressed - [`003c7ec`](https://github.com/ubiquitarianism/leonida/commit/003c7ec5d91007b2878abdc60d39f0e994affa14) gameinput: a pressed button the title has not read stays pressed until it does ### 📊 Changes **3 files changed** (+59 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `runtime/shims/gameinput.cpp` (+22 -0) 📝 `runtime/shims/gameinput.h` (+1 -0) 📝 `runtime/test/gameinput_test.cpp` (+36 -0) </details> ### 📄 Description 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.) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:19:41 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#982
No description provided.