[PR #113] [MERGED] horizon-ctl: mouse-move, and turn/look-at --over through the player's mouse path #2331

Closed
opened 2026-11-02 15:55:02 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/113
Author: @ludovic111
Created: 10/14/2026
Status: ✅ Merged
Merged: 10/14/2026
Merged by: @ludovic111

Base: main ← Head: feat/ctl-mouse-move


📝 Commits (1)

  • 2cfeed1 horizon-ctl: mouse-move and eased turns through the player's mouse path

📊 Changes

4 files changed (+394 additions, -28 deletions)

View changed files

📝 crates/horizon-client/src/bin/horizon-ctl/commands.rs (+36 -10)
📝 crates/horizon-client/src/game.rs (+22 -8)
📝 crates/horizon-client/src/game/agent.rs (+165 -7)
📝 crates/horizon-client/src/mouse.rs (+171 -3)

📄 Description

What was missing

Agents could only set the view directly (look, turn, look-at jump in one step). Nothing moved the view the way a player's mouse does, with the sensitivity curve, inverted axes, the cinematic camera and the per-frame accumulation, and nothing could spread a turn over time.

What vanilla 26.3 does

  • MouseHandler.onMove adds relative motion to accumulatedDX/DY while the pointer is grabbed; handleAccumulatedMovement runs once per frame and calls turnPlayer(mousea).
  • MouseHandler.turnPlayer: ss = sensitivity * 0.6F + 0.2F, sensitivityMod = ss³, sens = sensitivityMod * 8. With smoothCamera the motion goes through SmoothDouble.getNewDeltaValue(accumulated * sens, mousea * sens); while scoping in first person it is accumulated * sensitivityMod; otherwise accumulated * sens. Inverted axes negate, then LocalPlayer.turn → Entity.turn: yRot += (float)xo * 0.15F, xRot += (float)yo * 0.15F, pitch clamped to ±90.

Horizon already had this path (mouse::MouseLook, fed by DeviceEvent::MouseMotion); agents just had no way into it.

The change

  • horizon-ctl mouse-move DX DY (MCP mouse_move): adds the motion to MouseLook's accumulated movement (add_motion), so the next frame turns the player exactly as the same real mouse motion would. Agent motion counts as a grabbed pointer in an active window (an agent cannot grab the real pointer); a real grab or release hands control back. The reply comes after the frame that turned, with yaw and pitch.
  • turn DYAW DPITCH --over S, look-at … --over S (also look-at-block, look-at-entity): the degrees are converted to mouse units with the current options (mouse::motion_for_turn: degrees / (0.15 × sens), inversion undone) and fed over S seconds with ease-in-out (half cosine), as mouse-move steps each frame. look-at turns the shorter way round and reports the target. Without --over everything still jumps as before. turn is now an MCP tool with the same options.
  • stop cancels a turn in progress; a second turn while one runs, or any of these with a screen open, is refused with a message.

How it was tested

  • Unit tests in mouse.rs against MouseHandler.turnPlayer and Entity.turn (cited in the test): exact yaw/pitch for sensitivities 0–1 and several motions; inverted Y; scoping drops the factor 8; motion_for_turn round-trips through turnPlayer with inversion and scoping; the cinematic camera turns part of the motion in the first frame and reaches the same total over later frames; easing endpoints. horizon-ctl tests check the CLI/MCP argument → wire mapping for turn --over, mouse_move and look-at-block --over.
  • End to end over the control socket on vscreen (sensitivity 0.5, i.e. 0.15° per unit): mouse-move 100 0 → yaw 15.0; mouse-move -25 40 → yaw 11.25, pitch 6.0; turn 90 -10 --over 1 sampled every 0.1 s eased 0 → 7.2 → 24.1 → 38.8 → 60.9 → 72.7 → 85.9 → 90.0 (pitch to -10), replying after 1.08 s; look-at block … up --over 0.5 ends on the same yaw/pitch as the instant form with the block under the crosshair; MCP tools/list shows mouse_move and turn with schemas and tools/call turns the view; busy, stop and screen-open errors as described.
  • cargo fmt, cargo clippy --workspace --all-targets -D warnings, cargo test --workspace (730 passed), tools/check_public_tree.py.

Notes

  • The cinematic camera is only toggled by a real key (key.smoothCamera, unbound by default), so its path is covered by the unit test rather than end to end.
  • While a glide runs, real mouse motion adds to it, as two mice would.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/113 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/14/2026 **Status:** ✅ Merged **Merged:** 10/14/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/ctl-mouse-move` --- ### 📝 Commits (1) - [`2cfeed1`](https://github.com/horizon-rust/horizon/commit/2cfeed118b0c54106016b0c0742aa1a69d397b2f) horizon-ctl: mouse-move and eased turns through the player's mouse path ### 📊 Changes **4 files changed** (+394 additions, -28 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/bin/horizon-ctl/commands.rs` (+36 -10) 📝 `crates/horizon-client/src/game.rs` (+22 -8) 📝 `crates/horizon-client/src/game/agent.rs` (+165 -7) 📝 `crates/horizon-client/src/mouse.rs` (+171 -3) </details> ### 📄 Description ## What was missing Agents could only set the view directly (`look`, `turn`, `look-at` jump in one step). Nothing moved the view the way a player's mouse does, with the sensitivity curve, inverted axes, the cinematic camera and the per-frame accumulation, and nothing could spread a turn over time. ## What vanilla 26.3 does - `MouseHandler.onMove` adds relative motion to `accumulatedDX/DY` while the pointer is grabbed; `handleAccumulatedMovement` runs once per frame and calls `turnPlayer(mousea)`. - `MouseHandler.turnPlayer`: `ss = sensitivity * 0.6F + 0.2F`, `sensitivityMod = ss³`, `sens = sensitivityMod * 8`. With `smoothCamera` the motion goes through `SmoothDouble.getNewDeltaValue(accumulated * sens, mousea * sens)`; while scoping in first person it is `accumulated * sensitivityMod`; otherwise `accumulated * sens`. Inverted axes negate, then `LocalPlayer.turn` → `Entity.turn`: `yRot += (float)xo * 0.15F`, `xRot += (float)yo * 0.15F`, pitch clamped to ±90. Horizon already had this path (`mouse::MouseLook`, fed by `DeviceEvent::MouseMotion`); agents just had no way into it. ## The change - `horizon-ctl mouse-move DX DY` (MCP `mouse_move`): adds the motion to `MouseLook`'s accumulated movement (`add_motion`), so the next frame turns the player exactly as the same real mouse motion would. Agent motion counts as a grabbed pointer in an active window (an agent cannot grab the real pointer); a real grab or release hands control back. The reply comes after the frame that turned, with yaw and pitch. - `turn DYAW DPITCH --over S`, `look-at … --over S` (also `look-at-block`, `look-at-entity`): the degrees are converted to mouse units with the current options (`mouse::motion_for_turn`: degrees / (0.15 × sens), inversion undone) and fed over S seconds with ease-in-out (half cosine), as mouse-move steps each frame. `look-at` turns the shorter way round and reports the target. Without `--over` everything still jumps as before. `turn` is now an MCP tool with the same options. - `stop` cancels a turn in progress; a second turn while one runs, or any of these with a screen open, is refused with a message. ## How it was tested - Unit tests in `mouse.rs` against `MouseHandler.turnPlayer` and `Entity.turn` (cited in the test): exact yaw/pitch for sensitivities 0–1 and several motions; inverted Y; scoping drops the factor 8; `motion_for_turn` round-trips through `turnPlayer` with inversion and scoping; the cinematic camera turns part of the motion in the first frame and reaches the same total over later frames; easing endpoints. `horizon-ctl` tests check the CLI/MCP argument → wire mapping for `turn --over`, `mouse_move` and `look-at-block --over`. - End to end over the control socket on vscreen (sensitivity 0.5, i.e. 0.15° per unit): `mouse-move 100 0` → yaw 15.0; `mouse-move -25 40` → yaw 11.25, pitch 6.0; `turn 90 -10 --over 1` sampled every 0.1 s eased 0 → 7.2 → 24.1 → 38.8 → 60.9 → 72.7 → 85.9 → 90.0 (pitch to -10), replying after 1.08 s; `look-at block … up --over 0.5` ends on the same yaw/pitch as the instant form with the block under the crosshair; MCP `tools/list` shows `mouse_move` and `turn` with schemas and `tools/call` turns the view; busy, `stop` and screen-open errors as described. - `cargo fmt`, `cargo clippy --workspace --all-targets -D warnings`, `cargo test --workspace` (730 passed), `tools/check_public_tree.py`. ## Notes - The cinematic camera is only toggled by a real key (`key.smoothCamera`, unbound by default), so its path is covered by the unit test rather than end to end. - While a glide runs, real mouse motion adds to it, as two mice would. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 15:55:02 +07:00
Sign in to join this conversation.
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
horizon-rust/horizon#2331
No description provided.