input: the pad's triggers and the menus the mouse drives #500

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

@⁠lynxnathan on GitHub · 2026-12-04 19:22 UTC · original
lynxnathan:fix/controller-input → main · +176 −5 · 3 files · 1 commits · draft

Fixes #383, and the dead-menu half of #73.

The menu part is the same bit-3 acceptance as #448 (still open): this one also covers in_menu_now and action_active, which #448 did not touch, so it is a superset — if #448 lands first, that half here rebases down to nothing.

Summary

Keyboard-and-mouse play hands the title a stand-in pad (native_input(), on unless VICTORY_NATIVE_INPUT=0). Four things went wrong around it: the mouse dying in the first seconds of a run, a trigger that never fires, a right click pressing both triggers, and menus that eat the confirm button.

  1. The pad's trigger axes were never written. The mouse buttons only arrived as the virtual keys F13..F17 (config/native-keys.default.txt binds LeftClick/RightClick to action lists), so every scene that reads the axis instead of the action — the pull prompts, scripted LT/RT, brake and gas — saw no trigger at all, from any button.
  2. The relay sent the click's own action back as a trigger. It resolves the action the click activated to its pad source; for a right click in one pull scene that is 0x300c (RT), which was then sent as a pad event of its own. A held right click arrived as LT and RT together.
  3. A click that re-locked the capture muted itself. On button-down the capture does release + acquire when no raw motion has arrived (Xwayland with no relative-pointer support), and acquire seeds blocked from the buttons held at that instant — the click asking for the re-lock. read and read_native then mask it out until released (#383).
  4. Menus that mark their actions active on bit 3 were not recognised as menus. in_menu_now and action_active read bit 1 only, so the resolver's bit-3 acceptance never ran and every key of those menus was dropped (#73).

Changes

  • crates/victory-hle/src/modules/gameinput.rs: in the native branch, write lt/rt from the same buttons the title receives as keys — LMB is RT (shoot, gas), RMB is LT (aim, brake-reverse), as on the console's pad.
  • crates/victory-hle/src/modules/gameinput/mouse.rs: don't mute the button that triggered a re-lock (blocked &= !trigger after acquire); VICTORY_DEBUG_PAD=1 prints the pad on change (buttons, the relay's triggers, the triggers handed over).
  • crates/victory-loader/src/keyboard_events.rs: the mouse's virtual keys (0x7c..=0x7e) send no trigger source (they keep the button source); accept action state bit 3 in in_menu_now and action_active, as the resolver already does. New test a_mouse_button_sends_no_trigger_source.

Testing

  • RX 9070 XT (RADV GFX1201), Mesa 26.3.1 patched, Proton-CachyOS 11.0 SLR, GNOME Wayland + Xwayland, 2560x1440 with the title's built-in upscaler.
  • In game, instrumented (VICTORY_DEBUG_PAD=1), pull-prompt scene. Before: native pad buttons=0x02 relay_rt=1.0 lt=1.0 rt=1.0 (right click, both triggers) and the prompt ignored LT. After: relay_lt=0.0 relay_rt=0.0 lt=1.0 rt=0.0 for the right button, lt=0.0 rt=1.0 for the left, and the prompt takes either.
  • Menus: the confirm button works in the submenus that were dead (bit 3), with and without #448 applied.
  • ./build.sh test (Windows target, run under Wine): victory-loader 87 passed, 0 failed; victory-hle 155 passed, 7 failed — the same 7 that fail on main b2449c4 in this environment (gameinput ×3, lifecycle ×2, net, xgamesave), none of them this change.

Not measured

  • One title build, one machine, no physical pad and no DualSense: pad-device merging, rumble and the DualSense paths are untouched here but were not re-tested.
  • The weapon wheel and the map screen were not re-tested; only the submenus that were reported dead.
  • GetAsyncKeyState vs WM_*BUTTONDOWN was compared with a throwaway Win32 program under the same Proton (both agree), not across Wine versions.

Credits

The menu half builds on #448 (PoleTransformer) and #73; the capture half on #383.

