fix(mouse): the native mouse camera starts again from the game's angles across a map's load #2856

Merged
HumanBean merged 1 commit from HumanBean/Longshot:fix/mouse-camera-map-load-main into main 2026-11-30 02:36:19 +00:00
Owner

Summary

With Mouse camera: Native, walking through a loading zone with forward held swings the camera 45 to 90 degrees after
the load, further the more the view was turned from Link as he left
(#1728). This is the port to main of the mod-api fix,
#2851, into the C mouse look.

hos_mouse_camera (host/mouse_native.c) keeps its own yaw and pitch and puts them back into the player camera every
update, so the game's follow camera never drifts the view. It starts again from the game's angles only for a new camera,
a stick turn, a camera state other than 3 or 4, or 150 ms without an update. On this RTX 3090 PC, a run through the
Market's gate with the camera's fields read from memory showed:

  • the player camera is the same object before and after the load;
  • its yaw (+0x1a4) is kept in the map's own frame (the Market's view at -180 had yaw 0, Hyrule Field's view at 0 had
    -180);
  • the camera keeps updating in state 3 through the departure event.

So when a load is over within 150 ms of camera updates (a fast PC), the old map's yaw is pinned onto the new map's
camera, where it points another way: the swing.

Now, while a map loads or at the update that sees the map's name changed, while its arrival's events play and for 30
updates after them, the camera's angles are the mouse's start at each update. The mouse still turns them. An event with
no load (Navi's words as Link walks) leaves the mouse's angles held, so the follow drift the hold prevents does not come
back.

Read settling in host/mouse_native.c first, then hos_oot_map_moment in game/oot_tools.c (the loading flag,
EventMgr's event and Sequence_CurrentBanc's hash, bounded reads).

Fixes #1728

Testing

Tested: Not run here, as asked: no game run and no test suite for this port.

  • gcc -fsyntax-only -Wall -Wextra of host/mouse_native.c: clean. game/oot_tools.c's new function: no
    diagnostics (the file's two errors at lines 901 and 1194 are from the one-off compile's flags, not this change).
  • tests/test_mouse_native.py's fixture gets a stand-in for hos_oot_map_moment (no load, no event, no map), so its
    existing cases build and run as before; not run.
  • The same logic on mod-api (#2851): its game-free tests
    fail there before the fix and pass with it, and it ran in the game on Linux (RTX 3090) through the Market's gate.

Still to test:

  • Linux and Windows: mise run test (tests/test_mouse_native.py especially) and a game build (by hand).
  • Windows or Linux, keyboard and mouse, Mouse camera Native: hold W through a loading zone, straight and with the mouse
    turned as you pass, expecting the camera behind Link after the load with no swing (by hand).
  • The same with W let go during the transition, and with Disable camera centering on and off, expecting no change from
    main (by hand).

Measurements

Nothing to measure: a fix in the mouse look's decisions. Its cost is a few bounded flag and pointer reads per player
camera update while Mouse camera is Native.

Risks

  • During a load's arrival and for about half a second after it (30 updates), the game's own camera moves (its follow, its
    placement) count, as they do while the stick turns the camera; the mouse still turns the view throughout.
  • A revert is enough to undo it. Nothing changes for Mouse camera As the stick or Off, saves or longshot_options.ini.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says. (not run: asked to open without tests)
  • mise run test passes (any failure that also fails on main is named). (not run)
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A fix: a game-free test that fails on main and passes here. (the test is on #2851's Rust; none added to tests/test_mouse_native.py here)
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. (syntax-checked with gcc only)
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

🤖 Generated with Claude Code

## Summary With **Mouse camera: Native**, walking through a loading zone with forward held swings the camera 45 to 90 degrees after the load, further the more the view was turned from Link as he left ([#1728](https://git.magicbean.dev/MagicBeanDev/Longshot/issues/1728)). This is the port to `main` of the `mod-api` fix, [#2851](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2851), into the C mouse look. `hos_mouse_camera` (`host/mouse_native.c`) keeps its own yaw and pitch and puts them back into the player camera every update, so the game's follow camera never drifts the view. It starts again from the game's angles only for a new camera, a stick turn, a camera state other than 3 or 4, or 150 ms without an update. On this RTX 3090 PC, a run through the Market's gate with the camera's fields read from memory showed: - the player camera is the same object before and after the load; - its yaw (+0x1a4) is kept in the map's own frame (the Market's view at -180 had yaw 0, Hyrule Field's view at 0 had -180); - the camera keeps updating in state 3 through the departure event. So when a load is over within 150 ms of camera updates (a fast PC), the old map's yaw is pinned onto the new map's camera, where it points another way: the swing. Now, while a map loads or at the update that sees the map's name changed, while its arrival's events play and for 30 updates after them, the camera's angles are the mouse's start at each update. The mouse still turns them. An event with no load (Navi's words as Link walks) leaves the mouse's angles held, so the follow drift the hold prevents does not come back. Read `settling` in `host/mouse_native.c` first, then `hos_oot_map_moment` in `game/oot_tools.c` (the loading flag, EventMgr's event and `Sequence_CurrentBanc`'s hash, bounded reads). Fixes #1728 ## Testing **Tested:** Not run here, as asked: no game run and no test suite for this port. - `gcc -fsyntax-only -Wall -Wextra` of `host/mouse_native.c`: clean. `game/oot_tools.c`'s new function: no diagnostics (the file's two errors at lines 901 and 1194 are from the one-off compile's flags, not this change). - `tests/test_mouse_native.py`'s fixture gets a stand-in for `hos_oot_map_moment` (no load, no event, no map), so its existing cases build and run as before; not run. - The same logic on `mod-api` ([#2851](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2851)): its game-free tests fail there before the fix and pass with it, and it ran in the game on Linux (RTX 3090) through the Market's gate. **Still to test:** - Linux and Windows: `mise run test` (`tests/test_mouse_native.py` especially) and a game build (by hand). - Windows or Linux, keyboard and mouse, Mouse camera Native: hold W through a loading zone, straight and with the mouse turned as you pass, expecting the camera behind Link after the load with no swing (by hand). - The same with W let go during the transition, and with Disable camera centering on and off, expecting no change from `main` (by hand). ## Measurements Nothing to measure: a fix in the mouse look's decisions. Its cost is a few bounded flag and pointer reads per player camera update while Mouse camera is Native. ## Risks - During a load's arrival and for about half a second after it (30 updates), the game's own camera moves (its follow, its placement) count, as they do while the stick turns the camera; the mouse still turns the view throughout. - A revert is enough to undo it. Nothing changes for Mouse camera As the stick or Off, saves or `longshot_options.ini`. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [ ] Tested on my own PC, in the game for a change the game runs, as Testing says. (not run: asked to open without tests) - [ ] `mise run test` passes (any failure that also fails on `main` is named). (not run) - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [ ] A fix: a game-free test that fails on `main` and passes here. (the test is on #2851's Rust; none added to `tests/test_mouse_native.py` here) - [ ] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. (syntax-checked with gcc only) - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fix(mouse): the native mouse camera starts again from the game's angles across a map's load (#1728)
Some checks failed
CI / What the change needs (pull_request) Successful in 11s
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been skipped
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been skipped
CI / Third-party parts and guide screenshots (pull_request) Failing after 16s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 18s
PR description / Title and description (pull_request_target) Failing after 11s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Successful in 2m3s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Failing after 3m32s
CI / Website build and checks (pull_request) Failing after 35s
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Failing after 17m35s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Failing after 38m43s
cbbeb15aad
With Mouse camera on Native, the angles the mouse held were put back into the
player camera every update. The camera is the same object across a map's
load and keeps its yaw in the map's own frame, so when a load did not reset
the hold (a fast PC: the camera ran within 150 ms and in state 3 throughout),
the new map's camera, put behind Link by the game, was turned to the old
map's angles: a swing, larger the further the view stood from Link as he
left. Now, while a map loads or at the update that sees the map's name
changed, while its arrival's events play and for 30 updates after them, the
camera's angles are the mouse's start at each update (the mouse still turns
them). An event without a load leaves the mouse's angles held. The map's
moment is read by game/oot_tools.c's hos_oot_map_moment.

The port to main of the mod-api fix (#2851).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
HumanBean changed title from WIP: fix(mouse): the native mouse camera starts again from the game's angles across a map's load to fix(mouse): the native mouse camera starts again from the game's angles across a map's load 2026-11-30 02:36:09 +00:00
HumanBean deleted branch fix/mouse-camera-map-load-main 2026-11-30 02:36:20 +00:00
Sign in to join this conversation.
No reviewers
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
MagicBeanDev/Longshot!2856
No description provided.