Input: a key tapped between two asks is still seen at a frame a second; the scripted keys' hold can be set #1104

Open
github-bot wants to merge 2 commits from github-bot/gh-1104 into main AGit
Owner

@⁠Dathinel on GitHub · 2026-11-25 19:31 UTC · original
Dathinel:input/taps-between-asks → main · +21 −4 · 1 files · 2 commits · open

What

Two small changes in crates/victory-hle/src/modules/gameinput.rs (+13 −3) for runs at about a frame a second, which is where a 4 GB card is in the world today.

  1. A key tapped between two asks is still seen. The title asks for input once a frame. Host::keys reported only keys that were down at that instant (GetAsyncKeyState(vk) < 0), so at 1 fps a normal tap, down and up inside the second between two asks, never reached the title: menus and prompts needed the key held for over a second. It now also takes the low bit of GetAsyncKeyState (pressed since the last query), so such a tap shows as down for one ask. Still only while the title's window has focus.
  2. VICTORY_KEYS_HOLD_MS (diagnostics builds): the scripted keys of VICTORY_KEYS are held 0.2 s; at 1 fps that falls between two asks the same way. The variable sets the hold; unset, it stays 0.2 s.

Measured

RTX 3050 Laptop 4 GB, Ryzen 7 7435HS, Windows 11 26200, --console series-s, on d510ee4 with #1081 and #798 merged.

  • cargo test --locked -p victory-hle --lib gameinput, with and without --features diagnostics: 7 passed, on this branch (dd3a14b + this commit).
  • A scripted run before the change (VICTORY_KEYS with Enter every 8 to 15 s, 0.2 s holds): the person at the machine had to press Enter by hand to get through the screens once the frame rate dropped.
  • A scripted run after it, with VICTORY_KEYS_HOLD_MS=1500: the run went from boot into the opening (330 s) with the same key list.

Not tested

  • A physical keyboard tap at 1 fps after the change: I could not watch one, and I cannot rule out that someone pressed a key during the second scripted run. A check from anyone with a slow world frame would be welcome.
  • The low bit of GetAsyncKeyState can also carry a press made just before the window took focus; I did not look for a case where that matters.
  • Pads (XInput) are not touched.

AI-assisted (Claude Code). No game data attached.