**@⁠lynxnathan** on GitHub · 2026-12-04 19:22 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/500) `lynxnathan:fix/controller-input` → `main` · +176 −5 · 3 files · 1 commits · draft Fixes #383, and the dead-menu half of #73. The menu part is the same bit-3 acceptance as #448 (still open): this one also covers `in_menu_now` and `action_active`, which #448 did not touch, so it is a superset — if #448 lands first, that half here rebases down to nothing. ### Summary Keyboard-and-mouse play hands the title a stand-in pad (`native_input()`, on unless `VICTORY_NATIVE_INPUT=0`). Four things went wrong around it: the mouse dying in the first seconds of a run, a trigger that never fires, a right click pressing both triggers, and menus that eat the confirm button. 1. **The pad's trigger axes were never written.** The mouse buttons only arrived as the virtual keys `F13..F17` (`config/native-keys.default.txt` binds `LeftClick`/`RightClick` to action lists), so every scene that reads the *axis* instead of the action — the pull prompts, scripted `LT`/`RT`, brake and gas — saw no trigger at all, from any button. 2. **The relay sent the click's own action back as a trigger.** It resolves the action the click activated to its pad source; for a right click in one pull scene that is `0x300c` (RT), which was then sent as a pad event of its own. A held right click arrived as **LT and RT together**. 3. **A click that re-locked the capture muted itself.** On button-down the capture does `release` + `acquire` when no raw motion has arrived (Xwayland with no relative-pointer support), and `acquire` seeds `blocked` from the buttons held at that instant — the click asking for the re-lock. `read` and `read_native` then mask it out until released (#383). 4. **Menus that mark their actions active on bit 3 were not recognised as menus.** `in_menu_now` and `action_active` read bit 1 only, so the resolver's bit-3 acceptance never ran and every key of those menus was dropped (#73). ### Changes - `crates/victory-hle/src/modules/gameinput.rs`: in the native branch, write `lt`/`rt` from the same buttons the title receives as keys — LMB is RT (shoot, gas), RMB is LT (aim, brake-reverse), as on the console's pad. - `crates/victory-hle/src/modules/gameinput/mouse.rs`: don't mute the button that triggered a re-lock (`blocked &= !trigger` after `acquire`); `VICTORY_DEBUG_PAD=1` prints the pad on change (buttons, the relay's triggers, the triggers handed over). - `crates/victory-loader/src/keyboard_events.rs`: the mouse's virtual keys (`0x7c..=0x7e`) send no *trigger* source (they keep the button source); accept action state bit 3 in `in_menu_now` and `action_active`, as the resolver already does. New test `a_mouse_button_sends_no_trigger_source`. ### Testing - RX 9070 XT (RADV GFX1201), Mesa 26.3.1 patched, Proton-CachyOS 11.0 SLR, GNOME Wayland + Xwayland, 2560x1440 with the title's built-in upscaler. - In game, instrumented (`VICTORY_DEBUG_PAD=1`), pull-prompt scene. Before: `native pad buttons=0x02 relay_rt=1.0 lt=1.0 rt=1.0` (right click, both triggers) and the prompt ignored LT. After: `relay_lt=0.0 relay_rt=0.0 lt=1.0 rt=0.0` for the right button, `lt=0.0 rt=1.0` for the left, and the prompt takes either. - Menus: the confirm button works in the submenus that were dead (bit 3), with and without #448 applied. - `./build.sh test` (Windows target, run under Wine): `victory-loader` **87 passed, 0 failed**; `victory-hle` **155 passed, 7 failed** — the same 7 that fail on `main` `b2449c4` in this environment (`gameinput` ×3, `lifecycle` ×2, `net`, `xgamesave`), none of them this change. ### Not measured - One title build, one machine, no physical pad and no DualSense: pad-device merging, rumble and the DualSense paths are untouched here but were not re-tested. - The weapon wheel and the map screen were not re-tested; only the submenus that were reported dead. - `GetAsyncKeyState` vs `WM_*BUTTONDOWN` was compared with a throwaway Win32 program under the same Proton (both agree), not across Wine versions. ### Credits The menu half builds on #448 (PoleTransformer) and #73; the capture half on #383.
Keyboard-and-mouse play hands the title a stand-in pad, and three things went
wrong around it. Together they are the mouse dying in the first seconds of a
run, a trigger that never fires, and menus that eat the confirm button.

- The pad's trigger axes were never written on the default (`native_input()`)
  path: the mouse buttons only arrived as F13..F17 keys, so every scene that
  reads the axis — the pull prompts, scripted LT/RT, brake and gas — saw no
  trigger at all. Drive them from the same buttons, as the console's pad has
  them: LMB is RT (shoot, gas), RMB is LT (aim, brake-reverse).
