F1 key bindings: a wait for a key ends when the game window is not in front #4969

Open
github-bot wants to merge 1 commit from github-bot/gh-4968 into main AGit
Owner

@⁠eipastel on GitHub · 2026-12-01 15:50 UTC · original
eipastel:fix/f1-binding-focus → main · +76 −7 · 1 files · 1 commits · open

[pr-fix] Fixes point 2 of #4940.

What it changes

In F1 → KEY BINDINGS, a wait for a key read GetAsyncKeyState, which answers for the whole desktop. After Alt+Tab (or a click on another window) during the wait, the next key typed in the other program was written to bindings.ini. #2245 (9e0c369db) ended the wait as soon as the game window was not in front; the #4635 rewrite of menu.rs left that out (#4940, point 2).

This brings it back on the new menu, nearly as it was:

  • binds::Binds::heard returns Heard::{Nothing, Key, Lost}; heard_from takes "a window of ours is in front" and the key reader, and ends the wait with Lost before reading any key when we are not in front.
  • hear_binding shows NOT CHANGED: THE GAME WINDOW WAS NOT IN FRONT for Lost and binds nothing.
  • The test a_wait_for_a_key_ends_when_the_window_is_not_in_front comes back (adapted: Binds is built in the test, as there is no Binds::of any more).

Points 1, 3, 4 and 5 of #4940 are not touched here (3 and 5: #4943 and #4951; 4: #2868).

How it was tested

  • GPU and profile: RTX 5060 8 GB; not run in game (menu logic only).
  • cargo test -p victory-gpu --lib host::menu: the new test passes.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: only the five errors already on main (font.rs, menu.rs:667, panel.rs; #4680 / #4708), none in the changed lines.
  • cargo xtask policy --staged passes.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. #4943, #4951, #2868, #4712, #4765, #4797 and #4935 change menu.rs; none of their diffs adds a focus check to the binding wait (searched for focused(), heard, NOT IN FRONT).

🤖 Generated with Claude Code

**@⁠eipastel** on GitHub · 2026-12-01 15:50 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4968) `eipastel:fix/f1-binding-focus` → `main` · +76 −7 · 1 files · 1 commits · open [pr-fix] Fixes point 2 of #4940. ## What it changes In F1 → KEY BINDINGS, a wait for a key read `GetAsyncKeyState`, which answers for the whole desktop. After Alt+Tab (or a click on another window) during the wait, the next key typed in the other program was written to `bindings.ini`. #2245 (`9e0c369db`) ended the wait as soon as the game window was not in front; the #4635 rewrite of `menu.rs` left that out (#4940, point 2). This brings it back on the new menu, nearly as it was: - `binds::Binds::heard` returns `Heard::{Nothing, Key, Lost}`; `heard_from` takes "a window of ours is in front" and the key reader, and ends the wait with `Lost` before reading any key when we are not in front. - `hear_binding` shows `NOT CHANGED: THE GAME WINDOW WAS NOT IN FRONT` for `Lost` and binds nothing. - The test `a_wait_for_a_key_ends_when_the_window_is_not_in_front` comes back (adapted: `Binds` is built in the test, as there is no `Binds::of` any more). Points 1, 3, 4 and 5 of #4940 are not touched here (3 and 5: #4943 and #4951; 4: #2868). ## How it was tested - GPU and profile: RTX 5060 8 GB; not run in game (menu logic only). - `cargo test -p victory-gpu --lib host::menu`: the new test passes. - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: only the five errors already on `main` (font.rs, menu.rs:667, panel.rs; #4680 / #4708), none in the changed lines. - `cargo xtask policy --staged` passes. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. #4943, #4951, #2868, #4712, #4765, #4797 and #4935 change `menu.rs`; none of their diffs adds a focus check to the binding wait (searched for `focused()`, `heard`, `NOT IN FRONT`). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
GetAsyncKeyState answers for the whole desktop, so after Alt+Tab during a
wait for a key the next key typed in another program was written to
bindings.ini. #2245 ended the wait as soon as the game window was not in
front; the #4634 rewrite of menu.rs left that out. Back, with its test,
on the new menu: the wait ends before any key is read and the note says
NOT CHANGED: THE GAME WINDOW WAS NOT IN FRONT.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 15:55:39 +00:00
Author
Owner

