feat(input): controller gyro under Steam Input (Steam Controller, DualSense, Deck; Linux and Windows) #3045

Merged
HumanBean merged 2 commits from sandymac/Longshot:feat/steam-controller-gyro into main 2026-12-05 19:20:17 +00:00
Contributor

Summary

With Steam Input on, a game started from Steam gets SDL_GAMECONTROLLER_IGNORE_DEVICES, so SDL opens only Steam's
stand-in pads, which have no sensors. Longshot's Motion controls then had no gyro, except the Steam Deck's own controls
(#2660, #2802). Each real controller still streams its state reports, motion included, to every reader of its HID
device. This PR turns the builder's Deck reader (build_core::deck_imu) into one reader of controller families
that runs on Linux and Windows, and adds the Steam Controller (2026) and the DualSense / DualSense Edge.
Steam keeps the buttons, sticks, trackpads and the player's layout, and Longshot's own Motion page (sensitivity, invert,
deadzone) gets the gyro. Refs #2974.

Since #2822 the builder reads every pad for the game, so the reader lives there and its reading reaches the game in
the pads snapshot's trailer, as the Deck's did. The game opens no HID device, confined or not.

Read first: builder/crates/build-core/src/hid_imu.rs (the families, the parsers and each family's input signature,
then Reader::poll, then Background), then the wire in build_core::pads (Request, snapshot) and its client in
game/crates/longshot-game/src/builder_link/pads.rs, then motion_poll in host/pad_sdl.c.

  • One reader, two transports, its own thread. build_core::deck_imu → build_core::hid_imu. The reader holds the
    device choice, probing, live/stale motion and turning sensors on, and reaches the system only through its Hid
    trait: Linux's Sys is the old hidraw code (uevent's HID_ID now gives the vendor and product), Windows' Sys
    uses cfgmgr32's device interface list and the HID class driver's ioctls on an overlapped handle, not SetupDi/HidD_*,
    which Steam's overlay hooks in the processes it starts to hide the controllers Steam Input drives (PrimeRecomp's
    approach, MIT, written here from it). No new crate. The reader runs on a thread of its own (Background), started
    at the first request that wants motion: a pads request only stores what the game wants and copies the newest
    reading, so no device listing, feature report or slow controller can hold back a snapshot's buttons and sticks.
  • Families. Each family is its USB ids, a parser for its state report, and a kill switch:
    • Steam Deck built-in controls (28de:1205): as on main, its sensors turned on and its setting put back where the
      builder still owns it.
    • Steam Controller (2026) (28de:1302–1305: cable, Bluetooth, both receivers): reports 0x42/0x45/0x47 at
      SDL 3.4's offsets and axes, with its own sensor clock (a stalled one is no reading, as SDL).
    • DualSense / Edge (054c:0ce6, 0df2): 0x01 on a cable, 0x31 over Bluetooth with its CRC-32 checked; SDL's
      scale without the factory calibration (the filter learns the resting bias). Read only.
    • DualShock 4 and Switch Pro are one table row, one parser and one switch each, left for whoever can test them.
  • The wire (version 3 → 4). The request's Deck word becomes three: the families wanted (a mask, 0 stops the reader:
    a Deck's setting put back), options (bit 0: the Steam Controller's sensors may be turned on) and the Steam Input pad
    used last (vendor << 16 | product, a hint). The snapshot's trailer (28 → 48 bytes) says which family was read, a
    serial that changes with the device read (a fresh filter), how long ago that controller's own buttons or sticks
    moved, the device's id (its node's FNV-1a and the count of devices that node has had: the same while it stays
    plugged in), and the wire id of the pad SDL opened on the same node (0 none). game_builder_deck_imu → game_builder_hid_imu.
  • Which controller: the one whose own buttons or sticks moved last. The reader keeps up to 4 controllers open,
    drains them all each poll, and reads the one whose input signature (buttons, and each stick axis past 40%) changed
    last. Steam's stand-in pads were not reliable for this: after controllers reconnect, SDL's ids for them drift out of
    step (the pad named "DualSense Wireless Controller" reported 28de:1302), and a stand-in connected mid-game can come
    unnamed (28de:11ff). The stand-in pad used last is only a hint before anything has moved.
  • Steam turns a Steam Controller's sensors off; the reader turns them back on, and never off. Under Steam Input its
    IMU streams only while Steam's layout (or Steam's menus) use the gyro. When the controller being read has a frozen
    sensor clock for 150 ms, the reader sends the one setting SDL's Triton driver sends for it, SETTING_IMU_MODE = raw
    accel | raw gyro (feature report 1, 64 bytes), at most every 3 s, never while motion arrives. Lizard mode and the rest
    stay Steam's. Its receiver answers no settings request (EPIPE), so who owns the setting later can't be read: the
    reader never writes it off (Steam sets it with each layout it applies). HOS_STEAM_CONTROLLER_IMU_ON=0 keeps the
    reader to reading.
  • Beside a pad SDL reads the gyro of. The builder's SDL opens Valve's real pads beside Steam's stand-ins
    (steam_pads_without_valve), so a Steam Controller's gyro often comes through SDL. The reader keeps running then, and
    its controller is read over SDL's pad when its own buttons or sticks moved after the pad was last used
    (hid_imu_over_pad in host/hid_imu.h). The builder names the pad SDL opened on the reader's node (each open pad's
    path hashed as the reader's node is, case blind on Windows), and a controller SDL reads the sensors of stays SDL's:
    the reader's signature counts buttons SDL's pad doesn't (grips, trackpad clicks), so deciding by time would hand one
    controller back and forth. A second controller of the same kind on another node is another controller.
  • A Steam stand-in without its handle is still a stand-in (host/steam_pads.h): a pad with Valve's virtual id
    28de:11ff was taken for a real Valve pad and made motion only, so a Steam Controller connected mid-game lost its
    buttons.
  • A fresh filter per controller, its learned bias kept per device (8 devices), so switching back needs no new
    setting down, and a second controller of the same kind, or one Linux gives a node another left (/dev/hidrawN),
    starts unlearned.
  • The reader's log lines take pads::TARGET (#3249), so they reach the game's longshot_log.txt.
  • tests/test_deck_imu.py → tests/test_hid_imu.py (the game's side, and host/hid_imu.h's device table against the
    builder's); the reader's own tests are build-core's unit tests on a fake Hid: the parsers on real reports captured
    from these controllers, the 14 scenarios of the C reader this started as, main's Deck tests, a device that takes
    200 ms a feature report never holding a request back, and Steam taking a Steam Controller over before the end.

Testing

Tested: this PR's builder and game built with from-source on each machine, started from Steam:

  • Steam Deck LCD (SteamOS) with its own controls, a Steam Controller (2026) and a DualSense, both over Bluetooth: gyro
    aiming with all three, switching between them, the Steam Controller's grips and trackpad clicks while aiming (no
    hand-over), a controller off and on again. With Steam Input off for the game (Properties → Controller), the
    DualSense's gyro through SDL as on main.
  • Steam Machine (SteamOS, RADV NAVI33) with a Steam Controller and a DualSense: the same; with Steam Input off for the
    game, the DualSense through SDL.
  • Windows 11 (RTX 4060 laptop, NVIDIA), main's default (no sandbox): a Steam Controller and two DualSenses over
    Bluetooth: each one's buttons and gyro aiming, switching between all three, reconnects, a second start with no
    pipelines prepared again. With PlayStation controller support off in Steam's settings, the DualSense through SDL, switching
    with the Steam Controller.
  • At 40aa3ab1 (this PR on main @ f577a1ae); rebased onto main @ ca830e89 since (#3044's pads changes: one wire
    version up, the state's new fields kept), the tests below again, and at 77afed87 each controller's gyro and
    switching in game on all three machines again, beside #3044's new DualSense features.
  • Rebased onto main @ 67fda193 as 4444cedd: one conflict, in gpu/vk/switches.def (main's HOS_STEP_SHOWN beside
    the new HOS_STEAM_CONTROLLER_IMU* lines, all kept in order); the PR's own diff is unchanged (18 files, +3672
    −884). Then on Linux again: rustfmt, ffi-gen --check, schema-gen --check, clippy -D warnings --no-deps on
    build-core and longshot-game (with dependencies, host-sys and build-assets fail clippy on main @ 67fda193
    too), cargo test -p build-core -p longshot-game, and the Python checks below; mise run test-changed's 8 failed
    Python checks are 8 of the 15 that fail on main too.
  • Windows 11, HOS_SANDBOX=1, started from Steam, PlayStation controller support off (this PR's code, built at
    77afed87): the game confined in its AppContainer (the log's sandbox: lines); a DualSense through the builder's
    SDL: buttons and sticks as a gamepad (PS5 prompts), gyro aiming with the slingshot, the PS button opens Longshot's
    menu.
  • BeanBot's second review (L1 by node, L2 by device), at 0d352eb4 (on main @ 7bc53f84), Steam Input on: Steam Deck
    LCD with its own controls, the Steam Controller and a DualSense, and the Steam Machine with the Steam Controller and a
    DualSense: gyro aiming with each, the Steam Controller's grips and trackpad clicks while aiming (no hand-over),
    switching between them. Rebased since onto main @ b6330a5b as 83dfa98b: deck_imu.rs (#3249's log target,
    carried into hid_imu.rs), lib.rs (#3245's modules kept), input.md's tables and the session's fields (#3249's
    said kept). ffi-gen can't run on that main (host/game_host.h's new declarations have no doc comments,
    #3164, #3208); the PR's game.h lines are the ones it generated at 0d352eb4. Rebased again onto main @ a0e0c720
    as 7c417748: input.md's table (main's new keyboard and mouse row kept); the PR's code unchanged. rustfmt and one
    longshot-game test (settings_now) fail on main @ a0e0c720 too, in files this PR doesn't touch. Rebased since onto
    main @ 5aa5989e as 3afc328d (no conflict; BeanBot's @fix rebase in between, 19907f20): the PR's diff unchanged,
    the same checks again with the same results.
  • Checks: cargo test -p build-core (hid_imu, pads: 48) on Windows and Linux, cargo test -p longshot-game
    (builder_link: 43) on Linux; clippy -D warnings on both crates, rustfmt, ffi-gen --check;
    tests/test_hid_imu.py, test_steam_pads.py, test_pad_motion_policy.py, test_builder_pads_route.py,
    test_pads_after_menu.py, test_gyro_rearm.py, test_switch_table.py.

Still to test:

  • Windows at 3afc328d (the same code as 83dfa98b), Steam Input on: a Steam Controller's gyro aiming with its grips and trackpad clicks pressed
    (no hand-over), a DualSense picked up and back (by hand; asked on the PR and in the team room)
  • Steam Deck OLED: its own gyro as on main (Test Farm: @Beanstalk steamdeck, Motion controls aiming with the built-in
    gyro)
  • Windows with HOS_SANDBOX=1 and a DualSense under Steam Input (PlayStation controller support on): the confined
    game's controllers may come under Steam's Desktop Layout there (the builder is the process Steam started, the game's
    window is not), on main as here; the gyro path itself is the builder's either way (by hand)

Measurements

Verdict: the reader costs a pads request nothing measurable: its device work runs on its own thread. The kill
switches ship on: HOS_DECK_IMU (as before), HOS_STEAM_CONTROLLER_IMU, HOS_STEAM_CONTROLLER_IMU_ON,
HOS_DUALSENSE_IMU.

What a pads request waits on for motion (Background::motion), and the reader's own poll on its thread, every 4 ms for
20 s, all three families wanted (a scratch program over build_core::hid_imu, release build; hid_imu.rs is the same
at 40aa3ab1 and 77afed87). On the Steam Deck LCD its own controls were read (99% of polls with a reading) with the game
running; on Windows 11 no controller was connected. main's Deck reader polled on the request itself (not measured
there). Times in ms: median / p99 / p99.9 / max.

Before: main @ ca830e89 After: this PR @ 77afed87
Steam Controller under Steam Input (Deck, Steam Machine, Windows) gyro through the builder's SDL the same
DualSense under Steam Input (Deck, Steam Machine, Windows) no gyro gyro aiming works
Steam Deck's own controls gyro gyro, and switching with the others
Switching between Deck, Steam Controller, DualSenses n/a as fast as the player swaps
The reader's tests Deck only, Linux only three families, Linux and Windows
A pads request's motion call, Steam Deck (the reader @ 40aa3ab1) the Deck reader's poll, on the request 0.001 / 0.002 / 0.003 / 0.099
The reader's own poll, Steam Deck (the reader @ 40aa3ab1) on the request 0.014 / 0.031 / 0.370 / 5.3, on its own thread
A pads request's motion call, Windows 11, no controller (the reader @ 40aa3ab1) no reader 0.000 / 0.002 / 0.014 / 0.088
The reader's own poll, Windows 11 (the reader @ 40aa3ab1) no reader 0.001 / 0.003 / 2.26 / 2.89 (a device list every 2 s), on its own thread

Risks

  • Turning a Steam Controller's sensors on writes to a controller Steam drives. It is the one setting Steam itself sets
    for its gyro features, Steam sets it again with each layout, and the reader never writes it off.
    HOS_STEAM_CONTROLLER_IMU_ON=0 avoids any write.
  • A wrong axis or scale would aim the wrong way: the axes and scales are SDL 3.4's, checked against real reports from
    each controller and in the game on the Deck, the Steam Machine and Windows.
  • The pads wire changes version: the builder and game come from one build, and a mismatch is refused whole, as before.
  • Revert, or the family's kill switch, brings back main's behaviour. Saves, longshot_options.ini and the caches are
    untouched.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named). (mise run test --container, CI's
    image, under Docker on the Windows PC's WSL, on this PR @ 77afed87 and on main @ ca830e89: 870 passed, 15 failed
    or timed out, 13 skipped on both, the same 15 checks on both, none of them reading a file this PR changes: renderer
    and shader fixtures, test_builder_files_linux, test_crash_record, test_utf8_paths, test_run_all_junit, and
    test_lifter/test_lifter_semantics timing out on a laptop. Every check that reads this PR's files passes:
    test_hid_imu, test_steam_pads, test_pad_motion_policy, test_builder_pads_route, test_pads_after_menu,
    test_gyro_rearm, test_switch_table. clippy and rustfmt, which test_lifter runs, were run on build-core and
    longshot-game by hand.)
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.
    (Report layouts from SDL's zlib-licensed drivers, the Windows transport after PrimeRecomp's MIT approach, both
    written here in our own code; game/game.h regenerated by ffi-gen.)

