d3d12-hle: avoid PlayStation live glyphs when Xbox pad is connected #2894

Merged
lixonik merged 3 commits from upstream-pr/2894 into main 2026-12-02 01:14:41 +00:00
lixonik commented 2026-12-01 15:38:00 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-01T15:38:00Z.


Claimed in the coordination issue as: D3D12-GLYPHS-CONNECTED-XBOX-PAD (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7316069155)

What and why

Fixes @alpfilho's finding (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7312455119):

  • When an Xbox (XInput, non-Sony) pad is connected at startup, any keyboard or mouse event before the title reads its glyph movie (~3 s in) switches active_family() to Family::KeyboardMouse.
  • glyphs::live_set_for then served PLAYSTATION_LIVE (ps_live_prompt_glyphs.gfx) unless LEONIDA_PROMPTS_PAD=xbox was set, causing subsequent Xbox pad inputs to display PlayStation prompts.
  • Fix:
    • d3d12/crates/leonida-hle/src/modules/gameinput/family.rs & gameinput.rs: track connected_pad() (Option<Family>, preferring Sony over XInput, updated in Host::begin and Host::observe). In Host::observe, treat a remapper-mirrored Sony pad (xinput && self.mirror.active(now)) as Family::PlayStation so DS4Windows / Steam Input setups do not lose the live movie, while gating on xinput so unplugging the pad during Mirror::HOLD immediately reports None.
    • d3d12/crates/leonida-hle/src/modules/glyphs.rs: pass connected_pad() into live_set_for; when family is KeyboardMouse and LEONIDA_PROMPTS_PAD is unset (or auto), a connected Family::Xbox pad returns None (keeping KEYBOARD instead of PLAYSTATION_LIVE), while LEONIDA_PROMPTS_PAD=playstation still explicitly overrides it.
    • docs/gameinput.md & docs/prompt_glyphs.md: updated LEONIDA_PROMPTS_PAD and "What is served" to document the new default and single-read timing.

Scope & trade-off notes:

  • Because the title reads its glyph movie once near startup (~3 s in), this covers pads already connected at that read; a pad plugged in only after the read keeps whichever movie was served then.
  • Matching LEONIDA_PROMPTS_PAD=xbox, this serves the keyboard movie rather than the title's own Xbox movie, so an Xbox pad first used after a keyboard-start read shows keyboard glyphs for the session instead of PlayStation glyphs.

Tested

  • Red (without the connected_pad == Some(Family::Xbox) arm in live_set_for):
    • cargo test --locked -p leonida-hle --lib connected_xbox_pad_does_not_get_playstation_live_movie_on_keyboard_start: 0 passed, 1 failed (panicked returning PLAYSTATION_LIVE instead of None).
  • Green (at c9c5cc589 after merging origin/main):
    • cargo test --locked -p leonida-hle --lib observe_publishes_connected_pad_and_treats_mirrored_sony_pad_as_playstation -- --nocapture: 1 passed, 0 failed (pins Host::observe wiring across none -> XInput -> mirrored Sony -> disconnect during mirror hold -> direct Sony -> disconnected).
    • cargo test --locked -p leonida-hle: 246 + 1 + 1 passed, 2 ignored, 0 failed.
    • python -I tools/d3d12_switches.py --check d3d12/docs/switches.md: clean.
    • python -I -m unittest discover -s tests -p "test_docs_*.py": 57 passed, 0 failed.
    • python -I scripts/check_no_game_data.py: clean.
    • Not run: live in-game verification with a physical Xbox pad (needs game files + Xbox controller).

GPUs tested: n/a (CPU/HLE unit tests on Windows 10 Pro 22H2 build 19045, Ryzen 9 5950X 16C/32T)

