KBM: fix camera whip on focus regain, add absolute mouse support #1052

Closed
saurabhbhoir456 wants to merge 4 commits from upstream-pr/1059 into main
saurabhbhoir456 commented 2026-11-24 11:04:05 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by saurabhbhoir456 on 2026-11-24T11:04:05Z.


  • Issue #963: Use real dt for velocity rate calculation, clamp only for smoothing
  • Issue #962: Add last_abs field for absolute mouse coordinate delta calculation
  • Issue #961: Canonicalize game_root path in VFS (handles UNC paths)

Add unit tests for all three fixes.

What is in it

Tested

  • hardware (GPU + driver, CPU), Rust version, debug / release:
  • cargo test --workspace -- --test-threads=4: N passed, N failed, N ignored (SKIPPED GPU tests: …)

Regression run

main:

PR:

Not tested

AI use

  • none / tool and model, and what it did
<!-- greyfinch-sync:ivall/xcl:issue:5470920019 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1059). Originally posted by [saurabhbhoir456](https://github.com/saurabhbhoir456) on 2026-11-24T11:04:05Z. --- - Issue #963: Use real dt for velocity rate calculation, clamp only for smoothing - Issue #962: Add last_abs field for absolute mouse coordinate delta calculation - Issue #961: Canonicalize game_root path in VFS (handles UNC paths) Add unit tests for all three fixes. <!-- What changes and why, in a few sentences. "Fixes #N" / "Part of #N". Stacked: "Stacked on #N". --> **What is in it** - **Tested** - hardware (GPU + driver, CPU), Rust version, debug / release: - `cargo test --workspace -- --test-threads=4`: N passed, N failed, N ignored (SKIPPED GPU tests: …) **Regression run** <!-- Required when the PR changes crates/xcl/src outside tests: `scripts/smoke.ps1` on a real title, built from main and from this PR's head commit (no uncommitted changes); paste both blocks. Rerun the PR's after every push. Not needed for docs / tests / scripts only. --> main: PR: **Not tested** - **AI use** - none / tool and model, and what it did
ettehn commented 2026-11-24 14:06:33 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ettehn on 2026-11-24T13:28:10Z.


On b11945f, rustfmt --edition 2021 --check crates/xcl/src/hle/kbm.rs reports an unexpected closing }. There is an extra brace between mouse_reset_clears_last_abs and focus_loss_resets_mouse_velocity_and_wheel_state. Several Mouse { ... } initializers also omit last_abs.

For #962, a single shared last_abs can produce a large delta when two devices report alternately. Raw Input absolute positions are normalized over the primary screen or virtual desktop, so converting to pixels and keeping a separate baseline per device would address both cases.

OpenAI Codex (GPT-6.2 Sol) assisted with verification.

<!-- greyfinch-sync:ivall/xcl:comment:7132873666 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1059#issuecomment-7132873666). Originally posted by [ettehn](https://github.com/ettehn) on 2026-11-24T13:28:10Z. --- On `b11945f`, `rustfmt --edition 2021 --check crates/xcl/src/hle/kbm.rs` reports an unexpected closing `}`. There is an extra brace between `mouse_reset_clears_last_abs` and `focus_loss_resets_mouse_velocity_and_wheel_state`. Several `Mouse { ... }` initializers also omit `last_abs`. For #962, a single shared `last_abs` can produce a large delta when two devices report alternately. Raw Input absolute positions are normalized over the primary screen or virtual desktop, so converting to pixels and keeping a separate baseline per device would address both cases. OpenAI Codex (GPT-6.2 Sol) assisted with verification.
throny commented 2026-11-25 01:10:55 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-25T00:51:15Z.


Two contributors checked independently and found that #1066 #1522 solves the same problem (for #963) in a different way: #1607, group D66. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.

This is a hint from the community triage in #1607, not a maintainer decision.

AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.

