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

Merged
certified-retart merged 1 commit from upstream-pr/85 into main 2026-11-23 10:36:03 +00:00
certified-retart commented 2026-11-23 02:12:28 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by certified-retart on 2026-11-23T02:12:28Z.


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.
<!-- greyfinch-sync:ivall/xcl:issue:6550850068 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/85). Originally posted by [certified-retart](https://github.com/certified-retart) on 2026-11-23T02:12:28Z. --- ## 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**.
upstream-sync closed this pull request 2026-11-24 06:57:05 +00:00
ivall commented 2026-11-24 07:00:27 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ivall on 2026-11-23T10:36:38Z.


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!

<!-- greyfinch-sync:ivall/xcl:comment:7098218110 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/85#issuecomment-7098218110). Originally posted by [ivall](https://github.com/ivall) on 2026-11-23T10:36:38Z. --- 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!
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
xcl-dev/xcl!84
No description provided.