When it applies

  • A switch added or changed: it ships at the default the measurements chose, with its row in gpu/vk/switches.def.
  • A check under tests/ that reads changed source is updated, not weakened.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths.
  • Docs updated.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

Assisted-by: Claude Opus 5.5 (Claude Code)

## Summary With Steam Input on, a game started from Steam gets `SDL_GAMECONTROLLER_IGNORE_DEVICES`, so SDL opens only Steam's stand-in pads, which have no sensors. Longshot's Motion controls then had no gyro, except the Steam Deck's own controls (#2660, #2802). Each real controller still streams its state reports, motion included, to every reader of its HID device. This PR turns the builder's Deck reader (`build_core::deck_imu`) into one **reader of controller families** that runs on **Linux and Windows**, and adds the **Steam Controller (2026)** and the **DualSense / DualSense Edge**. Steam keeps the buttons, sticks, trackpads and the player's layout, and Longshot's own Motion page (sensitivity, invert, deadzone) gets the gyro. Refs #2974. Since #2822 the builder reads every pad for the game, so the reader lives there and its reading reaches the game in the pads snapshot's trailer, as the Deck's did. The game opens no HID device, confined or not. Read first: `builder/crates/build-core/src/hid_imu.rs` (the families, the parsers and each family's input signature, then `Reader::poll`, then `Background`), then the wire in `build_core::pads` (`Request`, `snapshot`) and its client in `game/crates/longshot-game/src/builder_link/pads.rs`, then `motion_poll` in `host/pad_sdl.c`. - **One reader, two transports, its own thread.** `build_core::deck_imu` → `build_core::hid_imu`. The reader holds the device choice, probing, live/stale motion and turning sensors on, and reaches the system only through its `Hid` trait: Linux's `Sys` is the old hidraw code (uevent's `HID_ID` now gives the vendor and product), Windows' `Sys` uses cfgmgr32's device interface list and the HID class driver's ioctls on an overlapped handle, not SetupDi/HidD_*, which Steam's overlay hooks in the processes it starts to hide the controllers Steam Input drives (PrimeRecomp's approach, MIT, written here from it). No new crate. The reader runs on a thread of its own (`Background`), started at the first request that wants motion: a pads request only stores what the game wants and copies the newest reading, so no device listing, feature report or slow controller can hold back a snapshot's buttons and sticks. - **Families.** Each family is its USB ids, a parser for its state report, and a kill switch: - Steam Deck built-in controls (`28de:1205`): as on `main`, its sensors turned on and its setting put back where the builder still owns it. - Steam Controller (2026) (`28de:1302`–`1305`: cable, Bluetooth, both receivers): reports `0x42`/`0x45`/`0x47` at SDL 3.4's offsets and axes, with its own sensor clock (a stalled one is no reading, as SDL). - DualSense / Edge (`054c:0ce6`, `0df2`): `0x01` on a cable, `0x31` over Bluetooth with its CRC-32 checked; SDL's scale without the factory calibration (the filter learns the resting bias). Read only. - DualShock 4 and Switch Pro are one table row, one parser and one switch each, left for whoever can test them. - **The wire** (version 3 → 4). The request's Deck word becomes three: the families wanted (a mask, 0 stops the reader: a Deck's setting put back), options (bit 0: the Steam Controller's sensors may be turned on) and the Steam Input pad used last (`vendor << 16 | product`, a hint). The snapshot's trailer (28 → 48 bytes) says which family was read, a serial that changes with the device read (a fresh filter), how long ago that controller's own buttons or sticks moved, the device's id (its node's FNV-1a and the count of devices that node has had: the same while it stays plugged in), and the wire id of the pad SDL opened on the same node (0 none). `game_builder_deck_imu` → `game_builder_hid_imu`. - **Which controller: the one whose own buttons or sticks moved last.** The reader keeps up to 4 controllers open, drains them all each poll, and reads the one whose input signature (buttons, and each stick axis past 40%) changed last. Steam's stand-in pads were not reliable for this: after controllers reconnect, SDL's ids for them drift out of step (the pad named "DualSense Wireless Controller" reported `28de:1302`), and a stand-in connected mid-game can come unnamed (`28de:11ff`). The stand-in pad used last is only a hint before anything has moved. - **Steam turns a Steam Controller's sensors off; the reader turns them back on, and never off.** Under Steam Input its IMU streams only while Steam's layout (or Steam's menus) use the gyro. When the controller being read has a frozen sensor clock for 150 ms, the reader sends the one setting SDL's Triton driver sends for it, `SETTING_IMU_MODE` = raw accel | raw gyro (feature report 1, 64 bytes), at most every 3 s, never while motion arrives. Lizard mode and the rest stay Steam's. Its receiver answers no settings request (`EPIPE`), so who owns the setting later can't be read: the reader never writes it off (Steam sets it with each layout it applies). `HOS_STEAM_CONTROLLER_IMU_ON=0` keeps the reader to reading. - **Beside a pad SDL reads the gyro of.** The builder's SDL opens Valve's real pads beside Steam's stand-ins (`steam_pads_without_valve`), so a Steam Controller's gyro often comes through SDL. The reader keeps running then, and its controller is read over SDL's pad when its own buttons or sticks moved after the pad was last used (`hid_imu_over_pad` in `host/hid_imu.h`). The builder names the pad SDL opened on the reader's node (each open pad's path hashed as the reader's node is, case blind on Windows), and a controller SDL reads the sensors of stays SDL's: the reader's signature counts buttons SDL's pad doesn't (grips, trackpad clicks), so deciding by time would hand one controller back and forth. A second controller of the same kind on another node is another controller. - **A Steam stand-in without its handle is still a stand-in** (`host/steam_pads.h`): a pad with Valve's virtual id `28de:11ff` was taken for a real Valve pad and made motion only, so a Steam Controller connected mid-game lost its buttons. - **A fresh filter per controller, its learned bias kept per device** (8 devices), so switching back needs no new setting down, and a second controller of the same kind, or one Linux gives a node another left (`/dev/hidrawN`), starts unlearned. - The reader's log lines take `pads::TARGET` (#3249), so they reach the game's `longshot_log.txt`. - `tests/test_deck_imu.py` → `tests/test_hid_imu.py` (the game's side, and `host/hid_imu.h`'s device table against the builder's); the reader's own tests are build-core's unit tests on a fake `Hid`: the parsers on real reports captured from these controllers, the 14 scenarios of the C reader this started as, `main`'s Deck tests, a device that takes 200 ms a feature report never holding a request back, and Steam taking a Steam Controller over before the end. ## Testing **Tested:** this PR's builder and game built with `from-source` on each machine, started from Steam: - Steam Deck LCD (SteamOS) with its own controls, a Steam Controller (2026) and a DualSense, both over Bluetooth: gyro aiming with all three, switching between them, the Steam Controller's grips and trackpad clicks while aiming (no hand-over), a controller off and on again. With Steam Input off for the game (Properties → Controller), the DualSense's gyro through SDL as on `main`. - Steam Machine (SteamOS, RADV NAVI33) with a Steam Controller and a DualSense: the same; with Steam Input off for the game, the DualSense through SDL. - Windows 11 (RTX 4060 laptop, NVIDIA), `main`'s default (no sandbox): a Steam Controller and two DualSenses over Bluetooth: each one's buttons and gyro aiming, switching between all three, reconnects, a second start with no pipelines prepared again. With PlayStation controller support off in Steam's settings, the DualSense through SDL, switching with the Steam Controller. - At `40aa3ab1` (this PR on `main` @ f577a1ae); rebased onto `main` @ ca830e89 since (#3044's pads changes: one wire version up, the state's new fields kept), the tests below again, and at `77afed87` each controller's gyro and switching in game on all three machines again, beside #3044's new DualSense features. - Rebased onto `main` @ 67fda193 as `4444cedd`: one conflict, in `gpu/vk/switches.def` (main's `HOS_STEP_SHOWN` beside the new `HOS_STEAM_CONTROLLER_IMU*` lines, all kept in order); the PR's own diff is unchanged (18 files, +3672 −884). Then on Linux again: rustfmt, `ffi-gen --check`, `schema-gen --check`, clippy `-D warnings --no-deps` on `build-core` and `longshot-game` (with dependencies, `host-sys` and `build-assets` fail clippy on `main` @ 67fda193 too), `cargo test -p build-core -p longshot-game`, and the Python checks below; `mise run test-changed`'s 8 failed Python checks are 8 of the 15 that fail on `main` too. - Windows 11, `HOS_SANDBOX=1`, started from Steam, PlayStation controller support off (this PR's code, built at `77afed87`): the game confined in its AppContainer (the log's `sandbox:` lines); a DualSense through the builder's SDL: buttons and sticks as a gamepad (PS5 prompts), gyro aiming with the slingshot, the PS button opens Longshot's menu. - BeanBot's second review (L1 by node, L2 by device), at `0d352eb4` (on `main` @ 7bc53f84), Steam Input on: Steam Deck LCD with its own controls, the Steam Controller and a DualSense, and the Steam Machine with the Steam Controller and a DualSense: gyro aiming with each, the Steam Controller's grips and trackpad clicks while aiming (no hand-over), switching between them. Rebased since onto `main` @ b6330a5b as `83dfa98b`: `deck_imu.rs` (#3249's log target, carried into `hid_imu.rs`), `lib.rs` (#3245's modules kept), `input.md`'s tables and the session's fields (#3249's `said` kept). `ffi-gen` can't run on that `main` (`host/game_host.h`'s new declarations have no doc comments, #3164, #3208); the PR's `game.h` lines are the ones it generated at `0d352eb4`. Rebased again onto `main` @ a0e0c720 as `7c417748`: `input.md`'s table (main's new keyboard and mouse row kept); the PR's code unchanged. rustfmt and one `longshot-game` test (`settings_now`) fail on `main` @ a0e0c720 too, in files this PR doesn't touch. Rebased since onto `main` @ 5aa5989e as `3afc328d` (no conflict; BeanBot's `@fix` rebase in between, `19907f20`): the PR's diff unchanged, the same checks again with the same results. - Checks: `cargo test -p build-core` (`hid_imu`, `pads`: 48) on Windows and Linux, `cargo test -p longshot-game` (`builder_link`: 43) on Linux; clippy `-D warnings` on both crates, rustfmt, `ffi-gen --check`; `tests/test_hid_imu.py`, `test_steam_pads.py`, `test_pad_motion_policy.py`, `test_builder_pads_route.py`, `test_pads_after_menu.py`, `test_gyro_rearm.py`, `test_switch_table.py`. **Still to test:** - Windows at `3afc328d` (the same code as `83dfa98b`), Steam Input on: a Steam Controller's gyro aiming with its grips and trackpad clicks pressed (no hand-over), a DualSense picked up and back (by hand; asked on the PR and in the team room) - Steam Deck OLED: its own gyro as on `main` (Test Farm: @Beanstalk steamdeck, Motion controls aiming with the built-in gyro) - Windows with `HOS_SANDBOX=1` and a DualSense under Steam Input (PlayStation controller support on): the confined game's controllers may come under Steam's Desktop Layout there (the builder is the process Steam started, the game's window is not), on `main` as here; the gyro path itself is the builder's either way (by hand) ## Measurements **Verdict:** the reader costs a pads request nothing measurable: its device work runs on its own thread. The kill switches ship on: `HOS_DECK_IMU` (as before), `HOS_STEAM_CONTROLLER_IMU`, `HOS_STEAM_CONTROLLER_IMU_ON`, `HOS_DUALSENSE_IMU`. What a pads request waits on for motion (`Background::motion`), and the reader's own poll on its thread, every 4 ms for 20 s, all three families wanted (a scratch program over `build_core::hid_imu`, release build; `hid_imu.rs` is the same at 40aa3ab1 and 77afed87). On the Steam Deck LCD its own controls were read (99% of polls with a reading) with the game running; on Windows 11 no controller was connected. `main`'s Deck reader polled on the request itself (not measured there). Times in ms: median / p99 / p99.9 / max. | | Before: main @ ca830e89 | After: this PR @ 77afed87 | |---|---|---| | Steam Controller under Steam Input (Deck, Steam Machine, Windows) | gyro through the builder's SDL | the same | | DualSense under Steam Input (Deck, Steam Machine, Windows) | no gyro | gyro aiming works | | Steam Deck's own controls | gyro | gyro, and switching with the others | | Switching between Deck, Steam Controller, DualSenses | n/a | as fast as the player swaps | | The reader's tests | Deck only, Linux only | three families, Linux and Windows | | A pads request's motion call, Steam Deck (the reader @ 40aa3ab1) | the Deck reader's poll, on the request | 0.001 / 0.002 / 0.003 / 0.099 | | The reader's own poll, Steam Deck (the reader @ 40aa3ab1) | on the request | 0.014 / 0.031 / 0.370 / 5.3, on its own thread | | A pads request's motion call, Windows 11, no controller (the reader @ 40aa3ab1) | no reader | 0.000 / 0.002 / 0.014 / 0.088 | | The reader's own poll, Windows 11 (the reader @ 40aa3ab1) | no reader | 0.001 / 0.003 / 2.26 / 2.89 (a device list every 2 s), on its own thread | ## Risks - Turning a Steam Controller's sensors on writes to a controller Steam drives. It is the one setting Steam itself sets for its gyro features, Steam sets it again with each layout, and the reader never writes it off. `HOS_STEAM_CONTROLLER_IMU_ON=0` avoids any write. - A wrong axis or scale would aim the wrong way: the axes and scales are SDL 3.4's, checked against real reports from each controller and in the game on the Deck, the Steam Machine and Windows. - The pads wire changes version: the builder and game come from one build, and a mismatch is refused whole, as before. - Revert, or the family's kill switch, brings back `main`'s behaviour. Saves, `longshot_options.ini` and the caches are untouched. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [x] `mise run test` passes (any failure that also fails on `main` is named). (`mise run test --container`, CI's image, under Docker on the Windows PC's WSL, on this PR @ 77afed87 and on `main` @ ca830e89: 870 passed, 15 failed or timed out, 13 skipped on both, the same 15 checks on both, none of them reading a file this PR changes: renderer and shader fixtures, `test_builder_files_linux`, `test_crash_record`, `test_utf8_paths`, `test_run_all_junit`, and `test_lifter`/`test_lifter_semantics` timing out on a laptop. Every check that reads this PR's files passes: `test_hid_imu`, `test_steam_pads`, `test_pad_motion_policy`, `test_builder_pads_route`, `test_pads_after_menu`, `test_gyro_rearm`, `test_switch_table`. clippy and rustfmt, which `test_lifter` runs, were run on build-core and longshot-game by hand.) - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. (Report layouts from SDL's zlib-licensed drivers, the Windows transport after PrimeRecomp's MIT approach, both written here in our own code; `game/game.h` regenerated by ffi-gen.) ### When it applies - [x] A switch added or changed: it ships at the default the measurements chose, with its row in `gpu/vk/switches.def`. - [x] A check under `tests/` that reads changed source is updated, not weakened. - [x] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. - [x] Docs updated. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. Assisted-by: Claude Opus 5.5 (Claude Code)
Started from Steam, SDL opens only Steam Input's stand-in pad, which has no
sensors, so a Steam Controller had no gyro in Longshot. The Deck's own
reader (host/deck_imu.c, #2660) already read a controller's state report
beside Steam; it becomes host/hid_imu.c, a reader of controller families:
each its USB ids, its report's parser and its kill switch.

- Steam Controller (2026): 28de:1302-1305 (cable, Bluetooth, both
  receivers); reports 0x42/0x45/0x47 at SDL 3.4's offsets and axes, its
  own sensor clock (a stalled one is no reading, as SDL). Read only:
  nothing is ever sent to it, so Steam keeps its modes and the layout.
- The stand-in pad's ids (Steam gives SDL the real controller's) say which
  family to read first: a docked Deck with a Steam Controller in hand
  reads the Steam Controller.
