DualSense: PS5 controller icon support #406

Open
github-bot wants to merge 3 commits from github-bot/gh-406 into main AGit
Owner

@⁠jyksityisyys on GitHub · 2026-12-04 00:40 UTC · original
jyksityisyys:dualsense-icons → main · +1027 −20 · 7 files · 3 commits · open

Summary

Adds optional PlayStation button prompts and a DualSense controller picture to
the Xbox build, gated behind the existing DualSense setting:

VICTORY_DUALSENSE=1
VICTORY_DUALSENSE_ICONS_PATH=Z:/path/to/dualsense-icons

Without the path, the Xbox assets are untouched.

Changes

  • dualsense_icons.rs loads and validates the converted assets, then replaces
    the inflated Xbox movie in place.
  • dstorage.rs redirects platform.ttpf to the converted picture and applies
    the movie substitution after inflate.
  • tools/dualsense-icons.py builds the folder from your own copies:
./tools/dualsense-icons.py --ps5-dump /path/to/ps5-copy

Xbox defaults to GAME from run.conf; pass --xbox-dump if it lives
elsewhere. Output defaults to local/dualsense-icons.

  • Docs updated: README.md, docs/SETTINGS.md, docs/CONTROLS.md,
    run.conf.default, and new docs/DUALSENSE-ICONS.md.

Conversion

  • PlayStation button shapes are renumbered into the Xbox movie's ID space.
  • Xbox export table, symbol classes, ABC and frame label are preserved
    byte-for-byte.
  • The DualSense texture is retiled for the Xbox 64 KiB swizzle and written into
    the original RDS5 chunk layout.
  • Output remains 222,976 bytes, matching the Xbox file.

Validation

  • Generated assets match the known-good outputs byte-for-byte.
  • Converted movie is 28,129 bytes and fits the 28,148-byte Xbox slot.
  • All 38 button sprites resolve; no missing shape references.
  • Xbox metadata tags are byte-identical to the source movie.

Notes

  • No game dump is modified.
  • Generated assets stay under local/ and are not committed.
  • Standard library only; no game assets shipped.
**@⁠jyksityisyys** on GitHub · 2026-12-04 00:40 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/406) `jyksityisyys:dualsense-icons` → `main` · +1027 −20 · 7 files · 3 commits · open ## Summary Adds optional PlayStation button prompts and a DualSense controller picture to the Xbox build, gated behind the existing DualSense setting: ```ini VICTORY_DUALSENSE=1 VICTORY_DUALSENSE_ICONS_PATH=Z:/path/to/dualsense-icons ``` Without the path, the Xbox assets are untouched. ## Changes - `dualsense_icons.rs` loads and validates the converted assets, then replaces the inflated Xbox movie in place. - `dstorage.rs` redirects `platform.ttpf` to the converted picture and applies the movie substitution after inflate. - `tools/dualsense-icons.py` builds the folder from your own copies: ```sh ./tools/dualsense-icons.py --ps5-dump /path/to/ps5-copy ``` Xbox defaults to `GAME` from `run.conf`; pass `--xbox-dump` if it lives elsewhere. Output defaults to `local/dualsense-icons`. - Docs updated: `README.md`, `docs/SETTINGS.md`, `docs/CONTROLS.md`, `run.conf.default`, and new `docs/DUALSENSE-ICONS.md`. ## Conversion - PlayStation button shapes are renumbered into the Xbox movie's ID space. - Xbox export table, symbol classes, ABC and frame label are preserved byte-for-byte. - The DualSense texture is retiled for the Xbox 64 KiB swizzle and written into the original `RDS5` chunk layout. - Output remains 222,976 bytes, matching the Xbox file. ## Validation - Generated assets match the known-good outputs byte-for-byte. - Converted movie is 28,129 bytes and fits the 28,148-byte Xbox slot. - All 38 button sprites resolve; no missing shape references. - Xbox metadata tags are byte-identical to the source movie. ## Notes - No game dump is modified. - Generated assets stay under `local/` and are not committed. - Standard library only; no game assets shipped.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-04 00:45:33 +00:00
Author
Owner

@⁠Kal0s-design on GitHub · 2026-12-04 07:33 UTC · original

Tested 013da4b natively on Windows (MSVC, not Wine), using only synthetic files and no game data.

At this head the victory-hle lib test target doesn't build, so none of the crate's tests can run. In leaves_other_assets_alone, let icons = icons(...) at dualsense_icons.rs:200 shadows the icons() helper, and the call at line 207 then fails with E0618 (expected function, found Icons). The lib itself builds fine. Renaming the local fixes it. With only that rename, cargo test -p victory-hle --lib -- --test-threads=2 gives 164 passed and 1 ignored. The merge base 1152b9c gives 160 passed and 1 ignored, so the difference is just the 4 new tests.

