menu: allow keyboard input on certain menus #448

Open
github-bot wants to merge 4 commits from github-bot/gh-448 into main AGit
Owner

@⁠PoleTransformer on GitHub · 2026-12-04 07:40 UTC · original
PoleTransformer:input_submenu → main · +26 −1 · 1 files · 4 commits · open

Fixes controls(A and B) dont work in certain menus. I've experienced this in the game save override menu and in gameplay menus during missions.

Likely related to this issue: #383

Logs captured during gameplay:

Pressing escape on keyboard to pause:

2026-12-05T04:12:05.778716Z TRACE keyboard_events: action +0x158 state monitor action=0xd82e0bd2 state=0x0000000a eligible=true in_menu=false bit_2=true bit_4=true bit_2_or_4=true

Entering game save override menu:

2026-12-05T04:14:06.487188Z TRACE keyboard_events: action +0x158 state monitor action=0x8dddc16e state=0x00000008 eligible=true in_menu=true bit_2=false bit_4=true bit_2_or_4=true

The oracle here is bit 4 is still active in the override save menu, while bit 2 toggles to 0.

In gameplay menu during storyline:

Upon entering the scripted scene, input context changed is fired:

2026-12-05T05:52:57.397339Z  INFO keyboard_events: input context changed menu=true map=false wheel=false veh=false walking=false menu_actions=["0x43dbf61f", "0x308588e6", "0x911cb09e", "0x4403f97f"]

After pressing Enter on keyboard in that gameplay menu to confirm repair:

2026-12-05T05:53:06.364987Z TRACE keyboard_events: action +0x158 state monitor action=0x8dddc16e state=0x00000000 eligible=false in_menu=true bit_2=false bit_4=false bit_2_or_4=false
2026-12-05T05:53:06.365001Z TRACE keyboard_events: action +0x158 state monitor action=0x43dbf61f state=0x0000000c eligible=true in_menu=true bit_2=false bit_4=true bit_2_or_4=true

In both cases bit 2 is false, while bit 4 remains true.

**@⁠PoleTransformer** on GitHub · 2026-12-04 07:40 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/448) `PoleTransformer:input_submenu` → `main` · +26 −1 · 1 files · 4 commits · open Fixes controls(A and B) dont work in certain menus. I've experienced this in the game save override menu and in gameplay menus during missions. Likely related to this issue: https://git.gtahub.st/github/lobomfz--VIctory-xmem/issues/383 Logs captured during gameplay: Pressing escape on keyboard to pause: ``` 2026-12-05T04:12:05.778716Z TRACE keyboard_events: action +0x158 state monitor action=0xd82e0bd2 state=0x0000000a eligible=true in_menu=false bit_2=true bit_4=true bit_2_or_4=true ``` Entering game save override menu: ``` 2026-12-05T04:14:06.487188Z TRACE keyboard_events: action +0x158 state monitor action=0x8dddc16e state=0x00000008 eligible=true in_menu=true bit_2=false bit_4=true bit_2_or_4=true ``` The oracle here is bit 4 is still active in the override save menu, while bit 2 toggles to 0. In gameplay menu during storyline: Upon entering the scripted scene, `input context changed` is fired: ``` 2026-12-05T05:52:57.397339Z INFO keyboard_events: input context changed menu=true map=false wheel=false veh=false walking=false menu_actions=["0x43dbf61f", "0x308588e6", "0x911cb09e", "0x4403f97f"] ``` After pressing Enter on keyboard in that gameplay menu to confirm repair: ``` 2026-12-05T05:53:06.364987Z TRACE keyboard_events: action +0x158 state monitor action=0x8dddc16e state=0x00000000 eligible=false in_menu=true bit_2=false bit_4=false bit_2_or_4=false 2026-12-05T05:53:06.365001Z TRACE keyboard_events: action +0x158 state monitor action=0x43dbf61f state=0x0000000c eligible=true in_menu=true bit_2=false bit_4=true bit_2_or_4=true ``` In both cases bit 2 is false, while bit 4 remains true.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-04 07:43:13 +00:00
Author
Owner

@⁠Kal0s-design on GitHub · 2026-12-04 08:00 UTC · original

Had a read through this one (head 24db9bf).

What it changes. Only resolve_active_sources in keyboard_events.rs (1030-1044). Before, an action counted only if +0x158 had the 0x2 bit. Now, while in_menu_now says we're in a menu, 0x2 or 0x8 is enough. Outside menus nothing changes. This is the keyboard/mouse to pad translation path only, so a real controller's A/B never goes through it. I read the A/B in the description as the keys that end up as A/B (Enter, Esc, clicks).