<!-- greyfinch-sync:ivall/xcl:comment:7148954419 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1059#issuecomment-7148954419). Originally posted by [throny](https://github.com/throny) on 2026-11-25T00:51:15Z. --- <!-- xcl-1607-hint:D66 --> Two contributors checked independently and found that #1066 #1522 solves the same problem (for #963) in a different way: #1607, group D66. You may want to compare them with the other author and agree on one, or say in the PR why both are needed. This is a hint from the community triage in #1607, not a maintainer decision. AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
JJAutoCompare commented 2026-11-25 03:05:35 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T02:13:42Z.


PR #1059 verification

KBM changes mouse velocity smoothing after long input gaps and adds absolute mouse handling. The PR diff also changes UNC game-root canonicalization in crates/xcl/src/vfs.rs.

  • PR head fetched from origin (refs/pull/1059/head): 54d51d71de6d3790b464ff3357785814cfd29279
  • Fetched origin/main: aaa093657bd96a146c05c0c1a9b61149fe761453
  • git merge-tree --write-tree origin/main HEAD exited 0 and returned tree 3d0cfa8c88979de8a7b3f03e57b505b583805fc9. Build and test commands used the clean, detached PR head.

Tested

  • STOR-WINLAB, Windows 11 Enterprise Evaluation build 26200.9974, AMD Ryzen 7 3800X, Intel Arc A770 16 GiB (driver 32.0.101.9175, wave range 8–32, DoublePrecisionFloatShaderOps=0). Rust rustc 1.100.0 (0ef1bc386 2026-11-09). Debug build and test profiles with debug info and incremental compilation disabled. Configured DXC/DXIL 1.9.2609.5.
  • cargo build --workspace and cargo test --workspace --no-run both exited 101.
  • cargo test -p xcl --lib hle::kbm::tests -- --show-output exited 101 before running any tests.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 --show-output exited 101 after acquiring the Arc A770 test lock. The lock was released. Full output is in L:\XclTooling\neon-slot-2\tmp\pr1059-suite.log.
  • All four commands stopped on an unexpected closing delimiter at crates/xcl/src/hle/kbm.rs:661. The diff adds a standalone closing brace at line 618 just before focus_loss_resets_mouse_velocity_and_wheel_state.
  • Zero tests executed. Cargo emitted no passed, failed, or ignored totals and no SKIPPED lines.

Not tested

  • Runtime and GPU behavior, interactive focus regain, absolute mouse input, UNC game-root canonicalization, and retail-title smoke comparisons on main and the PR head. Compilation blocked test execution.

AI use

  • T3 Code / Codex (gpt-6.2-sol) ran the build and test commands and drafted this report. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified the compiler error in pr1059-suite.log and published this report.
<!-- greyfinch-sync:ivall/xcl:comment:7150466776 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1059#issuecomment-7150466776). Originally posted by [JJAutoCompare](https://github.com/JJAutoCompare) on 2026-11-25T02:13:42Z. --- # PR #1059 verification KBM changes mouse velocity smoothing after long input gaps and adds absolute mouse handling. The PR diff also changes UNC game-root canonicalization in `crates/xcl/src/vfs.rs`. - PR head fetched from `origin` (`refs/pull/1059/head`): `54d51d71de6d3790b464ff3357785814cfd29279` - Fetched `origin/main`: `aaa093657bd96a146c05c0c1a9b61149fe761453` - `git merge-tree --write-tree origin/main HEAD` exited 0 and returned tree `3d0cfa8c88979de8a7b3f03e57b505b583805fc9`. Build and test commands used the clean, detached PR head. **Tested** - STOR-WINLAB, Windows 11 Enterprise Evaluation build 26200.9974, AMD Ryzen 7 3800X, Intel Arc A770 16 GiB (driver 32.0.101.9175, wave range 8–32, DoublePrecisionFloatShaderOps=0). Rust `rustc 1.100.0 (0ef1bc386 2026-11-09)`. Debug build and test profiles with debug info and incremental compilation disabled. Configured DXC/DXIL 1.9.2609.5. - `cargo build --workspace` and `cargo test --workspace --no-run` both exited 101. - `cargo test -p xcl --lib hle::kbm::tests -- --show-output` exited 101 before running any tests. - `cargo test --workspace --no-fail-fast -- --test-threads=4 --show-output` exited 101 after acquiring the Arc A770 test lock. The lock was released. Full output is in `L:\XclTooling\neon-slot-2\tmp\pr1059-suite.log`. - All four commands stopped on an unexpected closing delimiter at `crates/xcl/src/hle/kbm.rs:661`. The diff adds a standalone closing brace at line 618 just before `focus_loss_resets_mouse_velocity_and_wheel_state`. - Zero tests executed. Cargo emitted no passed, failed, or ignored totals and no `SKIPPED` lines. **Not tested** - Runtime and GPU behavior, interactive focus regain, absolute mouse input, UNC game-root canonicalization, and retail-title smoke comparisons on main and the PR head. Compilation blocked test execution. **AI use** - T3 Code / Codex (gpt-6.2-sol) ran the build and test commands and drafted this report. Coordinator #2 (T3 Code / Antigravity, `gemini-4-neon`) verified the compiler error in `pr1059-suite.log` and published this report.
winne42 commented 2026-11-25 07:05:45 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by winne42 on 2026-11-25T07:00:25Z.


