feat(xgameruntime): implement XSystemGetDeviceType and XPackageIsPackagedProcess #9

Manually merged
github merged 3 commits from gh-pr/9/head into gh-pr/9/base 2026-11-26 19:13:41 +00:00
Owner

@⁠CaseReed on GitHub · 2026-11-21 05:41 UTC · original
CaseReed:feat/xsystem-device-type → main · +126 −22 · 20 files · 3 commits · merged 2026-11-21 06:59 UTC

What

Implements XSystemGetDeviceType and XPackageIsPackagedProcess (#2). The ticket asks to decide what a desktop host should report; this is the choice and why.

XSystemGetDeviceType reports the console mode the title declares, not the host hardware. The public reference says the function returns the console mode rather than the actual hardware, and that an Xbox One title does not get a Series code. Console code typically switches on the value to pick a render resolution and has no Pc case, so reporting Pc to every title would send console builds down their default branch. The title already states its target in MicrosoftGame.config:

TargetDeviceFamily of the first <Executable> Reported
Scarlett XboxScarlettAnaconda
XboxOne, or an <Executable> without the attribute (the packaging default) XboxOneX
PC Pc
any other value stops with AbxUnsupported
no <Executable>, or no readable MicrosoftGame.config stops with AbxUnsupported, as XGameGetXboxTitleId does for a missing <TitleId>

Reporting the top model of each family whatever the host is an assumption; it is recorded in debt with a Closes when:. If you would rather report Pc, the lower models, or make it configurable, I'm happy to change it.

XPackageIsPackagedProcess returns false. A relinked title started from a folder has no package identity on the host. Recorded in debt.

Supporting changes:

  • The runtime reads TargetDeviceFamily in TitleConfig and exposes it through AbxTitleDeviceFamily(), shaped like AbxTitleName().
  • XSystemDeviceType is added to Types.hpp with the values from the public reference. The two functions live in new System.cpp and Package.cpp.
  • Seven e2e_device_* scenarios cover each row of the table, including an <Executable> without the attribute, a config without <Executable> and no config. The stand-in console DLL returns deliberately wrong values (0xffffffff, true), so the scenarios fail if the call is not routed to AnyBox.
  • docs/dev/debt/changes/gdk-inventory.md (a pending fragment already on main) named TaskQueue.cpp and Runtime.cpp as the only files with implemented exports; I added the two new files to that sentence so it stays true. A second fragment cannot change the same entry, so the edit is in place.

The debt fragment is named feat-xsystem-device-type.md: debt_fold.py reads changes/*.md only, so a file under changes/feat/ would not be found.

Self-review (second commit). An independent read of the first commit found that the XboxOne default also applied to a config the reader could not parse, that returning Unknown for a missing config did not follow "implement or stop", and that e2e_device_default did not test what it claimed. The second commit fixes the three. It also records in debt that the config reader does not skip XML comments (already true for <TitleId>, <Identity> and <ShellVisuals>); I left the reader itself alone to keep this PR on one topic and can send a separate fix.

Tested

Windows 11, MSVC 19.38 (VS 2022), CMake 4.4.4, Ninja 1.13.2, clean build directory, on top of #8.

  • Full build: ok. ctest: 29/29 (22 existing, 7 new).
  • python tools/check_conventions.py: ok. python tools/debt_fold.py --check: 2 fragments apply cleanly.
  • python tools/progress.py --module xgameruntime: 13 → 15 implemented, 378 → 376 stubs.

Not tested: the MinGW build (no GCC on this machine; relies on CI), MSVC 19.51, the run report schema check (jsonschema not installed), and behaviour against a console title.

Checklist

  • Based on current main; no other open PR implements the same functions (based on main plus #8, see Depends on)
  • One topic per PR; follow-ups go in a new PR
  • python tools/check_conventions.py passes (no comments in code, one declaration per export, Conventional Commit subjects)
  • Unimplemented paths stop (AbxNotImplemented / AbxUnsupported); silent stubs are listed under Silent stubs through a debt fragment
  • Known gaps added, changed or removed through docs/dev/debt/changes/<branch>.md
  • Generic behaviour, not specific to one title
  • No game files, keys, notes or logs added to the repository
  • Depends on: #8 (the libraries only build with MSVC on top of it; this branch contains its commit until it merges, then I will rebase onto main)
  • Fixes: Fixes #2
  • Unblocks: none
  • Source of behaviour: public documentation — XSystemGetDeviceType, XSystemDeviceType, XPackageIsPackagedProcess, Executable element
  • AI-assisted: yes

🤖 Generated with Claude Code

**@⁠CaseReed** on GitHub · 2026-11-21 05:41 UTC · [original](https://github.com/Dark3581/AnyBox/pull/9) `CaseReed:feat/xsystem-device-type` → `main` · +126 −22 · 20 files · 3 commits · merged 2026-11-21 06:59 UTC ### What Implements `XSystemGetDeviceType` and `XPackageIsPackagedProcess` (#2). The ticket asks to decide what a desktop host should report; this is the choice and why. **`XSystemGetDeviceType` reports the console mode the title declares, not the host hardware.** The public reference says the function returns the console mode rather than the actual hardware, and that an Xbox One title does not get a Series code. Console code typically switches on the value to pick a render resolution and has no `Pc` case, so reporting `Pc` to every title would send console builds down their default branch. The title already states its target in `MicrosoftGame.config`: | `TargetDeviceFamily` of the first `<Executable>` | Reported | |---|---| | `Scarlett` | `XboxScarlettAnaconda` | | `XboxOne`, or an `<Executable>` without the attribute (the packaging default) | `XboxOneX` | | `PC` | `Pc` | | any other value | stops with `AbxUnsupported` | | no `<Executable>`, or no readable `MicrosoftGame.config` | stops with `AbxUnsupported`, as `XGameGetXboxTitleId` does for a missing `<TitleId>` | Reporting the top model of each family whatever the host is an assumption; it is recorded in debt with a `Closes when:`. If you would rather report `Pc`, the lower models, or make it configurable, I'm happy to change it. **`XPackageIsPackagedProcess` returns `false`.** A relinked title started from a folder has no package identity on the host. Recorded in debt. Supporting changes: - The runtime reads `TargetDeviceFamily` in `TitleConfig` and exposes it through `AbxTitleDeviceFamily()`, shaped like `AbxTitleName()`. - `XSystemDeviceType` is added to `Types.hpp` with the values from the public reference. The two functions live in new `System.cpp` and `Package.cpp`. - Seven `e2e_device_*` scenarios cover each row of the table, including an `<Executable>` without the attribute, a config without `<Executable>` and no config. The stand-in console DLL returns deliberately wrong values (`0xffffffff`, `true`), so the scenarios fail if the call is not routed to AnyBox. - `docs/dev/debt/changes/gdk-inventory.md` (a pending fragment already on `main`) named `TaskQueue.cpp` and `Runtime.cpp` as the only files with implemented exports; I added the two new files to that sentence so it stays true. A second fragment cannot change the same entry, so the edit is in place. The debt fragment is named `feat-xsystem-device-type.md`: `debt_fold.py` reads `changes/*.md` only, so a file under `changes/feat/` would not be found. **Self-review (second commit).** An independent read of the first commit found that the `XboxOne` default also applied to a config the reader could not parse, that returning `Unknown` for a missing config did not follow "implement or stop", and that `e2e_device_default` did not test what it claimed. The second commit fixes the three. It also records in debt that the config reader does not skip XML comments (already true for `<TitleId>`, `<Identity>` and `<ShellVisuals>`); I left the reader itself alone to keep this PR on one topic and can send a separate fix. ### Tested Windows 11, MSVC 19.38 (VS 2022), CMake 4.4.4, Ninja 1.13.2, clean build directory, on top of #8. - Full build: ok. `ctest`: 29/29 (22 existing, 7 new). - `python tools/check_conventions.py`: ok. `python tools/debt_fold.py --check`: 2 fragments apply cleanly. - `python tools/progress.py --module xgameruntime`: 13 → 15 implemented, 378 → 376 stubs. Not tested: the MinGW build (no GCC on this machine; relies on CI), MSVC 19.51, the run report schema check (`jsonschema` not installed), and behaviour against a console title. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions (based on `main` plus #8, see Depends on) - [x] One topic per PR; follow-ups go in a new PR - [x] `python tools/check_conventions.py` passes (no comments in code, one declaration per export, Conventional Commit subjects) - [x] Unimplemented paths stop (`AbxNotImplemented` / `AbxUnsupported`); silent stubs are listed under Silent stubs through a debt fragment - [x] Known gaps added, changed or removed through `docs/dev/debt/changes/<branch>.md` - [x] Generic behaviour, not specific to one title - [x] No game files, keys, notes or logs added to the repository - [x] Depends on: #8 (the libraries only build with MSVC on top of it; this branch contains its commit until it merges, then I will rebase onto `main`) - [x] Fixes: Fixes #2 - [x] Unblocks: none - [x] Source of behaviour: public documentation — [XSystemGetDeviceType](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/system/xsystem/functions/xsystemgetdevicetype), [XSystemDeviceType](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/system/xsystem/enums/xsystemdevicetype), [XPackageIsPackagedProcess](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/system/xpackage/functions/xpackageispackagedprocess), [Executable element](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/system/microsoftgameconfig/elements/microsoftgameconfig-element-executable) - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The full build failed with MSVC 19.38, 19.44 and 19.51:

- C3829: [[noreturn]] after extern "C" __declspec(...) is rejected.
  Move the attribute after the function name, a standard position
  that GCC accepts too.
- C2589: std::min collides with the min macro from windows.h in
  Runtime.cpp. Parenthesise the call.
- LNK2001: link.exe resolves a forwarder's target at link time, so
  ab_gameinput and ab_xaudio2 need the Windows SDK import libraries.
  Link them for MSVC only; the MinGW link line is unchanged.

BUILD.md states the Windows SDK requirement.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
XSystemGetDeviceType reports the console mode the title declares in
MicrosoftGame.config, not the host hardware: TargetDeviceFamily
Scarlett gives XboxScarlettAnaconda, XboxOne or no value gives
XboxOneX, PC gives Pc, no readable config gives Unknown, and any
other value stops with AbxUnsupported.

XPackageIsPackagedProcess returns false: a relinked title started
from a folder has no package identity on the host.

The runtime reads TargetDeviceFamily from the first Executable
element and exposes it through AbxTitleDeviceFamily. Six end-to-end
scenarios cover each case.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Self-review of the previous commit:

- The XboxOne default applied whenever no <Executable> was found,
  including a config the reader could not parse. It now applies only
  to an <Executable> without the attribute.
- A missing config reported Unknown. It now stops with AbxUnsupported,
  like XGameGetXboxTitleId does for a missing <TitleId>.
- e2e_device_default tested a config without <Executable>, not an
  <Executable> without the attribute. It now tests the latter, and
  e2e_device_noexecutable covers the former.

Record in debt that the config reader does not skip XML comments, and
mention the new end-to-end checks in ARCHITECTURE.md.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:13:39 +00:00
github manually merged commit e3ebe0de09 into gh-pr/9/base 2026-11-26 19:13:41 +00:00
Author
Owner

@⁠Dark3581 on GitHub · 2026-11-21 06:59 UTC · original · approved these changes

Reviewed — looks good

Nothing blocks this change. Both functions match the public reference, and every row of the device table has an end-to-end test.

What I ran

Reviewed head e3ebe0d. Built it with MinGW (WinLibs GCC 15.2 UCRT, Ninja, Release) on Windows 10 from a clean build directory, and checked that it merges onto main after #8 with a tree identical to the tested head.

Results

Check Result Note
MinGW full build passed no warnings
CTest passed 29/29, including the 7 e2e_device_* scenarios
tools/check_conventions.py passed
tools/debt_fold.py --check passed 2 fragments apply cleanly
tools/progress.py --module xgameruntime passed 13 → 15 implemented
CI passed

Findings

Blocking

None.

Non-blocking

  • I first thought reading only the first <Executable> would misreport one build in a package that lists both an Xbox One and a Series executable. The Executable element reference rules that out for packages: "MakePkg.exe requires all executables in the MicrosoftGame.config use the same TargetDeviceFamily specification". A loose-file layout could still mix them. Matching the entry whose Name is the running executable would cover that, if it ever matters.
  • The XML comment gap you recorded for the config reader is worth the separate fix you offered.

Sources

The default for a missing attribute matches the same page: "Packaging will default to the XboxOne TargetDeviceFamily if no Executable has the TargetDevieFamily attribute defined when running MakePkg pack for XBOX consoles."

Not verified

Behaviour against a console title, and how titles react to the lower models of each family (recorded in debt with Closes when:).

To get this to a good state

Nothing is required. Reporting the top model of each family is a fair default; let's keep it.

**@⁠Dark3581** on GitHub · 2026-11-21 06:59 UTC · [original](https://github.com/Dark3581/AnyBox/pull/9#pullrequestreview-6003677349) · **approved these changes** # Reviewed — looks good Nothing blocks this change. Both functions match the public reference, and every row of the device table has an end-to-end test. ## What I ran Reviewed head `e3ebe0d`. Built it with MinGW (WinLibs GCC 15.2 UCRT, Ninja, Release) on Windows 10 from a clean build directory, and checked that it merges onto `main` after #8 with a tree identical to the tested head. ## Results | Check | Result | Note | |---|---|---| | MinGW full build | passed | no warnings | | CTest | passed | 29/29, including the 7 `e2e_device_*` scenarios | | `tools/check_conventions.py` | passed | | | `tools/debt_fold.py --check` | passed | 2 fragments apply cleanly | | `tools/progress.py --module xgameruntime` | passed | 13 → 15 implemented | | CI | passed | | ## Findings ### Blocking None. ### Non-blocking - I first thought reading only the first `<Executable>` would misreport one build in a package that lists both an Xbox One and a Series executable. The [Executable element reference](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/system/microsoftgameconfig/elements/microsoftgameconfig-element-executable) rules that out for packages: "MakePkg.exe requires all executables in the MicrosoftGame.config use the same TargetDeviceFamily specification". A loose-file layout could still mix them. Matching the entry whose `Name` is the running executable would cover that, if it ever matters. - The XML comment gap you recorded for the config reader is worth the separate fix you offered. ## Sources The default for a missing attribute matches the same page: "Packaging will default to the XboxOne TargetDeviceFamily if no Executable has the TargetDevieFamily attribute defined when running MakePkg pack for XBOX consoles." ## Not verified Behaviour against a console title, and how titles react to the lower models of each family (recorded in debt with `Closes when:`). ## To get this to a good state Nothing is required. Reporting the top model of each family is a fair default; let's keep it.
This discussion has been locked. Commenting is limited to contributors.
No description provided.