Repository navigation
hle: read Windows caption and high contrast settings - #23
Conversation
|
Other open pull requests change the same files. Check that they do not do the same work, and agree with their authors on which lands first: the other one will then need a rebase.
This comment is kept up to date automatically and removed when the overlap ends. |
|
This PR and #22 both implement the three accessibility methods in #6. I claimed the issue before #22 opened, and the two implementations were developed independently. For maintainers comparing them, #23 reads caption appearance through WinRT The test table above includes a synthetic caller reading caption state with ShowSounds off and on, then setting and reading the title override. Both PRs cover the same feature. Please let us know which one you’d like to carry forward. |
simnJS
left a comment
There was a problem hiding this comment.
Thanks, this is a clean implementation of #6, and it avoids the problems found in #22:
- the documented
ClosedCaptionPropertiesAPI instead of registry guesses; - an original high-contrast classifier;
- the C++
booltaken asu8 != 0.
I checked slots 0x18/0x20/0x28, the 28-byte layout (ARGB in memory order) and the style/edge/opacity/size mapping against the public GDK pages and the windows 0.62.2 bindings: they all match. The COM handling is sound too. windows-rs joins the implicit MTA only when the thread is uninitialised, and never changes an existing STA/MTA.
A few small things before I approve:
- Cost per call.
properties()makes 12 WinRT static calls on every call, andhigh_contrast()createsAccessibilitySettings(andUISettingswhen contrast is on) every time. If the class can't be activated, windows-rs retries the factory load and DLL search on each of those calls. Could you either post a per-call timing from your Sandbox run, or cache the snapshot and refresh it at most every second or so (asgameinput/triggers.rsdoes withRELIST)? - Module doc.
speech/captions.rsneeds a//!header like every other file inxtp-hle/src. - Sentinel test. Please add a case that
set_enabled(2)(and e.g.0xFF) reads back1. 2 is yourFOLLOW_WINDOWSsentinel, so that's the value worth pinning. - Nits. Please keep the module pointers in the
Cargo.tomlcomment (addmodules::speech::captionsrather than droppinggameinput::triggersandaudio::capture), and rewrap the first doc line ofspeech.rs. The vtable re-alignment is fine if you prefer it, but please keep the "closed captions" and "high contrast" labels on 0x18 and 0x28. - Optional.
- A host run with a custom caption style (e.g. yellow on blue) and with the Aquatic and Desert contrast themes would cover the WinRT paths the unit tests can't.
- A README line saying where ShowSounds lives (Control Panel > Ease of Access > "Use text or visual alternatives for sounds") would help, since Windows 11 Settings doesn't name it.
- Returning
Otheronly when the palette can't be read is fine; a sentence saying so would help. - The R7 row in
docs/analysis/hle.mdcan be marked done.
CI is green. Once these are in, I'll approve and merge. You claimed #6 first, so this PR goes ahead, and #22 will be closed once this lands.
|
@simnJS, could you review In the same offline Windows Sandbox, warm caption reads went from 87,754 to 84 ns per call and high-contrast reads went from 3,240 to 58 ns. These are medians of five 250-call batches in a debug build with high contrast off. A single running process also picked up ShowSounds changing from off to on to off after each refresh interval. All six speech-module tests passed. The provider test covers |
|
Thanks, bd8e20a covers everything I asked for:
I checked the cache: the two statics are independent, the lock is never nested and never calls back into the title, One thing before I merge: the description says Codex made this commit. Could you confirm here that you've read it yourself and take responsibility for it, as you did for the first one? Optional, not blocking:
CI ran just before #20 and #24 landed. Neither touches these files, and the README merges cleanly, so I'll approve and merge once you've confirmed. |
Yea, i confirm, |
simnJS
left a comment
There was a problem hiding this comment.
Thanks @AliceWood for confirming. Approving and merging.
What and why
Fixes #6. No PR dependencies.
Titles can read the player's Windows closed-caption appearance and high-contrast mode. Each query refreshes its Windows settings at most once per second. Captions initially follow ShowSounds. A title can change its own enabled flag immediately for the session. When Windows supplies no preference, XTP returns disabled captions with opaque white text on black, a transparent window, default font and edge, and 100% size.
Area
xtp-hleimplements the three accessibility provider methods and enables two features of the existing Windows bindings. The README documents where to find ShowSounds and how high-contrast mode is reported. The HLE plan marks R7 complete.Tests
cargo xtask pr-checkpasses on my machineA synthetic caller invoked the same three provider slots on the unmodified upstream base
0f08e4cand PR headbd8e20ain an offline Windows Sandbox. Both builds used Rust 1.98.1 MSVC, debug, and WARP. The runner verified the guest's ShowSounds setting before starting each probe.E_NOTIMPLand left the output untouchedE_NOTIMPLE_NOTIMPLand left the output untouchedcargo test --locked -p xtp-hle --lib modules::speech::passed all six tests. They cover the entire default output, enabled overrides including 2 and 255, null arguments, cache reuse and expiry, independent colors and opacity, font scaling and light/dark palette classification. A second probe kept one process alive and changed Windows ShowSounds from off to on to off. The getter read back 0, 1, 0 after 1.1 seconds per change. Custom colors and active contrast themes were covered with synthetic values only.The same synthetic caller timed repeated getter calls on the previous and revised PR heads in the same guest, with high contrast off. Each value is the median of five batch averages in nanoseconds per call, after one warm-up call and with 250 calls per batch. These measurements cover the cached path on the revised head.
985bca7)bd8e20a)cargo xtask pr-check --base origin/mainpassed formatting, both Clippy configurations, policy and conventions. Its workspace test stopped at the same seven GPU test names ascargo test --workspace --lockedon the unmodified base. A separatecargo test --locked -p xtp-hle --libon both revisions reproduced the same single failure,modules::xmem::tests::title_calls_succeed_under_open_heaps. The PR's HLE run passed 156 tests and ignored two.Provenance
AI assistance: OpenAI Codex wrote and reviewed the implementation, tests and documentation, ran the comparison and prepared this PR. Direct references included XTP's provider and contribution docs, its R7 plan, the windows-rs API bindings, and Microsoft's public API pages for Windows captions, ShowSounds, the caption properties and enum values. Codex inspected xcl's public accessibility reference for caller-visible defaults, byte layout and error behavior. The implementation and tests are original to XTP. The issue and R7 also summarize xcl's behavior second-hand. xcl reference revision · Windows caption settings · Windows ShowSounds
AliceWood personally reviewed
985bca7. Codex implemented and tested the subsequent review fixes inbd8e20a.Checklist
<area>: <summary>; one topic; under 400 changed lines, or the reason is above