Skip to content

feat(input): hold-to-toggle for any bound button - #2886

Open
simonwjackson wants to merge 1 commit into
NotRexed:mainfrom
simonwjackson:feat-input-hold-to-toggle
Open

simonwjackson wants to merge 1 commit into
NotRexed:mainfrom
simonwjackson:feat-input-hold-to-toggle

Conversation

@simonwjackson

Copy link
Copy Markdown
Contributor

Players who cannot keep a button held need another way to shield, target or aim. This adds an opt-in press-once, press-again alternative for any bound button (Game Accessibility Guidelines, motor: avoid holding buttons; Xbox Accessibility Guideline 107).

What changed

  • A Toggle cell for each Switch button on Insert → Controls. Every flag is Off by default and is saved beside the button's bindings.
  • Either gamepad binding or a bound key works the same latch. A press that is still held does not toggle again.
  • Opening Insert, losing focus, rebinding, Reset to defaults and the pause and map buttons clear latches. Presses inside the Insert menu never latch.
  • The Windows and SDL display paths are kept in step. Stick directions and the ocarina-note-only rows get no flag.
  • The mask of enabled buttons travels through the existing option callback (option 54). Neither MkwVkHost nor MkwVkRenderer changes, and MKWVK_API_VERSION is not bumped; an older renderer answers an unknown option with zero, which leaves the feature Off.

Controls page: ZL's Toggle cell On, with both gamepad bindings and the key binding

Run in the game

RX 7900 XT, RADV (Mesa 26.2.3), Ryzen 5 7600X, 32 GB, NixOS 26.11 / Linux 7.2.7, headless Sway 1.12 + Xwayland, 1920x1080 window, compute mesh path, udmabuf on, audio off, copied saves. Hyrule Castle Town (Market_Child), indoors by the wooden door. 8 min 38 s, ended cleanly through the control socket, no GPU hang or device-lost line.

ZL's flag was changed on the Controls page, and presses were sent through the control socket (#926):

Flag Input Result
On one press, 120 presents long shield raised, and still raised after the input queue was empty
On a second press shield lowered
Off the same 120-present press shield lowered when the press ended, as today
On, latched open Insert latch cleared

After the first press ended (queue empty at present 15,956; the press was queued at 15,750), the shield stays up:

Shield still raised after the press ended

After the second press:

Shield back on Link's back after the second press

More frames: On while pressed, Off while pressed, Off after release, released after opening Insert.

Game fps from the log's N presents, X fps lines, three 45-second samples standing still with no button held:

Flag Log samples Median fps
Off 21 56.70
On 22 56.85
Off again 21 56.90

No measurable cost in this scene. Both runs are in docs/tested-configurations.md, including an earlier start that ended before gameplay because shader preparation had not finished.

The run used 3b3da943 on main dae19300 (build pr-hold-3b3da943daa1, source 8fa27ae9). The branch was then rebased onto newer main, squashed to one commit, and the option ID moved from 53 to 54 to stay clear of #2860; it was not run in the game again after that.

Checks

Limits and not tested

  • Long binding names are cut off on the Controls page (example); the Toggle column takes some of their width, and this PR does not fix it.
  • The new help text has no translations yet and shows the English fallback.
  • Not run in the game: Windows, a physical controller, other actions than the shield.

Let either gamepad binding or a bound key latch a Switch button until the next press. Keep every flag Off by default, and release latches on menu, focus and binding changes. Carry the enabled-button mask through the existing option callback (option 54); neither API struct changes.

Assisted-by: OpenAI GPT-6 Astra
Co-Authored-By: OpenAI GPT-6 Astra <noreply@openai.com>
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.

1 participant