AI-assisted: Antigravity (plus separate read-only reviewer subagent)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5589022360 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2894). Originally posted by [lixonik](https://github.com/lixonik) on 2026-12-01T15:38:00Z. --- Claimed in the coordination issue as: `D3D12-GLYPHS-CONNECTED-XBOX-PAD` (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7316069155) ### What and why Fixes `@alpfilho`'s finding (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7312455119): - When an Xbox (XInput, non-Sony) pad is connected at startup, any keyboard or mouse event before the title reads its glyph movie (~3 s in) switches `active_family()` to `Family::KeyboardMouse`. - `glyphs::live_set_for` then served `PLAYSTATION_LIVE` (`ps_live_prompt_glyphs.gfx`) unless `LEONIDA_PROMPTS_PAD=xbox` was set, causing subsequent Xbox pad inputs to display PlayStation prompts. - **Fix:** - `d3d12/crates/leonida-hle/src/modules/gameinput/family.rs` & `gameinput.rs`: track `connected_pad()` (`Option<Family>`, preferring Sony over XInput, updated in `Host::begin` and `Host::observe`). In `Host::observe`, treat a remapper-mirrored Sony pad (`xinput && self.mirror.active(now)`) as `Family::PlayStation` so DS4Windows / Steam Input setups do not lose the live movie, while gating on `xinput` so unplugging the pad during `Mirror::HOLD` immediately reports `None`. - `d3d12/crates/leonida-hle/src/modules/glyphs.rs`: pass `connected_pad()` into `live_set_for`; when `family` is `KeyboardMouse` and `LEONIDA_PROMPTS_PAD` is unset (or `auto`), a connected `Family::Xbox` pad returns `None` (keeping `KEYBOARD` instead of `PLAYSTATION_LIVE`), while `LEONIDA_PROMPTS_PAD=playstation` still explicitly overrides it. - `docs/gameinput.md` & `docs/prompt_glyphs.md`: updated `LEONIDA_PROMPTS_PAD` and "What is served" to document the new default and single-read timing. **Scope & trade-off notes:** - Because the title reads its glyph movie once near startup (~3 s in), this covers pads already connected at that read; a pad plugged in only *after* the read keeps whichever movie was served then. - Matching `LEONIDA_PROMPTS_PAD=xbox`, this serves the keyboard movie rather than the title's own Xbox movie, so an Xbox pad first used after a keyboard-start read shows keyboard glyphs for the session instead of PlayStation glyphs. ### Tested - **Red (without the `connected_pad == Some(Family::Xbox)` arm in `live_set_for`):** - `cargo test --locked -p leonida-hle --lib connected_xbox_pad_does_not_get_playstation_live_movie_on_keyboard_start`: **0 passed, 1 failed** (panicked returning `PLAYSTATION_LIVE` instead of `None`). - **Green (at `c9c5cc589` after merging `origin/main`):** - `cargo test --locked -p leonida-hle --lib observe_publishes_connected_pad_and_treats_mirrored_sony_pad_as_playstation -- --nocapture`: **1 passed, 0 failed** (pins `Host::observe` wiring across none -> XInput -> mirrored Sony -> disconnect during mirror hold -> direct Sony -> disconnected). - `cargo test --locked -p leonida-hle`: **246 + 1 + 1 passed, 2 ignored, 0 failed**. - `python -I tools/d3d12_switches.py --check d3d12/docs/switches.md`: clean. - `python -I -m unittest discover -s tests -p "test_docs_*.py"`: **57 passed, 0 failed**. - `python -I scripts/check_no_game_data.py`: clean. - Not run: live in-game verification with a physical Xbox pad (needs game files + Xbox controller). GPUs tested: n/a (CPU/HLE unit tests on Windows 10 Pro 22H2 build 19045, Ryzen 9 5950X 16C/32T) AI-assisted: Antigravity (plus separate read-only reviewer subagent) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
merzleckeier commented 2026-12-01 15:58:51 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-01T15:58:51Z.


Win64 host-poll check for connected-pad glyph selection at 1496a6bd + 0ff8a532f under Wine 11.22. The 9 glyph and 13 input-family unit tests passed. I also ran the real Host::begin → pad → observe logic with a synthetic XInput slot at the API boundary, then called the glyph selector on the published state.

  • Connected Xbox plus a keyboard edge selects the keyboard movie. Explicit playstation still selects the live movie.
  • A disconnected Xbox clears the published pad and makes the live movie eligible again while the keyboard stays active. Reconnecting the Xbox restores the keyboard choice once the normal empty-slot polling backoff expires. Reporting a Sony pad as present then selects the live path.

Removing only the connected-pad publication from observe makes the new check fail at disconnect, with the old Xbox state still published. This covers the host polling and selection wiring with synthetic input. Physical USB/HID and actual glyph rendering were outside this fixture.

MEASURED. AI-assisted (Codex).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7316835695 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2894#issuecomment-7316835695). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-01T15:58:51Z. --- Win64 host-poll check for connected-pad glyph selection at 1496a6bd + 0ff8a532f under Wine 11.22. The 9 glyph and 13 input-family unit tests passed. I also ran the real Host::begin → pad → observe logic with a synthetic XInput slot at the API boundary, then called the glyph selector on the published state. - Connected Xbox plus a keyboard edge selects the keyboard movie. Explicit `playstation` still selects the live movie. - A disconnected Xbox clears the published pad and makes the live movie eligible again while the keyboard stays active. Reconnecting the Xbox restores the keyboard choice once the normal empty-slot polling backoff expires. Reporting a Sony pad as present then selects the live path. Removing only the connected-pad publication from observe makes the new check fail at disconnect, with the old Xbox state still published. This covers the host polling and selection wiring with synthetic input. Physical USB/HID and actual glyph rendering were outside this fixture. MEASURED. AI-assisted (Codex).
KelboLive commented 2026-12-01 17:28:42 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-12-01T17:28:42Z.

Review: COMMENTED


The gate and precedence look right: at the one glyph read, KeyboardMouse + a connected Xbox pad now keeps the keyboard movie (glyphs.rs:100-105), Sony still wins when both pads are attached (family.rs:93-101, test at :504), and CONNECTED_PAD is refreshed every observe so a connect/disconnect before the read is honoured. The core guard is mutation-pinned (removing it returns Some(PLAYSTATION_LIVE); reversing precedence fails the classification test), and 243/0/2 on leonida-hle.

Three things to settle before merge:

  1. It only covers a pad present at the read. The title reads the movie once, ~3 s in, so a pad connected later still gets PlayStation pieces from live::follow writing Family::Xbox (live.rs:387-404). The original symptom therefore persists for late connection — worth stating, or worth following up on.
  2. A DS4Windows/HidHide-mirrored Sony pad is classified as Xbox (connected_pad_from ignores mirror, family.rs:93-101), so a keyboard start loses the live movie even though the input path treats the mirror as PlayStation (gameinput.rs:1682). That is a behavioural regression for that configuration.
  3. Docs still describe the old default: docs/gameinput.md:536 and docs/prompt_glyphs.md:322 need the new rule.

Also, one test gap: removing the per-poll publication in observe leaves the full suite at 243/0 — the new coverage is pure-function only, so mid-session connect/disconnect of a real Host is untested. A hub-level test would pin the wiring.

Non-blocking, but worth a sentence in the body: the issue suggested the title's own Xbox movie; this serves the keyboard one instead, so an Xbox pad first used after the read shows key caps for the session. That is a reasonable trade-off, just not an obvious one.

Merge is clean against current main (21 commits behind, no conflict); the red check/linux-python-and-viewer jobs are inherited from the stale base (the test_piecewise_parse/wave_diff/x64_recomp failures main fixed in 9b7674d6), not this diff.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6136466631 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2894#pullrequestreview-6136466631). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-12-01T17:28:42Z. **Review:** COMMENTED --- The gate and precedence look right: at the one glyph read, `KeyboardMouse` + a connected Xbox pad now keeps the keyboard movie (`glyphs.rs:100-105`), Sony still wins when both pads are attached (`family.rs:93-101`, test at `:504`), and `CONNECTED_PAD` is refreshed every `observe` so a connect/disconnect before the read is honoured. The core guard is mutation-pinned (removing it returns `Some(PLAYSTATION_LIVE)`; reversing precedence fails the classification test), and 243/0/2 on `leonida-hle`. Three things to settle before merge: 1. **It only covers a pad present at the read.** The title reads the movie once, ~3 s in, so a pad connected later still gets PlayStation pieces from `live::follow` writing `Family::Xbox` (`live.rs:387-404`). The original symptom therefore persists for late connection — worth stating, or worth following up on. 2. **A DS4Windows/HidHide-mirrored Sony pad is classified as Xbox** (`connected_pad_from` ignores `mirror`, `family.rs:93-101`), so a keyboard start loses the live movie even though the input path treats the mirror as PlayStation (`gameinput.rs:1682`). That is a behavioural regression for that configuration. 3. **Docs still describe the old default**: `docs/gameinput.md:536` and `docs/prompt_glyphs.md:322` need the new rule. Also, one test gap: removing the per-poll publication in `observe` leaves the full suite at 243/0 — the new coverage is pure-function only, so mid-session connect/disconnect of a real `Host` is untested. A hub-level test would pin the wiring. Non-blocking, but worth a sentence in the body: the issue suggested the title's own Xbox movie; this serves the keyboard one instead, so an Xbox pad first used *after* the read shows key caps for the session. That is a reasonable trade-off, just not an obvious one. Merge is clean against current main (21 commits behind, no conflict); the red `check`/`linux-python-and-viewer` jobs are inherited from the stale base (the `test_piecewise_parse`/`wave_diff`/`x64_recomp` failures main fixed in `9b7674d6`), not this diff.
lixonik commented 2026-12-01 21:01:24 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-01T21:01:24Z.


@KelboLive Thanks for catching the mirrored Sony pad regression and the doc/test gaps! Addressed all items in c9c5cc589 and merged origin/main so CI picks up the Python test fixes:

  1. Mirrored Sony pad (gameinput.rs): moved CONNECTED_PAD publication to the end of Host::observe (after self.mirror updates) and computed let sony_pad = self.view.present || (xinput && self.mirror.active(now)); so remapper-mirrored Sony pads (DS4Windows / Steam Input) classify as Family::PlayStation while disconnecting XInput during Mirror::HOLD immediately reports None. (Note: if HidHide hides the Sony HID device from startup so view.present and view.pad stay false/none, mirror cannot observe Sony edges and LEONIDA_PROMPTS_PAD=playstation remains the opt-in override.)
  2. Wiring test (gameinput.rs): added host::observe_publishes_connected_pad_and_treats_mirrored_sony_pad_as_playstation, exercising Host::observe across none -> XInput -> mirrored Sony -> disconnect during Mirror::HOLD -> direct Sony -> disconnect.
  3. Docs (docs/gameinput.md, docs/prompt_glyphs.md): updated the LEONIDA_PROMPTS_PAD default/description and the "What is served" bullet (including the single-read startup timing).
  4. PR description: explicitly noted the single-read timing scope (late pad connect) and the intentional keyboard-movie trade-off matching LEONIDA_PROMPTS_PAD=xbox.

Re-verified cargo test --locked -p leonida-hle (246+1+1 passed, 0 failed, 2 ignored), tools/d3d12_switches.py --check d3d12/docs/switches.md, test_docs_*.py (57/57), and scripts/check_no_game_data.py.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7325625488 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2894#issuecomment-7325625488). Originally posted by [lixonik](https://github.com/lixonik) on 2026-12-01T21:01:24Z. --- @KelboLive Thanks for catching the mirrored Sony pad regression and the doc/test gaps! Addressed all items in `c9c5cc589` and merged `origin/main` so CI picks up the Python test fixes: 1. **Mirrored Sony pad (`gameinput.rs`):** moved `CONNECTED_PAD` publication to the end of `Host::observe` (after `self.mirror` updates) and computed `let sony_pad = self.view.present || (xinput && self.mirror.active(now));` so remapper-mirrored Sony pads (DS4Windows / Steam Input) classify as `Family::PlayStation` while disconnecting XInput during `Mirror::HOLD` immediately reports `None`. (Note: if HidHide hides the Sony HID device from startup so `view.present` and `view.pad` stay false/none, `mirror` cannot observe Sony edges and `LEONIDA_PROMPTS_PAD=playstation` remains the opt-in override.) 2. **Wiring test (`gameinput.rs`):** added `host::observe_publishes_connected_pad_and_treats_mirrored_sony_pad_as_playstation`, exercising `Host::observe` across none -> XInput -> mirrored Sony -> disconnect during `Mirror::HOLD` -> direct Sony -> disconnect. 3. **Docs (`docs/gameinput.md`, `docs/prompt_glyphs.md`):** updated the `LEONIDA_PROMPTS_PAD` default/description and the "What is served" bullet (including the single-read startup timing). 4. **PR description:** explicitly noted the single-read timing scope (late pad connect) and the intentional keyboard-movie trade-off matching `LEONIDA_PROMPTS_PAD=xbox`. Re-verified `cargo test --locked -p leonida-hle` (246+1+1 passed, 0 failed, 2 ignored), `tools/d3d12_switches.py --check d3d12/docs/switches.md`, `test_docs_*.py` (57/57), and `scripts/check_no_game_data.py`.
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
ProjectLeonida/mandy!2894
No description provided.