Things I checked that look fine

  • No double input. The function still returns one action per key (or one chord), and the native keyboard event is forwarded the same as before (relay, 81 then 86).
  • No stuck keys. Release goes through HELD by key (apply_release, 1216), not by re-resolving, so whatever got pressed gets released. Menu enter/exit still runs release_all_held and press_again (watch_menus, 482-484).
  • Our own settings menu still swallows everything. relay returns before translate when victory_core::menu::is_open() (70-79), and that's untouched.
  • Callers. git grep finds the function only in this file: press_again (684), retranslate_held (795) and translate (1183). press_again only runs after leaving a menu (484), so it mostly keeps the old rule. The other two get the wider rule whenever the menu check is true.

Things I'd look at before merging

  1. 0x8 doesn't mean "active". The file's own note on PLAY_ACTION (157-158) says INPUT_MOVE_UP_ONLY reads 0x0a in play and 0x08 in a menu. So at least one play action keeps 0x8 set while a menu is up. In a menu translate tries the menu list first and then the play list (1114-1119). With this change, any play action that has 0x8 set can now fire in a menu, and before it couldn't. Keys with an empty menu list are the easy case (T, Y, U, I, J, K, L, F9, F10 in native-keys.default.txt). Before, they did nothing in the pause menu. Now they send their play action's pad button if that action has 0x8 set.
  2. List order matters more now. The first entry that passes wins, so an entry with only 0x8 set can beat a later one that's really active. LeftClick's menu list starts with INPUT_SCRIPT_RT and INPUT_CONTEXT_RT, ahead of the accept actions (native-keys.default.txt:16, and the test at keyboard_events.rs:1768 pins SCRIPT_RT first). If SCRIPT_RT has 0x8 set in a normal menu, a left click there would send RT instead of accept. Same for RightClick and SCRIPT_LT/CONTEXT_LT (line 17). I can't tell from the code which actions have 0x8 set in which menus, so I can't say if it really happens. It's a possible regression in menus that work today, though.
  3. The fix only applies where in_menu_now is already true, and that needs one of MENU_ACTIONS to have 0x2 set (361-381). If the save override menu doesn't meet that, this branch never runs there. A log line from that menu would settle it (the "input context changed" one with menu=true and the menu_actions list, 461-473).
  4. Small stuff. in_menu_now is called inside the loop, once per matching action, and each call scans the whole action array again. It'd be cheaper to work it out once before the loop. It also doesn't account for IN_WHEEL, while translate does (1108). Passing in_menu in from the caller would keep the two in sync. The new if also isn't rustfmt-formatted, though main isn't fmt-clean either.

A narrower version would keep 0x2 as the first pass over the whole list, and only when nothing matches, do a second pass over the menu list alone that accepts 0x8. Normal menus would behave exactly as before, and play actions could never fire in a menu.

Tests. cargo test -p victory-loader --lib on the PR head, run natively on Windows (MSVC, not Wine): 84 passed, 0 failed. The changed logic reads live memory and isn't a pure function, so I didn't add tests for it. Not tested in game.

AI-assisted: yes

