ef39050dbc
windows-drivers / probe-and-proto (push) Successful in 47s
ci / web (push) Successful in 58s
apple / swift (push) Successful in 1m13s
decky / build-publish (push) Successful in 16s
ci / docs-site (push) Successful in 1m19s
docker / build-push (--build-arg FEDORA_VERSION=44, ci, ci/fedora-rpm.Dockerfile, punktfunk-fedora44-rpm) (push) Successful in 12s
docker / build-push (ci, ci/fedora-rpm.Dockerfile, punktfunk-fedora-rpm) (push) Successful in 9s
docker / build-push (ci, ci/rust-ci.Dockerfile, punktfunk-rust-ci) (push) Successful in 8s
docker / build-push (., web/Dockerfile, punktfunk-web) (push) Successful in 43s
windows-drivers / driver-build (push) Successful in 1m45s
docker / build-push (docs-site, docs-site/Dockerfile, punktfunk-docs) (push) Successful in 55s
ci / bench (push) Successful in 7m18s
flatpak / build-publish (push) Successful in 6m18s
docker / deploy-docs (push) Successful in 25s
windows-host / package (push) Successful in 8m31s
release / apple (push) Successful in 11m41s
android / android (push) Successful in 13m4s
windows-msix / package (arm64, C:\Users\Public\ffmpeg-arm64, --no-default-features, aarch64-pc-windows-msvc, C:\t-a64) (push) Successful in 1m57s
windows-msix / package (x64, C:\Users\Public\ffmpeg, , x86_64-pc-windows-msvc, C:\t) (push) Successful in 2m16s
arch / build-publish (push) Successful in 16m24s
windows / build (aarch64-pc-windows-msvc) (push) Successful in 1m6s
deb / build-publish (push) Successful in 17m54s
windows / build (x86_64-pc-windows-msvc) (push) Successful in 1m27s
ci / rust (push) Successful in 18m23s
apple / screenshots (push) Successful in 5m58s
rpm / build-publish (43, bazzite, punktfunk-fedora-rpm) (push) Successful in 20m24s
rpm / build-publish (44, fedora-44, punktfunk-fedora44-rpm) (push) Successful in 18m43s
Six parallel audits swept the root docs, docs-site, every per-directory README, and the packaging docs; every claim below was verified against the source before editing. - README: Layout gains the six missing crates (pf-client-core, pf-presenter, pf-console-ui, pf-ffvk, pf-driver-proto, punktfunk-tray), clients/session, api/ and ci/; Linux/Windows client rows reflect the shell + Vulkan-session split and the Vulkan Video -> VAAPI/D3D11VA -> software decode chains; the "every client over a C ABI" claim is corrected (Rust clients link the core directly); tiered stats overlay + console shell noted; Apple row mentions AV1. - CONTRIBUTING: drop the dead CLAUDE.md link (deliberately untracked); point at the README's build/invariants sections. SECURITY: 0.9.0. - host-cli/pairing: --allow-pairing/--require-pairing are no-op legacy names — pairing is required by default, --allow-tofu is the real flag; document --data-port and --idle-timeout-ms. - configuration: document PUNKTFUNK_RECOVER_SESSION_CMD (session-crash recovery hook), PUNKTFUNK_MDNS, PUNKTFUNK_DATA_PORT. - virtual-displays/gnome: GNOME per-client scaling shipped (host- persisted) — flip the ❌ to ✅ and describe how it works. - stats: new "Detail levels" section (Off/Compact/Normal/Detailed + per-platform cycle gestures); retire the GTK hand-off note. - clients/install-client/status/roadmap: decode chains, Windows client validation narrowed to HDR-only pending, adaptive bitrate, console shell, Apple AV1, Windows host vendor list. - Sub-READMEs: clients/linux rewritten for the re-architecture; session Windows decode rung + d3d11va knob; Windows tiered overlay; Android minSdk 28; decky file table; host zerocopy/ path; scripts port 47992 and steamos-host.md; pf-dualsense source path. - packaging: canary version bases are tag-derived (<next-minor> via pf-version.sh/.ps1), codecs-extra not ffmpeg-full, document the pinned offline-Skia tarball + SKIA_BINARIES_URL and vulkan-headers. - Convert 15 dangling design/*.md links to the punktfunk-planning prose convention (those docs live in the private planning repo). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
101 lines
6.6 KiB
Markdown
101 lines
6.6 KiB
Markdown
# Virtual Steam Deck via USB gadget — true Steam Input recognition
|
||
|
||
**Proven on a real Steam Deck (SteamOS 3.8.11), 2026-06-29.** A `raw_gadget` userspace emulator of a
|
||
real 3-interface USB Steam Deck (`28DE:1205`) — mouse = interface 0, keyboard = 1, **controller =
|
||
interface 2** — bound to a `dummy_hcd` loopback UDC, so the host's own Steam sees a genuine
|
||
interface-2 Deck and **promotes it through Steam Input** (XInput pad emission, glyphs, bindings).
|
||
|
||
## Why this exists (the interface-2 wall)
|
||
|
||
A virtual Deck created via **UHID** (the `inject/proto/steam_proto.rs` / `steam_controller.rs` path)
|
||
binds the kernel `hid-steam` driver, but **Steam Input will not manage it**: Steam filters the Deck's
|
||
controller to USB **interface 2**, and a UHID device has no USB interface number (`Interface: -1` in
|
||
Steam's `controller.txt`), so Steam enumerates it but never promotes it. A single-interface DualSense
|
||
is accepted at `-1` (no ambiguity), but the multi-interface Deck specifically needs interface 2. See
|
||
punktfunk-planning: `steam-controller-deck-support.md` §11.
|
||
|
||
A real multi-interface USB device with the controller on interface 2 requires a **USB gadget**.
|
||
SteamOS ships every piece (`CONFIG_USB_DUMMY_HCD=m`, `CONFIG_USB_RAW_GADGET=m`,
|
||
`CONFIG_USB_CONFIGFS_F_HID=y`), so this runs on a Deck with no module-building.
|
||
|
||
## What's here
|
||
|
||
- **`deck_raw_gadget.c`** — the working emulator. Presents the 3-interface Deck with descriptors
|
||
captured verbatim from a physical Deck (incl. the real 38-byte controller report descriptor), and
|
||
— crucially — answers **every** control transfer, including the HID feature reports (`f_hid` can't,
|
||
so it produced a "zombie controller" in Steam). Streams the 64-byte state report on the interface-2
|
||
interrupt-IN endpoint. Build static (the Deck has no compiler):
|
||
```sh
|
||
gcc -O2 -static -pthread -o deck_raw_gadget deck_raw_gadget.c
|
||
```
|
||
Run as root with `dummy_hcd` + `raw_gadget` loaded: `./deck_raw_gadget [seconds]`.
|
||
- **`configfs_gadget_up.sh` / `_down.sh`** — the simpler **configfs `f_hid`** variant. It proves the
|
||
structure (interface 2 → `hid-steam` binds → Steam *opens* it + *reserves an XInput slot*) but
|
||
`f_hid` cannot serve HID feature reports, so Steam can't read controller details and drops it as a
|
||
zombie. Kept as the minimal reproducer of the interface-2 result.
|
||
|
||
## Result (raw_gadget, live)
|
||
|
||
```
|
||
hid-steam ... Steam Controller 'PFDECK000' connected
|
||
input: Steam Deck / Steam Deck Motion Sensors (kernel gamepad + IMU evdevs)
|
||
controller.txt: Interface: 2 ... device opened for index 14 ... reserving XInput slot 1
|
||
input: Microsoft X-Box 360 pad 1 (Steam Input's XInput output — promoted)
|
||
```
|
||
Stable (1 connect, 0 disconnects), no zombie. The kernel `"Steam Deck"` evdev is then grabbed by
|
||
Steam Input, which exposes its own X-Box 360 pad — exactly a real Deck's behaviour.
|
||
|
||
## Key implementation gotchas (all real, all cost time)
|
||
|
||
- `struct usb_endpoint_descriptor` (ch9.h) is **9 bytes** (audio `bRefresh`/`bSynchAddress`); the wire
|
||
descriptor needs **7** — use a packed 7-byte struct in the config blob or the kernel mis-parses it.
|
||
- raw_gadget EP0: a **no-data OUT** control (`SET_CONFIGURATION`, `SET_INTERFACE`, `SET_IDLE`,
|
||
`SET_PROTOCOL`) is completed with a zero-length **`EP0_READ`**, not `EP0_WRITE` (using write →
|
||
`EBUSY`/`can't set config error -110`). IN controls (`GET_*`) use `EP0_WRITE`.
|
||
- Don't start the input streamer until after `SET_CONFIGURATION` is fully acked, or its blocking
|
||
`EP_WRITE` starves the control path.
|
||
- `dummy_hcd` + `raw_gadget` must both be loaded and `/dev/raw-gadget` present before launch.
|
||
|
||
## Host backend (shipped — default on for SteamOS)
|
||
|
||
The C PoC's transport is ported to a Rust host gamepad backend:
|
||
`crates/punktfunk-host/src/inject/linux/steam_gadget.rs` (`SteamDeckGadget`), driven by the same
|
||
`steam_proto` serializer as the UHID `SteamDeckPad`. The Steam-Deck manager
|
||
(`inject/linux/steam_controller.rs`) selects per-pad between **UHID** (universal) and the **USB
|
||
gadget**: the gadget is the **default on SteamOS hosts** (`gadget_preferred()` → `ID=steamos`;
|
||
best-effort `modprobe dummy_hcd raw_gadget`, graceful fallback to UHID if `/dev/raw-gadget` is
|
||
unusable), and off elsewhere where UHID stays the default. `PUNKTFUNK_STEAM_GADGET=1`/`0` forces it.
|
||
A Deck-as-host with a *physical* Deck never uses it — `resolve_gamepad`'s conflict gate degrades
|
||
`SteamDeck` → DualSense first.
|
||
|
||
The Rust transport is **validated on the Deck** (a static musl test binary that `#[path]`-includes the
|
||
real module): it enumerates the 3-interface Deck, hid-steam binds it + reads our serial + creates the
|
||
`Steam Deck` + `Motion Sensors` evdevs — identical to the C PoC. A real USB-stack bug it caught: on
|
||
musl, `ioctl(fd, RUN)` with no third arg passes a garbage `value`, and raw_gadget's `RUN`/`CONFIGURE`/
|
||
`EP0_STALL` reject a non-zero `value` with `EINVAL` — so the no-arg ioctls must pass an explicit `0`.
|
||
|
||
## Feature contract (hardened — churn fixed)
|
||
|
||
Steam's `GetControllerInfo` reads HID **feature reports**; serving the real ones is what stops Steam
|
||
re-probing (which was destroying + recreating the gamepad evdev — the "churn"). The contract was
|
||
captured from a physical Deck (`get_deck_attrs.c`, hidraw `HIDIOCGFEATURE`; usbmon truncates to 32B):
|
||
|
||
- **`0x83` GET_ATTRIBUTES_VALUES** — `[83, 2d, 9× (attr-id, u32-LE)]`: product id `0x1205`, a unit
|
||
serial (`0x0a`/`0x04` — we stamp a per-instance value so a gadget never collides with a real Deck),
|
||
and capability attrs (`0x09=0x2e`, `0x0b=0x0fa0`, `0x02/0x0c/0x0d/0x0e=0`). **This blob is the fix.**
|
||
- **`0xAE` GET_STRING_ATTRIBUTE** — `[ae, len, attr, ascii]`: serial (attr 1), board serial (attr 0).
|
||
- Other commands (e.g. `0x87` settings) read back the last write (echo).
|
||
|
||
Result on the Deck (`feature_reply` in `steam_gadget.rs`): **1 connect / 0 disconnect / 1 gamepad
|
||
evdev** (was constant churn), and Steam *activates* the controller cleanly (no `GetControllerInfo
|
||
failed`, no zombie) and emits its **X-Box 360 pad**. usbmon on the gadget's bus confirms our state
|
||
reports (with the pressed button at byte 8) are delivered on the interrupt-IN and consumed by
|
||
hid-steam — so the input transport is proven end-to-end.
|
||
|
||
## Remaining
|
||
|
||
- **Glass confirmation of the XInput mapping** — Steam Input only maps the gadget's raw input onto its
|
||
X-Box pad while a game using Steam Input is focused; confirm a button reaches a real game, then
|
||
default the gadget on for SteamOS hosts (it's strictly better than the non-promoted UHID path).
|
||
- A `punktfunk-host` build for SteamOS to exercise the integrated path end-to-end with a live client.
|