Input: keyboard and mouse played like a PC game (mouse look, rebindable [controls]) #577
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!577
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/577/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@claude-GTA6 on GitHub · 2026-11-25 02:28 UTC · original
claude-GTA6:pr-fx-kbm→main· +2002 −60 · 10 files · 3 commits · closed without mergingFrom a tester working with Claude (AI-assisted); measured on my own machine.
What
Keyboard and mouse played like a PC game: mouse look, the usual PC key layout, and a
[controls]section to rebind it. Today the keyboard only works as the fixed stand-in pad, only while no controller is connected, and there is no mouse at all.The title registers device callbacks for gamepads and keyboards only, never for a mouse, so it has no mouse path of its own. The keyboard and mouse therefore act as a pad: on the first connected host pad, or on the stand-in pad when none is connected.
WM_INPUTon a message-only window of its own thread: no pointer acceleration, no Windows setting involved) becomes the right stick. The title reads its stick as a turn rate, so the counts since its last pad read are divided by the time since that read, at that read. The same hand movement then asks for the same turn at any frame rate, as long as the title applies its stick over its real frame time (not verified at today's 0.5-2 s world frames; see Tested). A flick past full stick is turned in full a little later (at most 100 ms of carry).stick_deadzone/stick_curvecan undo the title's own stick shaping (defaults 0 / 1, not calibrated yet).keys_by_position = falsematches by letter.[controls]invictory.toml. Sensitivity, vertical scale, invert Y, capture, carry, dead zone, curve, walk speed, and[controls.on_foot]/[controls.vehicle]rebinding (one output, a list, or""to unbind). Unknown keys, outputs and fields are errors at start.enabled = falsekeeps the old stand-in pad exactly as it is. Seevictory.example.tomland the README's input section.VICTORY_KBM=<s>:<key>[*<hold>],<s>:MouseX=<counts>[*<hold>]plays input into this layer without touching OS input;VICTORY_LOG=victory_hle::modules::gameinput=debuglogs each pad state the title reads when it changes. The scriptedVICTORY_KEYSkeep their meaning, including this tree's press on pad 0.New file
crates/victory-hle/src/modules/controls.rs(plain data, no Windows calls; the unit tests live there).gameinput.rsfeeds it from the poll thread and drains it when the title reads a pad;lifecycle.rs's window hook handles the cursor;victory-core's config passes the[controls]table through. One commit onmaina803c87c.This is the same change as Marvisak/VIctory#1529 (approved there), rebased onto this tree, plus the position-based keys.
How it relates to the open keyboard PRs here
gameinput.rs's poll and conflict textually; with both, #74 would still be what makes the old stand-in table (enabled = false) reach a connected pad.[controls]layout too. #105's code merges with this one; only the README table conflicts. #105 is still what fixes the stand-in pad's own table.VICTORY_KEYBOARD_PADfor phantom XInput devices): with this PR the keyboard and mouse ride on whatever pad slot is connected, so a phantom controller no longer silences the keyboard. I have not tested a phantom device. Conflicts ingameinput.rs(the stand-in condition).gamepad_state, where this PR adds a log line, so a small textual conflict.I'm glad to rebase onto whichever of these lands first.
Tested
cargo test -p victory-hle -p victory-core: 114 + 11 pass.cargo clippy -p victory-hle -p victory-core --all-targets -- -D warnings: clean.cargo xtask policy: ok. Other crates are untouched.controls.rs(WASD + walk, buttons and triggers, vehicle layout, sub-frame taps, wheel pulses, counts to rate, slow frames, close reads, dead zone/curve/invert, flick carry, pad drift against the mouse, keys by position, config rebinding and refusals) and 4 ingameinput.rs(the stand-in pad without a host pad, riding on a connected host pad, a pad read carrying the mouse motion, an AZERTY key at the W place).VICTORY_KBM, no device loss): the pad state the title read (717 logged reads, pad slot 0) showed the right stick at +0.30 +/- 0.02 on x for each window of 600 mouse counts/s to the right (2,000 counts/s is a full stick), +0.30 on y for 600 counts/s upward, and the left stick at +1.0 for each press of W. The scripted start-screen presses still reached the world with keyboard and mouse on.stick_deadzone/stick_curveare for), a limited look-around in that scene, or the title capping its time step at 2 fps (then the same-angle-at-any-frame-rate property only holds at playable frame rates). I have not calibrated the two settings yet.Not covered
🤖 Generated with Claude Code
@laptopnotebook on GitHub · 2026-11-25 03:21 UTC · original
Tested this on Windows 11 with a real mouse and keyboard, no controller connected.
Works: mouse look turns the camera fine with a real mouse, and the cursor gets captured on focus and released with Esc / Alt-Tab. Two runs, ~7 min in game for the second, no crashes.
Sometimes no camera movement. Now and then dragging the mouse didn't seem to move the camera at all. I was tabbing out a lot and it was running at ~2 fps, so this might just be frame rate or focus, but it lines up with what you saw about small movements barely turning, probably the title's stick dead zone. I didn't try
stick_deadzone/stick_curve.Bug: resizing the window while the cursor is captured collapses it. Repro:
[controls]at defaults and let the window capture the cursor.MoveWindowfrom outside.I think it's
cursor()ingameinput.rs(~line 1348): focus gained from clicking the border captures the cursor (!self.was_focused→capture()), and then every poll re-clips to the current client rect while the size loop runs, so the clip follows the shrinking window. Not clipping betweenWM_ENTERSIZEMOVEandWM_EXITSIZEMOVE(the lifecycle hook already sees the window's messages), or only capturing on a click inside the client area instead of on any focus gain, should fix it. Might also be worth not clipping to a rect smaller than some minimum.@claude-GTA6 on GitHub · 2026-11-25 03:24 UTC · original
From a tester working with Claude (AI-assisted); measured on my own machine.
Thank you for testing with a real mouse and keyboard; that is the part my scripted runs could not cover.
WM_ENTERSIZEMOVEandWM_EXITSIZEMOVE(and not capture on a click that lands on the border) and push it here as a follow-up commit.stick_deadzone/stick_curveis queued here; I will post the measured values and set them as defaults if they hold.@claude-GTA6 on GitHub · 2026-11-25 03:29 UTC · original
From a tester working with Claude (AI-assisted); measured on my own machine.
Fixed in
cb3163c6: betweenWM_ENTERSIZEMOVEandWM_EXITSIZEMOVEthe cursor is yours (a captured cursor is freed when the loop starts, nothing captures or clips during it, a click in the window captures again afterwards), and focus gained by a mouse click no longer captures by itself, so a click on a border or the title bar never does.A captured cursor is also held 16 px inside the client area now, so it can't reach the borders in the first place. A unit test covers the state rules (
a_size_or_move_loop_frees_the_cursor_and_border_clicks_do_not_capture);cargo test -p victory-hle -p victory-corepasses (115 + 11) and clippy-D warningsis clean on both. I could not drag a real window here, so a re-test of your repro would be welcome.@laptopnotebook on GitHub · 2026-11-25 04:46 UTC · original
Re-tested
cb3163cwith the same repro (Windows 11, real mouse and keyboard, release build). Works fine now: with the cursor captured I can't reach the borders, and after Esc I can drag the bottom edge up and down without the window collapsing. Clicking the border or title bar doesn't capture, and a click back in the window does. No crashes. Thanks for the quick fix!@claude-GTA6 on GitHub · 2026-11-25 04:49 UTC · original
From a tester working with Claude (AI-assisted); measured on my own machine.
@laptopnotebook thanks for re-testing with a real mouse and keyboard. That was the part we could not check ourselves. The mouse sensitivity calibration that is still owed here is being run now, and I'll post it when it is done.
@claude-GTA6 on GitHub · 2026-11-25 06:55 UTC · original
From a tester working with Claude (AI-assisted); measured on my own machine.
Calibration of
stick_deadzone/stick_curve, as promised. Two scripted 420 s runs (diagnostics build of this branch, RTX 5090,Windows 11, ~2.2-2.4 fps in the opening, starting from an existing save). Steady mouse motion was fed through
VICTORY_KBMat fixedright-stick levels; the turn was measured as the horizontal shift between captured frames (one capture every 10 frames, column
cross-correlation). The title read the stick about once per frame at the intended level in every window (
gameinput=debug).Opening lookout scene (the camera turns here):
So the title's dead zone sits close to 0.3: 0.30 barely moves the camera, 0.49 moves it ~50x more. This matches the "small drags
sometimes do nothing" report: at the old default (no dead zone skipped) a hand speed under ~600 counts/s landed inside it.
The curve is not pinned down by three points (the 1.0 point may hit the scene's yaw limit); a linear response fits within the
noise, so
stick_curvestays 1.0.New default (pushed as
b675e1d0):stick_deadzone = 0.3(was 0.0),stick_curve = 1.0andmouse_sensitivity = 1.0unchanged. Any mousemotion now starts just past the dead zone, so small movements turn the camera. Tests that check the linear mapping now set
deadzone: 0.0themselves. If a dead zone of 0.3 overshoots on your setup (the camera creeps when you barely touch the mouse),stick_deadzone = 0.25in[controls]is the next value to try; please say which feels right.Not measured / open:
scripted run: 30 s at full stick turned it ≤7 px, and
W(read by the title as left stick +1.0) did not move the player.Both runs end ~3 minutes after that point at this frame rate, so this is most likely the title not handing over control yet
rather than input shaping. I could not measure the
free-play camera's dead zone, so the 0.3 comes from the lookout camera only.
frame rate.
Pull request closed