Repository navigation
Input: keyboard and mouse played like a PC game (mouse look, rebindable [controls]) - #577
claude-GTA6 wants to merge 3 commits into
Conversation
…le [controls]) The title reads gamepads and keyboards only (it registers no mouse), so the keyboard and mouse act as a pad: on the first connected host pad, or on the stand-in pad when none is. The series' usual PC keys sit on the console buttons that do the same; F switches to a vehicle layout (W/S on the triggers), G switches it alone. Mouse look: raw input (no pointer acceleration) 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 then, at that read: the same hand movement turns the same angle at any frame rate (spans up to 1 s, for today's slow world frames). The title's stick dead zone and curve can be undone (stick_deadzone, stick_curve), a flick past full stick is turned in full a little later, and the cursor is hidden and held in the window while it has focus (Alt-Tab or Esc frees it, a click or Esc captures it; the capturing click is no shot). Pad and keyboard/mouse work together: buttons OR, triggers max, each stick from whichever device moved it last (a resting pad's drift never takes it). Presses and wheel steps stay down until the title has read them, so taps shorter than a frame count. Letters, digits and punctuation are the keys at their places on a US keyboard (scan codes), so the left stick is Z Q S D on an AZERTY keyboard with no setup; keys_by_position = false matches by letter. [controls] in victory.toml sets and rebinds everything; enabled = false keeps the old stand-in pad. The scripted VICTORY_KEYS keep their meaning. Diagnostics: VICTORY_KBM plays keys and mouse motion into this layer; gameinput=debug logs each pad state the title reads. First written for Marvisak/VIctory#1529. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
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 Bug: resizing the window while the cursor is captured collapses it. Repro:
I think it's |
|
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.
|
…oes not capture it Dragging a window border with the cursor captured collapsed the window to its title bar: every poll clipped the cursor to the client area, and the clip followed that area as the size loop shrank it (reported with a repro on the pull request). - Between WM_ENTERSIZEMOVE and WM_EXITSIZEMOVE the cursor is the user's: a captured cursor is freed when the loop starts, nothing captures or clips during it, and it stays free afterwards until a click in the window. - Focus gained by a mouse click no longer captures by itself: a click in the client area captures (as before), one on a border or the title bar does not. Focus gained without a button down (Alt-Tab) still captures. - A captured cursor is held 16 px inside the client area, so it cannot reach the borders; a client area too small for that is not clipped. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
From a tester working with Claude (AI-assisted); measured on my own machine. Fixed in cb3163c: between 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 ( |
|
Re-tested cb3163c with 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! |
|
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. |
Measured in the opening lookout scene (two scripted 420 s runs, one capture every 10 frames): right stick 0.30 turned ~0.04 px per frame, 0.49 turned 1.9 px, 1.0 about 5 px. The title's dead zone sits near 0.3, so mouse motion under ~600 counts/s at sensitivity 1.0 used to turn nothing. stick_deadzone now defaults to 0.3; curve and sensitivity stay 1.0. Tests of the linear mapping set deadzone 0.0 themselves. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> (cherry picked from commit 538c7883d495eb77045df5b6522df62b0d2c0d04)
|
From a tester working with Claude (AI-assisted); measured on my own machine. Calibration of 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 New default (pushed as Not measured / open:
|
From 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 onmaina803c87.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, Keep keyboard controls working when a controller is connected #74 would still be what makes the old stand-in table (enabled = false) reach a connected pad.[controls]layout too. hle/gameinput: match keyboard controls by physical position, not letter #105's code merges with this one; only the README table conflicts. hle/gameinput: match keyboard controls by physical position, not letter #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