- Each device opened is a fresh motion filter (hid_imu_serial).
- HOS_STEAM_CONTROLLER_IMU=0 kills the new family; HOS_DECK_IMU as before.

Refs #2974

Co-Authored-By: Claude Opus 5.5 <[email protected]>
feat(input): turn a Steam Controller's sensors on when Steam's layout leaves them off
Some checks failed
PR description / Title and description (pull_request_target) Successful in 7s
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
f637332357
Under Steam Input, Steam has a Steam Controller (2026)'s IMU stream only
while its layout (or its own menus) use the gyro: in a game whose layout
has no gyro action, the reports' motion stops (its clock frozen), seen on
a Steam Machine through the receiver. After a second without motion the
reader now sends the one setting SDL's Triton driver sends for it,
SETTING_IMU_MODE = raw accel | raw gyro (feature report 1, 64 bytes), at
most every 3 s while they stay off, never while motion arrives. Nothing
else is sent (no lizard mode). The receiver answers no settings request
(EPIPE), so the old value can't be read and isn't put back; Steam sets it
again with its layout. HOS_STEAM_CONTROLLER_IMU_ON=0 keeps the reader to
reading.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Contributor

Tested in game: SteamOS on a Steam Machine (RADV NAVI33, Mesa 26.2), Steam Controller (2026) through its receiver, started from Steam with Steam Input on and a layout without gyro: the reader found the controller, turned its sensors on (Steam had them off), and gyro aiming of the slingshot, bow and hookshot works well (directions and sensitivity right); buttons and sticks still through Steam's layout.

Tested in game: SteamOS on a Steam Machine (RADV NAVI33, Mesa 26.2), Steam Controller (2026) through its receiver, started from Steam with Steam Input on and a layout without gyro: the reader found the controller, turned its sensors on (Steam had them off), and gyro aiming of the slingshot, bow and hookshot works well (directions and sensitivity right); buttons and sticks still through Steam's layout.
feat(input): the HID motion reader on Windows too, one reader over a small transport
Some checks failed
PR description / Title and description (pull_request_target) Has been cancelled
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
7a71e67dea
host/hid_imu.c no longer talks to the system: it reaches devices through
host/hid_imu_os.h's six calls (list, open, read, set and get a feature
report, close), so the device choice, probing, live/stale motion and
turning sensors on are one code everywhere, and its transport test runs
on a fake transport on Linux and Windows alike.

- host/hid_imu_linux.c: the hidraw code as it was.
- host/hid_imu_win.c: cfgmgr32's device interface list and the HID class
  driver's ioctls on an overlapped handle, not SetupDi/HidD_*, which
  Steam's overlay hooks in the games it starts to hide the controllers
  Steam Input drives (the approach of PrimeRecomp's Windows HID code, MIT;
  written here from it). cfgmgr32.dll and hid.dll are loaded at run time:
  no link flag changes.
- A Steam Controller whose sensors this reader turned on has them turned
  off again when it lets go (as Steam had them); not when it is gone.

Checked on Windows 11 with a Steam Controller (2026) on a cable under a
running Steam: Steam had its IMU off, the reader turned it on, motion at
the full rate, and off again at the end.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
feat(input): the DualSense's gyro under Steam Input, read from its HID device
Some checks failed
PR description / Title and description (pull_request_target) Successful in 7s
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
fa78d5a88b
A third family for the shared reader: Sony's DualSense (054c:0ce6) and
DualSense Edge (054c:0df2), on a cable (report 0x01, 64 bytes) or over
Bluetooth (0x31, 78 bytes, its CRC-32 checked as SDL does). Gyroscope at
15, accelerometer at 21, the sensors' clock at 27 (a third of a
microsecond); SDL's axes, and SDL's scale without the factory calibration
(1/16 degree a second, 1/8192 g; the filter learns the resting bias).
Read only: nothing is sent to it. HOS_DUALSENSE_IMU=0 kills the family.
The read buffer grows to 128 bytes for the Bluetooth report.

Checked on Windows 11: a DualSense on a cable beside a Steam Controller,
found and read by the real reader at about 215 readings a second, 1 g at
rest; the test has its real report and a CRC-checked Bluetooth copy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
fix(input): a Steam stand-in pad without its handle plays, and its controller's gyro is read
Some checks failed
PR description / Title and description (pull_request_target) Has been cancelled
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
9b64e3557b
On a Steam Deck, a Steam Controller connected while the game ran came
through SDL as "Steam Virtual Gamepad", 28de:11ff, with no Steam Input
handle: SDL had no word from Steam about it. Taken for a real Valve pad
beside a stand-in, it was made motion only, so its buttons were dropped,
and the HID reader had no idea it should read that controller, so the
Deck's own gyro stayed the source.

- steam_pads_stand_in(): a handle, or Valve's virtual pad id, is a
  stand-in; such a pad is never motion only.
- hid_imu_prefer(): a stand-in that doesn't name its controller stands
  for one that isn't the Deck's built-in controls (those always come
  named), so any other family (Steam Controller, DualSense) is read over
  the Deck's, at once; using the Deck's controls again goes back at once.
- One log line when the pad in use changes: which controller it stands
  for, and what the reader takes first.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
chore(input): log which Steam Input pad is the one used last, for the motion reader's choice
Some checks failed
PR description / Title and description (pull_request_target) Successful in 8s
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
684d8f40c3
Co-Authored-By: Claude Opus 5.5 <[email protected]>
perf(input): hand motion between controllers faster
Some checks failed
PR description / Title and description (pull_request_target) Successful in 7s
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
c9ec61da0c
Seen on a Steam Deck switching between its own controls, a Steam
Controller and a DualSense: each switch worked but took a moment.

- A Steam Controller opened with its sensors off (its clock frozen) has
  them turned on after 150 ms, not a second.