At head 733f42b this PR does not compile, not even the library (cargo check -p xcl --target x86_64-pc-windows-gnu):

error: unexpected closing delimiter: `}`
   --> crates/xcl/src/hle/kbm.rs:661:1

There is an extra } after the new mouse_reset_clears_last_abs test, which closes mod tests early. Once that is fixed, the Mouse { … } literals in on_message, apply and focus_loss_resets_mouse_velocity_and_wheel_state still lack the new last_abs field.

Checked on Linux, Wine 10.0, Rust 1.98.1 (x86_64-pc-windows-gnu), as part of the D66 check on #1607. Written with Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7155386332 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1059#issuecomment-7155386332). Originally posted by [winne42](https://github.com/winne42) on 2026-11-25T07:00:25Z. --- At head `733f42b` this PR does not compile, not even the library (`cargo check -p xcl --target x86_64-pc-windows-gnu`): ``` error: unexpected closing delimiter: `}` --> crates/xcl/src/hle/kbm.rs:661:1 ``` There is an extra `}` after the new `mouse_reset_clears_last_abs` test, which closes `mod tests` early. Once that is fixed, the `Mouse { … }` literals in `on_message`, `apply` and `focus_loss_resets_mouse_velocity_and_wheel_state` still lack the new `last_abs` field. Checked on Linux, Wine 10.0, Rust 1.98.1 (`x86_64-pc-windows-gnu`), as part of the D66 check on #1607. Written with Claude Code (Claude Opus 5.5).
DavidM1911 commented 2026-11-25 09:08:26 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T09:05:47Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • Does not compile: error: unexpected closing delimiter: '}' at crates/xcl/src/hle/kbm.rs:661 (extra } after the tests module). Fails on the PR head itself, not a merge artifact.

— Devin

<!-- greyfinch-sync:ivall/xcl:comment:7157868127 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1059#issuecomment-7157868127). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T09:05:47Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - **Does not compile**: `error: unexpected closing delimiter: '}'` at `crates/xcl/src/hle/kbm.rs:661` (extra `}` after the tests module). Fails on the PR head itself, not a merge artifact. — Devin
ruben2s commented 2026-11-25 22:06:50 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ruben2s on 2026-11-25T21:48:22Z.


@saurabhbhoir456 this is slop

<!-- greyfinch-sync:ivall/xcl:comment:7175562103 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1059#issuecomment-7175562103). Originally posted by [ruben2s](https://github.com/ruben2s) on 2026-11-25T21:48:22Z. --- @saurabhbhoir456 this is slop
gut0to commented 2026-11-26 17:03:40 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by gut0to on 2026-11-26T17:03:40Z.

