mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:40:52 +01:00
[PR #944] [CLOSED] gameinput: a pressed button the title has not read stays pressed until it does (RT-GAMEINPUT-BUTTON-HOLD) #982
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#982
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 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)
a5cc2afgameinput: LEONIDA_BUTTON_HOLD_MS keeps a pressed button reading as pressed003c7ecgameinput: 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_AUTOPRESShas 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;GetGamepadStateon a reading that holds that button clears it. So:poll_onceis skipped and every reading is built as before. The one change that is always there is an atomicfetch_andon a per-device field inGetGamepadState, 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 inGetGamepadStatebut not asGameInputUiNavigationAccept. 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. OnlyGetGamepadStatecounts as a read; readings taken through other calls (for exampleGetRawReportor 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 indocs/gameinput.mdhere; the line belongs next to the otherLEONIDA_*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_testhas 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
main(a28927849) and merges cleanly (a conflicting pull request is labeledneeds rebase).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.