d3d12-hle, tools: fix live prompt glyphs on keyboard-only start #3501

Code

Clone this repository

Checkout

From your project repository, check out a new branch and test the changes.

git fetch -u  "fix/prompts-keyboard-start:Henriazz11-fix/prompts-keyboard-start"
git switch "Henriazz11-fix/prompts-keyboard-start"
Open
leonida/mandy
Henriazz11 wants to merge 1 commit from Henriazz11/mandy:fix/prompts-keyboard-start into main

This branch is out-of-date with the base branch

Conversation
Reviewers 0 approvals
  • No reviewers
Details
This pull request is blocked because it's outdated.
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 'fix/prompts-keyboard-start:Henriazz11-fix/prompts-keyboard-start'
git switch 'Henriazz11-fix/prompts-keyboard-start'
First-time contributor

Claimed in the coordination issue #3312 as: D3D12-PROMPTS-KEYBOARD-START. Fixes #3065.

What and why

Players starting with only a keyboard and mouse saw PlayStation button prompts when ps_live_prompt_glyphs.gfx was served.

  • Cause 1 — slot never written on keyboard start (d3d12/crates/leonida-hle/src/modules/glyphs/live.rs:304,353,372): follow_with initialized written = served both at start (live.rs:304) and whenever scan found the live lnLo/lnFamily/lnHi slots (live.rs:353), and only called write_family when now != written (live.rs:372). On a keyboard-only start (served == Family::KeyboardMouse) with no device switch (now == Family::KeyboardMouse), now != written was never true, so write_family was never called after live family slot found.
  • Cause 2 — lnShow exited early on getChildByName("p") (tools/live_prompt_glyphs.py:314-315,443-444): Even after lnFamily was written (2.0) and Main.lnInit ran (prompts made rose 3 -> 15), pictures switched (lnShown) stayed 0. lnFamily (2.0, Family::KeyboardMouse as u8, gameinput/family.rs:31, live.rs:51-53) and lnShow's already-shown check (tools/live_prompt_glyphs.py:318-321) were both right, but sprite_tag (tools/live_prompt_glyphs.py:443-444) placed the first PlayStation piece as a DefineShape3 with PlaceObject2's PlaceFlagHasName ("p"), and write_show (tools/live_prompt_glyphs.py:314-315) returned immediately when sprite.getChildByName("p") returned null (Scaleform does not expose PlaceObject2 instance names on DefineShape3s).
  • Fixes:
    1. In d3d12/crates/leonida-hle/src/modules/glyphs/live.rs, track written as Option<Family> initialized to None and reset to None whenever scan finds slots (including if slots are lost and found again), so write_family writes active_family() immediately on find (prompt glyphs: family written <family> (at find)) and on each subsequent family change.
    2. In tools/live_prompt_glyphs.py, record each Main_Button_<N>'s exact split child index (1 + len(keys)) from its constructor into a weak-key flash.utils.Dictionary (Main.lnSplits), and have lnShow read the split index from Main.lnSplits instead of calling getChildByName("p") (also guarding numChildren < 3 and removing PlaceFlagHasName from DefineShape3 placements).
  • Limit: Prompts that draw their own shapes outside input_icons.gfx (such as the incoming call notification's d-pad, where prompts made does not rise) do not instantiate Main_Button_<N> and are not affected by this movie.
  • Updated module docs in d3d12/crates/leonida-hle/src/modules/glyphs/live.rs, docs/prompt_glyphs.md, and tools/live_prompt_glyphs.py.
  • Left CHANGELOG.md ("Known issues") untouched, as CONTRIBUTING.md specifies that maintainers update CHANGELOG.md upon merge.

Tested

  • python -I -m unittest discover -s tests -p "test_live_prompt_glyphs.py": 16 passed, 0 failed (updated Behaviour to use unnamed Shape children and verified each Main_Button_<N> constructor records its exact split index).
  • cargo test --locked -j 8 -p leonida-hle glyphs -- --test-threads=1: 23 passed, 0 failed (includes new family_found_while_keyboard_writes_keyboard_once_without_switch and updated following_finds_the_slots_and_writes_each_change_once).
  • cargo test --locked -j 8 -p leonida-hle -- --test-threads=1: 310 passed, 2 ignored, 0 failed (run outside the agent's sandbox; inside it, the hardlink test modules::xgamesave::tests::a_kept_blob_past_the_link_limit_is_copied fails with PermissionDenied).
  • cargo clippy --locked -j 8 -p leonida-hle -p leonida-gpu -p leonida --all-targets --features dlss -- -D warnings: 0 warnings/errors in modified files (fails only on the 2 pre-existing collapsible_if in crates/leonida-hle/src/modules/xmem.rs:345,3072).
  • In title (RTX 5080, Windows 11, Series X profile, DLSS quality; keyboard and mouse only, no pad connected; movie rebuilt from this branch with python -I tools/prompt_glyph_movies.py --game <game dir> --dest <dir> and served with LEONIDA_PS_LIVE_GLYPHS; pause menu opened with Esc):
    prompt glyphs: live family slot found at 0x... after 6.5 s ... stride=8 copies=4
    prompt glyphs: family written keyboard and mouse (at find) slots=4
    prompt glyphs: live code counters (every 30 s): prompts made 3, pictures switched 3
    prompt glyphs: live code counters (every 30 s): prompts made 15, pictures switched 15
    
    The pause menu footer shows keyboard key caps (MODO FOTO [R] SELECCIONAR [SPACE] VOLVER [CTRL]). Negative control: the same run with the first fix only and the movie built by main's tool showed [square] [cross] [circle], with prompts made 15, pictures switched 0. No device loss in either run.
    Not checked: switching to a pad and back in the same session (covered by the unit tests), and a Sony pad.

Checklist

  • Claimed in #3312 (D3D12-PROMPTS-KEYBOARD-START)
  • Root cause identified and unit test added that fails without the fix
  • Module docs and docs/prompt_glyphs.md updated
  • No game data added
  • Checked in the title (pause menu, keyboard only)

AI-assisted. Gemini 4 Hydrogen (Antigravity CLI) wrote the change and ran the checks; Claude Code reviewed it.

🤖 Generated with Claude Code

Claimed in the coordination issue #3312 as: D3D12-PROMPTS-KEYBOARD-START. Fixes #3065. ## What and why Players starting with only a keyboard and mouse saw PlayStation button prompts when `ps_live_prompt_glyphs.gfx` was served. - **Cause 1 — slot never written on keyboard start (`d3d12/crates/leonida-hle/src/modules/glyphs/live.rs:304,353,372`):** `follow_with` initialized `written = served` both at start (`live.rs:304`) and whenever `scan` found the live `lnLo`/`lnFamily`/`lnHi` slots (`live.rs:353`), and only called `write_family` when `now != written` (`live.rs:372`). On a keyboard-only start (`served == Family::KeyboardMouse`) with no device switch (`now == Family::KeyboardMouse`), `now != written` was never true, so `write_family` was never called after `live family slot found`. - **Cause 2 — `lnShow` exited early on `getChildByName("p")` (`tools/live_prompt_glyphs.py:314-315,443-444`):** Even after `lnFamily` was written (`2.0`) and `Main.lnInit` ran (`prompts made` rose 3 -> 15), `pictures switched` (`lnShown`) stayed `0`. `lnFamily` (`2.0`, `Family::KeyboardMouse as u8`, `gameinput/family.rs:31`, `live.rs:51-53`) and `lnShow`'s already-shown check (`tools/live_prompt_glyphs.py:318-321`) were both right, but `sprite_tag` (`tools/live_prompt_glyphs.py:443-444`) placed the first PlayStation piece as a `DefineShape3` with `PlaceObject2`'s `PlaceFlagHasName` (`"p"`), and `write_show` (`tools/live_prompt_glyphs.py:314-315`) returned immediately when `sprite.getChildByName("p")` returned `null` (Scaleform does not expose `PlaceObject2` instance names on `DefineShape3`s). - **Fixes:** 1. In `d3d12/crates/leonida-hle/src/modules/glyphs/live.rs`, track `written` as `Option<Family>` initialized to `None` and reset to `None` whenever `scan` finds slots (including if slots are lost and found again), so `write_family` writes `active_family()` immediately on find (`prompt glyphs: family written <family> (at find)`) and on each subsequent family change. 2. In `tools/live_prompt_glyphs.py`, record each `Main_Button_<N>`'s exact split child index (`1 + len(keys)`) from its constructor into a weak-key `flash.utils.Dictionary` (`Main.lnSplits`), and have `lnShow` read the split index from `Main.lnSplits` instead of calling `getChildByName("p")` (also guarding `numChildren < 3` and removing `PlaceFlagHasName` from `DefineShape3` placements). - **Limit:** Prompts that draw their own shapes outside `input_icons.gfx` (such as the incoming call notification's d-pad, where `prompts made` does not rise) do not instantiate `Main_Button_<N>` and are not affected by this movie. - Updated module docs in `d3d12/crates/leonida-hle/src/modules/glyphs/live.rs`, `docs/prompt_glyphs.md`, and `tools/live_prompt_glyphs.py`. - Left `CHANGELOG.md` ("Known issues") untouched, as `CONTRIBUTING.md` specifies that maintainers update `CHANGELOG.md` upon merge. ## Tested - `python -I -m unittest discover -s tests -p "test_live_prompt_glyphs.py"`: 16 passed, 0 failed (updated `Behaviour` to use unnamed `Shape` children and verified each `Main_Button_<N>` constructor records its exact split index). - `cargo test --locked -j 8 -p leonida-hle glyphs -- --test-threads=1`: 23 passed, 0 failed (includes new `family_found_while_keyboard_writes_keyboard_once_without_switch` and updated `following_finds_the_slots_and_writes_each_change_once`). - `cargo test --locked -j 8 -p leonida-hle -- --test-threads=1`: 310 passed, 2 ignored, 0 failed (run outside the agent's sandbox; inside it, the hardlink test `modules::xgamesave::tests::a_kept_blob_past_the_link_limit_is_copied` fails with `PermissionDenied`). - `cargo clippy --locked -j 8 -p leonida-hle -p leonida-gpu -p leonida --all-targets --features dlss -- -D warnings`: 0 warnings/errors in modified files (fails only on the 2 pre-existing `collapsible_if` in `crates/leonida-hle/src/modules/xmem.rs:345,3072`). - In title (RTX 5080, Windows 11, Series X profile, DLSS quality; keyboard and mouse only, no pad connected; movie rebuilt from this branch with `python -I tools/prompt_glyph_movies.py --game <game dir> --dest <dir>` and served with `LEONIDA_PS_LIVE_GLYPHS`; pause menu opened with `Esc`): ``` prompt glyphs: live family slot found at 0x... after 6.5 s ... stride=8 copies=4 prompt glyphs: family written keyboard and mouse (at find) slots=4 prompt glyphs: live code counters (every 30 s): prompts made 3, pictures switched 3 prompt glyphs: live code counters (every 30 s): prompts made 15, pictures switched 15 ``` The pause menu footer shows keyboard key caps (`MODO FOTO [R] SELECCIONAR [SPACE] VOLVER [CTRL]`). Negative control: the same run with the first fix only and the movie built by `main`'s tool showed `[square] [cross] [circle]`, with `prompts made 15, pictures switched 0`. No device loss in either run. Not checked: switching to a pad and back in the same session (covered by the unit tests), and a Sony pad. ## Checklist - [x] Claimed in #3312 (`D3D12-PROMPTS-KEYBOARD-START`) - [x] Root cause identified and unit test added that fails without the fix - [x] Module docs and `docs/prompt_glyphs.md` updated - [x] No game data added - [x] Checked in the title (pause menu, keyboard only) AI-assisted. Gemini 4 Hydrogen (Antigravity CLI) wrote the change and ran the checks; Claude Code reviewed it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Fixes #3065.

1. In modules/glyphs/live.rs, track written family as Option<Family> (None initially and on slot find) so active_family() is written immediately when the live slot is found, not only on subsequent device switches.
2. In tools/live_prompt_glyphs.py, record each Main_Button_<N>'s split child index in Main.lnSplits (weak-key Dictionary) from its constructor and read it in lnShow instead of calling getChildByName('p') on a DefineShape3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
First-time contributor

Independent local verification of this change (I changed no code).

  • Head 9007795c, merge base 0036195a. Both new tests are absent on the base: git grep -F <test> 0036195a -- <path> -> exit 1 for test_every_sprite_holds_both_pictures_and_records_its_split (tests/test_live_prompt_glyphs.py) and for family_found_while_keyboard_writes_keyboard_once_without_switch (live.rs).
  • On the PR head: python -I -m unittest discover -s tests -p test_live_prompt_glyphs.py -> Ran 16 tests, OK; and cargo test -p leonida-hle --locked --lib modules::glyphs::live::tests::family_found_while_keyboard_writes_keyboard_once_without_switch -- --exact (private CARGO_TARGET_DIR) -> 1 passed / 311 filtered.
  • Note on the merge: this PR shows mergeable=false in the list view, but that is the stacked-PR retargeting after #3500 landed. git merge --no-commit --no-ff onto current main (f4b0404e) applies without conflict; the two tests were run on the PR head against its own merge base 0036195a, not on that merged tree. No is_none() device gate is added by the diff.
  • git diff --check 0036195a 9007795c -> clean. python -I scripts/check_no_game_data.py on live.rs, tests/test_live_prompt_glyphs.py, tools/live_prompt_glyphs.py and docs/prompt_glyphs.md -> clean.

GPUs tested: none (synthetic VM prompt fixtures and a CPU-only HLE unit test; no game launch). Driver: n/a. No game data, assets or extracted shaders were used or attached.

AI-assisted: yes, Hy4 flash (verification only). No approval implied; this is a local test report.

Independent local verification of this change (I changed no code). - Head `9007795c`, merge base `0036195a`. Both new tests are absent on the base: `git grep -F <test> 0036195a -- <path>` -> exit 1 for `test_every_sprite_holds_both_pictures_and_records_its_split` (tests/test_live_prompt_glyphs.py) and for `family_found_while_keyboard_writes_keyboard_once_without_switch` (live.rs). - On the PR head: `python -I -m unittest discover -s tests -p test_live_prompt_glyphs.py` -> Ran 16 tests, OK; and `cargo test -p leonida-hle --locked --lib modules::glyphs::live::tests::family_found_while_keyboard_writes_keyboard_once_without_switch -- --exact` (private `CARGO_TARGET_DIR`) -> 1 passed / 311 filtered. - Note on the merge: this PR shows `mergeable=false` in the list view, but that is the stacked-PR retargeting after #3500 landed. `git merge --no-commit --no-ff` onto current main (`f4b0404e`) applies without conflict; the two tests were run on the PR head against its own merge base `0036195a`, not on that merged tree. No `is_none()` device gate is added by the diff. - `git diff --check 0036195a 9007795c` -> clean. `python -I scripts/check_no_game_data.py` on live.rs, tests/test_live_prompt_glyphs.py, tools/live_prompt_glyphs.py and docs/prompt_glyphs.md -> clean. GPUs tested: none (synthetic VM prompt fixtures and a CPU-only HLE unit test; no game launch). Driver: n/a. No game data, assets or extracted shaders were used or attached. AI-assisted: yes, Hy4 flash (verification only). No approval implied; this is a local test report.
Sign in to join this conversation.
No description provided.