Everything else I checked looks fine. Reading open_file, the redirected file becomes a raw handle only on success (dstorage.rs:140), and the only from_raw_handle is at dstorage.rs:174. A failed open falls back to the old files::CreateFileW path, so I don't see a double close or a leak. With the vars unset, with VICTORY_DUALSENSE set to "0" or "true", or with no icons path, load() returned None, so nothing changes for anyone else. A native folder worked with both slash styles and platform.ttpf was redirected. A missing Z:/... folder only logs a warning and keeps the Xbox assets. replace_gfx didn't panic on 0 to 7 byte buffers, a header-only buffer or an oversized replacement, and it left the buffer untouched when it refused.

There are two small nits. First, is_movie panics on an empty name because windows(0) panics (dualsense_icons.rs:80). Today it's only called with the constant, so you can't hit it. Second, replace_gfx checks and writes the full out.len(), but the closure still returns inflate's written (dstorage.rs:1385). On the copy path only data[..n] reaches the title (dstorage.rs:1629), so a converted movie longer than written would get cut off there. Returning out.len() after a substitution would avoid that.

AI-assisted: yes

**@⁠Kal0s-design** on GitHub · 2026-12-04 07:33 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/406#issuecomment-7404807014) Tested 013da4b natively on Windows (MSVC, not Wine), using only synthetic files and no game data. At this head the victory-hle lib test target doesn't build, so none of the crate's tests can run. In `leaves_other_assets_alone`, `let icons = icons(...)` at dualsense_icons.rs:200 shadows the `icons()` helper, and the call at line 207 then fails with E0618 (expected function, found `Icons`). The lib itself builds fine. Renaming the local fixes it. With only that rename, `cargo test -p victory-hle --lib -- --test-threads=2` gives 164 passed and 1 ignored. The merge base 1152b9c gives 160 passed and 1 ignored, so the difference is just the 4 new tests. Everything else I checked looks fine. Reading `open_file`, the redirected file becomes a raw handle only on success (dstorage.rs:140), and the only `from_raw_handle` is at dstorage.rs:174. A failed open falls back to the old `files::CreateFileW` path, so I don't see a double close or a leak. With the vars unset, with `VICTORY_DUALSENSE` set to "0" or "true", or with no icons path, `load()` returned None, so nothing changes for anyone else. A native folder worked with both slash styles and `platform.ttpf` was redirected. A missing `Z:/...` folder only logs a warning and keeps the Xbox assets. `replace_gfx` didn't panic on 0 to 7 byte buffers, a header-only buffer or an oversized replacement, and it left the buffer untouched when it refused. There are two small nits. First, `is_movie` panics on an empty name because `windows(0)` panics (dualsense_icons.rs:80). Today it's only called with the constant, so you can't hit it. Second, `replace_gfx` checks and writes the full `out.len()`, but the closure still returns inflate's `written` (dstorage.rs:1385). On the copy path only `data[..n]` reaches the title (dstorage.rs:1629), so a converted movie longer than `written` would get cut off there. Returning `out.len()` after a substitution would avoid that. AI-assisted: yes
Author
Owner

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

One must-fix, in is_movie (crates/victory-hle/src/modules/dualsense_icons.rs:77-81): it accepts any buffer that starts with GFX* and contains platform_xbsx.input_icons anywhere, and replace_gfx only refuses when the destination is smaller (:51-63) — a bigger destination is overwritten and zero-filled past self.gfx.len(). Your own tool's comment says that string is also part of the UI movie (tools/dualsense-icons.py:28-30), so if the UI movie is inflated through this pool the whole interface is replaced by the 28 KiB icon movie, with one info! to show for it. Bound it: reject destinations over a few hundred KiB before matching, and/or require the name NUL-terminated or present in the export table. The real movie is 28,148 bytes, so any of those keeps it working.

Worth checking while you are there:

  • A partial page run hitting fill prints the once-only "the converted movie is larger than the title's slot; keeping the Xbox icons" warning (:51-59) even though the slot is fine — misleading, since into_pages can call fill with a slice (dstorage.rs:1598-1600).
  • tools/dualsense-icons.py:262 heads the TTPF section "Xbox RDS5 with a stored (uncompressed) chunk" while :386-389 requires zlib and writes zlib.compress(...); one of the two is wrong.
  • :189-192 raises StopIteration instead of die(...) when the export tag is missing.

Please also say whether you saw the icons on screen and on which build — the feature depends on the movie arriving as one zlib request starting at the slot's first byte.