Code review location: crates/xcl/src/hle/kbm.rs; line 325

@@ -307,8 +314,20 @@ pub unsafe fn on_message(hwnd: *mut c_void, msg: u32, wp: usize, lp: isize) -> b
             let n = GetRawInputData(lp, RID_INPUT, &mut raw as *mut _ as *mut c_void, &mut size, 24);
             if n != u32::MAX && n as usize >= std::mem::size_of::<RawMouseInput>() && raw.kind == RIM_TYPEMOUSE && CAPTURED.load(Ordering::Acquire) {
                 if raw.flags & MOUSE_MOVE_ABSOLUTE == 0 {
+                    // Relative movement
                     DX.fetch_add(raw.last_x, Ordering::Relaxed);
                     DY.fetch_add(raw.last_y, Ordering::Relaxed);
+                } else {
+                    // Absolute movement: compute delta from last absolute position
+                    let mut g = MOUSE.lock().unwrap_or_else(|e| e.into_inner());
+                    let m = g.get_or_insert_with(|| Mouse { last: Instant::now(), velocity: Velocity::default(), wheel: Wheel::default(), wheel_rest: 0 });
+                    if let Some((last_x, last_y)) = m.last_abs {
+                        let dx = raw.last_x - last_x;

Could the absolute coordinates be converted to display coordinates before these differences are added to DX/DY? For MOUSE_MOVE_ABSOLUTE, lLastX/lLastY are normalized to 0–65535, not pixel deltas; Windows also uses MOUSE_VIRTUAL_DESKTOP to select the coordinate surface. Treating these values as relative counts makes sensitivity depend heavily on display resolution and can produce a huge velocity when the pointer moves across the surface. Please map absolute positions to screen coordinates before computing deltas and add tests for both coordinate surfaces. AI-assisted review: I checked the Windows RAWMOUSE definition, but I did not run tests.

<!-- greyfinch-sync:ivall/xcl:review-comment:4711457324 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1059#discussion_r4711457324). Originally posted by [gut0to](https://github.com/gut0to) on 2026-11-26T17:03:40Z. **Code review location:** `crates/xcl/src/hle/kbm.rs`; line 325 ~~~~diff @@ -307,8 +314,20 @@ pub unsafe fn on_message(hwnd: *mut c_void, msg: u32, wp: usize, lp: isize) -> b let n = GetRawInputData(lp, RID_INPUT, &mut raw as *mut _ as *mut c_void, &mut size, 24); if n != u32::MAX && n as usize >= std::mem::size_of::<RawMouseInput>() && raw.kind == RIM_TYPEMOUSE && CAPTURED.load(Ordering::Acquire) { if raw.flags & MOUSE_MOVE_ABSOLUTE == 0 { + // Relative movement DX.fetch_add(raw.last_x, Ordering::Relaxed); DY.fetch_add(raw.last_y, Ordering::Relaxed); + } else { + // Absolute movement: compute delta from last absolute position + let mut g = MOUSE.lock().unwrap_or_else(|e| e.into_inner()); + let m = g.get_or_insert_with(|| Mouse { last: Instant::now(), velocity: Velocity::default(), wheel: Wheel::default(), wheel_rest: 0 }); + if let Some((last_x, last_y)) = m.last_abs { + let dx = raw.last_x - last_x; ~~~~ --- Could the absolute coordinates be converted to display coordinates before these differences are added to `DX`/`DY`? For `MOUSE_MOVE_ABSOLUTE`, `lLastX`/`lLastY` are normalized to 0–65535, not pixel deltas; Windows also uses `MOUSE_VIRTUAL_DESKTOP` to select the coordinate surface. Treating these values as relative counts makes sensitivity depend heavily on display resolution and can produce a huge velocity when the pointer moves across the surface. Please map absolute positions to screen coordinates before computing deltas and add tests for both coordinate surfaces. AI-assisted review: I checked the Windows `RAWMOUSE` definition, but I did not run tests.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
xcl-dev/xcl!1052
No description provided.