@⁠cloph-dsp on GitHub · 2026-12-01 18:05 UTC · original

Verification (independent, AI-assisted: Hy4 flash). Windows, Rust 1.100.0 (Scoop rust-msvc), MSVC, commit-scoped shallow worktree.

Base 5fabb46eaf6ed8771321787f8871051abde69b9b, head cb586d1d038300d4619ed4263b1be50125b71a0f. git diff --numstat → crates/victory-gpu/src/host/menu.rs 76/7.

a_wait_for_a_key_ends_when_the_window_is_not_in_front is new on the base (git grep -F a_wait_for_a_key_ends_when_the_window_is_not_in_front 5fabb46e -- . → no match, exit 1). whole_view_above_window-style helper changes in the same hunk are production code, not tests.

git diff --check "5fabb46e..cb586d1d" → no output, exit 0.

$env:CARGO_TARGET_DIR='D:\Victory-Contrib\NVIDIA-Contrib\target-4968'
cargo test --locked -p victory-gpu --lib -- host::menu::binds::tests::a_wait_for_a_key_ends_when_the_window_is_not_in_front --exact --test-threads=1 --quiet

Result: running 1 test, test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 1161 filtered out; finished in 0.00s.

What the test actually pins, since it is worth being precise: it drives Binds::heard_from(ours, held) with a closure, so no OS input is read. The cases are — no wait in progress → Heard::Nothing and the closure panics if called; waiting and in front with nothing held → Nothing and the wait survives; Esc while waiting → Nothing (Esc is not bindable) and the wait still survives; E while waiting → Heard::Key(b'E') and waiting is cleared; waiting while another program is in front → Heard::Lost, the wait is cleared, and the closure is never called; back in front afterwards → Nothing. It closes by reading the binding back (value("Y") == "F").

So it covers the new "not in front ends the wait" branch and that the branch does not consume a key. No device, GPU/driver N/A. No game data.

**@⁠cloph-dsp** on GitHub · 2026-12-01 18:05 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4968#issuecomment-7320378371) Verification (independent, AI-assisted: Hy4 flash). Windows, Rust 1.100.0 (Scoop rust-msvc), MSVC, commit-scoped shallow worktree. Base `5fabb46eaf6ed8771321787f8871051abde69b9b`, head `cb586d1d038300d4619ed4263b1be50125b71a0f`. `git diff --numstat` → crates/victory-gpu/src/host/menu.rs 76/7. `a_wait_for_a_key_ends_when_the_window_is_not_in_front` is new on the base (`git grep -F a_wait_for_a_key_ends_when_the_window_is_not_in_front 5fabb46e -- .` → no match, exit 1). `whole_view_above_window`-style helper changes in the same hunk are production code, not tests. `git diff --check "5fabb46e..cb586d1d"` → no output, exit 0. ``` $env:CARGO_TARGET_DIR='D:\Victory-Contrib\NVIDIA-Contrib\target-4968' cargo test --locked -p victory-gpu --lib -- host::menu::binds::tests::a_wait_for_a_key_ends_when_the_window_is_not_in_front --exact --test-threads=1 --quiet ``` Result: `running 1 test`, `test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 1161 filtered out; finished in 0.00s`. What the test actually pins, since it is worth being precise: it drives `Binds::heard_from(ours, held)` with a closure, so no OS input is read. The cases are — no wait in progress → `Heard::Nothing` and the closure panics if called; waiting and in front with nothing held → `Nothing` and the wait survives; Esc while waiting → `Nothing` (Esc is not bindable) and the wait still survives; `E` while waiting → `Heard::Key(b'E')` and `waiting` is cleared; waiting while another program is in front → `Heard::Lost`, the wait is cleared, and the closure is never called; back in front afterwards → `Nothing`. It closes by reading the binding back (`value("Y") == "F"`). So it covers the new "not in front ends the wait" branch and that the branch does not consume a key. No device, GPU/driver N/A. No game data.
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/host/menu.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-4968'
git switch 'github-bot/gh-4968'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-4968'
git switch 'github-bot/gh-4968'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-4968'
git switch 'main'
git merge --squash 'github-bot/gh-4968'
git switch 'main'
git merge --ff-only 'github-bot/gh-4968'
git switch 'main'
git merge 'github-bot/gh-4968'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!4969
No description provided.