xgameruntime: add XAccessibility closed caption and high contrast fallback #85

Manually merged
github merged 1 commit from gh-pr/85/head into gh-pr/85/base 2026-11-26 04:08:58 +00:00
Owner

@⁠certified-retart on GitHub · 2026-11-23 02:12 UTC · original
certified-retart:feat/xaccessibility-apis → main · +278 −0 · 3 files · 1 commits · merged 2026-11-23 10:36 UTC

Summary

Implements offline/fallback support for the GDK XAccessibility closed-caption and high-contrast APIs (XAccessibility.h):

  • crates/xcl/src/hle/xgameruntime/accessibility.rs:
    • Adds ABI-accurate #[repr(C, align(4))] XColor (A, R, G, B) and 28-byte XClosedCaptionProperties structs with explicitly zeroed trailing padding.
    • Implements XClosedCaptionGetProperties, XClosedCaptionSetEnabled (taking u8 at the FFI boundary to normalize any non-zero C/C++ byte safely without Rust bool UB), and XHighContrastGetMode (querying Win32 SystemParametersInfoW(SPI_GETHIGHCONTRAST) and classifying active themes via GetSysColor(COLOR_WINDOW) luminance, returning E_FAIL on OS query failure).
  • crates/xcl/src/hle/xgameruntime/mod.rs:
    • Exports XClosedCaptionGetProperties, XClosedCaptionSetEnabled, and XHighContrastGetMode by name in exports().
  • crates/xcl/src/hle/xgameruntime/api.rs:
    • Adds xcl_xaccessibility_object() and wires None if c == XACCESSIBILITY in QueryApiImpl as a built-in fallback when System32\xgameruntime.dll is not installed (matching the existing XAsync fallback pattern). When Gaming Services is present on the host, QueryApiImpl continues to delegate directly to the native PC runtime so host Windows caption settings, custom high-contrast themes, and XSpeech* remain untouched.

XGameRuntimeIsFeatureAvailable(0) (XAccessibility) already returned true; this ensures titles querying XAccessibility without System32\xgameruntime.dll or importing the functions directly do not hit REGDB_E_CLASSNOTREG / unresolved imports.

Testing

  • Added unit tests covering XColor / XClosedCaptionProperties sizes, alignments, field offsets, raw ARGB byte layout, null-pointer E_INVALIDARG, poisoned-buffer zero-padding verification, non-zero u8 normalization, XHighContrastMode luma classification & OS query, and xcl_xaccessibility_object() COM vtable dispatch (slots 3..=5 + E_NOTIMPL on slot 6).
  • Ran cargo test -p xcl --lib hle::xgameruntime -- --test-threads=2: 44 passed; 0 failed.
**@⁠certified-retart** on GitHub · 2026-11-23 02:12 UTC · [original](https://github.com/xcl-dev/xcl/pull/85) `certified-retart:feat/xaccessibility-apis` → `main` · +278 −0 · 3 files · 1 commits · merged 2026-11-23 10:36 UTC ## Summary Implements offline/fallback support for the GDK `XAccessibility` closed-caption and high-contrast APIs (`XAccessibility.h`): - **`crates/xcl/src/hle/xgameruntime/accessibility.rs`**: - Adds ABI-accurate `#[repr(C, align(4))] XColor` (`A, R, G, B`) and 28-byte `XClosedCaptionProperties` structs with explicitly zeroed trailing padding. - Implements `XClosedCaptionGetProperties`, `XClosedCaptionSetEnabled` (taking `u8` at the FFI boundary to normalize any non-zero C/C++ byte safely without Rust `bool` UB), and `XHighContrastGetMode` (querying Win32 `SystemParametersInfoW(SPI_GETHIGHCONTRAST)` and classifying active themes via `GetSysColor(COLOR_WINDOW)` luminance, returning `E_FAIL` on OS query failure). - **`crates/xcl/src/hle/xgameruntime/mod.rs`**: - Exports `XClosedCaptionGetProperties`, `XClosedCaptionSetEnabled`, and `XHighContrastGetMode` by name in `exports()`. - **`crates/xcl/src/hle/xgameruntime/api.rs`**: - Adds `xcl_xaccessibility_object()` and wires `None if c == XACCESSIBILITY` in `QueryApiImpl` as a built-in fallback when `System32\xgameruntime.dll` is not installed (matching the existing `XAsync` fallback pattern). When Gaming Services is present on the host, `QueryApiImpl` continues to delegate directly to the native PC runtime so host Windows caption settings, custom high-contrast themes, and `XSpeech*` remain untouched. `XGameRuntimeIsFeatureAvailable(0)` (`XAccessibility`) already returned `true`; this ensures titles querying `XAccessibility` without `System32\xgameruntime.dll` or importing the functions directly do not hit `REGDB_E_CLASSNOTREG` / unresolved imports. ## Testing - Added unit tests covering `XColor` / `XClosedCaptionProperties` sizes, alignments, field offsets, raw ARGB byte layout, null-pointer `E_INVALIDARG`, poisoned-buffer zero-padding verification, non-zero `u8` normalization, `XHighContrastMode` luma classification & OS query, and `xcl_xaccessibility_object()` COM vtable dispatch (slots 3..=5 + `E_NOTIMPL` on slot 6). - Ran `cargo test -p xcl --lib hle::xgameruntime -- --test-threads=2`: **44 passed; 0 failed**.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:08:56 +00:00
github manually merged commit 98cb80af93 into gh-pr/85/base 2026-11-26 04:08:58 +00:00
Author
Owner

@⁠ivall on GitHub · 2026-11-23 10:36 UTC · original

Merged. Tested on Windows 11 with an RX 9070 (RDNA4): cargo test --workspace green with the retail samples (shader pack, console DLLs, texture archive), lib tests also with XCL_SPLIT_WAVE64=1; Unicorn Overlord, Minecraft and Fortnite run with this round merged. Thanks!

**@⁠ivall** on GitHub · 2026-11-23 10:36 UTC · [original](https://github.com/xcl-dev/xcl/pull/85#issuecomment-7098218110) Merged. Tested on Windows 11 with an RX 9070 (RDNA4): `cargo test --workspace` green with the retail samples (shader pack, console DLLs, texture archive), lib tests also with `XCL_SPLIT_WAVE64=1`; Unicorn Overlord, Minecraft and Fortnite run with this round merged. Thanks!
This discussion has been locked. Commenting is limited to contributors.
No description provided.