**@⁠Kal0s-design** on GitHub · 2026-12-04 08:00 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/448#issuecomment-7405363568) Had a read through this one (head 24db9bf). What it changes. Only `resolve_active_sources` in keyboard_events.rs (1030-1044). Before, an action counted only if +0x158 had the 0x2 bit. Now, while `in_menu_now` says we're in a menu, 0x2 or 0x8 is enough. Outside menus nothing changes. This is the keyboard/mouse to pad translation path only, so a real controller's A/B never goes through it. I read the A/B in the description as the keys that end up as A/B (Enter, Esc, clicks). Things I checked that look fine - No double input. The function still returns one action per key (or one chord), and the native keyboard event is forwarded the same as before (relay, 81 then 86). - No stuck keys. Release goes through HELD by key (`apply_release`, 1216), not by re-resolving, so whatever got pressed gets released. Menu enter/exit still runs `release_all_held` and `press_again` (watch_menus, 482-484). - Our own settings menu still swallows everything. relay returns before `translate` when `victory_core::menu::is_open()` (70-79), and that's untouched. - Callers. git grep finds the function only in this file: `press_again` (684), `retranslate_held` (795) and `translate` (1183). press_again only runs after leaving a menu (484), so it mostly keeps the old rule. The other two get the wider rule whenever the menu check is true. Things I'd look at before merging 1. 0x8 doesn't mean "active". The file's own note on PLAY_ACTION (157-158) says INPUT_MOVE_UP_ONLY reads 0x0a in play and 0x08 in a menu. So at least one play action keeps 0x8 set while a menu is up. In a menu `translate` tries the menu list first and then the play list (1114-1119). With this change, any play action that has 0x8 set can now fire in a menu, and before it couldn't. Keys with an empty menu list are the easy case (T, Y, U, I, J, K, L, F9, F10 in native-keys.default.txt). Before, they did nothing in the pause menu. Now they send their play action's pad button if that action has 0x8 set. 2. List order matters more now. The first entry that passes wins, so an entry with only 0x8 set can beat a later one that's really active. LeftClick's menu list starts with INPUT_SCRIPT_RT and INPUT_CONTEXT_RT, ahead of the accept actions (native-keys.default.txt:16, and the test at keyboard_events.rs:1768 pins SCRIPT_RT first). If SCRIPT_RT has 0x8 set in a normal menu, a left click there would send RT instead of accept. Same for RightClick and SCRIPT_LT/CONTEXT_LT (line 17). I can't tell from the code which actions have 0x8 set in which menus, so I can't say if it really happens. It's a possible regression in menus that work today, though. 3. The fix only applies where `in_menu_now` is already true, and that needs one of MENU_ACTIONS to have 0x2 set (361-381). If the save override menu doesn't meet that, this branch never runs there. A log line from that menu would settle it (the "input context changed" one with menu=true and the menu_actions list, 461-473). 4. Small stuff. `in_menu_now` is called inside the loop, once per matching action, and each call scans the whole action array again. It'd be cheaper to work it out once before the loop. It also doesn't account for IN_WHEEL, while `translate` does (1108). Passing `in_menu` in from the caller would keep the two in sync. The new `if` also isn't rustfmt-formatted, though main isn't fmt-clean either. A narrower version would keep 0x2 as the first pass over the whole list, and only when nothing matches, do a second pass over the menu list alone that accepts 0x8. Normal menus would behave exactly as before, and play actions could never fire in a menu. Tests. `cargo test -p victory-loader --lib` on the PR head, run natively on Windows (MSVC, not Wine): 84 passed, 0 failed. The changed logic reads live memory and isn't a pure function, so I didn't add tests for it. Not tested in game. AI-assisted: yes
Author
Owner

@⁠Luxuride on GitHub · 2026-12-04 11:28 UTC · original

The bit's meaning is the whole PR, and the only recorded evidence in the tree says the opposite: crates/victory-loader/src/keyboard_events.rs:157-158 notes 0x0a in play and 0x08 in a menu for PLAY_ACTION — i.e. 8 is what an action reads while a menu is suppressing it, not a mark of "this menu wants keyboard". If that generalises, state & (2 | 8) is true for nearly every action whenever a menu is up. Please attach a +0x158 dump from the save-override menu (and an ordinary pause menu) showing 8 selects only the actions you mean.

Also: the comment at keyboard_events.rs:1032 says "bit 3" for & 8; this file numbers bits one-based (:1070 pairs "bit 2" with & 2), so pick one. And in_menu_now(base) walks the whole action table — hoist it above the for &id in actions loop the way in_plane_now is hoisted at :1019-1021.

Partly superseded: 50861c5 already fixed footer confirmation dialogs via bindings (:1772-1794). If #383's menus are those footers this cannot help; if they are the save-override and story menus, say so — it is worth knowing which case still reproduces.

**@⁠Luxuride** on GitHub · 2026-12-04 11:28 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/448#issuecomment-7410141041) The bit's meaning is the whole PR, and the only recorded evidence in the tree says the opposite: `crates/victory-loader/src/keyboard_events.rs:157-158` notes `0x0a` in play and `0x08` *in a menu* for `PLAY_ACTION` — i.e. `8` is what an action reads while a menu is suppressing it, not a mark of "this menu wants keyboard". If that generalises, `state & (2 | 8)` is true for nearly every action whenever a menu is up. Please attach a `+0x158` dump from the save-override menu (and an ordinary pause menu) showing `8` selects only the actions you mean. Also: the comment at `keyboard_events.rs:1032` says "bit 3" for `& 8`; this file numbers bits one-based (`:1070` pairs "bit 2" with `& 2`), so pick one. And `in_menu_now(base)` walks the whole action table — hoist it above the `for &id in actions` loop the way `in_plane_now` is hoisted at `:1019-1021`. Partly superseded: `50861c5` already fixed footer confirmation dialogs via bindings (`:1772-1794`). If #383's menus are those footers this cannot help; if they are the save-override and story menus, say so — it is worth knowing which case still reproduces.
github-bot changed title from menu: allow input on certain menus to menu: allow keyboard input on certain menus 2026-12-05 04:32:44 +00:00
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/448/head:github-bot/gh-448'
git switch 'github-bot/gh-448'

Merge

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