Honor Shift, Ctrl and Alt bindings in native mouse mode #4628

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

@⁠F0RLE on GitHub · 2026-12-01 00:10 UTC · original
F0RLE:fix/native-ini-modifiers → main · +59 −14 · 1 files · 1 commits · open

Refs #3801

What it changes

In native mouse mode, Windows reports left and right modifiers separately. A binding such as A = Shift in the existing bindings.ini therefore misses both physical Shift keys.

Match either side for plain Shift, Ctrl and Alt, and suppress the corresponding stock button so a remapped key does not fire both actions. Explicit left/right bindings still affect only that side. Left Shift and Left Ctrl retain vehicle pitch when the binding is generic. No config migration is needed.

How it was tested

  • cargo test --release --locked --offline -j 2 -p victory-hle --lib on 4999167b: 471 passed, 13 ignored. Includes regression tests for both sides, stock-button suppression and vehicle pitch.
  • cargo xtask policy: passed. No in-game test on this commit.

Checked for overlap

  • Searched open PRs for the same issue and for the file this touches. #4589 changes prompts, #3055 handles Native.* overrides, and #4587 changes the shipped layout. This patch fixes generic modifiers in existing unprefixed bindings on main.
**@⁠F0RLE** on GitHub · 2026-12-01 00:10 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4627) `F0RLE:fix/native-ini-modifiers` → `main` · +59 −14 · 1 files · 1 commits · open Refs #3801 ## What it changes In native mouse mode, Windows reports left and right modifiers separately. A binding such as `A = Shift` in the existing `bindings.ini` therefore misses both physical Shift keys. Match either side for plain `Shift`, `Ctrl` and `Alt`, and suppress the corresponding stock button so a remapped key does not fire both actions. Explicit left/right bindings still affect only that side. Left Shift and Left Ctrl retain vehicle pitch when the binding is generic. No config migration is needed. ## How it was tested - `cargo test --release --locked --offline -j 2 -p victory-hle --lib` on `4999167b`: 471 passed, 13 ignored. Includes regression tests for both sides, stock-button suppression and vehicle pitch. - `cargo xtask policy`: passed. No in-game test on this commit. ## Checked for overlap - [x] Searched open PRs for the same issue and for the file this touches. #4589 changes prompts, #3055 handles `Native.*` overrides, and #4587 changes the shipped layout. This patch fixes generic modifiers in existing unprefixed bindings on `main`.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 00:11:32 +00:00
Author
Owner

@⁠Trillazill on GitHub · 2026-12-01 07:15 UTC · original

A layout problem in the lines this PR rewrites, which it keeps ("Keep both physical-position and virtual-key matching"): on a non-US layout a bound letter also fires by its US position.

On a French AZERTY keyboard the key labelled Q sits where a US keyboard has A (scan 0x1E), so pad_key reports it as A. With the commenter's file in #4537 (MoveLeft = Q, A = A), pressing Q also presses what A = A binds. That is the "Q is the rear brake at the same time" there. The same mix-up lets the table's button at a key's place fire for a key the file binds by label: the A key (US Q position) also presses the table's LB.

bindings.ini names keys by their label (F1 KEY BINDINGS writes the virtual key that was pressed), so a bound key should count by virtual_key alone. A test on this branch shows it, with KeyState { scan_code: 0x1E, virtual_key: b'Q' } and bindings [(b'A', A)]:

assertion `left == right` failed: Q (bound to MoveLeft) presses the A button
  left: 4
 right: 0

Suggested change in stand_in_buttons. It keeps your generic-modifier handling and only drops the positional match for bound keys:

let bound_key = |k: &KeyState| {
    bound.iter().any(|&(key, _)| key == k.virtual_key || generic_modifier_matches(key, k.virtual_key))
};
let stock = FALLBACK_BUTTONS
    .iter()
    .filter(|&&(vk, _)| {
        !(driving && matches!(vk, 0xA0..=0xA3)) && keys.iter().any(|k| pad_key(k) == vk && !bound_key(k))
    })
    .fold(0, |all, (_, bit)| all | bit);
bound.iter().fold(stock, |all, &(vk, bit)| {
    let pressed = keys.iter().any(|k| {
        k.virtual_key == vk
            || (!(driving && matches!(k.virtual_key, 0xA0 | 0xA2))
                && generic_modifier_matches(vk, k.virtual_key))
    });
    if pressed { all | bit } else { all }
})

On US layouts this gives the same buttons, since a letter's position and label agree there. With it, cargo test -p victory-hle --lib -- gameinput:: passes 99 (2 ignored), including your modifier tests and the AZERTY one above. I couldn't check it in game: the game's key-file input reports letters at US positions, so AZERTY can't be played through it. I can push it to a branch if that's easier to pick up.

