Skip to content

xgameruntime_offline: answer text entry with the title's default text - #4953

Open
romainveurrier wants to merge 1 commit into
ItsNotRexed:mainfrom
romainveurrier:rt/xgameui-textentry
Open

romainveurrier wants to merge 1 commit into
ItsNotRexed:mainfrom
romainveurrier:rt/xgameui-textentry

Conversation

@romainveurrier

Copy link
Copy Markdown
Contributor

Item: new RT item, claimed in #4933 (claim). It's the follow-up left from closed #3657, which main's XGameUiImpl (ec34b54) superseded apart from this one behaviour.

Why

XGameUiShowTextEntryAsync, ResultSize and Result (XGameUiImpl slots 17–19) fail before starting on main. A title that asks the player for a name or a save label therefore gets a failure, and may stop there or retry.

What

runtime/shims/xgameruntime_offline.cpp, next to the message and error dialogs. There's no keyboard to show, so text entry is answered with the title's own default text, as if OK were pressed without typing:

  • The text is cut to maxTextLength, and a null default gives an empty answer.
  • It's logged as [rt] game text entry: "<title>": <description> [answered with the default text: "..."], in the style of [rt] game dialog:.
  • XGameUiShowTextEntryResultSize and resultTextBufferUsed count the terminator. A buffer shorter than the size fails.
  • The answer rides in the async context and is freed on XAsyncOp::Cleanup. XAsyncBegin fails only before the provider is attached, so in that case the answer is freed directly.

Signatures are from the public GDK reference (the three XGameUiShowTextEntry pages). The reference documents no cancellation code, so none is invented.

Tests

Four new checks in xgameruntime_offline_test (now 33):

  • the default text, with the size and bytes used counting the terminator;
  • a default text cut to maxTextLength;
  • no default text;
  • a buffer shorter than ResultSize, on its own call, because xtaskqueue releases a call whose result buffer is too small.

Tested

Fedora 44, clang-cl 22.1.8 with xwin (SDK 10.0.26100), /W4: no warnings in the changed files. Under Wine 11.21, xgameruntime_offline passes (33/33). The full suite gives 171/175. The four failures (gameinput_host, device_proxy, file_system, d3d12_indirect_dispatch_count) build no xgameruntime source. Not run: MSVC, native Windows.

No game files. AI-assisted (Claude Code).

🤖 Generated with Claude Code

XGameUiShowTextEntryAsync/ResultSize/Result (XGameUiImpl slots 17-19)
failed before starting, so a title asking for a name or a save label got
a failure. With no keyboard to show, the answer is now the title's own
default text, as if OK were pressed without typing, cut to maxTextLength,
and logged ("[rt] game text entry:"). The answer rides in the async
context and is freed on Cleanup; ResultSize and resultTextBufferUsed count
the terminator.

From closed ItsNotRexed#3657 (superseded by ec34b54, except for this). Tests: four
new checks in xgameruntime_offline_test (default text, cut to the
maximum, no default, a buffer shorter than ResultSize); 33 checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gertify

gertify commented Nov 23, 2026

Copy link
Copy Markdown

Tested bac5353 on Windows 11 (NVIDIA GeForce RTX 4080 machine, driver 617.42; the test is CPU-side), cross-built with clang-cl + xwin: pass.

xgameruntime_offline_test: exit 0, 33 checks, 0 failures, including the four new text entry checks:

  • PASS text entry is answered with the default text; ResultSize and resultTextBufferUsed count the terminator
  • PASS a default text longer than maxTextLength is cut to it
  • PASS no default text: an empty answer
  • PASS a buffer shorter than ResultSize fails

AI-assisted.

@tupacfan04

Copy link
Copy Markdown
Contributor

Tested bac53531 on Windows 11 26300 (x64), native MSVC 19.51.36260.0, RelWithDebInfo: pass.

  • Configured runtime with -DBUILD_TESTING=ON and built target xgameruntime_offline_test; no compiler warnings.
  • xgameruntime_offline_test: exit 0, 33 checks, 0 failures.
  • Same binary with LEONIDA_HDR=1: exit 0, 33 checks, 0 failures.
  • The four new checks all pass: default text answered with the terminator counted, truncation to maxTextLength, an empty answer when defaultText is null, and a too-small result buffer failing with resultTextBufferUsed == 0.
  • Code review: the heap std::string answer is freed in XAsyncOp::Cleanup, and also on the XAsyncBegin failure path; ResultSize and GetResult agree on size + 1 bytes. No GPU/Vulkan path and no game data involved.

This adds native MSVC coverage; the author tested clang-cl/xwin under Wine, and gertify tested a clang-cl/xwin build on Windows.

AI-assisted.

@tupacfan04

Copy link
Copy Markdown
Contributor

One functional issue in the new default-text path, in addition to the passing tests above:

runtime/shims/xgameruntime_offline.cpp:248 treats maxTextLength == 0 as "no space" and truncates. GDK's text-entry contract uses 0 to mean the default maximum (1024), so a title calling with 0 gets an empty answer instead of the default. The byte cut also runs on a UTF-8 string, so a non-ASCII default can be split mid-codepoint. Clamp 0 to the default before the copy, and cut on a codepoint boundary.

Slots 34-39 still return E_FAIL, unchanged by this PR.

AI-assisted review, no game data.

@Flyander Flyander left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One API-contract gap in the default-text truncation.

const char* default_text, uint32_t, uint32_t max_length) {
if (!async) return E_POINTER;
auto* answer = new std::string(default_text ? default_text : "");
if (answer->size() > max_length) answer->resize(max_length);

@Flyander Flyander Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The maxTextLength == 0 case is already reported in the conversation, so this note is only the separate Password-scope edge. Microsoft documents that Password scope always uses a 1024-character maximum and ignores the supplied maxTextLength (GDK docs). Here inputScope is unnamed and this line still clips by max_length; for a Password call with defaultText="abc" and maxTextLength=1, the answer is reduced to "a" even though the API limit is 1024. Please preserve the Password-specific limit. The earlier comment also covers the UTF-8 boundary concern.

@Atomic258

Copy link
Copy Markdown
Contributor

Independent check of bac53531 — pass on Windows.

Environment: Windows 11, MSVC 19.44 (RelWithDebInfo, Ninja), CPU only, synthetic inputs, no game files.

  • Built xgameruntime_offline_test target only (15 compile steps): clean
  • PR head → 33 checks, 0 failures — text entry now answered with the title's default text, ResultSize/resultTextBufferUsed count the terminator, over-length defaults cut to maxTextLength, short buffers fail
  • Negative control: same binary against main's xgameruntime_offline.cpp → 33 checks, 4 failures, all in the new text-entry cases — the parent leaves the slots unavailable (E_FAIL) exactly as described

AI-assisted (Devin).

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.

5 participants