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

Open
eipastel wants to merge 1 commit from upstream-pr/4968 into main
eipastel commented 2026-12-01 15:50:28 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by eipastel on 2026-12-01T15:50:28Z.


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

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 #4634 rewrite of menu.rs left that out (#4939, 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 #4939 are not touched here (3 and 5: #4942 and #4950; 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; #4679 / #4707), 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. #4942, #4950, #2868, #4711, #4764, #4796 and #4934 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

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5589246104 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4968). Originally posted by [eipastel](https://github.com/eipastel) on 2026-12-01T15:50:28Z. --- [pr-fix] Fixes point 2 of #4939. ## 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 #4634 rewrite of `menu.rs` left that out (#4939, 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 #4939 are not touched here (3 and 5: #4942 and #4950; 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; #4679 / #4707), 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. #4942, #4950, #2868, #4711, #4764, #4796 and #4934 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)
cloph-dsp commented 2026-12-01 18:05:07 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by cloph-dsp on 2026-12-01T18:05:07Z.


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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7320378371 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4968#issuecomment-7320378371). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-12-01T18:05:07Z. --- 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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/4968:upstream-pr/4968'
git switch 'upstream-pr/4968'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/4968'
git switch 'upstream-pr/4968'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/4968'
git switch 'upstream-pr/4968'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/4968'
git switch 'main'
git merge --squash 'upstream-pr/4968'
git switch 'main'
git merge --ff-only 'upstream-pr/4968'
git switch 'main'
git merge 'upstream-pr/4968'
git push origin 'main'
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
trustno1-coder/VIctory-NVIDIA!4968
No description provided.