**@⁠Trillazill** on GitHub · 2026-12-01 07:15 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4627#issuecomment-7303830694) A layout problem in the lines this PR rewrites, which it keeps ("Keep both physical-position and virtual-key matching"): on a non-US layout a bound letter also fires by its US position. On a French AZERTY keyboard the key labelled **Q** sits where a US keyboard has A (scan 0x1E), so `pad_key` reports it as `A`. With the commenter's file in #4537 (`MoveLeft = Q`, `A = A`), pressing Q also presses what `A = A` binds. That is the "Q is the rear brake at the same time" there. The same mix-up lets the table's button at a key's place fire for a key the file binds by label: the A key (US Q position) also presses the table's LB. `bindings.ini` names keys by their label (F1 KEY BINDINGS writes the virtual key that was pressed), so a bound key should count by `virtual_key` alone. A test on this branch shows it, with `KeyState { scan_code: 0x1E, virtual_key: b'Q' }` and bindings `[(b'A', A)]`: ``` assertion `left == right` failed: Q (bound to MoveLeft) presses the A button left: 4 right: 0 ``` Suggested change in `stand_in_buttons`. It keeps your generic-modifier handling and only drops the positional match for bound keys: ```rust let bound_key = |k: &KeyState| { bound.iter().any(|&(key, _)| key == k.virtual_key || generic_modifier_matches(key, k.virtual_key)) }; let stock = FALLBACK_BUTTONS .iter() .filter(|&&(vk, _)| { !(driving && matches!(vk, 0xA0..=0xA3)) && keys.iter().any(|k| pad_key(k) == vk && !bound_key(k)) }) .fold(0, |all, (_, bit)| all | bit); bound.iter().fold(stock, |all, &(vk, bit)| { let pressed = keys.iter().any(|k| { k.virtual_key == vk || (!(driving && matches!(k.virtual_key, 0xA0 | 0xA2)) && generic_modifier_matches(vk, k.virtual_key)) }); if pressed { all | bit } else { all } }) ``` On US layouts this gives the same buttons, since a letter's position and label agree there. With it, `cargo test -p victory-hle --lib -- gameinput::` passes 99 (2 ignored), including your modifier tests and the AZERTY one above. I couldn't check it in game: the game's key-file input reports letters at US positions, so AZERTY can't be played through it. I can push it to a branch if that's easier to pick up.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-12-01 09:14 UTC · original

I applied Trillazill's suggested fix on the exact PR head 4999167b. Explicit button bindings now use the key label from the active layout. A held key already claimed by a binding skips its stock button. Unbound buttons keep their positional defaults. Review commit

The new Windows/MSVC regression reproduced the extra A button bit (4) for the Q key on AZERTY. With 36f66ad0ccb32e3e1fea69715c0a8e2dfb236e61, Q no longer emits A, the key labelled A emits only its bound button, and removing the binding restores the positional shoulder button. The two existing modifier tests passed, including generic Shift/Ctrl/Alt and vehicle pitch, and cargo xtask policy --staged accepted the one-file change.

This is the button-activation part of #4537. It is ready to cherry-pick into this PR with its Git author and co-author preserved. A run on the reporter's AZERTY setup is still needed.

AI-assisted with OpenAI Codex.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-12-01 09:14 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4627#issuecomment-7306427480) I applied Trillazill's [suggested fix](https://git.gtahub.st/github/trustno1-coder--VIctory-NVIDIA/pulls/4628) on the exact PR head `4999167b`. Explicit button bindings now use the key label from the active layout. A held key already claimed by a binding skips its stock button. Unbound buttons keep their positional defaults. [Review commit](https://github.com/andrewpozdnakov7-jpg/VIctory-NVIDIA/commit/36f66ad0ccb32e3e1fea69715c0a8e2dfb236e61) The new Windows/MSVC regression reproduced the extra A button bit (4) for the Q key on AZERTY. With `36f66ad0ccb32e3e1fea69715c0a8e2dfb236e61`, Q no longer emits A, the key labelled A emits only its bound button, and removing the binding restores the positional shoulder button. The two existing modifier tests passed, including generic Shift/Ctrl/Alt and vehicle pitch, and `cargo xtask policy --staged` accepted the one-file change. This is the button-activation part of #4537. It is ready to cherry-pick into this PR with its Git author and co-author preserved. A run on the reporter's AZERTY setup is still needed. AI-assisted with OpenAI Codex.
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/4628/head:github-bot/gh-4627'
git switch 'github-bot/gh-4627'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-4627'
git switch 'github-bot/gh-4627'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-4627'
git switch 'github-bot/gh-4627'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-4627'
git switch 'main'
git merge --squash 'github-bot/gh-4627'
git switch 'main'
git merge --ff-only 'github-bot/gh-4627'
git switch 'main'
git merge 'github-bot/gh-4627'
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!4628
No description provided.