**@⁠Dathinel** on GitHub · 2026-11-25 19:31 UTC · [original](https://github.com/fxceless/victory-fork/pull/1104) `Dathinel:input/taps-between-asks` → `main` · +21 −4 · 1 files · 2 commits · open ## What Two small changes in `crates/victory-hle/src/modules/gameinput.rs` (+13 −3) for runs at about a frame a second, which is where a 4 GB card is in the world today. 1. **A key tapped between two asks is still seen.** The title asks for input once a frame. `Host::keys` reported only keys that were down at that instant (`GetAsyncKeyState(vk) < 0`), so at 1 fps a normal tap, down and up inside the second between two asks, never reached the title: menus and prompts needed the key held for over a second. It now also takes the low bit of `GetAsyncKeyState` (pressed since the last query), so such a tap shows as down for one ask. Still only while the title's window has focus. 2. **`VICTORY_KEYS_HOLD_MS`** (diagnostics builds): the scripted keys of `VICTORY_KEYS` are held 0.2 s; at 1 fps that falls between two asks the same way. The variable sets the hold; unset, it stays 0.2 s. ## Measured RTX 3050 Laptop 4 GB, Ryzen 7 7435HS, Windows 11 26200, `--console series-s`, on d510ee4 with #1081 and #798 merged. - `cargo test --locked -p victory-hle --lib gameinput`, with and without `--features diagnostics`: 7 passed, on this branch (dd3a14b + this commit). - A scripted run before the change (`VICTORY_KEYS` with Enter every 8 to 15 s, 0.2 s holds): the person at the machine had to press Enter by hand to get through the screens once the frame rate dropped. - A scripted run after it, with `VICTORY_KEYS_HOLD_MS=1500`: the run went from boot into the opening (330 s) with the same key list. ## Not tested - A physical keyboard tap at 1 fps after the change: I could not watch one, and I cannot rule out that someone pressed a key during the second scripted run. A check from anyone with a slow world frame would be welcome. - The low bit of `GetAsyncKeyState` can also carry a press made just before the window took focus; I did not look for a case where that matters. - Pads (XInput) are not touched. AI-assisted (Claude Code). No game data attached.
At a frame a second the title asks for input once a second, so a tap that
ends before the next ask was lost, and so were the scripted keys' 0.2 s.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:57:35 +00:00
Author
Owner

@⁠Dathinel on GitHub · 2026-11-25 20:02 UTC · original

The review's point holds: with focus away, keys() does not query the keys, so the low bit could carry a press made in another window into the first look after focus returns. Fixed in 5ea4ed5: Host remembers whether the last look had focus, and the first look after it comes back takes only keys that are down at that instant (it still queries, which clears the stale bits). The first look of a run counts as such too. cargo test --locked -p victory-hle --lib gameinput, with and without diagnostics: 7 passed; clippy on victory-hle clean. Not tested by hand with a second window.

**@⁠Dathinel** on GitHub · 2026-11-25 20:02 UTC · [original](https://github.com/fxceless/victory-fork/pull/1104#issuecomment-7173101461) The review's point holds: with focus away, `keys()` does not query the keys, so the low bit could carry a press made in another window into the first look after focus returns. Fixed in `5ea4ed5`: `Host` remembers whether the last look had focus, and the first look after it comes back takes only keys that are down at that instant (it still queries, which clears the stale bits). The first look of a run counts as such too. `cargo test --locked -p victory-hle --lib gameinput`, with and without `diagnostics`: 7 passed; clippy on `victory-hle` clean. Not tested by hand with a second window.
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-25 19:31 UTC · original · edited 2026-11-25 20:05 UTC

Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-25T20:05:13.563183Z 5ea4ed5 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review" or "@⁠codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-25 19:31 UTC · [original](https://github.com/fxceless/victory-fork/pull/1104#issuecomment-7172425539) · edited 2026-11-25 20:05 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"5ea4ed558d9128a2f68e20275b370e851ce3aa9b","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-25T20:05:13.563183Z">2026-11-25T20:05:13.563183Z</relative-time> | `5ea4ed5` | New commits | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review" or "@⁠codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-25 19:35 UTC · original
On crates/victory-hle/src/modules/gameinput.rs line 1179 (outdated):

@@ -1171,8 +1171,13 @@ mod host {
                 // mouse buttons (below 0x08).
                 let held: Vec<u8> = (0x08..=0xFE_u8)
                     .filter(|vk| !(0x10..=0x12).contains(vk) && !down.contains(vk))
+                    // Down now, or pressed since the last look (the low bit): a title that
+                    // asks once a frame at a frame a second still sees a tap between two asks.
                     // SAFETY: plain queries.
-                    .filter(|&vk| unsafe { GetAsyncKeyState(i32::from(vk)) } < 0)
+                    .filter(|&vk| {
+                        let state = unsafe { GetAsyncKeyState(i32::from(vk)) };
+                        state < 0 || state & 1 != 0

P2 Badge Discard historical presses when regaining focus

On Windows, pressing and releasing Enter or Esc in another application can now generate input when returning to the title. keys() skips GetAsyncKeyState while focused() is false, so the low bit can retain a background press until the first focused poll. This condition then reports the already-released key as down; with no controller connected, fallback() also maps it to an A/Menu button press, potentially confirming a prompt or toggling pause merely by refocusing. Discard historical pressed bits on focus regain before accepting them as title input.

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-25 19:35 UTC · [original](https://github.com/fxceless/victory-fork/pull/1104#discussion_r4699914745) On `crates/victory-hle/src/modules/gameinput.rs` line 1179 (outdated): ```diff @@ -1171,8 +1171,13 @@ mod host { // mouse buttons (below 0x08). let held: Vec<u8> = (0x08..=0xFE_u8) .filter(|vk| !(0x10..=0x12).contains(vk) && !down.contains(vk)) + // Down now, or pressed since the last look (the low bit): a title that + // asks once a frame at a frame a second still sees a tap between two asks. // SAFETY: plain queries. - .filter(|&vk| unsafe { GetAsyncKeyState(i32::from(vk)) } < 0) + .filter(|&vk| { + let state = unsafe { GetAsyncKeyState(i32::from(vk)) }; + state < 0 || state & 1 != 0 ``` **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Discard historical presses when regaining focus** On Windows, pressing and releasing Enter or Esc in another application can now generate input when returning to the title. `keys()` skips `GetAsyncKeyState` while `focused()` is false, so the low bit can retain a background press until the first focused poll. This condition then reports the already-released key as down; with no controller connected, `fallback()` also maps it to an A/Menu button press, potentially confirming a prompt or toggling pause merely by refocusing. Discard historical pressed bits on focus regain before accepting them as title input. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1104/head:github-bot/gh-1104'
git switch 'github-bot/gh-1104'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1104'
git switch 'github-bot/gh-1104'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1104'
git switch 'github-bot/gh-1104'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1104'
git switch 'main'
git merge --squash 'github-bot/gh-1104'
git switch 'main'
git merge --ff-only 'github-bot/gh-1104'
git switch 'main'
git merge 'github-bot/gh-1104'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.