Skip to content

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

Open
lixonik wants to merge 1 commit into
ProjectLeonida:mainfrom
lixonik:fix/glyphs-connected-xbox-pad
Open

lixonik wants to merge 1 commit into
ProjectLeonida:mainfrom
lixonik:fix/glyphs-connected-xbox-pad

Conversation

@lixonik

@lixonik lixonik commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: D3D12-GLYPHS-CONNECTED-XBOX-PAD (#2570 (comment))

What and why

Fixes @alpfilho's finding (#2570 (comment)):

  • When an Xbox (XInput, non-Sony) pad is connected at startup, any keyboard or mouse event before the title reads its glyph movie 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).
    • 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.

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 1496a6bd2):
    • cargo test --locked -p leonida-hle: 245 passed, 0 failed across all unit/doc/integration targets (243 lib + 1 doc/lib? -- exact counts: 1 + 243 + 1 passed, 2 ignored, 0 failed).
    • cargo check --workspace --all-targets --locked: passed.
    • python -I scripts/check_no_game_data.py: clean.
    • (Note: cargo clippy --locked -p leonida-hle --no-deps --all-targets -- -D warnings has 0 warnings in the touched files; only hits the pre-existing modules/glyphs/live.rs:121 lint tracked in d3d12: fix remaining workspace clippy warnings #2873.)
    • 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.

@merzleckeier

Copy link
Copy Markdown
Contributor

Win64 host-poll check for connected-pad glyph selection at 1496a6b + 0ff8a53 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 KelboLive left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants