WIP: fix(input): the mouse's side buttons stay their controls' in the game's menus #1329

Draft
cuecuemoar wants to merge 3 commits from cuecuemoar/Longshot:fix/side-buttons-in-game-menus into main
Contributor

Type: fix · Risk: low · Tested on: Windows 10, RTX 4090 · Needs: none

Why

With A bound to a mouse side button (Mouse 4), ordinary dialogue advances but a choice in the text box, such as Navi's "Sleep until morning" at a bed, can't be confirmed: the button does nothing there. A keyboard key on A works. Fixes #1306.

How to reproduce

Seen on: Windows 10 22H2, RTX 4090, NVIDIA 617.42 (the report: Windows 11, RTX 4090, v3.0.0-rc.5)
Settings and switches: A on Mouse 4 (Insert menu, Controls; key_a=69,5), Mouse camera on (As the stick or Native)
Steps: with the mouse captured, open a choice of the text box (the report: any bed, Navi's sleep choice) and press Mouse 4
Expected: the focused choice is confirmed, as with the key on A
Actual: on main nothing happens

What changed

On Windows each of the game's own menus takes the mouse from the camera (host/oot_menu.c, host/display.c): the capture ends and the cursor is that menu's. The left, right and middle buttons are its clicks there. A bound mouse button counted as its control only while the mouse was captured (host/nn_hid.c), so in a menu the two side buttons reached neither the menu nor their controls. Now they stay their controls' while one of the game's menus has the mouse, as a key does.

  • The window (host/display.c): menus_mouse, the one place the two menus' states change, records whether a game menu has the mouse with the Insert menu closed; hos_mouse_in_game_menu gives it to the game's thread (a volatile LONG, as the capture's own flag).
  • The mouse's buttons (host/nn_hid.c): mouse_buttons_arm(captured, menu) arms the side buttons also while a game menu has the mouse; read_input asks the window, not with Mouse camera Off, and reads the bound mouse buttons then too. The arming rule is the same as for a capture: a side button held as the menu opens with the mouse free counts only after it was let go; one held from play into the menu, or back, stays one press.
  • Unchanged: the left, right and middle buttons in a menu are its clicks, never their controls (the open question of #85 is left alone); with the Insert menu open nothing counts; with the mouse free in play (Esc) no mouse button counts; Mouse camera Off never makes a mouse button a control.
  • Linux (host/posix/display_sdl.c): its window does not hand the mouse to the game's menus, so the capture and the buttons stay the game's there; hos_mouse_in_game_menu returns 0 and nothing changes. (#1172 is the side buttons being readable on Linux at all.)
  • The checks: a menu-side-buttons case in tests/test_input_background.py, through the real read_input, and the new tests/test_game_menu_mouse_buttons.py, which runs menus_mouse (both in their own commit before the fix); tests/test_bound_keys.py checks the arming with the new argument; tests/display_pointer_test.cpp, which compiles menus_mouse, gets the new flag and two checks of it.
  • Docs: the README's line on mouse buttons as keys.
  • Runs: docs/tested/2026-11-16-side-buttons-menus-cuecuemoar-run01.md and run02.

This touches the same lines of host/nn_hid.c as #1257 (a mouse button held when a menu takes the mouse); whichever lands second needs a small rebase, and the two rules compose.

Measurements

Verdict: fixed: Mouse 4 on A confirms the choice with this change and does not on main (by hand, a real mouse); the game-free check fails on main and passes here. Nothing to measure for speed: one flag read and a few integer operations per input read.

Hardware: Windows 10 Pro 22H2 (19045), RTX 4090 24 GB, NVIDIA 617.42, Core i9-13900K, 32 GB
Scene: a copied save, a choice of the text box
Method: by hand with a mouse that has side buttons, A on E and Mouse 4 in both builds (the control bridge's presses do not go through the mouse's buttons)
How to reproduce: as in How to reproduce

Before: main @ e090cc48 After: this PR @ b59bcab3 (the code of b81f4cfa, which adds only a test fixture's lines)
Mouse 4 on a choice of the text box (by hand) does not confirm confirms
tests/test_input_background.py --case menu-side-buttons (main @ 6d72ca93 with the test commit 9caabea7; this PR @ b81f4cfa) FAIL PASS
tests/test_game_menu_mouse_buttons.py (the same commits) stops: main has no such state to cut PASS

Baseline: main e090cc48 is the dev_packs.py base on this PC; the fix's build is main 6d72ca93 plus this change, as a pack over it. mouse_buttons_arm, bound_down and menus_mouse are the same on e090cc48 and 6d72ca93.

main @ 6d72ca93 + 9caabea7 (the tests alone):
tests/test_input_background.py --case menu-side-buttons
FAIL:148 G64(address + 8) == buttons        (the packet after Mouse 4 is pressed in the menu: A expected, none read)
tests/test_game_menu_mouse_buttons.py
srccut: 'static volatile LONG game_menu_mouse;' is not in host/display.c (cut by tests/test_game_menu_mouse_buttons.py) (renamed or reshaped? update the check with the source)

this PR @ b81f4cfa:
PASS: the mouse's side buttons stay their controls' while one of the game's menus has the mouse
PASS

Flags and settings

None.

Testing

Tested:

  • By hand (cuecuemoar; Windows 10 22H2, RTX 4090, a mouse with side buttons): main does not confirm a choice of the text box with Mouse 4 on A; the fix's build does.
  • The checks against broken fixes, each failing: the flag never set, the flag set under the Insert menu too, only Mouse 5 let through, every mouse button let through (two checks), Mouse camera Off let through, and read_input not reading the buttons in a menu.
  • The checks that read host/nn_hid.c, host/display.c, host/posix/display_sdl.c or the README: they pass but for the ones that fail on main too (below). tests/test_display_pointer.py compiles menus_mouse and failed on the first version of the fix for want of the new flag: its fixture is updated in the fix commit.
  • host/nn_hid.c and host/display.c compiled whole for Windows in the pack's build (llvm-mingw, no warning: in its log).
  • python -I -B tests/run_all.py on Linux (WSL, Ubuntu 22.04), main @ 6d72ca93 and this branch at the same commit, run side by side: main 563 passed, 49 failed, 108 skipped; the branch before the fixture update 563 passed, 50 failed, 108 skipped, the one more being tests/test_display_pointer.py, which passes since. The 49 are the same checks on both (this WSL machine has no clang, Vulkan headers or some Python modules); among them, of the checks that read the changed files: test_crash_record, test_display_startup_failure, test_hud_layout_row, test_longshot_saves, test_tested_configurations (another PR's file with two rows), test_walk_key.

Not tested:

  • Linux: not built here (the lift's headers are needed to compile host/); the change there is one function that returns 0, and host/nn_hid.c's changed functions are compiled with gcc on Linux by the checks.
  • By hand: the pause menu, the title's lists and the other menus of the game with a side button (the same rule and code path as the text box's choices); Mouse 5; a side button held as a menu opens or closes (the check's cases); Mouse camera Native and Off (the run was As the stick).
  • The reporter's note that a left click on the choice did nothing either: not looked at here (the left button's rule is unchanged; #85).
  • The Test Farm: its input goes through the bridge, not the mouse.

Must be tested:

  • None.

Risks

What could break: a control bound to a side button now acts in the game's menus where it did nothing before: with B or Plus on one, it backs out of or closes the menu there, as its key would.

Turning it off: revert the commit.

Compatibility: Nothing changes: no save, option, cache or interface is touched (gpu/vk/vk_api.h is not).

Issues

Fixes #1306

Checklist

Everyone

  • One topic.
  • The title is a Conventional Commit (type(scope): description) of the status line's type.
  • Why gives the reason plainly and links the issues that fit (the tracker searched).
  • Measurements has a verdict, or one line saying why there is nothing to measure.
  • Testing names what was tested, what wasn't, and what must still be tested, where and how.
  • Rebased on current main.
  • python -I -B tests/run_all.py passes (any failure that also fails on main is named).
  • No game files, dumps, build output or generated files.
  • third_party/ untouched (a new folder with a PROVENANCE.md instead).
  • The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled.

When it applies

  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.
  • A file in docs/tested/ for each new measured run (format in docs/tested-configurations.md).
  • A game-free test added for the fix, failing on main and passing here.
  • A check under tests/ that reads changed source updated in this PR, not weakened.
  • Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths. (Windows built; Linux not built here, see Not tested.)
  • Docs updated.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VxeaZkuxWxPjY31qDxgN1k

**Type:** fix · **Risk:** low · **Tested on:** Windows 10, RTX 4090 · **Needs:** none ## Why With A bound to a mouse side button (Mouse 4), ordinary dialogue advances but a choice in the text box, such as Navi's "Sleep until morning" at a bed, can't be confirmed: the button does nothing there. A keyboard key on A works. Fixes #1306. ## How to reproduce **Seen on:** Windows 10 22H2, RTX 4090, NVIDIA 617.42 (the report: Windows 11, RTX 4090, v3.0.0-rc.5) **Settings and switches:** A on Mouse 4 (Insert menu, Controls; `key_a=69,5`), Mouse camera on (As the stick or Native) **Steps:** with the mouse captured, open a choice of the text box (the report: any bed, Navi's sleep choice) and press Mouse 4 **Expected:** the focused choice is confirmed, as with the key on A **Actual:** on main nothing happens ## What changed On Windows each of the game's own menus takes the mouse from the camera (`host/oot_menu.c`, `host/display.c`): the capture ends and the cursor is that menu's. The left, right and middle buttons are its clicks there. A bound mouse button counted as its control only while the mouse was captured (`host/nn_hid.c`), so in a menu the two side buttons reached neither the menu nor their controls. Now they stay their controls' while one of the game's menus has the mouse, as a key does. - **The window** (`host/display.c`): `menus_mouse`, the one place the two menus' states change, records whether a game menu has the mouse with the Insert menu closed; `hos_mouse_in_game_menu` gives it to the game's thread (a `volatile LONG`, as the capture's own flag). - **The mouse's buttons** (`host/nn_hid.c`): `mouse_buttons_arm(captured, menu)` arms the side buttons also while a game menu has the mouse; `read_input` asks the window, not with Mouse camera Off, and reads the bound mouse buttons then too. The arming rule is the same as for a capture: a side button held as the menu opens with the mouse free counts only after it was let go; one held from play into the menu, or back, stays one press. - **Unchanged:** the left, right and middle buttons in a menu are its clicks, never their controls (the open question of #85 is left alone); with the Insert menu open nothing counts; with the mouse free in play (Esc) no mouse button counts; Mouse camera Off never makes a mouse button a control. - **Linux** (`host/posix/display_sdl.c`): its window does not hand the mouse to the game's menus, so the capture and the buttons stay the game's there; `hos_mouse_in_game_menu` returns 0 and nothing changes. (#1172 is the side buttons being readable on Linux at all.) - **The checks:** a `menu-side-buttons` case in `tests/test_input_background.py`, through the real `read_input`, and the new `tests/test_game_menu_mouse_buttons.py`, which runs `menus_mouse` (both in their own commit before the fix); `tests/test_bound_keys.py` checks the arming with the new argument; `tests/display_pointer_test.cpp`, which compiles `menus_mouse`, gets the new flag and two checks of it. - **Docs:** the README's line on mouse buttons as keys. - **Runs:** `docs/tested/2026-11-16-side-buttons-menus-cuecuemoar-run01.md` and `run02`. This touches the same lines of `host/nn_hid.c` as #1257 (a mouse button held when a menu takes the mouse); whichever lands second needs a small rebase, and the two rules compose. ## Measurements **Verdict:** fixed: Mouse 4 on A confirms the choice with this change and does not on main (by hand, a real mouse); the game-free check fails on main and passes here. Nothing to measure for speed: one flag read and a few integer operations per input read. Hardware: Windows 10 Pro 22H2 (19045), RTX 4090 24 GB, NVIDIA 617.42, Core i9-13900K, 32 GB Scene: a copied save, a choice of the text box Method: by hand with a mouse that has side buttons, A on E and Mouse 4 in both builds (the control bridge's presses do not go through the mouse's buttons) How to reproduce: as in How to reproduce | | Before: main @ e090cc48 | After: this PR @ b59bcab3 (the code of b81f4cfa, which adds only a test fixture's lines) | |---|---|---| | Mouse 4 on a choice of the text box (by hand) | does not confirm | confirms | | `tests/test_input_background.py --case menu-side-buttons` (main @ 6d72ca93 with the test commit 9caabea7; this PR @ b81f4cfa) | FAIL | PASS | | `tests/test_game_menu_mouse_buttons.py` (the same commits) | stops: main has no such state to cut | PASS | Baseline: main e090cc48 is the `dev_packs.py` base on this PC; the fix's build is main 6d72ca93 plus this change, as a pack over it. `mouse_buttons_arm`, `bound_down` and `menus_mouse` are the same on e090cc48 and 6d72ca93. ``` main @ 6d72ca93 + 9caabea7 (the tests alone): tests/test_input_background.py --case menu-side-buttons FAIL:148 G64(address + 8) == buttons (the packet after Mouse 4 is pressed in the menu: A expected, none read) tests/test_game_menu_mouse_buttons.py srccut: 'static volatile LONG game_menu_mouse;' is not in host/display.c (cut by tests/test_game_menu_mouse_buttons.py) (renamed or reshaped? update the check with the source) this PR @ b81f4cfa: PASS: the mouse's side buttons stay their controls' while one of the game's menus has the mouse PASS ``` ### Flags and settings None. ## Testing **Tested:** - By hand (cuecuemoar; Windows 10 22H2, RTX 4090, a mouse with side buttons): main does not confirm a choice of the text box with Mouse 4 on A; the fix's build does. - The checks against broken fixes, each failing: the flag never set, the flag set under the Insert menu too, only Mouse 5 let through, every mouse button let through (two checks), Mouse camera Off let through, and `read_input` not reading the buttons in a menu. - The checks that read `host/nn_hid.c`, `host/display.c`, `host/posix/display_sdl.c` or the README: they pass but for the ones that fail on main too (below). `tests/test_display_pointer.py` compiles `menus_mouse` and failed on the first version of the fix for want of the new flag: its fixture is updated in the fix commit. - `host/nn_hid.c` and `host/display.c` compiled whole for Windows in the pack's build (llvm-mingw, no `warning:` in its log). - `python -I -B tests/run_all.py` on Linux (WSL, Ubuntu 22.04), main @ 6d72ca93 and this branch at the same commit, run side by side: main 563 passed, 49 failed, 108 skipped; the branch before the fixture update 563 passed, 50 failed, 108 skipped, the one more being `tests/test_display_pointer.py`, which passes since. The 49 are the same checks on both (this WSL machine has no clang, Vulkan headers or some Python modules); among them, of the checks that read the changed files: `test_crash_record`, `test_display_startup_failure`, `test_hud_layout_row`, `test_longshot_saves`, `test_tested_configurations` (another PR's file with two rows), `test_walk_key`. **Not tested:** - Linux: not built here (the lift's headers are needed to compile `host/`); the change there is one function that returns 0, and `host/nn_hid.c`'s changed functions are compiled with gcc on Linux by the checks. - By hand: the pause menu, the title's lists and the other menus of the game with a side button (the same rule and code path as the text box's choices); Mouse 5; a side button held as a menu opens or closes (the check's cases); Mouse camera Native and Off (the run was As the stick). - The reporter's note that a left click on the choice did nothing either: not looked at here (the left button's rule is unchanged; #85). - The Test Farm: its input goes through the bridge, not the mouse. **Must be tested:** - None. ## Risks **What could break:** a control bound to a side button now acts in the game's menus where it did nothing before: with B or Plus on one, it backs out of or closes the menu there, as its key would. **Turning it off:** revert the commit. **Compatibility:** Nothing changes: no save, option, cache or interface is touched (`gpu/vk/vk_api.h` is not). ## Issues Fixes #1306 ## Checklist ### Everyone - [x] One topic. - [x] The title is a Conventional Commit (`type(scope): description`) of the status line's type. - [x] Why gives the reason plainly and links the issues that fit (the tracker searched). - [x] Measurements has a verdict, or one line saying why there is nothing to measure. - [x] Testing names what was tested, what wasn't, and what must still be tested, where and how. - [x] Rebased on current `main`. - [x] `python -I -B tests/run_all.py` passes (any failure that also fails on `main` is named). - [x] No game files, dumps, build output or generated files. - [x] `third_party/` untouched (a new folder with a `PROVENANCE.md` instead). - [x] The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled. ### When it applies - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. - [x] A file in `docs/tested/` for each new measured run (format in `docs/tested-configurations.md`). - [x] A game-free test added for the fix, failing on `main` and passing here. - [x] A check under `tests/` that reads changed source updated in this PR, not weakened. - [ ] Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths. (Windows built; Linux not built here, see Not tested.) - [x] Docs updated. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01VxeaZkuxWxPjY31qDxgN1k
A case for tests/test_input_background.py, through the real read_input: Mouse 4 on A is A in play and stays A
while a menu of the game's has the mouse; the left button there is the menu's click; a keys-only control on
Mouse 5; a press held into the menu and back; the mouse free in play; Mouse camera Off. It fails on main at the
press in the menu (Longshot #1306).

tests/test_game_menu_mouse_buttons.py runs display.c's menus_mouse and asks whether a game menu has the mouse; main
has no such answer yet, so there it stops at the missing marker.

Assisted-by: Claude Code
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VxeaZkuxWxPjY31qDxgN1k
A mouse button counted as its control only while the mouse was captured, and on Windows each of the game's menus
takes the mouse: the title's lists, the pause menu, the text box's choices. The left, right and middle buttons are
that menu's clicks there. The side buttons were nothing: with A on Mouse 4, ordinary dialogue advanced (the mouse
still captured) and a choice such as "Sleep until morning" could not be confirmed.

While one of the game's menus has the mouse and the Insert menu is closed (host/display.c hos_mouse_in_game_menu),
the two side buttons now stay their controls', as a key does; one held as the menu opens with the mouse free still
waits to be let go. The other three stay the menu's clicks, and with Mouse camera Off no mouse button is a control,
as before. Linux's window does not hand the mouse to the game's menus, so nothing changes there.

Fixes #1306

Assisted-by: Claude Code
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VxeaZkuxWxPjY31qDxgN1k
docs(tested): Mouse 4 on A in a choice of the text box, main and the fix, by hand
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 4s
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval waiting for a BigBean's 👍 on the request
888d9923a4
Assisted-by: Claude Code
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VxeaZkuxWxPjY31qDxgN1k
Author
Contributor

Tested in game: RTX 4090, NVIDIA 617.42, Windows 10 22H2, by hand with a mouse that has side buttons (cuecuemoar): A on Mouse 4, a choice of the text box. main @ e090cc48 does not confirm it; this change's build (b59bcab3, a pack over that base) confirms it.

Tested in game: RTX 4090, NVIDIA 617.42, Windows 10 22H2, by hand with a mouse that has side buttons (cuecuemoar): A on Mouse 4, a choice of the text box. main @ e090cc48 does not confirm it; this change's build (b59bcab3, a pack over that base) confirms it.
Author
Contributor

@Beanstalk please build this branch on Linux (any GPU) and start the game to the title screen and into a save: the Linux build was not made on my PC. On Linux the change is one new function in host/posix/display_sdl.c that returns 0 and its call in host/nn_hid.c, so the run only has to show that it builds, links and plays as main does.

🤖 Posted by an agent for cuecuemoar.

@Beanstalk please build this branch on Linux (any GPU) and start the game to the title screen and into a save: the Linux build was not made on my PC. On Linux the change is one new function in host/posix/display_sdl.c that returns 0 and its call in host/nn_hid.c, so the run only has to show that it builds, links and plays as main does. 🤖 Posted by an agent for cuecuemoar.
Member

@cuecuemoar only members of BigBeans can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.

@cuecuemoar only members of `BigBeans` can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 4s
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval waiting for a BigBean's 👍 on the request
This pull request is marked as a work in progress.
Some workflows are waiting to be reviewed.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'fix/side-buttons-in-game-menus:cuecuemoar-fix/side-buttons-in-game-menus'
git switch 'cuecuemoar-fix/side-buttons-in-game-menus'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
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
MagicBeanDev/Longshot!1329
No description provided.