Skip to content

hle: Decouple in-game actions from menu button rebinds (Fixes #608) - #642

Closed
jfpaardoo wants to merge 1 commit into
Revivedx:testfrom
jfpaardoo:fix/attack-sort-key-binding
Closed

jfpaardoo wants to merge 1 commit into
Revivedx:testfrom
jfpaardoo:fix/attack-sort-key-binding

Conversation

@jfpaardoo

Copy link
Copy Markdown
Contributor

What this changes

Fixes #608.

In the Controls / Key bindings settings page, the raw Switch buttons (A, B, X, Y) are listed under the Menus section as "Menu: confirm", "Menu: back", "Menu: Hero's Path", and "Menu: sort / sensor" ("what no action covers: the game's menus and quick menus").

However, when an action is at factory defaults (such as Attack #3 at Mouse Left / West), rt_act_query yields -1 to let the game query its native Switch pad layer. In gameplay (!in_menu), the native Switch layer was reading key_buttons and pad_buttons mapped directly to g_bind_key / g_bind_pad. If a player rebound "Menu: sort / sensor" to a key (such as Y or Alt), BIND_Y was set by that key in gameplay instead of Attack's binding (Mouse Left), causing Link to attack with the menu key while Left Click stopped attacking.

This change:

  1. Adds route_gameplay_buttons() in runtime/hle/input.c to decouple in-game action buttons (Y, X, A, B) during gameplay from menu-only rebinds.
  2. During gameplay (!in_menu), buttons Y, X, A, and B strictly follow their bound game actions (Attack, Jump, Interact, Sprint/Cancel).
  3. Inside menus (in_menu), buttons follow their respective menu rebinds (Menu: sort / sensor, Hero's Path, confirm, back).
  4. Adds an automated test assertion in tests/test_pc_controls.c validating that rebinding g_bind_key[BIND_Y] to SDL_SCANCODE_Y does not trigger Attack during gameplay, while Mouse Left continues to attack.

How it was tested

  • OS / Environment: Windows 11, MSYS2 UCRT64 (Clang 19).
  • Unit & Subsystem Tests:
    • make test-actions: 100% PASS (validating action hook, queries, fallback, and schema migrations).
    • make test-pc-controls: 100% PASS (including new automated regression test for Attack Button Incorrectly Follows Sort/Sensor Key Binding #608).
    • make runtime-objs: 100% PASS cleanly without warnings or errors.
    • python3 tools/i18n_check.py: 100% PASS (translation integrity confirmed).
    • git diff --check: 100% PASS.

Checklist

  • Based on the latest test and opened against test
  • Built and run locally, and checked in the game
  • No game files, keys, firmware, generated game code or save files in the changes

Copilot AI balanced review requested due to automatic review settings November 9, 2026 18:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Revivedx added a commit that referenced this pull request Nov 12, 2026
…links, hybrid CPUs, refresh rate, haze, taller windows, horse keyboard

- Water: a barrier after a new colour image's clear, before its uploads (PR #756, fixes #649).
- Vibration: SDL_RumbleGamepad on a worker thread, so Bluetooth controllers no longer stall input (PR #757, fixes #730).
- Launcher: folder picker errors are shown, and the game folder path can be typed (PR #758, fixes #724).
- Vulkan: pipelines that can't be skipped are linked inline, and build jobs are drained during stalls (PR #651, fixes #591).
- Windows: every logical processor is kept on hybrid CPUs, and critical threads get a higher priority (PR #650, fixes #639).
- Window: the monitor's real refresh rate is detected, and higher-Hz display modes are picked (PR #641, fixes #623).
- Video > Haze: 75 % or more (PR #601).
- Taller windows: HUD, menus and map layouts on 16:10 and other tall views (PR #720). Conflict with vdyn_reset resolved.
- Keyboard on horseback: forward is ignored while steering, and the horse camera site comes from game_sites.py (PR #343,
  fixes #290). Conflicts resolved; the input focus test keeps a single photo_pad stub.

Not included: PR #642 (#608). In play it cleared A/B/X/Y unless an action held them, so scripted and console buttons
stopped reaching the game (test-input-focus).

Checked: game code regenerated (169 sites), game sites, layout codegen, i18n, launch flags, input focus, PC controls,
GPU settings and vibration tests; a hidden run in the Lanayru rain; and a visible playtest from a 100% save.

Co-authored-by: jfpaardoo <juaparpar@alum.us.es>
Co-authored-by: devall96 <devall96@proton.me>
Co-authored-by: sabeliam <50827860+sabeliam@users.noreply.github.com>
Co-authored-by: rvsting <347107652+rvsting@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Revivedx

Revivedx commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

Thanks for this. We didn't take it into today's batch, because route_gameplay_buttons breaks other input during play.

In play it clears A/B/X/Y unless an action holds them. That also drops the buttons that don't come from a host binding:

  • the control endpoint and console (script_buttons);
  • scripted test input;
  • buttons the game itself injects.

tools/test_input_focus.c catches it: a scripted A press comes out as 0x960300 instead of 0x960301.

The fix also hardcodes which action goes to which Switch button (Attack/Spin to Y, Jump to X, Interact to A, Sprint/Cancel to B). The game already answers factory-default actions from those raw bits.

#648 goes at the root of #608: the "Menu: ..." rows stop reaching play. That is the direction we'd like. If you want to keep this PR going, it would need to:

  • leave non-host buttons (script, control, injected) untouched;
  • only stop a menu-row rebind from moving the action bits;
  • pass make test-input-focus.

@jfpaardoo
jfpaardoo force-pushed the fix/attack-sort-key-binding branch from e0ab595 to 14506e7 Compare November 13, 2026 12:24
@jfpaardoo

Copy link
Copy Markdown
Contributor Author

Updated: \�ct_gameplay_buttons\ now lives in
untime/hle/bindings.c\ and only rewrites the raw \key_buttons | pad_buttons\ A/B/X/Y bits during gameplay, leaving \script_buttons, console inputs (\control_input_apply), \�ow, \escape_buttons, \�uto_continue_buttons, and \pc_cursor_buttons\ untouched. Verified with \make test-input-focus, \make test-pc-controls, \make test-actions, and \make runtime-objs.

Revivedx added a commit that referenced this pull request Nov 13, 2026
- Controls: rebinding a "Menu: ..." row no longer moves the gameplay A/B/X/Y buttons. In play, those four come from
  the action bindings (Attack, Jump, Interact, Sprint/Cancel); script, console, cursor and auto-continue buttons are
  left untouched (PR #642, fixes #608).
- Output scale: near-16:9 integer sizes like 1366x768 render 1:1 instead of 1365 px wide with a sub-pixel offset,
  which made them blurrier than 1280x720 (PR #802, fixes #770).

Checked: output scale, PC controls, input focus and action tests; a hidden 1366x768 run; a visible playtest from a
100% save.

Co-authored-by: jfpaardoo <juaparpar@alum.us.es>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Revivedx

Copy link
Copy Markdown
Owner

Thanks for the update, this version addresses what we asked: script, console, cursor and auto-continue buttons are untouched now, and test-input-focus, test-pc-controls and test-actions pass. It also passed a visible playtest on a 100% save. It's in test now (086bc68) and ships with the next release. Closing here since it landed as a clean commit.

@Revivedx Revivedx closed this Nov 13, 2026
Fayberr added a commit to Fayberr/SavageWindRecomp that referenced this pull request Nov 14, 2026
Upstream's Revivedx#642 fix (act_gameplay_buttons, which rewrote only A/B/X/Y) goes
away: this branch replaces it at the root with act_play_keys / act_play_pads,
which cover every raw action button. Keep upstream's act_refresh calls, the
moved act_switch_button, and the pc_cursor_active gate in input_buttons_now.
Revivedx added a commit that referenced this pull request Nov 15, 2026
…links, hybrid CPUs, refresh rate, haze, taller windows, horse keyboard

- Water: a barrier after a new colour image's clear, before its uploads (PR #756, fixes #649).
- Vibration: SDL_RumbleGamepad on a worker thread, so Bluetooth controllers no longer stall input (PR #757, fixes #730).
- Launcher: folder picker errors are shown, and the game folder path can be typed (PR #758, fixes #724).
- Vulkan: pipelines that can't be skipped are linked inline, and build jobs are drained during stalls (PR #651, fixes #591).
- Windows: every logical processor is kept on hybrid CPUs, and critical threads get a higher priority (PR #650, fixes #639).
- Window: the monitor's real refresh rate is detected, and higher-Hz display modes are picked (PR #641, fixes #623).
- Video > Haze: 75 % or more (PR #601).
- Taller windows: HUD, menus and map layouts on 16:10 and other tall views (PR #720). Conflict with vdyn_reset resolved.
- Keyboard on horseback: forward is ignored while steering, and the horse camera site comes from game_sites.py (PR #343,
  fixes #290). Conflicts resolved; the input focus test keeps a single photo_pad stub.

Not included: PR #642 (#608). In play it cleared A/B/X/Y unless an action held them, so scripted and console buttons
stopped reaching the game (test-input-focus).

Checked: game code regenerated (169 sites), game sites, layout codegen, i18n, launch flags, input focus, PC controls,
GPU settings and vibration tests; a hidden run in the Lanayru rain; and a visible playtest from a 100% save.

Co-authored-by: jfpaardoo <juaparpar@alum.us.es>
Co-authored-by: devall96 <devall96@proton.me>
Co-authored-by: sabeliam <50827860+sabeliam@users.noreply.github.com>
Co-authored-by: rvsting <347107652+rvsting@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Revivedx added a commit that referenced this pull request Nov 15, 2026
- Controls: rebinding a "Menu: ..." row no longer moves the gameplay A/B/X/Y buttons. In play, those four come from
  the action bindings (Attack, Jump, Interact, Sprint/Cancel); script, console, cursor and auto-continue buttons are
  left untouched (PR #642, fixes #608).
- Output scale: near-16:9 integer sizes like 1366x768 render 1:1 instead of 1365 px wide with a sub-pixel offset,
  which made them blurrier than 1280x720 (PR #802, fixes #770).

Checked: output scale, PC controls, input focus and action tests; a hidden 1366x768 run; a visible playtest from a
100% save.

Co-authored-by: jfpaardoo <juaparpar@alum.us.es>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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.

3 participants