- They stay on while another controller is read, so coming back to it
  needs no second wait; the end (hid_imu_stop: the run's end, Motion off,
  a pad's own sensors) turns off every Steam Controller the reader turned
  on, opening again one it doesn't read then. A gone one is forgotten.
- The motion filter keeps what it learned of a gyroscope's resting bias
  by controller family, as pads keep theirs: no new setting down after a
  switch back.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
fix(input): read the gyro of the controller whose own buttons moved last
Some checks failed
PR description / Title and description (pull_request_target) Successful in 7s
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
6591b185da
On a Steam Deck with its own controls, a Steam Controller and a DualSense
under Steam Input, SDL's ids for Steam's stand-in pads drifted out of
step with the pads after controllers reconnected (the pad named
"DualSense Wireless Controller" reported the Steam Controller's
28de:1302), so the player held the DualSense and the Steam Controller's
motion was read. A fresh boot had them right; a reconnect, as players do
(sleep, battery, Bluetooth range), did not.

The reader now keeps up to 4 controllers open, drains them all each poll,
and reads the one whose own buttons or sticks changed last, from its own
state report (an input signature per family: buttons, and each stick axis
past 40%; a first report is its rest, not a press). The stand-in pad's ids
only decide before any controller has moved. Switching is immediate; the
30 s let-go rule is gone. Sensors are turned on only on the controller
read; at the end every Steam Controller the reader turned on is turned
off, once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
sandymac changed title from WIP: feat(input): Steam Controller (2026) gyro under Steam Input to WIP: feat(input): controller gyro under Steam Input (Steam Controller, DualSense, Deck; Linux and Windows) 2026-12-03 03:44:39 +00:00
Author
Contributor

Grew from Linux + Steam Controller to one shared reader over a small transport (Linux and Windows), with the DualSense as a third family. The controller read is now the one whose own buttons or sticks moved last (Steam's stand-in pad ids drift after reconnects). Tested in the game on a Steam Deck with its own controls, a Steam Controller and a DualSense, switching between all three; Windows tested outside the game so far.

Grew from Linux + Steam Controller to one shared reader over a small transport (Linux and Windows), with the DualSense as a third family. The controller read is now the one whose own buttons or sticks moved last (Steam's stand-in pad ids drift after reconnects). Tested in the game on a Steam Deck with its own controls, a Steam Controller and a DualSense, switching between all three; Windows tested outside the game so far.
fix(input): the HID reader beside a pad SDL reads the gyro of, by recency of input
Some checks failed
PR description / Title and description (pull_request_target) Successful in 7s
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
dd297c599e
On Windows, SDL opened a Bluetooth Steam Controller itself (its gyro its
own) beside Steam's stand-in pads, and an open pad with sensors switched
the HID reader off: a DualSense picked up then had no motion of its own,
the Steam Controller's was read.

The reader now runs whenever Motion controls is on, and its controller is
read over SDL's pad when its own buttons or sticks moved after the pad was
last used (hid_imu_over_pad, a tie stays with the pad; hid_imu_input_ns()
gives the reader's side). Released only when Motion controls goes off.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
fix(input): one controller read by both SDL and the HID reader stays SDL's
Some checks failed
PR description / Title and description (pull_request_target) Successful in 7s
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
9669237ddf
On Windows, SDL has a Bluetooth Steam Controller open with its gyro, and
the HID reader watches the same controller: a press on it updated both
sides, and the source took turns between them, each turn a fresh motion
filter. When the reader's controller is the same kind as the pad SDL reads
the sensors of, SDL's pad is read (hid_imu_over_pad's same).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Contributor

Tested in the game on Windows 11: Steam Controller and DualSense over Bluetooth under Steam Input, both aim, switching between them works, the DualSense survives reconnects. Two fixes on the way (dd297c59, 9669237d): the reader runs beside a pad SDL reads the gyro of (Windows' SDL opens a Bluetooth Steam Controller itself), chosen by recency of input, and one controller read by both stays SDL's.

Tested in the game on Windows 11: Steam Controller and DualSense over Bluetooth under Steam Input, both aim, switching between them works, the DualSense survives reconnects. Two fixes on the way (dd297c59, 9669237d): the reader runs beside a pad SDL reads the gyro of (Windows' SDL opens a Bluetooth Steam Controller itself), chosen by recency of input, and one controller read by both stays SDL's.
Author
Contributor

Rechecked on the Steam Deck LCD with 9669237d: its own controls, a Steam Controller and a DualSense (both Bluetooth), motion with each and switching between all three as before.

Rechecked on the Steam Deck LCD with 9669237d: its own controls, a Steam Controller and a DualSense (both Bluetooth), motion with each and switching between all three as before.
Author
Contributor

Full suite in CI's container (mise run test --container) on this branch and on main: the same 123 checks fail or time out on both, none from this PR; every check reading its files passes.

Full suite in CI's container (mise run test --container) on this branch and on main: the same 123 checks fail or time out on both, none from this PR; every check reading its files passes.
Author
Contributor

Heads-up: #2822 moved controller reading into the builder (the game is sandboxed and opens no hidraw), so this PR's C reader in host/ no longer fits. I'm porting it onto build_core: the Deck reader in build_core::deck_imu generalized to the Steam Controller (2026) and DualSense, a Windows backend for its Hid trait, and the pads request and snapshot trailer extended for the families wanted and the one read. The game-side choice in pad_sdl.c stays. It stays WIP until the port is retested on a Steam Machine, a Steam Deck and Windows.

Heads-up: #2822 moved controller reading into the builder (the game is sandboxed and opens no hidraw), so this PR's C reader in host/ no longer fits. I'm porting it onto build_core: the Deck reader in build_core::deck_imu generalized to the Steam Controller (2026) and DualSense, a Windows backend for its Hid trait, and the pads request and snapshot trailer extended for the families wanted and the one read. The game-side choice in pad_sdl.c stays. It stays WIP until the port is retested on a Steam Machine, a Steam Deck and Windows.
sandymac force-pushed feat/steam-controller-gyro from 9669237ddf
Some checks failed
PR description / Title and description (pull_request_target) Successful in 7s
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
to a6b24b7148
Some checks failed
PR description / Title and description (pull_request_target) Has been cancelled
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
2026-12-04 01:58:13 +00:00
Compare
Author
Contributor

Ported onto the builder-side pads of #2822 and rebased onto main @ 7c3c16f0 (head a6b24b71): the C reader in host/ is gone; build_core::deck_imu became build_core::hid_imu (Deck, Steam Controller 2026, DualSense; Linux hidraw and a Windows cfgmgr32/ioctl transport), the pads wire goes to version 3 (families wanted, options, the stand-in hint; a 40-byte trailer with the family, a serial and the input's age), and pad_sdl.c keeps its choice between SDL's gyro and the reader's. Retested in game on a Steam Deck LCD, a Steam Machine and Windows 11 with all three controllers, and the full container suite matches main's (the same 20 failures on both). Description rewritten for the new design.

Ported onto the builder-side pads of #2822 and rebased onto main @ 7c3c16f0 (head a6b24b71): the C reader in host/ is gone; build_core::deck_imu became build_core::hid_imu (Deck, Steam Controller 2026, DualSense; Linux hidraw and a Windows cfgmgr32/ioctl transport), the pads wire goes to version 3 (families wanted, options, the stand-in hint; a 40-byte trailer with the family, a serial and the input's age), and pad_sdl.c keeps its choice between SDL's gyro and the reader's. Retested in game on a Steam Deck LCD, a Steam Machine and Windows 11 with all three controllers, and the full container suite matches main's (the same 20 failures on both). Description rewritten for the new design.
sandymac changed title from WIP: feat(input): controller gyro under Steam Input (Steam Controller, DualSense, Deck; Linux and Windows) to feat(input): controller gyro under Steam Input (Steam Controller, DualSense, Deck; Linux and Windows) 2026-12-04 02:44:45 +00:00
Member
@review
BeanBot requested changes 2026-12-04 02:47:13 +00:00
Dismissed
BeanBot left a comment

Recommendation: Request changes. The new reader can select the wrong controller, reuse another controller’s gyro bias, and stall the shared pad poll while waiting for a device. Its cleanup can also turn off sensors that Steam has since started using.

The change adds gyro support behind Steam Input for DualSense and Steam Controller devices and preserves the Deck reader. The reported game runs show the feature working, but controller identity, device ownership and input latency need correction.

Blocking (2): must change before merging.

  1. L3 builder/crates/build-core/src/hid_imu.rs:1158: A feature report waits on the pads request thread, delaying the entire input snapshot when a controller does not answer promptly. (more on the line) Do: Move feature-report operations off the pads request path and publish their results asynchronously, keeping the request and cancellation buffers alive until completion.
  2. L4 builder/crates/build-core/src/hid_imu.rs:695: Cleanup unconditionally disables a Steam Controller after this reader has enabled it, even if Steam subsequently began using its gyro. (more on the line) Do: Coordinate ownership with Steam or avoid writing a destructive off value when the current owner cannot be determined; add a test for Steam taking over before cleanup.

Should fix (2): not blocking, but worth doing before merging.

  • L1 host/pad_sdl.c:352: Matching only the family treats two different controllers as the same device and prevents the newer HID controller from taking over. (more on the line) Do: Match actual device identity across SDL and HID, or use a selection scheme that distinguishes two controllers of the same family; cover that case with a behavioral test.
  • L2 host/pad_sdl.c:409: The saved gyro bias is keyed by family rather than controller, so switching between devices applies one device's calibration to another. (more on the line) Do: Keep bias by stable controller identity, or start with an unlearned bias when the actual device changes.

Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)

  • L5: The remaining direct SDL and Deck OLED motion paths need the in-game runs already identified in the description. When: The reader now runs beside SDL-owned sensors, and the Deck reader's selection and lifetime changed; the reported runs do not cover a directly opened DualSense or the OLED built-in controls. Do: Run gyro aiming and controller switching with Steam Input off on Windows and Linux, and test the OLED built-in gyro in game.
  • L6: The added work on the pads polling path has no measured input or frame-time cost. When: With Motion enabled, the builder scans HID devices and drains up to four devices while answering pad requests; the description provides no comparison of polling latency or frame times against main. Do: Measure pad response latency and frame-time distributions against main with Motion on and off, including multiple connected controllers, on Windows and SteamOS. (@fix does its part first: Move device discovery and feature operations off the request path and bound the work performed per poll.)

@fix can do L1, L2, L3, L4 and L6.

Checks: Still running: 11 checks.

More: does it help, other systems, switches, what was read

Does it help: Yes: the author reports DualSense gyro aiming working under Steam Input on SteamOS and Windows, where main had no gyro. The runs do not quantify the added polling cost or input latency.

Other systems: The reader also runs alongside SDL-owned controllers and affects the shared pads snapshot on Windows and Linux. Direct SDL motion, Deck OLED, Windows sandbox mode and polling latency remain unverified in the reported runs.

Switches: HOS_DECK_IMU remains on but now runs beside SDL motion pads. HOS_STEAM_CONTROLLER_IMU, HOS_STEAM_CONTROLLER_IMU_ON and HOS_DUALSENSE_IMU are added on by default, with switch-table entries. The defaults enable the tested feature, but the sensor-write and polling issues need fixing.

Reviewed: a6b24b7148 against 7c3c16f0a7: Read the repository rules, PR template, standards, commit and diff, HID reader and host selection paths; inspected the pads wire changes, tests, documentation and generated header. The large test and pads files were skimmed in part. docs/review-checklist.md and the adjacent Tooling checkout were unavailable.; nothing run (a code review).

Checked and fine:

  • The pads request and snapshot versions and lengths change together, and the client validates the new trailer.
  • The commit records AI assistance, and the new switches have table entries.
  • The reported runs include SteamOS and Windows in-game testing of the principal Steam Input cases.

Testing: Read-only review; no project code, tests or builds were run. CI was still running in the supplied status.

Overlaps and merge order: Not checked; network access was unavailable.


Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** The new reader can select the wrong controller, reuse another controller’s gyro bias, and stall the shared pad poll while waiting for a device. Its cleanup can also turn off sensors that Steam has since started using. The change adds gyro support behind Steam Input for DualSense and Steam Controller devices and preserves the Deck reader. The reported game runs show the feature working, but controller identity, device ownership and input latency need correction. **Blocking (2)**: must change before merging. 1. **L3** `builder/crates/build-core/src/hid_imu.rs:1158`: A feature report waits on the pads request thread, delaying the entire input snapshot when a controller does not answer promptly. (more on the line) **Do:** Move feature-report operations off the pads request path and publish their results asynchronously, keeping the request and cancellation buffers alive until completion. 2. **L4** `builder/crates/build-core/src/hid_imu.rs:695`: Cleanup unconditionally disables a Steam Controller after this reader has enabled it, even if Steam subsequently began using its gyro. (more on the line) **Do:** Coordinate ownership with Steam or avoid writing a destructive off value when the current owner cannot be determined; add a test for Steam taking over before cleanup. **Should fix (2)**: not blocking, but worth doing before merging. - **L1** `host/pad_sdl.c:352`: Matching only the family treats two different controllers as the same device and prevents the newer HID controller from taking over. (more on the line) **Do:** Match actual device identity across SDL and HID, or use a selection scheme that distinguishes two controllers of the same family; cover that case with a behavioral test. - **L2** `host/pad_sdl.c:409`: The saved gyro bias is keyed by family rather than controller, so switching between devices applies one device's calibration to another. (more on the line) **Do:** Keep bias by stable controller identity, or start with an unlearned bias when the actual device changes. **Testing before merging (2)** (runs on the systems it can change; it doesn't hold the recommendation) - **L5**: The remaining direct SDL and Deck OLED motion paths need the in-game runs already identified in the description. *When:* The reader now runs beside SDL-owned sensors, and the Deck reader's selection and lifetime changed; the reported runs do not cover a directly opened DualSense or the OLED built-in controls. **Do:** Run gyro aiming and controller switching with Steam Input off on Windows and Linux, and test the OLED built-in gyro in game. - **L6**: The added work on the pads polling path has no measured input or frame-time cost. *When:* With Motion enabled, the builder scans HID devices and drains up to four devices while answering pad requests; the description provides no comparison of polling latency or frame times against main. **Do:** Measure pad response latency and frame-time distributions against main with Motion on and off, including multiple connected controllers, on Windows and SteamOS. *(`@fix` does its part first: Move device discovery and feature operations off the request path and bound the work performed per poll.)* `@fix` can do L1, L2, L3, L4 and L6. **Checks:** Still running: 11 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes: the author reports DualSense gyro aiming working under Steam Input on SteamOS and Windows, where main had no gyro. The runs do not quantify the added polling cost or input latency. **Other systems:** The reader also runs alongside SDL-owned controllers and affects the shared pads snapshot on Windows and Linux. Direct SDL motion, Deck OLED, Windows sandbox mode and polling latency remain unverified in the reported runs. **Switches:** HOS_DECK_IMU remains on but now runs beside SDL motion pads. HOS_STEAM_CONTROLLER_IMU, HOS_STEAM_CONTROLLER_IMU_ON and HOS_DUALSENSE_IMU are added on by default, with switch-table entries. The defaults enable the tested feature, but the sensor-write and polling issues need fixing. **Reviewed:** a6b24b7148f2 against 7c3c16f0a709: Read the repository rules, PR template, standards, commit and diff, HID reader and host selection paths; inspected the pads wire changes, tests, documentation and generated header. The large test and pads files were skimmed in part. docs/review-checklist.md and the adjacent Tooling checkout were unavailable.; nothing run (a code review). **Checked and fine:** - The pads request and snapshot versions and lengths change together, and the client validates the new trailer. - The commit records AI assistance, and the new switches have table entries. - The reported runs include SteamOS and Windows in-game testing of the principal Steam Input cases. **Testing:** Read-only review; no project code, tests or builds were run. CI was still running in the supplied status. **Overlaps and merge order:** Not checked; network access was unavailable. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.</sub>
@ -0,0 +692,4 @@
&& read_setting(&self.hid, &mut w.dev) == Some(set)
{
send_setting(&self.hid, &mut w.dev, ID_SET_SETTINGS_VALUES, saved);
}
Member

L4 (blocking): Cleanup unconditionally disables a Steam Controller after this reader has enabled it, even if Steam subsequently began using its gyro.

When: Start with a layout that leaves the gyro off, so the reader enables it; then switch to a Steam layout that uses gyro and turn Longshot Motion off or exit. The cleanup sends mode zero and interrupts Steam's now-active gyro stream.

Do: Coordinate ownership with Steam or avoid writing a destructive off value when the current owner cannot be determined; add a test for Steam taking over before cleanup.

**L4** (blocking): Cleanup unconditionally disables a Steam Controller after this reader has enabled it, even if Steam subsequently began using its gyro. *When:* Start with a layout that leaves the gyro off, so the reader enables it; then switch to a Steam layout that uses gyro and turn Longshot Motion off or exit. The cleanup sends mode zero and interrupts Steam's now-active gyro stream. **Do:** Coordinate ownership with Steam or avoid writing a destructive off value when the current owner cannot be determined; add a test for Steam taking over before cleanup.
@ -0,0 +1155,4 @@
if GetLastError() != ERROR_IO_PENDING {
return None;
}
if WaitForSingleObject(ov.hEvent, FEATURE_MS) != WAIT_OBJECT_0 {
Member

L3 (blocking): A feature report waits on the pads request thread, delaying the entire input snapshot when a controller does not answer promptly.

When: On Windows, a Steam Controller with stalled sensor reports causes triton_enable to issue this request; an unanswered feature request waits 50 ms before cancellation, and retries occur every three seconds. During each wait the shared pad snapshot, including buttons and sticks, cannot be returned.

Do: Move feature-report operations off the pads request path and publish their results asynchronously, keeping the request and cancellation buffers alive until completion.

**L3** (blocking): A feature report waits on the pads request thread, delaying the entire input snapshot when a controller does not answer promptly. *When:* On Windows, a Steam Controller with stalled sensor reports causes triton_enable to issue this request; an unanswered feature request waits 50 ms before cancellation, and retries occur every three seconds. During each wait the shared pad snapshot, including buttons and sticks, cannot be returned. **Do:** Move feature-report operations off the pads request path and publish their results asynchronously, keeping the request and cancellation buffers alive until completion.
host/pad_sdl.c Outdated
@ -296,0 +349,4 @@
int64_t hid_input_ns = 0;
const int hid_ok = hid_poll(want, prefer, now, hid_a, hid_g, &hid_family, &hid_serial, &hid_input_ns);
/* (the reader's controller over SDL's pad only when its own input is the newer: host/hid_imu.h) */
const int hid_same = pick >= 0 && hid_family >= 0 &&
Member

L1 (should fix): Matching only the family treats two different controllers as the same device and prevents the newer HID controller from taking over.

When: With one Steam Controller opened by SDL and a second Steam Controller read through HID, moving the second makes it the reader's choice, but both have the Triton family. hid_same remains true and the game continues aiming with the first controller.

Do: Match actual device identity across SDL and HID, or use a selection scheme that distinguishes two controllers of the same family; cover that case with a behavioral test.

**L1** (should fix): Matching only the family treats two different controllers as the same device and prevents the newer HID controller from taking over. *When:* With one Steam Controller opened by SDL and a second Steam Controller read through HID, moving the second makes it the reader's choice, but both have the Triton family. hid_same remains true and the game continues aiming with the first controller. **Do:** Match actual device identity across SDL and HID, or use a selection scheme that distinguishes two controllers of the same family; cover that case with a behavioral test.
host/pad_sdl.c Outdated
@ -346,2 +406,4 @@
if (src >= 0 && pads[src].has_bias)
memcpy(motion.bias, pads[src].bias, sizeof motion.bias), motion.learned_t = pads[src].bias_t;
motion_hid_family = src == MOTION_SRC_HID ? hid_family : -1;
if (motion_hid_family >= 0 && motion_hid_family < HID_IMU_FAMILIES && motion_hid_has_bias[motion_hid_family])
Member

L2 (should fix): The saved gyro bias is keyed by family rather than controller, so switching between devices applies one device's calibration to another.

When: After a DualSense has learned its resting bias, switching to a second DualSense restores the first controller's bias even though the reader supplies a new serial. A different sensor offset then produces aim drift until the filter relearns it.

Do: Keep bias by stable controller identity, or start with an unlearned bias when the actual device changes.

**L2** (should fix): The saved gyro bias is keyed by family rather than controller, so switching between devices applies one device's calibration to another. *When:* After a DualSense has learned its resting bias, switching to a second DualSense restores the first controller's bias even though the reader supplies a new serial. A different sensor offset then produces aim drift until the filter relearns it. **Do:** Keep bias by stable controller identity, or start with an unlearned bias when the actual device changes.
sandymac force-pushed feat/steam-controller-gyro from a6b24b7148
Some checks failed
PR description / Title and description (pull_request_target) Has been cancelled
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
to 77afed87bd
Some checks failed
PR description / Title and description (pull_request_target) Successful in 6s
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
2026-12-04 04:23:17 +00:00
Compare
Author
Contributor

Thanks for the review. Pushed 77afed87 (rebased onto main @ ca830e89, squashed to one commit). Per finding:

L3 (blocking), a feature report on the pads request: fixed. The reader runs on a thread of its own
(hid_imu::Background, started at the first request that wants motion, alive for the builder's life). A pads request
stores what the game wants and copies the newest reading; the input's age is worked out from the absolute time the
reader saw it, at the reply. Device listing, probing, the Deck's settings and the Steam Controller's IMU-on all happen
on that thread. Test: a_slow_device_never_holds_a_request_back (a fake Deck whose feature reports take 200 ms each:
every request returns under 100 ms, the reading still arrives, the end puts the setting back). The session's end waits
up to 500 ms for the reader to stop, so a Deck's setting goes back before the builder may exit.

L4 (blocking), the off-write at cleanup: fixed by never writing it. The receiver answers no settings request
(EPIPE), so who owns the IMU mode later can't be told; the reader now never writes a Steam Controller's IMU off, at the
end or when its family stops being wanted. Steam sets that setting with each layout it applies. Test:
a_steam_controller_steam_took_over_is_not_turned_off. The Deck is unchanged: its setting is read first and put back
only where the builder still owns it.

L1 (should fix), the same family as SDL's pad: kept, with the reason in the code and a test. I tried the time-based
rule (the reader's controller of the pad's own kind wins when its input is newer than the pad's last use by more than
250 ms). On Windows with one Steam Controller, the log showed motion handed back and forth between SDL's pad and the
reader: the reader's signature counts the grips and trackpad clicks, SDL's pad doesn't, so a grip press read as another
controller picked up, and the next face button handed it back. The case it was for doesn't come up: the builder's SDL
opens every Valve pad beside Steam's stand-ins (steam_pads_without_valve), so a second Steam Controller is an SDL pad
too, and SDL's own last use picks between them. The DualSense, which SDL doesn't open under Steam Input, has no SDL pad
to compete with. hid_imu_over_pad's comment says this, and tests/test_hid_imu.py pins it (a grip pressed 2 s later
stays SDL's). Tested in game with one Steam Controller and two DualSenses on Windows, and grips and trackpad clicks
while aiming on the Deck and Windows: no hand-over.

L2 (should fix), the bias by family: fixed. The trailer carries the physical device's stable id (FNV-1a of its
path, never 0); pad_sdl.c keeps the learned bias by device id (8 entries, the oldest replaced), and an unknown device
starts unlearned. The serial still decides a fresh filter.

L5 (testing): run. Steam Input off for the game on the Steam Deck and the Steam Machine, and PlayStation controller
support off on Windows: the DualSense's gyro through SDL as on main, switching with the Steam Controller. The Deck
OLED stays with the Test Farm (Still to test).

L6 (measure): measured. A request's wait for motion and the reader's own poll, every 4 ms for 20 s (Measurements):
on the Deck with its controls read and the game running, the request's median 0.001 ms, p99.9 0.003 ms, max 0.099 ms;
the reader's thread median 0.014 ms, max 5.3 ms, none of it on the request. On Windows (no controller connected) the
request's max is 0.088 ms; the 2 ms device list every 2 s is on the reader's thread. No frame-time comparison: the
request path no longer touches a device, so there is nothing for frame pacing to see.

Thanks for the review. Pushed `77afed87` (rebased onto `main` @ ca830e89, squashed to one commit). Per finding: **L3 (blocking), a feature report on the pads request: fixed.** The reader runs on a thread of its own (`hid_imu::Background`, started at the first request that wants motion, alive for the builder's life). A pads request stores what the game wants and copies the newest reading; the input's age is worked out from the absolute time the reader saw it, at the reply. Device listing, probing, the Deck's settings and the Steam Controller's IMU-on all happen on that thread. Test: `a_slow_device_never_holds_a_request_back` (a fake Deck whose feature reports take 200 ms each: every request returns under 100 ms, the reading still arrives, the end puts the setting back). The session's end waits up to 500 ms for the reader to stop, so a Deck's setting goes back before the builder may exit. **L4 (blocking), the off-write at cleanup: fixed by never writing it.** The receiver answers no settings request (`EPIPE`), so who owns the IMU mode later can't be told; the reader now never writes a Steam Controller's IMU off, at the end or when its family stops being wanted. Steam sets that setting with each layout it applies. Test: `a_steam_controller_steam_took_over_is_not_turned_off`. The Deck is unchanged: its setting is read first and put back only where the builder still owns it. **L1 (should fix), the same family as SDL's pad: kept, with the reason in the code and a test.** I tried the time-based rule (the reader's controller of the pad's own kind wins when its input is newer than the pad's last use by more than 250 ms). On Windows with one Steam Controller, the log showed motion handed back and forth between SDL's pad and the reader: the reader's signature counts the grips and trackpad clicks, SDL's pad doesn't, so a grip press read as another controller picked up, and the next face button handed it back. The case it was for doesn't come up: the builder's SDL opens every Valve pad beside Steam's stand-ins (`steam_pads_without_valve`), so a second Steam Controller is an SDL pad too, and SDL's own last use picks between them. The DualSense, which SDL doesn't open under Steam Input, has no SDL pad to compete with. `hid_imu_over_pad`'s comment says this, and `tests/test_hid_imu.py` pins it (a grip pressed 2 s later stays SDL's). Tested in game with one Steam Controller and two DualSenses on Windows, and grips and trackpad clicks while aiming on the Deck and Windows: no hand-over. **L2 (should fix), the bias by family: fixed.** The trailer carries the physical device's stable id (FNV-1a of its path, never 0); `pad_sdl.c` keeps the learned bias by device id (8 entries, the oldest replaced), and an unknown device starts unlearned. The serial still decides a fresh filter. **L5 (testing): run.** Steam Input off for the game on the Steam Deck and the Steam Machine, and PlayStation controller support off on Windows: the DualSense's gyro through SDL as on `main`, switching with the Steam Controller. The Deck OLED stays with the Test Farm (Still to test). **L6 (measure): measured.** A request's wait for motion and the reader's own poll, every 4 ms for 20 s (Measurements): on the Deck with its controls read and the game running, the request's median 0.001 ms, p99.9 0.003 ms, max 0.099 ms; the reader's thread median 0.014 ms, max 5.3 ms, none of it on the request. On Windows (no controller connected) the request's max is 0.088 ms; the 2 ms device list every 2 s is on the reader's thread. No frame-time comparison: the request path no longer touches a device, so there is nothing for frame pacing to see.
First-time contributor

Thanks for this, reading the real controller next to Steam Input is exactly what was missing for the gyro.

Would you consider carrying haptics over the same path, in this PR or a follow-up?

With Steam Input on, the game's rumble goes to Steam's stand-in pad, so a Steam Controller (2026) only gets what Steam makes of it. Its grips can play HD haptics (Longshot already does this through RenHDrum), but only by writing to the real device, which is the same device your reader already finds and opens on Linux (hidraw) and Windows (cfgmgr32 + HID ioctls, avoiding the SetupDi/HidD calls Steam's overlay hooks).

What I have in mind:

  • Share the reader's device (or its path) with the haptics output, so RenHDrum's grip stream reaches the same Steam Controller the gyro comes from, with Steam Input on, on both platforms.
  • Keep the writes off the pads request thread, for the same reason as L3: an output report that stalls must not delay buttons and sticks.
  • On cleanup, only turn off the grip output if we turned it on, the same concern as L4 for the sensors.
  • A kill switch like the IMU ones (e.g. HOS_STEAM_CONTROLLER_HAPTICS).

If it's out of scope here, a note on where the device handle could be exposed would already help someone pick it up. Happy to test on a Steam Controller (2026) over cable and the puck on Windows and Linux

Thanks for this, reading the real controller next to Steam Input is exactly what was missing for the gyro. Would you consider carrying haptics over the same path, in this PR or a follow-up? With Steam Input on, the game's rumble goes to Steam's stand-in pad, so a Steam Controller (2026) only gets what Steam makes of it. Its grips can play HD haptics (Longshot already does this through RenHDrum), but only by writing to the real device, which is the same device your reader already finds and opens on Linux (hidraw) and Windows (cfgmgr32 + HID ioctls, avoiding the SetupDi/HidD calls Steam's overlay hooks). What I have in mind: - Share the reader's device (or its path) with the haptics output, so RenHDrum's grip stream reaches the same Steam Controller the gyro comes from, with Steam Input on, on both platforms. - Keep the writes off the pads request thread, for the same reason as L3: an output report that stalls must not delay buttons and sticks. - On cleanup, only turn off the grip output if we turned it on, the same concern as L4 for the sensors. - A kill switch like the IMU ones (e.g. `HOS_STEAM_CONTROLLER_HAPTICS`). If it's out of scope here, a note on where the device handle could be exposed would already help someone pick it up. Happy to test on a Steam Controller (2026) over cable and the puck on Windows and Linux
First-time contributor

One more thing if haptics ever go through this path: Steam's rumble intensity setting only applies to what goes through its stand-in pad. Anything written straight to the controller (RenHDrum's grip stream, for one) ignores it, so the grips stay at full strength even when the player turned vibration down in Steam.

Steam keeps that setting in plain text files, so it can be followed without touching Steam:

  • General, per controller: <Steam>/steamapps/common/Steam Controller Configs/<account id>/config/preferences_<serial>.vdf, key "rumble_intensity" inside "ControllerPersonalization".
  • Per game (wins when set): <Steam>/userdata/<account id>/config/localconfig.vdf, key "SteamControllerRumbleIntensityV2" under "UserLocalConfigStore" > "apps" > "<app id>". Missing or 0 means the game follows the general setting.

Values (smaller is stronger): very high 60, high 100, medium-high 200, medium 0 (default; 320 when set in a game's own settings), medium-low 1000, low 8000, very low 16000.

Finding the Steam folder:

  • Windows: HKCU\Software\Valve\Steam SteamPath; the account is HKCU\Software\Valve\Steam\ActiveProcess ActiveUser.
  • Linux native: ~/.local/share/Steam (or ~/.steam/steam).
  • Under Proton the registry points at Proton's own Steam folder; the real one is in STEAM_COMPAT_CLIENT_INSTALL_PATH. When no account is named, the one whose localconfig.vdf changed last works.

Re-reading the files every couple of seconds (only when their write time changes) lets the player change it with the game open. I'm doing exactly this in a small DLL for another game and it behaves well on Windows; the Proton path is new.

One more thing if haptics ever go through this path: Steam's rumble intensity setting only applies to what goes through its stand-in pad. Anything written straight to the controller (RenHDrum's grip stream, for one) ignores it, so the grips stay at full strength even when the player turned vibration down in Steam. Steam keeps that setting in plain text files, so it can be followed without touching Steam: - General, per controller: `<Steam>/steamapps/common/Steam Controller Configs/<account id>/config/preferences_<serial>.vdf`, key `"rumble_intensity"` inside `"ControllerPersonalization"`. - Per game (wins when set): `<Steam>/userdata/<account id>/config/localconfig.vdf`, key `"SteamControllerRumbleIntensityV2"` under `"UserLocalConfigStore" > "apps" > "<app id>"`. Missing or 0 means the game follows the general setting. Values (smaller is stronger): very high 60, high 100, medium-high 200, medium 0 (default; 320 when set in a game's own settings), medium-low 1000, low 8000, very low 16000. Finding the Steam folder: - Windows: `HKCU\Software\Valve\Steam` `SteamPath`; the account is `HKCU\Software\Valve\Steam\ActiveProcess` `ActiveUser`. - Linux native: `~/.local/share/Steam` (or `~/.steam/steam`). - Under Proton the registry points at Proton's own Steam folder; the real one is in `STEAM_COMPAT_CLIENT_INSTALL_PATH`. When no account is named, the one whose `localconfig.vdf` changed last works. Re-reading the files every couple of seconds (only when their write time changes) lets the player change it with the game open. I'm doing exactly this in a small DLL for another game and it behaves well on Windows; the Proton path is new.
Author
Contributor

@iafx Thanks for the detailed write-up, and for the notes on Steam's rumble strength setting.

Haptics would widen this PR beyond reading motion. It has already been reworked heavily several times to keep up with how fast main moves, so I'd like to get it merged as it is before working on the next improvements.

Could you open an issue with the idea, both the grip haptics and following Steam's rumble strength? Please mention me (@sandymac) in it, so I can track it more easily later. The device discovery a haptics path would share is in build_core::hid_imu (builder/crates/build-core/src/hid_imu.rs): the Hid trait with its Linux (hidraw) and Windows (cfgmgr32 plus HID ioctls) implementations, and the reader's own thread, Background.

@iafx Thanks for the detailed write-up, and for the notes on Steam's rumble strength setting. Haptics would widen this PR beyond reading motion. It has already been reworked heavily several times to keep up with how fast `main` moves, so I'd like to get it merged as it is before working on the next improvements. Could you open an issue with the idea, both the grip haptics and following Steam's rumble strength? Please mention me (@sandymac) in it, so I can track it more easily later. The device discovery a haptics path would share is in `build_core::hid_imu` (`builder/crates/build-core/src/hid_imu.rs`): the `Hid` trait with its Linux (hidraw) and Windows (cfgmgr32 plus HID ioctls) implementations, and the reader's own thread, `Background`.
sandymac force-pushed feat/steam-controller-gyro from 77afed87bd
Some checks failed
PR description / Title and description (pull_request_target) Successful in 6s
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
to 4444ceddba
Some checks failed
beanstalk/approval waiting for a BigBean's 👍 on the request
PR description / Title and description (pull_request_target) Successful in 6s
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
2026-12-04 22:57:47 +00:00
Compare
Author
Contributor

Rebased onto main @ 67fda193 as 4444cedd; it no longer merged. One conflict, in gpu/vk/switches.def: main's new HOS_STEP_SHOWN line sits beside this PR's HOS_STEAM_CONTROLLER_IMU* lines, and all three are kept in order. The PR's own diff is otherwise unchanged (18 files, +3672 −884).

Run again on Linux:

  • passed: rustfmt, ffi-gen --check, schema-gen --check, clippy -D warnings --no-deps on build-core and longshot-game, cargo test -p build-core -p longshot-game, and the pad checks (test_hid_imu, test_steam_pads, test_builder_pads_route, test_pads_after_menu, test_switch_table, test_switches_removed);
  • failing on main too: clippy with dependencies, in host-sys's settings_abi.rs and in build-assets.

Ready for a re-review.

Rebased onto `main` @ 67fda193 as `4444cedd`; it no longer merged. One conflict, in `gpu/vk/switches.def`: main's new `HOS_STEP_SHOWN` line sits beside this PR's `HOS_STEAM_CONTROLLER_IMU*` lines, and all three are kept in order. The PR's own diff is otherwise unchanged (18 files, +3672 −884). Run again on Linux: - passed: rustfmt, `ffi-gen --check`, `schema-gen --check`, clippy `-D warnings --no-deps` on `build-core` and `longshot-game`, `cargo test -p build-core -p longshot-game`, and the pad checks (`test_hid_imu`, `test_steam_pads`, `test_builder_pads_route`, `test_pads_after_menu`, `test_switch_table`, `test_switches_removed`); - failing on `main` too: clippy with dependencies, in `host-sys`'s `settings_abi.rs` and in `build-assets`. Ready for a re-review.
Author
Contributor

@Beanstalk steamdeck: Motion controls on, aim the slingshot with the Steam Deck OLED's built-in gyro; it should follow the Deck's tilt as on main.

@Beanstalk steamdeck: Motion controls on, aim the slingshot with the Steam Deck OLED's built-in gyro; it should follow the Deck's tilt as on main.
Member

@sandymac only members of BigBeans can start the farm.

One of them can approve this request by reacting 👍 to it or to this comment. This request was for 4444ced, and the PR has changed since (83dfa98), so a 👍 no longer approves it. Comment @Beanstalk again to ask for the new commit.

@sandymac only members of `BigBeans` can start the farm. ~~One of them can approve this request by reacting 👍 to it or to this comment.~~ This request was for `4444ced`, and the PR has changed since (`83dfa98`), so a 👍 no longer approves it. Comment `@Beanstalk` again to ask for the new commit.
Member
@review
BeanBot left a comment

Recommendation: Approve. The feature works in the reported Steam Input tests, but controller identity still has gaps: same-family HID controllers cannot take over from an SDL pad, and Linux can reuse a device node for a different controller’s saved bias. The Deck OLED run and CI are also outstanding. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.

Adds gyro input behind Steam Input for Steam Controller and DualSense devices on Linux and Windows, while moving HID work to a background thread. It improves controller support at the cost of additional device-selection and calibration state.

Should fix (2): not blocking, but worth doing before merging.

  • L1 host/pad_sdl.c:352: Matching only the family treats two different controllers as the same device and prevents the newer HID controller from taking over. When: With one Steam Controller opened by SDL and a second Steam Controller read through HID, moving the second makes it the reader's choice, but both have the Triton family. hid_same remains true and the game continues aiming with the first controller. Do: Match actual device identity across SDL and HID, or use a selection scheme that distinguishes two controllers of the same family; cover that case with a behavioral test.
  • L2 host/pad_sdl.c:409: The device key hashes a reusable Linux hidraw node rather than identifying the physical controller. When: After one controller’s bias is saved, it disconnects and another controller is assigned the same /dev/hidrawN node. The new controller receives the old controller’s bias. Do: Use a physical-device identity where available, and avoid restoring a saved bias when the identity cannot distinguish devices.

Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)

  • L5: The Steam Deck OLED built-in gyro path still needs its in-game run. When: The reader changes the built-in Deck gyro path, but the reported Deck run used an LCD model. Do: Run motion aiming with the OLED’s built-in gyro and record the result.

@fix can do L1 and L2.

Since the last review (on a6b24b7148)
Resolved: L3 (A feature report waits on the pads request thread, delaying the entire input snapshot when…); L4 (Cleanup unconditionally disables a Steam Controller after this reader has enabled it, even…); L6 (The added work on the pads polling path has no measured input or frame-time cost.)
Still open: L1 (Matching only the family treats two different controllers as the same device and prevents…); L2 (The device key hashes a reusable Linux hidraw node rather than identifying the physical co…); L5 (The Steam Deck OLED built-in gyro path still needs its in-game run.)

Checks: Still running: 10 checks.

Also noticed (2; not asked for, not blocking)
  • A frame-time or input-latency comparison would clarify the background reader’s total cost.
  • Windows sandbox with DualSense under Steam Input remains listed for testing.
More: does it help, other systems, switches, what was read

Does it help: Yes: the author reports gyro aiming and controller switching in game on Steam Deck LCD, Steam Machine and Windows. The request-side motion call measured a 0.003 ms p99.9 and 0.099 ms maximum on Deck; these are not before-and-after frame-time measurements.

Other systems: The reported runs cover Linux, Windows, Steam Input and direct SDL motion. Deck OLED and Windows sandbox with DualSense under Steam Input remain untested; CI is still running.

Switches: HOS_STEAM_CONTROLLER_IMU, HOS_STEAM_CONTROLLER_IMU_ON and HOS_DUALSENSE_IMU are added, default on; HOS_DECK_IMU remains on by default. The defaults enable the feature, with IMU_ON allowing the Steam Controller write to be disabled.

Reviewed: 4444ceddba against 67fda193c3: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the supplied range diff and the relevant controller selection, bias and background-reader code. The full changed files, remaining project standards and generated files were not read in full; the review checklist file was absent.; nothing run (a code review).

Checked and fine:

  • Steam Controller cleanup leaves Steam’s IMU setting alone.
  • The background reader publishes motion without holding the shared lock during device polling.

Testing: No commands that build or run project code were executed. The author reports in-game tests on Deck LCD, Steam Machine and Windows, plus game-free checks; CI is still running.

Overlaps and merge order: Not checked.


Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The feature works in the reported Steam Input tests, but controller identity still has gaps: same-family HID controllers cannot take over from an SDL pad, and Linux can reuse a device node for a different controller’s saved bias. The Deck OLED run and CI are also outstanding. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge. Adds gyro input behind Steam Input for Steam Controller and DualSense devices on Linux and Windows, while moving HID work to a background thread. It improves controller support at the cost of additional device-selection and calibration state. **Should fix (2)**: not blocking, but worth doing before merging. - **L1** `host/pad_sdl.c:352`: Matching only the family treats two different controllers as the same device and prevents the newer HID controller from taking over. *When:* With one Steam Controller opened by SDL and a second Steam Controller read through HID, moving the second makes it the reader's choice, but both have the Triton family. hid_same remains true and the game continues aiming with the first controller. **Do:** Match actual device identity across SDL and HID, or use a selection scheme that distinguishes two controllers of the same family; cover that case with a behavioral test. - **L2** `host/pad_sdl.c:409`: The device key hashes a reusable Linux hidraw node rather than identifying the physical controller. *When:* After one controller’s bias is saved, it disconnects and another controller is assigned the same /dev/hidrawN node. The new controller receives the old controller’s bias. **Do:** Use a physical-device identity where available, and avoid restoring a saved bias when the identity cannot distinguish devices. **Testing before merging (1)** (runs on the systems it can change; it doesn't hold the recommendation) - **L5**: The Steam Deck OLED built-in gyro path still needs its in-game run. *When:* The reader changes the built-in Deck gyro path, but the reported Deck run used an LCD model. **Do:** Run motion aiming with the OLED’s built-in gyro and record the result. `@fix` can do L1 and L2. **Since the last review** (on a6b24b7148f2) Resolved: L3 (A feature report waits on the pads request thread, delaying the entire input snapshot when…); L4 (Cleanup unconditionally disables a Steam Controller after this reader has enabled it, even…); L6 (The added work on the pads polling path has no measured input or frame-time cost.) Still open: L1 (Matching only the family treats two different controllers as the same device and prevents…); L2 (The device key hashes a reusable Linux hidraw node rather than identifying the physical co…); L5 (The Steam Deck OLED built-in gyro path still needs its in-game run.) **Checks:** Still running: 10 checks. <details> <summary>Also noticed (2; not asked for, not blocking)</summary> - A frame-time or input-latency comparison would clarify the background reader’s total cost. - Windows sandbox with DualSense under Steam Input remains listed for testing. </details> <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes: the author reports gyro aiming and controller switching in game on Steam Deck LCD, Steam Machine and Windows. The request-side motion call measured a 0.003 ms p99.9 and 0.099 ms maximum on Deck; these are not before-and-after frame-time measurements. **Other systems:** The reported runs cover Linux, Windows, Steam Input and direct SDL motion. Deck OLED and Windows sandbox with DualSense under Steam Input remain untested; CI is still running. **Switches:** HOS_STEAM_CONTROLLER_IMU, HOS_STEAM_CONTROLLER_IMU_ON and HOS_DUALSENSE_IMU are added, default on; HOS_DECK_IMU remains on by default. The defaults enable the feature, with IMU_ON allowing the Steam Controller write to be disabled. **Reviewed:** 4444ceddbaf9 against 67fda193c384: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the supplied range diff and the relevant controller selection, bias and background-reader code. The full changed files, remaining project standards and generated files were not read in full; the review checklist file was absent.; nothing run (a code review). **Checked and fine:** - Steam Controller cleanup leaves Steam’s IMU setting alone. - The background reader publishes motion without holding the shared lock during device polling. **Testing:** No commands that build or run project code were executed. The author reports in-game tests on Deck LCD, Steam Machine and Windows, plus game-free checks; CI is still running. **Overlaps and merge order:** Not checked. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.</sub>
sandymac force-pushed feat/steam-controller-gyro from 4444ceddba
Some checks failed
beanstalk/approval waiting for a BigBean's 👍 on the request
PR description / Title and description (pull_request_target) Successful in 6s
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
to 83dfa98b92
Some checks failed
beanstalk/approval changed since the request: ask again
PR description / Title and description (pull_request_target) Has been cancelled
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
2026-12-05 17:23:38 +00:00
Compare
Author
Contributor

Thanks for the re-review. Pushed 83dfa98b, rebased onto main @ b6330a5b: the earlier commit, then one for L1 and L2.

L1 (should fix), the same family as SDL's pad: fixed, by node. The builder now names the pad SDL opened on the HID node the reader reads: it hashes each open pad's path (SDL_GetGamepadPath) as it hashes the reader's node (hid_imu::node_id; case blind on Windows, where cfgmgr32 and SDL's hidapi spell one path in different cases), and puts that pad's wire id in the motion trailer (48 bytes now; 0 none). The game treats the reader's controller as SDL's only when that pad is one whose sensors SDL reads (pad_sdl.c: hid_sdl); the family no longer decides. So a second Steam Controller on another node is another controller, picked up by its own input like a DualSense, while one controller that SDL and the reader both read still doesn't take turns with itself (its grips and trackpad clicks, which SDL's pad doesn't count). The builder logs which it is when that changes (pads: motion: ... is a pad SDL reads too / ... is no pad SDL opened), and since #3249 those lines are in the game's log. Tests: the_hid_motion_names_the_pad_sdl_opened_on_its_node (a pad on another node: none; the pad on its node: its id), the trailer's tests on both sides (a pad not among the pads is refused), and tests/test_hid_imu.py (no match by family left).

L2 (should fix), a reused hidraw node: fixed. The device id is now the node's id hashed with the count of devices that node has had (hid_imu::device_id(path, plugged)). The reader keeps the count while the node is there and drops it when the device is gone (a read that says so, or a look that no longer finds the node), so the next controller on that node gets another id and starts unlearned, while one controller keeps its id across Motion controls off and on. Test: another_controller_on_a_node_reused_is_another_device (unplugged and replaced on the same node, with and without a read that says so).

Tested in game at 0d352eb4 (the same code on main @ 7bc53f84), Steam Input on: the Steam Deck LCD with its own controls, the Steam Controller and a DualSense, and the Steam Machine with the Steam Controller and a DualSense: gyro aiming with each, the Steam Controller's grips and trackpad clicks while aiming (no hand-over), switching between them.

Checks on Linux: rustfmt, clippy -D warnings --no-deps, cargo test -p build-core -p longshot-game (262, 232), the pad checks (test_hid_imu, test_steam_pads, test_builder_pads_route, test_pads_after_menu, test_pad_motion_policy, test_gyro_rearm, test_switch_table, test_sdl_pad_diagnostics); build-core's on Windows too. ffi-gen --check fails on main @ b6330a5b itself (host/game_host.h: rx_menu_open and rx_display_refresh_mhz have no doc comment, from #3208 and #3164), so it can't run here; this PR's game.h lines are the ones it generated at 0d352eb4, unchanged by the rebase.

Wanted: a Windows run. I can't test Windows for about 12 hours. Could someone with a Steam Controller (2026) and/or a DualSense on Windows build this PR and play with Steam Input on (started from Steam, Motion controls on)?

  1. Aim with the Steam Controller's gyro (the slingshot), pressing its grips and clicking its trackpads while aiming: the aim should not jump, stop or switch.
  2. Pick up the DualSense and aim, then go back to the Steam Controller: motion follows the one in use.
  3. Say what longshot_log.txt has for pads: motion: (which controller, and whether it "is a pad SDL reads too").
Thanks for the re-review. Pushed `83dfa98b`, rebased onto `main` @ b6330a5b: the earlier commit, then one for L1 and L2. **L1 (should fix), the same family as SDL's pad: fixed, by node.** The builder now names the pad SDL opened on the HID node the reader reads: it hashes each open pad's path (`SDL_GetGamepadPath`) as it hashes the reader's node (`hid_imu::node_id`; case blind on Windows, where cfgmgr32 and SDL's hidapi spell one path in different cases), and puts that pad's wire id in the motion trailer (48 bytes now; 0 none). The game treats the reader's controller as SDL's only when that pad is one whose sensors SDL reads (`pad_sdl.c`: `hid_sdl`); the family no longer decides. So a second Steam Controller on another node is another controller, picked up by its own input like a DualSense, while one controller that SDL and the reader both read still doesn't take turns with itself (its grips and trackpad clicks, which SDL's pad doesn't count). The builder logs which it is when that changes (`pads: motion: ... is a pad SDL reads too` / `... is no pad SDL opened`), and since #3249 those lines are in the game's log. Tests: `the_hid_motion_names_the_pad_sdl_opened_on_its_node` (a pad on another node: none; the pad on its node: its id), the trailer's tests on both sides (a pad not among the pads is refused), and `tests/test_hid_imu.py` (no match by family left). **L2 (should fix), a reused hidraw node: fixed.** The device id is now the node's id hashed with the count of devices that node has had (`hid_imu::device_id(path, plugged)`). The reader keeps the count while the node is there and drops it when the device is gone (a read that says so, or a look that no longer finds the node), so the next controller on that node gets another id and starts unlearned, while one controller keeps its id across Motion controls off and on. Test: `another_controller_on_a_node_reused_is_another_device` (unplugged and replaced on the same node, with and without a read that says so). **Tested in game** at `0d352eb4` (the same code on `main` @ 7bc53f84), Steam Input on: the Steam Deck LCD with its own controls, the Steam Controller and a DualSense, and the Steam Machine with the Steam Controller and a DualSense: gyro aiming with each, the Steam Controller's grips and trackpad clicks while aiming (no hand-over), switching between them. **Checks** on Linux: rustfmt, clippy `-D warnings --no-deps`, `cargo test -p build-core -p longshot-game` (262, 232), the pad checks (`test_hid_imu`, `test_steam_pads`, `test_builder_pads_route`, `test_pads_after_menu`, `test_pad_motion_policy`, `test_gyro_rearm`, `test_switch_table`, `test_sdl_pad_diagnostics`); `build-core`'s on Windows too. `ffi-gen --check` fails on `main` @ b6330a5b itself (`host/game_host.h`: `rx_menu_open` and `rx_display_refresh_mhz` have no doc comment, from #3208 and #3164), so it can't run here; this PR's `game.h` lines are the ones it generated at `0d352eb4`, unchanged by the rebase. **Wanted: a Windows run.** I can't test Windows for about 12 hours. Could someone with a Steam Controller (2026) and/or a DualSense on Windows build this PR and play with Steam Input on (started from Steam, Motion controls on)? 1. Aim with the Steam Controller's gyro (the slingshot), pressing its grips and clicking its trackpads while aiming: the aim should not jump, stop or switch. 2. Pick up the DualSense and aim, then go back to the Steam Controller: motion follows the one in use. 3. Say what `longshot_log.txt` has for `pads: motion:` (which controller, and whether it "is a pad SDL reads too").
Owner
@review
BeanBot left a comment

Recommendation: Request changes. It conflicts with its base branch: bring it up to date (@​fix or @​rebase try first). (L7) The node-based pad matching addresses the controller handover issue, but a replacement controller can still inherit a previous controller’s gyro bias when the swap happens while Motion controls are off. The Steam Deck OLED run also remains outstanding.

This adds gyro input behind Steam Input for supported controllers on Linux and Windows, with device work moved off the pads request thread. It improves controller coverage at the cost of a platform-specific HID reader and device-selection logic.

Blocking (1): must change before merging.

  1. L7: It conflicts with its base branch: bring it up to date (@​fix or @​rebase try first). (for the author)

Should fix (1): not blocking, but worth doing before merging.

  • L2 host/pad_sdl.c:409: A replacement on a reused node can still receive the previous controller’s device ID when the swap occurs while the reader is stopped. When: Turn Motion controls off, unplug a controller, connect another that receives the same /dev/hidrawN, then turn Motion back on. The retained plugged entry supplies the old count, so the game restores the first controller’s learned bias. Do: Track device removal while motion is stopped, or use a physical-device identity that distinguishes the replacement while preserving the ID for a controller that remains connected.

Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)

  • L5: The Steam Deck OLED built-in gyro path still needs its in-game run. When: The reader changes the built-in Deck gyro path, but the reported Deck run used an LCD model. Do: Run motion aiming with the OLED’s built-in gyro and record the result.

@fix can do L2.

Since the last review (on 4444ceddba)
Resolved: L1 (Matching only the family treats two different controllers as the same device and prevents…)
Still open: L2 (A replacement on a reused node can still receive the previous controller’s device ID when…); L5 (The Steam Deck OLED built-in gyro path still needs its in-game run.)
New: L7 (It conflicts with its base branch: bring it up to date (@​fix or @​rebase try first).)

Checks: Still running: 11 checks.

Also noticed (1; not asked for, not blocking)
  • The input reference still describes selection beside an SDL pad in terms of another controller kind, although the code now matches nodes.
More: does it help, other systems, switches, what was read

Does it help: Yes. The author reports gyro aiming and controller switching in game on Steam Deck LCD, Steam Machine and Windows. The reported request motion-call time on Deck was 0.001 ms median and 0.003 ms p99.9; those numbers are not a before-and-after frame-time comparison.

Other systems: The reader affects Linux and Windows HID devices, SDL sensor selection and the builder-game pads wire. Linux switching was retested after the node-matching fix; the corresponding Windows run and the Deck OLED built-in gyro run remain outstanding. CI is still running.

Switches: HOS_DECK_IMU remains on by default. HOS_STEAM_CONTROLLER_IMU, HOS_STEAM_CONTROLLER_IMU_ON and HOS_DUALSENSE_IMU default on; the IMU_ON switch permits the Steam Controller sensor setting write. The defaults enable the feature tested by the author, with opt-outs documented.

Reviewed: 83dfa98b92 against b6330a5b0b: Read AGENTS.md, CONTRIBUTING.md and the pull request template in full. Read the fix diff and the relevant reader, background polling, snapshot matching and motion-selection code; the remaining changed files and tests were skimmed, not read in full.; nothing run (a code review).

Checked and fine:

  • The snapshot client rejects a named motion pad that is absent from the snapshot.
  • The fix retains the HID reader and its controller-motion path.

Testing: No commands that build or run project code were executed. Author-reported Linux and Windows runs and checks are described in the pull request; the OLED run and current CI remain outstanding.

Overlaps and merge order: No overlapping pull request identified from the supplied material.


Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** It conflicts with its base branch: bring it up to date (`@​fix` or `@​rebase` try first). (L7) The node-based pad matching addresses the controller handover issue, but a replacement controller can still inherit a previous controller’s gyro bias when the swap happens while Motion controls are off. The Steam Deck OLED run also remains outstanding. This adds gyro input behind Steam Input for supported controllers on Linux and Windows, with device work moved off the pads request thread. It improves controller coverage at the cost of a platform-specific HID reader and device-selection logic. **Blocking (1)**: must change before merging. 1. **L7**: It conflicts with its base branch: bring it up to date (`@​fix` or `@​rebase` try first). *(for the author)* **Should fix (1)**: not blocking, but worth doing before merging. - **L2** `host/pad_sdl.c:409`: A replacement on a reused node can still receive the previous controller’s device ID when the swap occurs while the reader is stopped. *When:* Turn Motion controls off, unplug a controller, connect another that receives the same /dev/hidrawN, then turn Motion back on. The retained plugged entry supplies the old count, so the game restores the first controller’s learned bias. **Do:** Track device removal while motion is stopped, or use a physical-device identity that distinguishes the replacement while preserving the ID for a controller that remains connected. **Testing before merging (1)** (runs on the systems it can change; it doesn't hold the recommendation) - **L5**: The Steam Deck OLED built-in gyro path still needs its in-game run. *When:* The reader changes the built-in Deck gyro path, but the reported Deck run used an LCD model. **Do:** Run motion aiming with the OLED’s built-in gyro and record the result. `@fix` can do L2. **Since the last review** (on 4444ceddbaf9) Resolved: L1 (Matching only the family treats two different controllers as the same device and prevents…) Still open: L2 (A replacement on a reused node can still receive the previous controller’s device ID when…); L5 (The Steam Deck OLED built-in gyro path still needs its in-game run.) New: L7 (It conflicts with its base branch: bring it up to date (`@​fix` or `@​rebase` try first).) **Checks:** Still running: 11 checks. <details> <summary>Also noticed (1; not asked for, not blocking)</summary> - The input reference still describes selection beside an SDL pad in terms of another controller kind, although the code now matches nodes. </details> <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes. The author reports gyro aiming and controller switching in game on Steam Deck LCD, Steam Machine and Windows. The reported request motion-call time on Deck was 0.001 ms median and 0.003 ms p99.9; those numbers are not a before-and-after frame-time comparison. **Other systems:** The reader affects Linux and Windows HID devices, SDL sensor selection and the builder-game pads wire. Linux switching was retested after the node-matching fix; the corresponding Windows run and the Deck OLED built-in gyro run remain outstanding. CI is still running. **Switches:** HOS_DECK_IMU remains on by default. HOS_STEAM_CONTROLLER_IMU, HOS_STEAM_CONTROLLER_IMU_ON and HOS_DUALSENSE_IMU default on; the IMU_ON switch permits the Steam Controller sensor setting write. The defaults enable the feature tested by the author, with opt-outs documented. **Reviewed:** 83dfa98b92b6 against b6330a5b0b0e: Read AGENTS.md, CONTRIBUTING.md and the pull request template in full. Read the fix diff and the relevant reader, background polling, snapshot matching and motion-selection code; the remaining changed files and tests were skimmed, not read in full.; nothing run (a code review). **Checked and fine:** - The snapshot client rejects a named motion pad that is absent from the snapshot. - The fix retains the HID reader and its controller-motion path. **Testing:** No commands that build or run project code were executed. Author-reported Linux and Windows runs and checks are described in the pull request; the OLED run and current CI remain outstanding. **Overlaps and merge order:** No overlapping pull request identified from the supplied material. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
sandymac force-pushed feat/steam-controller-gyro from 83dfa98b92
Some checks failed
beanstalk/approval changed since the request: ask again
PR description / Title and description (pull_request_target) Has been cancelled
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
to 7c4177481e
Some checks failed
beanstalk/approval changed since the request: ask again
PR description / Title and description (pull_request_target) Has been cancelled
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
2026-12-05 18:32:48 +00:00
Compare
Author
Contributor

Rebased onto main @ a0e0c720 as 7c417748; it no longer merged. One conflict, in docs/dev/reference/input.md's table: main's rewritten keyboard and mouse row kept beside this PR's two rows. The PR's code is unchanged (the same diff as 83dfa98b).

Run again on Linux: clippy -D warnings --no-deps on build-core and longshot-game, cargo test -p build-core (all pass), and the pad checks (test_hid_imu, test_steam_pads, test_builder_pads_route, test_pads_after_menu, test_pad_motion_policy, test_gyro_rearm, test_switch_table, test_sdl_pad_diagnostics: pass). Failing on main @ a0e0c720 too, in files this PR doesn't touch: rustfmt (gamecube.rs, devices/tests.rs and others), longshot-game's settings_now::tests::a_file_of_every_frozen_key_is_read_and_written_back_byte_identical, and ffi-gen (host/game_host.h's rx_menu_open has no doc comment).

The Windows run asked for above is still wanted, on this head.

Rebased onto `main` @ a0e0c720 as `7c417748`; it no longer merged. One conflict, in `docs/dev/reference/input.md`'s table: main's rewritten keyboard and mouse row kept beside this PR's two rows. The PR's code is unchanged (the same diff as `83dfa98b`). Run again on Linux: clippy `-D warnings --no-deps` on `build-core` and `longshot-game`, `cargo test -p build-core` (all pass), and the pad checks (`test_hid_imu`, `test_steam_pads`, `test_builder_pads_route`, `test_pads_after_menu`, `test_pad_motion_policy`, `test_gyro_rearm`, `test_switch_table`, `test_sdl_pad_diagnostics`: pass). Failing on `main` @ a0e0c720 too, in files this PR doesn't touch: rustfmt (`gamecube.rs`, `devices/tests.rs` and others), `longshot-game`'s `settings_now::tests::a_file_of_every_frozen_key_is_read_and_written_back_byte_identical`, and `ffi-gen` (`host/game_host.h`'s `rx_menu_open` has no doc comment). The Windows run asked for above is still wanted, on this head.
Owner
@review
BeanBot left a comment

Recommendation: Approve. The controller gyro feature has been demonstrated in game, but the Steam Deck OLED built-in gyro run is still outstanding. A controller swapped while motion reading is stopped can also inherit the previous controller’s learned bias. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.

Adds builder-side gyro reading behind Steam Input on Linux and Windows, with device selection and per-device bias. It moves device work off the pads request thread, at the cost of a more complex reader and controller selection path.

Should fix (1): not blocking, but worth doing before merging.

  • L2 host/pad_sdl.c:409: A replacement on a reused node can still receive the previous controller’s device ID when the swap occurs while the reader is stopped. When: Turn Motion controls off, unplug a controller, connect another that receives the same /dev/hidrawN, then turn Motion back on. The retained plugged entry supplies the old count, so the game restores the first controller’s learned bias. Do: Track device removal while motion is stopped, or use a physical-device identity that distinguishes the replacement while preserving the ID for a controller that remains connected.

Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)

  • L5: The Steam Deck OLED built-in gyro path still needs its in-game run. When: The reader changes the built-in Deck gyro path, but the reported Deck run used an LCD model. Do: Run motion aiming with the OLED’s built-in gyro and record the result.

@fix can do L2.

Since the last review (on 83dfa98b92)
Resolved: L7 (It conflicts with its base branch: bring it up to date (@​fix or @​rebase try first).)
Still open: L2 (A replacement on a reused node can still receive the previous controller’s device ID when…); L5 (The Steam Deck OLED built-in gyro path still needs its in-game run.)

Checks: Still running: 11 checks.

Also noticed (2; not asked for, not blocking)
  • The revised node-matching path still awaits the requested Windows in-game controller-switching run.
  • The description also lists a confined Windows Steam Input run as outstanding.
More: does it help, other systems, switches, what was read

Does it help: Yes: the author reports gyro aiming and controller switching in game on Steam Deck LCD, Steam Machine and Windows. Request motion-call measurements on Deck were 0.001 ms median and 0.099 ms maximum; they do not compare frame times against main.

Other systems: The reader affects Linux and Windows controller discovery, Steam Input, SDL sensor selection and the Deck’s built-in controls. Linux in-game testing covers the revised node matching; the revised Windows path and Deck OLED run remain outstanding.

Switches: HOS_DECK_IMU remains enabled by default. HOS_STEAM_CONTROLLER_IMU, HOS_STEAM_CONTROLLER_IMU_ON and HOS_DUALSENSE_IMU default to enabled; the reported controller runs support those defaults, with the remaining hardware checks noted.

Reviewed: 7c4177481e against a0e0c72073: Read the repository rules and PR template, ledger-related reader and bias code, and the input documentation diffs. Skimmed the remaining change and recorded runs; the full changed code and tests were not reread.; nothing run (a code review).

Checked and fine:

  • The rebase preserves the PR’s input documentation changes alongside main’s updated keyboard and mouse row.
  • The author reports in-game gyro operation and switching on Steam Deck LCD and Steam Machine with the revised node matching.

Testing: No commands that build or run project code were executed. The author reports passing relevant checks on the head; CI is still running.

Overlaps and merge order: none found


Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The controller gyro feature has been demonstrated in game, but the Steam Deck OLED built-in gyro run is still outstanding. A controller swapped while motion reading is stopped can also inherit the previous controller’s learned bias. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge. Adds builder-side gyro reading behind Steam Input on Linux and Windows, with device selection and per-device bias. It moves device work off the pads request thread, at the cost of a more complex reader and controller selection path. **Should fix (1)**: not blocking, but worth doing before merging. - **L2** `host/pad_sdl.c:409`: A replacement on a reused node can still receive the previous controller’s device ID when the swap occurs while the reader is stopped. *When:* Turn Motion controls off, unplug a controller, connect another that receives the same /dev/hidrawN, then turn Motion back on. The retained plugged entry supplies the old count, so the game restores the first controller’s learned bias. **Do:** Track device removal while motion is stopped, or use a physical-device identity that distinguishes the replacement while preserving the ID for a controller that remains connected. **Testing before merging (1)** (runs on the systems it can change; it doesn't hold the recommendation) - **L5**: The Steam Deck OLED built-in gyro path still needs its in-game run. *When:* The reader changes the built-in Deck gyro path, but the reported Deck run used an LCD model. **Do:** Run motion aiming with the OLED’s built-in gyro and record the result. `@fix` can do L2. **Since the last review** (on 83dfa98b92b6) Resolved: L7 (It conflicts with its base branch: bring it up to date (`@​fix` or `@​rebase` try first).) Still open: L2 (A replacement on a reused node can still receive the previous controller’s device ID when…); L5 (The Steam Deck OLED built-in gyro path still needs its in-game run.) **Checks:** Still running: 11 checks. <details> <summary>Also noticed (2; not asked for, not blocking)</summary> - The revised node-matching path still awaits the requested Windows in-game controller-switching run. - The description also lists a confined Windows Steam Input run as outstanding. </details> <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes: the author reports gyro aiming and controller switching in game on Steam Deck LCD, Steam Machine and Windows. Request motion-call measurements on Deck were 0.001 ms median and 0.099 ms maximum; they do not compare frame times against main. **Other systems:** The reader affects Linux and Windows controller discovery, Steam Input, SDL sensor selection and the Deck’s built-in controls. Linux in-game testing covers the revised node matching; the revised Windows path and Deck OLED run remain outstanding. **Switches:** HOS_DECK_IMU remains enabled by default. HOS_STEAM_CONTROLLER_IMU, HOS_STEAM_CONTROLLER_IMU_ON and HOS_DUALSENSE_IMU default to enabled; the reported controller runs support those defaults, with the remaining hardware checks noted. **Reviewed:** 7c4177481eb3 against a0e0c72073d9: Read the repository rules and PR template, ledger-related reader and bias code, and the input documentation diffs. Skimmed the remaining change and recorded runs; the full changed code and tests were not reread.; nothing run (a code review). **Checked and fine:** - The rebase preserves the PR’s input documentation changes alongside main’s updated keyboard and mouse row. - The author reports in-game gyro operation and switching on Steam Deck LCD and Steam Machine with the revised node matching. **Testing:** No commands that build or run project code were executed. The author reports passing relevant checks on the head; CI is still running. **Overlaps and merge order:** none found </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
Owner
@fix
BeanBot force-pushed feat/steam-controller-gyro from 7c4177481e
Some checks failed
beanstalk/approval changed since the request: ask again
PR description / Title and description (pull_request_target) Has been cancelled
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
to 19907f20c7
Some checks failed
beanstalk/approval changed since the request: ask again
PR description / Title and description (pull_request_target) Has been cancelled
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
2026-12-05 18:44:26 +00:00
Compare
BeanBot left a comment

Recommendation: Approve. The gyro feature works in the reported Linux and Windows runs, but the Steam Deck OLED built-in gyro run remains outstanding. A controller replaced while motion reading is stopped can also inherit the previous controller’s learned bias. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.

What @fix changed
I changed this pull request: the new head is 19907f20c7. I rebased it onto main (14f452f810).

Not done

  • Device identity across stopped motion, host/pad_sdl.c:409: The retained node count can still be reused after a replacement. This needs a way to detect removal across the stopped interval on both Linux and Windows while preserving the ID of a controller that stayed connected.

Nothing was built or run: the checks run again on the new head.

The builder reads gyro data from supported controllers alongside Steam Input and passes it to the game without doing device work on the pads request thread. It adds controller selection, device identity and platform transport complexity.

Should fix (1): not blocking, but worth doing before merging.

  • L2 host/pad_sdl.c:409: A replacement on a reused node can still receive the previous controller’s device ID when the swap occurs while the reader is stopped. When: Turn Motion controls off, unplug a controller, connect another that receives the same /dev/hidrawN, then turn Motion back on. The retained plugged entry supplies the old count, so the game restores the first controller’s learned bias. Do: Track device removal while motion is stopped, or use a physical-device identity that distinguishes the replacement while preserving the ID for a controller that remains connected.

Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)

  • L5: The Steam Deck OLED built-in gyro path still needs its in-game run. When: The reader changes the built-in Deck gyro path, but the reported Deck run used an LCD model. Do: Run motion aiming with the OLED’s built-in gyro and record the result.

@fix can do L2.

Checks: they run again on this head; a failure shows on the pull request.

Also noticed (1; not asked for, not blocking)
  • The latest Windows in-game check of controller selection and hand-over is still outstanding.
More: does it help, other systems, switches, what was read

Does it help: Yes. The author reports successful in-game gyro aiming and controller switching on Steam Deck LCD, Steam Machine and Windows. Request-side motion calls measured 0.002 ms p99 on the Deck and Windows; there is no comparable baseline timing.

Other systems: The reader affects Linux and Windows controller discovery, Steam Input, SDL sensor selection and the Deck’s sensor setting. Reported runs cover several combinations; the OLED built-in gyro and the latest Windows controller-selection changes remain untested in game.

Switches: HOS_DECK_IMU remains on by default and now uses the shared reader. HOS_STEAM_CONTROLLER_IMU, HOS_STEAM_CONTROLLER_IMU_ON and HOS_DUALSENSE_IMU are added, all on by default; the IMU_ON switch permits the Steam Controller sensor write. These defaults support the feature and have kill switches.

Reviewed: 19907f20c7 against 14f452f810: Read the repository rules, the reader’s stop, device identity and background paths, the game’s bias handling, and the switch diff. Skimmed the changed-file summary and reported runs; the full changed code and tests were not reread in this check.; nothing run (a code review).

Checked and fine:

  • The reader stops device work when no motion family is wanted.
  • The game stores and restores HID gyro bias by the reported device ID.

Testing: No tests were run. The author reports in-game testing on Steam Deck LCD, Steam Machine and Windows, plus build-core and pad checks; CI has not yet run on the head.

Overlaps and merge order: None found in the supplied information.


Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The gyro feature works in the reported Linux and Windows runs, but the Steam Deck OLED built-in gyro run remains outstanding. A controller replaced while motion reading is stopped can also inherit the previous controller’s learned bias. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge. **What `@fix` changed** I changed this pull request: the new head is 19907f20c7d6. I rebased it onto `main` (14f452f810a3). **Not done** - **Device identity across stopped motion, host/pad_sdl.c:409**: The retained node count can still be reused after a replacement. This needs a way to detect removal across the stopped interval on both Linux and Windows while preserving the ID of a controller that stayed connected. Nothing was built or run: the checks run again on the new head. The builder reads gyro data from supported controllers alongside Steam Input and passes it to the game without doing device work on the pads request thread. It adds controller selection, device identity and platform transport complexity. **Should fix (1)**: not blocking, but worth doing before merging. - **L2** `host/pad_sdl.c:409`: A replacement on a reused node can still receive the previous controller’s device ID when the swap occurs while the reader is stopped. *When:* Turn Motion controls off, unplug a controller, connect another that receives the same /dev/hidrawN, then turn Motion back on. The retained plugged entry supplies the old count, so the game restores the first controller’s learned bias. **Do:** Track device removal while motion is stopped, or use a physical-device identity that distinguishes the replacement while preserving the ID for a controller that remains connected. **Testing before merging (1)** (runs on the systems it can change; it doesn't hold the recommendation) - **L5**: The Steam Deck OLED built-in gyro path still needs its in-game run. *When:* The reader changes the built-in Deck gyro path, but the reported Deck run used an LCD model. **Do:** Run motion aiming with the OLED’s built-in gyro and record the result. `@fix` can do L2. **Checks:** they run again on this head; a failure shows on the pull request. <details> <summary>Also noticed (1; not asked for, not blocking)</summary> - The latest Windows in-game check of controller selection and hand-over is still outstanding. </details> <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes. The author reports successful in-game gyro aiming and controller switching on Steam Deck LCD, Steam Machine and Windows. Request-side motion calls measured 0.002 ms p99 on the Deck and Windows; there is no comparable baseline timing. **Other systems:** The reader affects Linux and Windows controller discovery, Steam Input, SDL sensor selection and the Deck’s sensor setting. Reported runs cover several combinations; the OLED built-in gyro and the latest Windows controller-selection changes remain untested in game. **Switches:** HOS_DECK_IMU remains on by default and now uses the shared reader. HOS_STEAM_CONTROLLER_IMU, HOS_STEAM_CONTROLLER_IMU_ON and HOS_DUALSENSE_IMU are added, all on by default; the IMU_ON switch permits the Steam Controller sensor write. These defaults support the feature and have kill switches. **Reviewed:** 19907f20c7d6 against 14f452f810a3: Read the repository rules, the reader’s stop, device identity and background paths, the game’s bias handling, and the switch diff. Skimmed the changed-file summary and reported runs; the full changed code and tests were not reread in this check.; nothing run (a code review). **Checked and fine:** - The reader stops device work when no motion family is wanted. - The game stores and restores HID gyro bias by the reported device ID. **Testing:** No tests were run. The author reports in-game testing on Steam Deck LCD, Steam Machine and Windows, plus build-core and pad checks; CI has not yet run on the head. **Overlaps and merge order:** None found in the supplied information. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.</sub>
sandymac force-pushed feat/steam-controller-gyro from 19907f20c7
Some checks failed
beanstalk/approval changed since the request: ask again
PR description / Title and description (pull_request_target) Has been cancelled
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
to 3afc328d09
Some checks are pending
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
CI / What the change needs (pull_request) Blocked by required conditions
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Blocked by required conditions
CI / Third-party parts and guide screenshots (pull_request) Blocked by required conditions
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Blocked by required conditions
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Blocked by required conditions
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Blocked by required conditions
beanstalk/approval changed since the request: ask again
PR description / Title and description (pull_request_target) Successful in 7s
2026-12-05 19:16:24 +00:00
Compare
Author
Contributor

Rebased onto main @ 5aa5989e as 3afc328d: the forge said it no longer merged after BeanBot's @fix rebase (19907f20, on 14f452f8). No conflict, and the PR's diff is unchanged.

Run again: cargo test -p build-core (hid_imu, pads: 48) on Windows; on Linux clippy -D warnings --no-deps, cargo test -p build-core (262) and the pad checks pass. Failing on main @ 5aa5989e too, in files this PR doesn't touch: rustfmt, longshot-game's settings_now::…byte_identical, and ffi-gen (host/game_host.h's rx_menu_open has no doc comment).

L2's remaining case (a controller swapped onto the same hidraw node while Motion controls is off) is still open; I'll follow up on it after the Windows run.

Rebased onto `main` @ 5aa5989e as `3afc328d`: the forge said it no longer merged after BeanBot's `@fix` rebase (`19907f20`, on 14f452f8). No conflict, and the PR's diff is unchanged. Run again: `cargo test -p build-core` (`hid_imu`, `pads`: 48) on Windows; on Linux clippy `-D warnings --no-deps`, `cargo test -p build-core` (262) and the pad checks pass. Failing on `main` @ 5aa5989e too, in files this PR doesn't touch: rustfmt, `longshot-game`'s `settings_now::…byte_identical`, and `ffi-gen` (`host/game_host.h`'s `rx_menu_open` has no doc comment). L2's remaining case (a controller swapped onto the same hidraw node while Motion controls is off) is still open; I'll follow up on it after the Windows run.
HumanBean deleted branch feat/steam-controller-gyro 2026-12-05 19:20:17 +00:00
Some checks are pending
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
CI / What the change needs (pull_request) Blocked by required conditions
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Blocked by required conditions
CI / Third-party parts and guide screenshots (pull_request) Blocked by required conditions
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Blocked by required conditions
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Blocked by required conditions
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Blocked by required conditions
beanstalk/approval changed since the request: ask again
PR description / Title and description (pull_request_target) Successful in 7s
Some workflows are waiting to be reviewed.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
6 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!3045
No description provided.