Read and edit the first key in BOM-prefixed bindings.ini #5029

Open
RanoGames wants to merge 1 commit from upstream-pr/5029 into main
RanoGames commented 2026-12-01 17:46:55 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by RanoGames on 2026-12-01T17:46:55Z.


What it changes

A UTF-8 byte-order mark at the start of bindings.ini becomes part of the first key name in the mouse and keyboard reader. A binding such as A = Enter then fails to parse. The F1 key-binding editor also misses that first binding and can append a second assignment when the player edits it.

Skip the leading BOM when reading binding names. Preserve it and the existing line endings when the F1 editor writes the new mapping.

How it was tested

Windows x64, commit 241e240f on 5fabb46e. Both tests use synthetic bindings and require no game or GPU rendering.

  • cargo test --locked -p victory-hle --lib reads_bindings_with_a_utf8_bom passed. This covers files starting with a binding or a comment.
  • cargo test --locked -p victory-gpu --lib edits_first_binding_in_a_utf8_bom_file passed. The editor reads the first key and replaces it once while preserving the BOM, CRLF and the next binding.

Checked for overlap

  • Searched open and closed reports for UTF-8 BOM handling and checked open changes to both source files. #4795 and #4798 handle victory-settings.txt for the launcher and general F1 settings. #1997 also handles the general menu settings file. This change covers the separate bindings.ini runtime parser and key-binding editor. #3722 concerns reloading bindings after edits and #4968 concerns key capture on focus loss.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5591225533 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/5029). Originally posted by [RanoGames](https://github.com/RanoGames) on 2026-12-01T17:46:55Z. --- ## What it changes A UTF-8 byte-order mark at the start of `bindings.ini` becomes part of the first key name in the mouse and keyboard reader. A binding such as `A = Enter` then fails to parse. The F1 key-binding editor also misses that first binding and can append a second assignment when the player edits it. Skip the leading BOM when reading binding names. Preserve it and the existing line endings when the F1 editor writes the new mapping. ## How it was tested Windows x64, commit `241e240f` on `5fabb46e`. Both tests use synthetic bindings and require no game or GPU rendering. - `cargo test --locked -p victory-hle --lib reads_bindings_with_a_utf8_bom` passed. This covers files starting with a binding or a comment. - `cargo test --locked -p victory-gpu --lib edits_first_binding_in_a_utf8_bom_file` passed. The editor reads the first key and replaces it once while preserving the BOM, CRLF and the next binding. ## Checked for overlap - [x] Searched open and closed reports for UTF-8 BOM handling and checked open changes to both source files. #4795 and #4798 handle `victory-settings.txt` for the launcher and general F1 settings. #1997 also handles the general menu settings file. This change covers the separate `bindings.ini` runtime parser and key-binding editor. #3722 concerns reloading bindings after edits and #4968 concerns key capture on focus loss.
cloph-dsp commented 2026-12-01 17:58:21 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by cloph-dsp on 2026-12-01T17:58:21Z.


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

Base 5fabb46eaf6ed8771321787f8871051abde69b9b, head 241e240f68b644e97252d12bb98a4f0855e97e09. git diff --numstat → crates/victory-gpu/src/host/menu.rs 23/2, crates/victory-hle/src/modules/mnk.rs 10/0.

Two new tests, both absent on the base (git grep -F <name> 5fabb46e -- . → no match, exit 1): edits_first_binding_in_a_utf8_bom_file and reads_bindings_with_a_utf8_bom.

Note the split: they live in two different crates, so one filter cannot find both.

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

$env:CARGO_TARGET_DIR='D:\Victory-Contrib\NVIDIA-Contrib\target-5029'
cargo test --locked -p victory-gpu --lib -- host::menu::binds::tests::edits_first_binding_in_a_utf8_bom_file --exact --test-threads=1 --quiet
cargo test --locked -p victory-hle --lib -- modules::gameinput::mnk::tests::reads_bindings_with_a_utf8_bom --exact --test-threads=1 --quiet

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

Both write their own BOM-prefixed bindings file in a temp dir and read it back through the parser; nothing touches the title's files or a device, GPU/driver N/A. No game data.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7320167945 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/5029#issuecomment-7320167945). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-12-01T17:58:21Z. --- Verification (independent, AI-assisted: Hy4 flash). Windows, Rust 1.100.0 (Scoop rust-msvc), MSVC, commit-scoped shallow worktree. Base `5fabb46eaf6ed8771321787f8871051abde69b9b`, head `241e240f68b644e97252d12bb98a4f0855e97e09`. `git diff --numstat` → crates/victory-gpu/src/host/menu.rs 23/2, crates/victory-hle/src/modules/mnk.rs 10/0. Two new tests, both absent on the base (`git grep -F <name> 5fabb46e -- .` → no match, exit 1): `edits_first_binding_in_a_utf8_bom_file` and `reads_bindings_with_a_utf8_bom`. Note the split: they live in two different crates, so one filter cannot find both. `git diff --check "5fabb46e..241e240f"` → no output, exit 0. ``` $env:CARGO_TARGET_DIR='D:\Victory-Contrib\NVIDIA-Contrib\target-5029' cargo test --locked -p victory-gpu --lib -- host::menu::binds::tests::edits_first_binding_in_a_utf8_bom_file --exact --test-threads=1 --quiet cargo test --locked -p victory-hle --lib -- modules::gameinput::mnk::tests::reads_bindings_with_a_utf8_bom --exact --test-threads=1 --quiet ``` Results: `running 1 test`, `test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 1161 filtered out; finished in 0.02s` and `1 passed; 0 failed; 0 ignored; 0 measured; 482 filtered out; finished in 0.00s`. Both write their own BOM-prefixed bindings file in a temp dir and read it back through the parser; nothing touches the title's files or a 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/5029:upstream-pr/5029'
git switch 'upstream-pr/5029'

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/5029'
git switch 'upstream-pr/5029'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/5029'
git switch 'upstream-pr/5029'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/5029'
git switch 'main'
git merge --squash 'upstream-pr/5029'
git switch 'main'
git merge --ff-only 'upstream-pr/5029'
git switch 'main'
git merge 'upstream-pr/5029'
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!5029
No description provided.