- The relay resolves the click's own action back to a pad source and sent it as
  a pad event of its own, so a held right click arrived as LT and RT together.
  The mouse's virtual keys must not send a trigger source; they still send the
  button source the title needs for the actions that are not triggers.
- A click that re-locked the capture muted itself: `release` + `acquire` seeds
  `blocked` from the buttons held at that instant, which on Xwayland (no raw
  motion arrives) is the click asking for the re-lock (#383).
- Menus that mark their actions active on bit 3 were not recognised as menus:
  `in_menu_now` and `action_active` read bit 1 only, and the resolver's
  bit-3 acceptance (#448, #73) was never reached. Accept both bits in the three
  readers, so the confirm button of those menus works.

`VICTORY_DEBUG_PAD=1` prints the pad on change (buttons, the relay's triggers,
the triggers handed over): it is what told a lost button from a lost field.

Credits: the menu half builds on #448 by PoleTransformer and #73; the capture
half on #383.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-04 19:27:14 +00:00
github-bot force-pushed github-bot/gh-500 from e60b29b0c0 to 953d32b89f 2026-12-04 19:32:38 +00:00 Compare
Author
Owner

@⁠Kal0s-design on GitHub · 2026-12-04 19:53 UTC · original

Checked 953d32b on native Windows (didn't run the game). Baseline is the merge-base b2449c4; main hasn't touched these three files since.

Tests, MSVC, not Wine. VICTORY_NATIVE_INPUT=0 cargo test -p victory-hle --lib gives 162 passed, 0 failed, 1 ignored on both PR and base, so the 7 failures in the description look like a Wine thing. cargo test -p victory-loader --lib gives 87 passed on the PR, 86 on base (the new test). The loader tests don't need any input hooks. Clippy on both crates shows no new warnings, just the same ones as base.

The re-lock fix (point 3, #383) isn't in the diff. The description says blocked &= !trigger after acquire, but the only mouse.rs changes are the two debug fields and the logging. acquire still seeds blocked: mouse_buttons() (mouse.rs:400), the button-down arm still does release + acquire (568-577), and read_native still masks it (818-819). So a click that triggers a re-lock is still muted until it's released, and that now includes the new trigger axes too. It isn't only an Xwayland thing either. last_raw is only set by raw motion (mouse.rs:91) and acquire resets the whole Capture, so on Windows a click before the first mouse move after getting focus back takes the same path. Maybe a commit got left behind?

Bit 3 in in_menu_now and action_active (keyboard_events.rs:377, 407). The PLAY_ACTION note at 157-158 says INPUT_MOVE_UP_ONLY is 0x0a in play and 0x08 in a menu. With & (2|8), 0x08 counts as active, so play comes out true and context says "not a menu". I checked this with a throwaway test that builds a fake action array and calls in_menu_now directly.

  • MOVE_UP 0x08 + FRONTEND_ACCEPT 0x02 (a normal pause menu, going by that note) gives menu on base and not a menu on the PR
  • MOVE_UP 0x08 + ACCEPT 0x08 gives not a menu on both
  • MOVE_UP 0x00 + ACCEPT 0x08 gives not a menu on base and a menu on the PR (the case this is for)
  • play (0x0a) gives not a menu on both

So it only helps when the play action is fully off. Where it keeps 0x08, a menu that's detected today would stop being detected. action_active also feeds the play check in watch_menus (458), so IN_MENU would go false there too, along with the map flag (461), which needs menu. VEH_ACCEL (462), the radial actions (444-446) and the nav list (450) all get the wider bit as well. I can't see live action states, so this is going by the note, but it would be worth a log line from the pause menu (the "input context changed" one) before and after.

resolve_active_sources (1053-1065) is #448's change as it was. So the point from there still applies: an action with only 0x8 set can win over a later one that's really active. The new mouse filter makes that worse. LeftClick's menu list starts with SCRIPT_RT and CONTEXT_RT (native-keys.default.txt:16). With MOVE_UP 0x00, SCRIPT_RT 0x08 and ACCEPT 0x02, base resolves ACCEPT and sends A. The PR resolves SCRIPT_RT, the filter drops RT (keyboard_events.rs:564-575), and apply_press_many returns with nothing sent. The click ends up as only the pad's RT, with no accept. A menu-only second pass that accepts 0x8 after a normal 0x2 pass finds nothing would avoid both problems.

The relay filter does what it says. One thing about the new test, though. The resolver hands triggers over as axes (is_axis covers 0x3009/0x300c, keyboard_events.rs:967-969), so a real click is (0x300c, true, 1.0), not the false the test uses. I ran the same sequences with the axis form on both trees.

  • base holds the click as a relay axis (rt=1 while LMB is down, lt=1 while RMB is down, both with both held), which goes into the pad through with_held_axes (gameinput.rs:557-558), and every release puts it back to 0
  • the PR holds nothing for mouse keys, so the pad's own trigger is the only one, which is the point
  • rapid taps and a release without a press leave nothing held on either
  • keyboard keys keep their trigger source

Trigger axes (gameinput.rs:1074-1082). I read this part but couldn't run it, since it sits behind GetAsyncKeyState and the foreground check. It's 0 or 1.0, recomputed every poll. Release clears it on the next poll, and so does losing focus, because read_native returns all zeros when the window isn't foreground (mouse.rs:791-793). So I don't see a way for it to stick after alt-tab. There's no new shared state for it to race on either. It's set on a local pad from the read_native snapshot, which is taken under the capture mutex, and the menu flags are the same relaxed loads as before. The only new shared thing is the debug LAST mutex. A tap shorter than the poll can be missed, same as F13 on base. The non-native path already did this (2116-2119), so this brings the two in line.

It's written after the menu/map/wheel branches, though, so it applies everywhere.

  • On the map, LMB forces RT=1.0 over the wheel zoom (1060-1061), so a left click there would also zoom in, and a right click zoom out
  • In ordinary menus every accept/cancel click also holds a trigger
  • The settings overlay. keys() drops keyboard input while menu::is_open() (1960), but read_native has no such check, and I couldn't find anything that releases the capture when the overlay opens. The non-native path returns an empty pad there (2017). So an overlay click may now reach the title as RT/LT.

You said the map and the wheel weren't re-tested, so these are worth a quick look.

VICTORY_NATIVE_INPUT=0 only covers the hle half. keyboard_events::start is called on every run (apps/victory/src/run.rs:209) and starts the menu watcher unless VICTORY_KEY_ACTIONS is set (keyboard_events.rs:1510-1527), so the bit 3 change applies with native input off too. The mouse filter doesn't matter there, since F13-F15 only come from the native branch.

AI-assisted: yes

**@⁠Kal0s-design** on GitHub · 2026-12-04 19:53 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/500#issuecomment-7422533724) Checked 953d32b on native Windows (didn't run the game). Baseline is the merge-base b2449c4; main hasn't touched these three files since. Tests, MSVC, not Wine. `VICTORY_NATIVE_INPUT=0 cargo test -p victory-hle --lib` gives 162 passed, 0 failed, 1 ignored on both PR and base, so the 7 failures in the description look like a Wine thing. `cargo test -p victory-loader --lib` gives 87 passed on the PR, 86 on base (the new test). The loader tests don't need any input hooks. Clippy on both crates shows no new warnings, just the same ones as base. The re-lock fix (point 3, #383) isn't in the diff. The description says `blocked &= !trigger` after `acquire`, but the only mouse.rs changes are the two debug fields and the logging. `acquire` still seeds `blocked: mouse_buttons()` (mouse.rs:400), the button-down arm still does release + acquire (568-577), and `read_native` still masks it (818-819). So a click that triggers a re-lock is still muted until it's released, and that now includes the new trigger axes too. It isn't only an Xwayland thing either. `last_raw` is only set by raw motion (mouse.rs:91) and `acquire` resets the whole `Capture`, so on Windows a click before the first mouse move after getting focus back takes the same path. Maybe a commit got left behind? Bit 3 in `in_menu_now` and `action_active` (keyboard_events.rs:377, 407). The PLAY_ACTION note at 157-158 says INPUT_MOVE_UP_ONLY is 0x0a in play and 0x08 in a menu. With `& (2|8)`, 0x08 counts as active, so `play` comes out true and `context` says "not a menu". I checked this with a throwaway test that builds a fake action array and calls `in_menu_now` directly. - MOVE_UP 0x08 + FRONTEND_ACCEPT 0x02 (a normal pause menu, going by that note) gives menu on base and not a menu on the PR - MOVE_UP 0x08 + ACCEPT 0x08 gives not a menu on both - MOVE_UP 0x00 + ACCEPT 0x08 gives not a menu on base and a menu on the PR (the case this is for) - play (0x0a) gives not a menu on both So it only helps when the play action is fully off. Where it keeps 0x08, a menu that's detected today would stop being detected. `action_active` also feeds the play check in `watch_menus` (458), so IN_MENU would go false there too, along with the map flag (461), which needs menu. VEH_ACCEL (462), the radial actions (444-446) and the nav list (450) all get the wider bit as well. I can't see live action states, so this is going by the note, but it would be worth a log line from the pause menu (the "input context changed" one) before and after. `resolve_active_sources` (1053-1065) is #448's change as it was. So the point from there still applies: an action with only 0x8 set can win over a later one that's really active. The new mouse filter makes that worse. LeftClick's menu list starts with SCRIPT_RT and CONTEXT_RT (native-keys.default.txt:16). With MOVE_UP 0x00, SCRIPT_RT 0x08 and ACCEPT 0x02, base resolves ACCEPT and sends A. The PR resolves SCRIPT_RT, the filter drops RT (keyboard_events.rs:564-575), and `apply_press_many` returns with nothing sent. The click ends up as only the pad's RT, with no accept. A menu-only second pass that accepts 0x8 after a normal 0x2 pass finds nothing would avoid both problems. The relay filter does what it says. One thing about the new test, though. The resolver hands triggers over as axes (`is_axis` covers 0x3009/0x300c, keyboard_events.rs:967-969), so a real click is `(0x300c, true, 1.0)`, not the `false` the test uses. I ran the same sequences with the axis form on both trees. - base holds the click as a relay axis (rt=1 while LMB is down, lt=1 while RMB is down, both with both held), which goes into the pad through `with_held_axes` (gameinput.rs:557-558), and every release puts it back to 0 - the PR holds nothing for mouse keys, so the pad's own trigger is the only one, which is the point - rapid taps and a release without a press leave nothing held on either - keyboard keys keep their trigger source Trigger axes (gameinput.rs:1074-1082). I read this part but couldn't run it, since it sits behind GetAsyncKeyState and the foreground check. It's 0 or 1.0, recomputed every poll. Release clears it on the next poll, and so does losing focus, because `read_native` returns all zeros when the window isn't foreground (mouse.rs:791-793). So I don't see a way for it to stick after alt-tab. There's no new shared state for it to race on either. It's set on a local `pad` from the `read_native` snapshot, which is taken under the capture mutex, and the menu flags are the same relaxed loads as before. The only new shared thing is the debug `LAST` mutex. A tap shorter than the poll can be missed, same as F13 on base. The non-native path already did this (2116-2119), so this brings the two in line. It's written after the menu/map/wheel branches, though, so it applies everywhere. - On the map, LMB forces RT=1.0 over the wheel zoom (1060-1061), so a left click there would also zoom in, and a right click zoom out - In ordinary menus every accept/cancel click also holds a trigger - The settings overlay. `keys()` drops keyboard input while `menu::is_open()` (1960), but `read_native` has no such check, and I couldn't find anything that releases the capture when the overlay opens. The non-native path returns an empty pad there (2017). So an overlay click may now reach the title as RT/LT. You said the map and the wheel weren't re-tested, so these are worth a quick look. `VICTORY_NATIVE_INPUT=0` only covers the hle half. `keyboard_events::start` is called on every run (apps/victory/src/run.rs:209) and starts the menu watcher unless `VICTORY_KEY_ACTIONS` is set (keyboard_events.rs:1510-1527), so the bit 3 change applies with native input off too. The mouse filter doesn't matter there, since F13-F15 only come from the native branch. AI-assisted: yes
Author
Owner

@⁠lynxnathan on GitHub · 2026-12-04 21:24 UTC · original

Not ready for prime time yet

**@⁠lynxnathan** on GitHub · 2026-12-04 21:24 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/500#issuecomment-7424647585) Not ready for prime time yet
This pull request has changes conflicting with the target branch.
  • crates/victory-hle/src/modules/gameinput.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/500/head:github-bot/gh-500'
git switch 'github-bot/gh-500'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-500'
git switch 'github-bot/gh-500'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-500'
git switch 'github-bot/gh-500'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-500'
git switch 'main'
git merge --squash 'github-bot/gh-500'
git switch 'main'
git merge --ff-only 'github-bot/gh-500'
git switch 'main'
git merge 'github-bot/gh-500'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.