**@⁠Luxuride** on GitHub · 2026-12-04 11:28 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/406#issuecomment-7410145048) One must-fix, in `is_movie` (`crates/victory-hle/src/modules/dualsense_icons.rs:77-81`): it accepts any buffer that starts with `GFX*` and contains `platform_xbsx.input_icons` *anywhere*, and `replace_gfx` only refuses when the destination is smaller (`:51-63`) — a bigger destination is overwritten and zero-filled past `self.gfx.len()`. Your own tool's comment says that string is also part of the UI movie (`tools/dualsense-icons.py:28-30`), so if the UI movie is inflated through this pool the whole interface is replaced by the 28 KiB icon movie, with one `info!` to show for it. Bound it: reject destinations over a few hundred KiB before matching, and/or require the name NUL-terminated or present in the export table. The real movie is 28,148 bytes, so any of those keeps it working. Worth checking while you are there: - A partial page run hitting `fill` prints the once-only "the converted movie is larger than the title's slot; keeping the Xbox icons" warning (`:51-59`) even though the slot is fine — misleading, since `into_pages` can call `fill` with a slice (`dstorage.rs:1598-1600`). - `tools/dualsense-icons.py:262` heads the TTPF section "Xbox RDS5 with a stored (uncompressed) chunk" while `:386-389` requires zlib and writes `zlib.compress(...)`; one of the two is wrong. - `:189-192` raises `StopIteration` instead of `die(...)` when the export tag is missing. Please also say whether you saw the icons on screen and on which build — the feature depends on the movie arriving as one zlib request starting at the slot's first byte.
Author
Owner

@⁠jyksityisyys on GitHub · 2026-12-05 01:48 UTC · original

#406: Thanks for this. Looked into these issues and the tests now pass.

  • The E0618 is fixed: the test helper is now make_icons(), with its call sites updated, so the victory-hle lib test target builds again.

  • is_movie now rejects an empty name (!name.is_empty()), with a regression test, so windows(0) is unreachable.

  • After a substitution, the dstorage closure now returns out.len() instead of inflate's written, so the copy path receives the whole padded converted movie.

#406: Thanks all four are addressed.

  • is_movie: bounded before the name scan. is_xbox_movie now rejects anything
    over 512 KiB (MAX_MOVIE_BYTES, about 18x the real 28 KiB movie), with a
    regression test that a large buffer containing platform_xbsx.input_icons is
    not matched. I used the size bound rather than NUL termination because the
    name is not NUL-terminated in the assets (117 occurrences, none terminated);
    parsing the export table would be a much larger change for the same
    protection.

  • Partial-page warning: I traced the fill path. into_pages passes
    window.bytes(), and page_window only returns when one contiguous run covers
    the requested range, setting PageWindow.len to that full range;
    lazy::linear likewise requires n == len. So fill always receives the
    request's full destination_size, never a sub-slice. I still reworded the
    message from "the title's slot" to "this request's destination" and updated
    docs/DUALSENSE-ICONS.md, since a request can be a fragment of a larger asset.

  • TTPF header: fixed — it now says "zlib-compressed chunk". The code was
    already right (zlib.compress(..., 9) and codec 8).

  • StopIteration: fixed — a missing export tag now reports "the Xbox/PlayStation
    movie has no export table" through die(...), instead of raising
    StopIteration.

On screen: yes, the PlayStation button prompts and the DualSense controller
picture are visible and render as expected on the current branch build. The log
shows a single 28,129-byte substitution, consistent with the movie arriving as
one zlib request at the slot's first byte.

**@⁠jyksityisyys** on GitHub · 2026-12-05 01:48 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/406#issuecomment-7429643501) https://git.gtahub.st/github/lobomfz--VIctory-xmem/pulls/406: Thanks for this. Looked into these issues and the tests now pass. - The E0618 is fixed: the test helper is now make_icons(), with its call sites updated, so the victory-hle lib test target builds again. - is_movie now rejects an empty name (!name.is_empty()), with a regression test, so windows(0) is unreachable. - After a substitution, the dstorage closure now returns out.len() instead of inflate's written, so the copy path receives the whole padded converted movie. https://git.gtahub.st/github/lobomfz--VIctory-xmem/pulls/406: Thanks all four are addressed. - is_movie: bounded before the name scan. is_xbox_movie now rejects anything over 512 KiB (MAX_MOVIE_BYTES, about 18x the real 28 KiB movie), with a regression test that a large buffer containing platform_xbsx.input_icons is not matched. I used the size bound rather than NUL termination because the name is not NUL-terminated in the assets (117 occurrences, none terminated); parsing the export table would be a much larger change for the same protection. - Partial-page warning: I traced the fill path. into_pages passes window.bytes(), and page_window only returns when one contiguous run covers the requested range, setting PageWindow.len to that full range; lazy::linear likewise requires n == len. So fill always receives the request's full destination_size, never a sub-slice. I still reworded the message from "the title's slot" to "this request's destination" and updated docs/DUALSENSE-ICONS.md, since a request can be a fragment of a larger asset. - TTPF header: fixed — it now says "zlib-compressed chunk". The code was already right (zlib.compress(..., 9) and codec 8). - StopIteration: fixed — a missing export tag now reports "the Xbox/PlayStation movie has no export table" through die(...), instead of raising StopIteration. On screen: yes, the PlayStation button prompts and the DualSense controller picture are visible and render as expected on the current branch build. The log shows a single 28,129-byte substitution, consistent with the movie arriving as one zlib request at the slot's first byte.
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/406/head:github-bot/gh-406'
git switch 'github-bot/gh-406'

Merge

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