Key bindings: three small safeguards from #1365 (focus loss, failed save, default file) #2245

Merged
hussainmussa merged 3 commits from upstream-pr/2245 into main 2026-11-30 14:12:03 +00:00
hussainmussa commented 2026-11-29 11:00:24 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by hussainmussa on 2026-11-29T11:00:24Z.


Part of #1365: the three small input safeguards listed there. The ideas are @ItsYungFlexer's, from that issue; the third is done the way their fork does it (create_new). Three commits, each independent, so any one can be taken alone. The HUD prompts in #1365 are not touched.

What it changes

  1. A wait for a key ends when the game window is not in front (menu.rs). F1's KEY BINDINGS waits for the key with GetAsyncKeyState, which sees keys in every program. After Enter on a line, a click on another window or a key typed there was saved to bindings.ini, and the wait stayed on while the player was away. Now the wait ends before any key is read, the line keeps its key, and the note says NOT CHANGED: THE GAME WINDOW WAS NOT IN FRONT. Not covered: Alt+Tab itself still binds Alt, because Alt goes down while the game is still in front.
  2. The list shows a key only once bindings.ini took it (menu.rs). Binds::set changed the shown text, then wrote the file. After a failed write the line showed the new key while the game used the old one, and the next line that did save wrote the failed key too. Now the text is written first and kept only if the write worked.
  3. The default bindings.ini is never written over one that is there (play.rs, scripts/play-foxhound.ps1). Both launchers did "is it there? if not, write", and the write empties whatever is at that path. Both now create the file in one step that fails if it exists. This is a small window, not an everyday bug; the test pins the rule.

How it was tested

  • GPU and profile: RTX 4070 12 GB, Core Ultra 7 265KF, Windows 11. Unit tests only; not run in the game yet.
  • cargo test -p victory-gpu --lib host::menu -- --test-threads=1: 16 passed, with the new a_wait_for_a_key_ends_when_the_window_is_not_in_front and a_binding_is_shown_only_once_its_file_took_it (the second fails with the old order: "a key that was not saved is shown").
  • cargo test -p victory: 79 + 1 + 2 passed, with the new the_default_bindings_are_never_written_over_a_file_that_is_there.
  • The script's copy line was run by hand in a scratch folder: a new file equals the default, an existing file is kept.
  • Run in parallel, one older menu test (a_change_is_saved_at_once_however_the_game_was_started) fails on main as well, without this change.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #1739 rewrites this area; #652 and #482 add their own remapping pages; none does these three.

Written with help from Claude; everything above was built and run on my machine.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5550056652 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2245). Originally posted by [hussainmussa](https://github.com/hussainmussa) on 2026-11-29T11:00:24Z. --- Part of #1365: the three small input safeguards listed there. The ideas are @ItsYungFlexer's, from that issue; the third is done the way their fork does it (`create_new`). Three commits, each independent, so any one can be taken alone. The HUD prompts in #1365 are not touched. ## What it changes 1. **A wait for a key ends when the game window is not in front** (`menu.rs`). F1's KEY BINDINGS waits for the key with `GetAsyncKeyState`, which sees keys in every program. After Enter on a line, a click on another window or a key typed there was saved to `bindings.ini`, and the wait stayed on while the player was away. Now the wait ends before any key is read, the line keeps its key, and the note says NOT CHANGED: THE GAME WINDOW WAS NOT IN FRONT. Not covered: Alt+Tab itself still binds Alt, because Alt goes down while the game is still in front. 2. **The list shows a key only once `bindings.ini` took it** (`menu.rs`). `Binds::set` changed the shown text, then wrote the file. After a failed write the line showed the new key while the game used the old one, and the next line that did save wrote the failed key too. Now the text is written first and kept only if the write worked. 3. **The default `bindings.ini` is never written over one that is there** (`play.rs`, `scripts/play-foxhound.ps1`). Both launchers did "is it there? if not, write", and the write empties whatever is at that path. Both now create the file in one step that fails if it exists. This is a small window, not an everyday bug; the test pins the rule. ## How it was tested - GPU and profile: RTX 4070 12 GB, Core Ultra 7 265KF, Windows 11. Unit tests only; not run in the game yet. - `cargo test -p victory-gpu --lib host::menu -- --test-threads=1`: 16 passed, with the new `a_wait_for_a_key_ends_when_the_window_is_not_in_front` and `a_binding_is_shown_only_once_its_file_took_it` (the second fails with the old order: "a key that was not saved is shown"). - `cargo test -p victory`: 79 + 1 + 2 passed, with the new `the_default_bindings_are_never_written_over_a_file_that_is_there`. - The script's copy line was run by hand in a scratch folder: a new file equals the default, an existing file is kept. - Run in parallel, one older menu test (`a_change_is_saved_at_once_however_the_game_was_started`) fails on main as well, without this change. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #1739 rewrites this area; #652 and #482 add their own remapping pages; none does these three. Written with help from Claude; everything above was built and run on my machine.
ItsYungFlexer commented 2026-11-29 12:06:38 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by ItsYungFlexer on 2026-11-29T12:06:38Z.


Thanks @hussainmussa for crediting my fork and keeping the HUD work separate. This covers the three safeguards I wanted upstream, so please proceed with your PR—I won’t submit duplicates.

My current build is victory-reviewed-defaults.exe, with its source now on [VIctory-NVIDIA-Reloaded/main](https://github.com/ItsYungFlexer/VIctory-NVIDIA-Reloaded). The previous main is preserved on a backup branch.

Codex reviewed your diff at d59447b2cca584e45ef1e69376493327c107fb13 and independently ran four isolated Rust checks plus the PowerShell no-overwrite copy check; all passed. That validation did not include the full upstream workspace suite or in-game testing.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7255573845 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2245#issuecomment-7255573845). Originally posted by [ItsYungFlexer](https://github.com/ItsYungFlexer) on 2026-11-29T12:06:38Z. --- Thanks @hussainmussa for crediting my fork and keeping the HUD work separate. This covers the three safeguards I wanted upstream, so please proceed with your PR—I won’t submit duplicates. My current build is **victory-reviewed-defaults.exe**, with its source now on [[VIctory-NVIDIA-Reloaded/main](https://github.com/ItsYungFlexer/VIctory-NVIDIA-Reloaded)](https://github.com/ItsYungFlexer/VIctory-NVIDIA-Reloaded). The previous main is preserved on a backup branch. Codex reviewed your diff at `d59447b2cca584e45ef1e69376493327c107fb13` and independently ran four isolated Rust checks plus the PowerShell no-overwrite copy check; all passed. That validation did not include the full upstream workspace suite or in-game testing.
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!2245
No description provided.