fix(input): the Steam Deck's own gyro when Steam Input hides it #2660

Merged
HumanBean merged 2 commits from omgitsgela/Longshot:deck-imu into main 2026-11-27 23:08:33 +00:00
Member

Summary

Fixes #2659, for the Deck itself.

On a Steam Deck the game had no motion aim: the Insert menu's Motion controls row said the connected pad had no gyro,
while Steam's own controller settings showed the deck's gyro working. Started from Steam, SDL opens only Steam Input's
stand-in pad, which has no accelerometer and no gyroscope, while the Deck's own controller keeps streaming its 64-byte
state report with the IMU in it, switched off until something asks for it.

What this changes:

  • host/deck_imu.c / host/deck_imu.h (new): reads the Deck's own controller. Its DECK_STATE report carries
    accelerometer and gyroscope, the same packet SDL's Steam Deck driver parses, in the same frame and units (accel
    m/s^2, gyro rad/s). The reader finds the node that streams it without ever waiting on the device (one candidate held open for up to 100 ms across polls, one non-blocking read per poll, a directory look at most every 2 s) and judges a node by that report rather than by
    Valve's vendor id, since the same device also exposes mouse and keyboard interfaces. Presence, and the Motion controls
    row, follow reports actually read in the last three seconds, so nothing claims a gyro before one arrives. The sensors
    are turned on with one SETTING_IMU_MODE feature report, written only when the value it replaces could be read, and
    put back only while the setting still holds what the reader wrote; a value Steam set later is left alone. Nothing else
    is written, and the Deck's built-in controls are never opened as a pad, so lizard mode stays on and Steam's trackpad,
    button and paddle mappings are left as Steam set them. Between reports it hands back the newest reading, the way SDL's
    sensor reads do, because a filter polled with gaps resets and the aim twitches.
  • host/pad_sdl.c: motion_poll() uses that reader only when no open pad reports sensors, so every desktop path
    and every real pad keep the SDL path they had. gyro_status reports the Deck's gyro, so the Motion controls row stops
    saying there is none. HOS_DECK_IMU=0 turns the reader off.
  • gpu/vk/switches.def: the row for the new switch.
  • tests/test_deck_imu.py (new): compiles the parser and checks the axis mapping, both full scales, every field's
    offset, and that foreign, short or other-version reports are refused. It also asserts the wiring invariants that keep
    the pad path first, stop the reader at the run's end, and give the Deck source its own identity in motion_poll().

Relation to #1181. That PR solves the same player-visible problem from the other side: it takes Valve's ids out of
Steam's ignore list (sizing the buffer from the list, which is why the strip never ran) so SDL opens the Deck's built-in
controls and their sensors are read through SDL. Opening them runs SDL's Steam Deck driver, which clears their digital
mappings and sets the trackpad modes as it opens them, so lizard mode goes off for the run, which is what
HOS_DECK_GYRO=0 there is for. This PR reads the same report beside SDL and opens nothing, so Steam's mappings survive,
and it deliberately leaves pads_start() alone: a Valve pad other than the Deck still is not opened for its motion
under Steam, which is #1181's fix rather than one duplicated here. The two do not conflict.

How to see the bug on main: start Longshot from its Steam tile in Game Mode, open the Insert menu's Controls page
(Motion controls says the pad has no gyro), and aim with the slingshot while tilting the Deck: nothing moves. The log
reads hid: controller "Steam Deck Controller" connected (SDL), Steam Input's; ... mapping-name="Steam Virtual Gamepad" and hid: 1 controller through SDL, with no sensor-bearing pad at all.

A reviewer should read host/deck_imu.c's feature-report and hold-the-reading paths first, then the motion_poll()
hunk in host/pad_sdl.c (source selection and the sensor-status line).

Testing

Tested: Steam Deck LCD (VanGogh, RADV, SteamOS 3), this change in the game. Game Mode, the desktop-mode runs and the
switch's off state all ran on head 728f14aec (the binary it was built into hashes 19dcfb67..., and the log shows the
reader's line and the motion-source line once each). The review's changes in 72117fa8c and the later change that keeps probe candidates open across polls are not yet run in the game: the Deck is offline and the rebuild is waiting on it, and that run will be added here.

  • Game Mode, started from the Steam tile: the log reads hid: the Steam Deck's own gyroscope and accelerometer: read from the controller once, then hid: motion controls from the Steam Deck's built-in controls, read from the controller. Gyro aim works and feels like a Switch Pro Controller's, with the filter's bias learned after holding
    still for a second.

  • Desktop Mode, Steam exited, started directly: gyro works through SDL's own path, and buttons, sticks, trackpads
    and rumble are normal.

  • Desktop Mode, Steam running, started directly: SDL opens the real controller (with a gyroscope; guid=0300f617...)
    and the reader's line appears zero times; gyro works through the pad path, unchanged by this change.

  • The switch's off state, Game Mode from the tile with HOS_DECK_IMU=0 in longshot_env.txt: the game reports no
    gyro and tilting the Deck does nothing, as on main. In the log, the reader's line appears zero times, the
    motion-source line appears zero times, and the pad lines are the stock ones (Steam Input's, mapping Steam Virtual Gamepad, 1 controller through SDL). So the switch removes the reader and nothing else.

  • A Steam Deck OLED, reported by a player on the community Discord: works there, gyro aim included, with the
    controls behaving normally. That answers the one hardware question this PR carried, since the report comes from the
    OLED's own report stream being read straight from hidraw rather than my LCD.

Game-free checks: tests/test_deck_imu.py, tests/test_switch_table.py (includes the new row), tests/test_env_on.py,
and the controller tests that compile blocks out of host/pad_sdl.c (test_gyro_rearm, test_steam_pads, test_stick_rest,
test_stick_dead_zone, test_touchpad_menu, test_rumble_refresh, test_vibration_pick, test_pads_after_menu,
test_motion_background, test_sdl_pad_diagnostics, test_input_background) all pass.

The whole suite, tests/run_all.py (the same tests mise run test runs; mise is not installed on this machine), against
clean 86b3b9e4f in a separate worktree and against this branch:

Tree Result
86b3b9e4f, clean 673 passed, 2 failed, 185 skipped
This branch 674 passed, 2 failed, 185 skipped

The two failures are the same test identities on both, and they are this machine's toolchain, not the tree:
tests/test_thinlto_tls.py (its cc1plus rejects -flto=thin; the test wants clang) and
tests/test_oot_song_inventory.py (GCC refuses taking the address of a temporary array in the shim it generates). The one
extra pass is this change's new test.

CI on this head (728f14aec): Host C for Windows (llvm-mingw, compile only), both renderer build checks, lint, the
website check and the description check pass. Four fail, and three of them are main's own:

  • Rust (rustfmt, clippy, cargo test, end to end), Third-party parts and guide screenshots and Game-free checks (part 2/2) are the same three jobs that fail on main's own push run at 86b3b9e4f. On part 2/2 there the failure is
    tests/test_lifter.py: "this expression creates a reference which is immediately dereferenced by the compiler".
  • Game-free checks (part 1/2) fails only on this head, on tests/test_present_semaphores.py: (no output). That check
    compiles a C++ fixture of the swapchain code with clang++ and runs it with no GPU, no game and no host code, and this
    diff does not touch gpu/vk/, so it reads as a flake on that run and wants a re-run rather than a change.

Still to test: The current changes need a game run on the Steam Deck; the Deck is offline and the rebuild is waiting on it.

Measurements

Nothing to measure: this routes input that never reached the game before; no rendering, timing or memory behaviour changes, and the switch ships on, at the behaviour that existed before the reader.

Risks

  • If Steam stops streaming the controller's state reports, the reader sees nothing, logs nothing, and the game behaves
    as it did before; HOS_DECK_IMU=0 or turning Motion controls off disables it, and the one setting it writes is put
    back when the reader stops.
  • The reader writes exactly one feature report (the IMU mode), only after reading the value it replaces, and restores it
    only while the setting still holds what the reader wrote. If Steam turns the gyro on or off during the run, Steam's
    value is the one left in place, so the two do not fight over it.
  • The reader is released as soon as an open pad reports sensors of its own, or Motion controls goes off, and it reopens
    by itself if the fallback is needed again.
  • The Deck's built-in controls are never opened, so nothing here changes lizard mode, the trackpad modes, the paddles or
    Steam's input mappings. A player who also has Steam Input's gyro-to-mouse layout on would get both at once.
  • Nothing changes after updating for saves, longshot_options.ini or the caches.

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 (the two failures that also fail on main are named in Testing).
  • 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.

When it applies

  • A fix: a game-free test that fails on main and passes here.
  • A switch added or changed: it ships at the default the measurements chose, with its row in gpu/vk/switches.def
    (on; both ways run in the game, in Testing).
  • 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: CI's Host C for Windows (llvm-mingw, compile only) job passed on 728f14aec; host/deck_imu.c compiles clean here with its non-Linux branch selected
    (gcc -U__linux__ -Werror -fsyntax-only), and returns zeros there.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested: a Steam Deck LCD here in every launch state, and a Steam Deck OLED from
    a player's report.
  • Approved in review, every comment answered.
  • CI passes on the head.
## Summary Fixes #2659, for the Deck itself. On a Steam Deck the game had no motion aim: the Insert menu's Motion controls row said the connected pad had no gyro, while Steam's own controller settings showed the deck's gyro working. Started from Steam, SDL opens only Steam Input's stand-in pad, which has no accelerometer and no gyroscope, while the Deck's own controller keeps streaming its 64-byte state report with the IMU in it, switched off until something asks for it. What this changes: - **`host/deck_imu.c` / `host/deck_imu.h`** (new): reads the Deck's own controller. Its `DECK_STATE` report carries accelerometer and gyroscope, the same packet SDL's Steam Deck driver parses, in the same frame and units (accel m/s^2, gyro rad/s). The reader finds the node that streams it without ever waiting on the device (one candidate held open for up to 100 ms across polls, one non-blocking read per poll, a directory look at most every 2 s) and judges a node by that report rather than by Valve's vendor id, since the same device also exposes mouse and keyboard interfaces. Presence, and the Motion controls row, follow reports actually read in the last three seconds, so nothing claims a gyro before one arrives. The sensors are turned on with one `SETTING_IMU_MODE` feature report, written only when the value it replaces could be read, and put back only while the setting still holds what the reader wrote; a value Steam set later is left alone. Nothing else is written, and the Deck's built-in controls are never opened as a pad, so lizard mode stays on and Steam's trackpad, button and paddle mappings are left as Steam set them. Between reports it hands back the newest reading, the way SDL's sensor reads do, because a filter polled with gaps resets and the aim twitches. - **`host/pad_sdl.c`**: `motion_poll()` uses that reader only when no open pad reports sensors, so every desktop path and every real pad keep the SDL path they had. `gyro_status` reports the Deck's gyro, so the Motion controls row stops saying there is none. `HOS_DECK_IMU=0` turns the reader off. - **`gpu/vk/switches.def`**: the row for the new switch. - **`tests/test_deck_imu.py`** (new): compiles the parser and checks the axis mapping, both full scales, every field's offset, and that foreign, short or other-version reports are refused. It also asserts the wiring invariants that keep the pad path first, stop the reader at the run's end, and give the Deck source its own identity in `motion_poll()`. **Relation to #1181.** That PR solves the same player-visible problem from the other side: it takes Valve's ids out of Steam's ignore list (sizing the buffer from the list, which is why the strip never ran) so SDL opens the Deck's built-in controls and their sensors are read through SDL. Opening them runs SDL's Steam Deck driver, which clears their digital mappings and sets the trackpad modes as it opens them, so lizard mode goes off for the run, which is what `HOS_DECK_GYRO=0` there is for. This PR reads the same report beside SDL and opens nothing, so Steam's mappings survive, and it deliberately leaves `pads_start()` alone: a Valve pad other than the Deck still is not opened for its motion under Steam, which is #1181's fix rather than one duplicated here. The two do not conflict. How to see the bug on `main`: start Longshot from its Steam tile in Game Mode, open the Insert menu's Controls page (Motion controls says the pad has no gyro), and aim with the slingshot while tilting the Deck: nothing moves. The log reads `hid: controller "Steam Deck Controller" connected (SDL), Steam Input's; ... mapping-name="Steam Virtual Gamepad"` and `hid: 1 controller through SDL`, with no sensor-bearing pad at all. A reviewer should read `host/deck_imu.c`'s feature-report and hold-the-reading paths first, then the `motion_poll()` hunk in `host/pad_sdl.c` (source selection and the sensor-status line). ## Testing **Tested:** Steam Deck LCD (VanGogh, RADV, SteamOS 3), this change in the game. Game Mode, the desktop-mode runs and the switch's off state all ran on head `728f14aec` (the binary it was built into hashes `19dcfb67...`, and the log shows the reader's line and the motion-source line once each). The review's changes in `72117fa8c` and the later change that keeps probe candidates open across polls are not yet run in the game: the Deck is offline and the rebuild is waiting on it, and that run will be added here. - **Game Mode, started from the Steam tile:** the log reads `hid: the Steam Deck's own gyroscope and accelerometer: read from the controller` once, then `hid: motion controls from the Steam Deck's built-in controls, read from the controller`. Gyro aim works and feels like a Switch Pro Controller's, with the filter's bias learned after holding still for a second. - **Desktop Mode, Steam exited, started directly:** gyro works through SDL's own path, and buttons, sticks, trackpads and rumble are normal. - **Desktop Mode, Steam running, started directly:** SDL opens the real controller (`with a gyroscope; guid=0300f617...`) and the reader's line appears zero times; gyro works through the pad path, unchanged by this change. - **The switch's off state, Game Mode from the tile with `HOS_DECK_IMU=0` in `longshot_env.txt`:** the game reports no gyro and tilting the Deck does nothing, as on `main`. In the log, the reader's line appears zero times, the motion-source line appears zero times, and the pad lines are the stock ones (`Steam Input's`, mapping `Steam Virtual Gamepad`, `1 controller through SDL`). So the switch removes the reader and nothing else. - **A Steam Deck OLED, reported by a player on the community Discord:** works there, gyro aim included, with the controls behaving normally. That answers the one hardware question this PR carried, since the report comes from the OLED's own report stream being read straight from hidraw rather than my LCD. Game-free checks: `tests/test_deck_imu.py`, `tests/test_switch_table.py` (includes the new row), `tests/test_env_on.py`, and the controller tests that compile blocks out of `host/pad_sdl.c` (`test_gyro_rearm`, `test_steam_pads`, `test_stick_rest`, `test_stick_dead_zone`, `test_touchpad_menu`, `test_rumble_refresh`, `test_vibration_pick`, `test_pads_after_menu`, `test_motion_background`, `test_sdl_pad_diagnostics`, `test_input_background`) all pass. The whole suite, `tests/run_all.py` (the same tests `mise run test` runs; `mise` is not installed on this machine), against clean `86b3b9e4f` in a separate worktree and against this branch: | Tree | Result | |---|---| | `86b3b9e4f`, clean | 673 passed, 2 failed, 185 skipped | | This branch | 674 passed, 2 failed, 185 skipped | The two failures are the same test identities on both, and they are this machine's toolchain, not the tree: `tests/test_thinlto_tls.py` (its `cc1plus` rejects `-flto=thin`; the test wants clang) and `tests/test_oot_song_inventory.py` (GCC refuses taking the address of a temporary array in the shim it generates). The one extra pass is this change's new test. CI on this head (`728f14aec`): `Host C for Windows (llvm-mingw, compile only)`, both renderer build checks, lint, the website check and the description check pass. Four fail, and three of them are `main`'s own: - `Rust (rustfmt, clippy, cargo test, end to end)`, `Third-party parts and guide screenshots` and `Game-free checks (part 2/2)` are the same three jobs that fail on `main`'s own push run at `86b3b9e4f`. On part 2/2 there the failure is `tests/test_lifter.py`: "this expression creates a reference which is immediately dereferenced by the compiler". - `Game-free checks (part 1/2)` fails only on this head, on `tests/test_present_semaphores.py: (no output)`. That check compiles a C++ fixture of the swapchain code with `clang++` and runs it with no GPU, no game and no host code, and this diff does not touch `gpu/vk/`, so it reads as a flake on that run and wants a re-run rather than a change. **Still to test:** The current changes need a game run on the Steam Deck; the Deck is offline and the rebuild is waiting on it. ## Measurements Nothing to measure: this routes input that never reached the game before; no rendering, timing or memory behaviour changes, and the switch ships on, at the behaviour that existed before the reader. ## Risks - If Steam stops streaming the controller's state reports, the reader sees nothing, logs nothing, and the game behaves as it did before; `HOS_DECK_IMU=0` or turning Motion controls off disables it, and the one setting it writes is put back when the reader stops. - The reader writes exactly one feature report (the IMU mode), only after reading the value it replaces, and restores it only while the setting still holds what the reader wrote. If Steam turns the gyro on or off during the run, Steam's value is the one left in place, so the two do not fight over it. - The reader is released as soon as an open pad reports sensors of its own, or Motion controls goes off, and it reopens by itself if the fallback is needed again. - The Deck's built-in controls are never opened, so nothing here changes lizard mode, the trackpad modes, the paddles or Steam's input mappings. A player who also has Steam Input's gyro-to-mouse layout on would get both at once. - Nothing changes after updating for saves, `longshot_options.ini` or the caches. ## 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 (the two failures that also fail on `main` are named in Testing). - [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. ### When it applies - [x] A fix: a game-free test that fails on `main` and passes here. - [x] A switch added or changed: it ships at the default the measurements chose, with its row in `gpu/vk/switches.def` (on; both ways run in the game, in Testing). - [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: CI's `Host C for Windows (llvm-mingw, compile only)` job passed on `728f14aec`; `host/deck_imu.c` compiles clean here with its non-Linux branch selected (`gcc -U__linux__ -Werror -fsyntax-only`), and returns zeros there. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [x] Tier 1 hardware it can affect is tested: a Steam Deck LCD here in every launch state, and a Steam Deck OLED from a player's report. - [ ] Approved in review, every comment answered. - [ ] CI passes on the head.
fix(input): the Steam Deck's own gyro when Steam Input hides it
Some checks failed
CI / What the change needs (pull_request) Successful in 7s
CI / Third-party parts and guide screenshots (pull_request) Failing after 12s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 2m13s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Successful in 2m23s
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Successful in 2m26s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Failing after 3m18s
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Successful in 3m49s
CI / Website build and checks (pull_request) Successful in 2m10s
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Successful in 13m30s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Failing after 22m40s
PR description / Title and description (pull_request_target) Successful in 4s
beanstalk/approval can't be tested as asked: see the farm's comment
5a643b6ec5
Started from Steam, SDL opens only Steam Input's stand-in pad, which has no sensors, so a Deck player has no motion aim
while every other pad does. Read the controller's own state report instead: the same 64-byte DECK_STATE packet SDL's
Steam Deck driver parses, on the controller's hidraw node, with one feature report turning SETTING_IMU_MODE on (and put
back as it was found when the reader stops). It is only used when no open pad reports sensors, so a real pad's gyro
always wins.

Also size the ignore list Steam hands SDL from the list itself. Steam's is over 11 KB and the fixed 4 KB buffer made
steam_pads_without_valve refuse it, so the valve-id strip never ran and no Valve pad was opened for motion at all.
Author
Member

Tested in game: Steam Deck LCD (VanGogh, RADV, SteamOS 3), nightly-842-86b3b9e4 with this change, in the game: Game Mode from the Steam tile (log reads 'the Steam Deck's own gyroscope and accelerometer: read from the controller' and 'motion controls from the Steam Deck's built-in controls, read from the controller'; gyro aim works and feels like a Switch Pro Controller's); Desktop Mode with Steam running and started directly (SDL opens the real controller, the reader's line appears zero times, gyro works through the pad path); Desktop Mode with Steam exited (gyro works, buttons/sticks/trackpads/rumble normal).

Tested in game: Steam Deck LCD (VanGogh, RADV, SteamOS 3), nightly-842-86b3b9e4 with this change, in the game: Game Mode from the Steam tile (log reads 'the Steam Deck's own gyroscope and accelerometer: read from the controller' and 'motion controls from the Steam Deck's built-in controls, read from the controller'; gyro aim works and feels like a Switch Pro Controller's); Desktop Mode with Steam running and started directly (SDL opens the real controller, the reader's line appears zero times, gyro works through the pad path); Desktop Mode with Steam exited (gyro works, buttons/sticks/trackpads/rumble normal).
Member

Possibly related, for context:

  • PR #1181 feat(host): the Steam Deck's gyro reaches Motion controls when Steam starts the game — Open overlapping PR addresses Steam-launched Deck gyro and IMU access.
Possibly related, for context: - PR #1181 feat(host): the Steam Deck's gyro reaches Motion controls when Steam starts the game — Open overlapping PR addresses Steam-launched Deck gyro and IMU access.
omgitsgela changed title from WIP: fix(input): the Steam Deck's own gyro when Steam Input hides it to fix(input): the Steam Deck's own gyro when Steam Input hides it 2026-11-27 11:28:14 +00:00
Author
Member

@Beanstalk a Steam Deck OLED: start Longshot from its Steam tile in Game Mode, open the Insert menu's Controls page, and aim with the slingshot while tilting the deck. Expect the Motion controls row to name the deck's gyro, gyro aim to work like a Switch Pro controller's, and buttons, trackpads, paddles and rumble to be normal. It matters here because this change also makes the Valve-id strip in pads_start() run for the first time: if the OLED's built-in controls report a product id other than 0x28de/0x1205, SDL now opens them rather than keeping them out, which is the case that wants looking at beside Steam Input.

@Beanstalk a Steam Deck OLED: start Longshot from its Steam tile in Game Mode, open the Insert menu's Controls page, and aim with the slingshot while tilting the deck. Expect the Motion controls row to name the deck's gyro, gyro aim to work like a Switch Pro controller's, and buttons, trackpads, paddles and rumble to be normal. It matters here because this change also makes the Valve-id strip in `pads_start()` run for the first time: if the OLED's built-in controls report a product id other than `0x28de/0x1205`, SDL now opens them rather than keeping them out, which is the case that wants looking at beside Steam Input.
Member

Beanstalk test farm

Commit 0293c11 · approved by nobody yet · dashboard

A member of BigBeans can review this commit and comment @Beanstalk to test it.

<!-- beanstalk:sticky --> ### Beanstalk test farm Commit `0293c11` · approved by nobody yet · [dashboard](https://beanstalk.magicbean.dev/prs/2660) A member of `BigBeans` can review this commit and comment `@Beanstalk` to test it.
omgitsgela force-pushed deck-imu from 5a643b6ec5
Some checks failed
CI / What the change needs (pull_request) Successful in 7s
CI / Third-party parts and guide screenshots (pull_request) Failing after 12s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 2m13s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Successful in 2m23s
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Successful in 2m26s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Failing after 3m18s
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Successful in 3m49s
CI / Website build and checks (pull_request) Successful in 2m10s
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Successful in 13m30s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Failing after 22m40s
PR description / Title and description (pull_request_target) Successful in 4s
beanstalk/approval can't be tested as asked: see the farm's comment
to 728f14aec3
Some checks failed
CI / What the change needs (pull_request) Successful in 7s
CI / Third-party parts and guide screenshots (pull_request) Failing after 11s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 1m31s
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Successful in 2m37s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Successful in 3m28s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Failing after 3m49s
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Successful in 5m41s
CI / Website build and checks (pull_request) Successful in 3m48s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Failing after 7m16s
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Failing after 10m20s
beanstalk/approval not approved yet
PR description / Title and description (pull_request_target) Successful in 5s
2026-11-27 11:33:27 +00:00
Compare
Author
Member

Related: #1181 solves the same problem from the other side. It lets SDL open the Deck's built-in controls, so their sensors are read through SDL, and it sizes the ignore list from the list itself. This PR reads the same 64-byte state report beside SDL and never opens the pad.

That difference is the point. Opening the Deck's built-in controls runs SDL's Steam Deck driver, which clears their digital mappings and sets the trackpad modes as it opens them, so lizard mode is off for as long as the game runs. #1181 knows this and carries HOS_DECK_GYRO=0 to keep them out. Here nothing is opened: Steam's trackpad, button and paddle mappings survive untouched, and the only thing ever sent to the controller is the one IMU-mode feature report, which is put back as it was found when the reader stops.

One trap for anyone taking the read-only route later: the reader has to hand back the newest reading on every poll, whether or not a new packet arrived, the way SDL's sensor reads do. Returning nothing between packets marks the source gone, resets the Mahony filter on the next packet, and reads in game as a twitch with almost no strength. I hit exactly that on my first build tonight. The test's comment in host/deck_imu.c says why, and Testing's Game Mode run is what caught it.

What this PR deliberately does not do: it does not size the ignore list, so a Valve pad other than the Deck still is not opened for its motion under Steam. That is #1181's fix and there is no need for two, and leaving pads_start() alone means the two PRs do not conflict.

Related: #1181 solves the same problem from the other side. It lets SDL open the Deck's built-in controls, so their sensors are read through SDL, and it sizes the ignore list from the list itself. This PR reads the same 64-byte state report beside SDL and never opens the pad. That difference is the point. Opening the Deck's built-in controls runs SDL's Steam Deck driver, which clears their digital mappings and sets the trackpad modes as it opens them, so lizard mode is off for as long as the game runs. #1181 knows this and carries `HOS_DECK_GYRO=0` to keep them out. Here nothing is opened: Steam's trackpad, button and paddle mappings survive untouched, and the only thing ever sent to the controller is the one IMU-mode feature report, which is put back as it was found when the reader stops. One trap for anyone taking the read-only route later: the reader has to hand back the newest reading on every poll, whether or not a new packet arrived, the way SDL's sensor reads do. Returning nothing between packets marks the source gone, resets the Mahony filter on the next packet, and reads in game as a twitch with almost no strength. I hit exactly that on my first build tonight. The test's comment in `host/deck_imu.c` says why, and Testing's Game Mode run is what caught it. What this PR deliberately does not do: it does not size the ignore list, so a Valve pad other than the Deck still is not opened for its motion under Steam. That is #1181's fix and there is no need for two, and leaving `pads_start()` alone means the two PRs do not conflict.
Author
Member

Update: a player on the community Discord reports this working on a Steam Deck OLED, gyro aim included and controls normal. That closes the last hardware question this PR carried, so Testing now reads Steam Deck LCD here and OLED from that report, and Still to test is None.

Update: a player on the community Discord reports this working on a Steam Deck OLED, gyro aim included and controls normal. That closes the last hardware question this PR carried, so Testing now reads Steam Deck LCD here and OLED from that report, and Still to test is None.
Author
Member

CI read from the checks tab, since the CLI's links are unreliable on this head:

  • Pass: What the change needs, Lint, Host C for Windows (llvm-mingw), both renderer build checks, Website, PR description.
  • Fail: Rust, Third-party parts, Game-free part 2/2, Game-free part 1/2.

The first three are main's own reds at 86b3b9e4f; on part 2/2 there the failure is tests/test_lifter.py's clippy error. Part 1/2 fails only here, on tests/test_present_semaphores.py with no output: a clang++ fixture of the swapchain code, no GPU, no game, no host code, and this diff does not touch gpu/vk. It wants a re-run rather than a change, if someone with rights can kick it.

CI read from the checks tab, since the CLI's links are unreliable on this head: - Pass: What the change needs, Lint, Host C for Windows (llvm-mingw), both renderer build checks, Website, PR description. - Fail: Rust, Third-party parts, Game-free part 2/2, Game-free part 1/2. The first three are main's own reds at 86b3b9e4f; on part 2/2 there the failure is tests/test_lifter.py's clippy error. Part 1/2 fails only here, on tests/test_present_semaphores.py with no output: a clang++ fixture of the swapchain code, no GPU, no game, no host code, and this diff does not touch gpu/vk. It wants a re-run rather than a change, if someone with rights can kick it.
Owner
@review
BeanBot left a comment

Recommendation: Request changes. The fallback reports a gyro for any Valve hidraw device and can block the Linux input/window thread while probing devices. It also does not reliably restore or release the Deck's sensor setting when ownership changes.

The change reads the Deck's built-in motion sensors when Steam Input exposes only a virtual pad, and the reported Deck runs show motion aim working. The fallback adds device probing and shared sensor-setting ownership that need tighter handling.

Blocking (8): must change before merging.

  1. L1 host/deck_imu.c:196: Presence is reported for every Valve hidraw device, without establishing that it is a Deck controller or that its sensors can be read. (more on the line) Do: Report Deck sensor availability only after identifying a usable Deck state-report node, and clear it when that node cannot be read.
  2. L2 host/deck_imu.c:102: The fallback waits synchronously for each candidate hidraw node on the SDL polling thread. (more on the line) Do: Identify the correct interface without blocking the polling thread, or perform probing asynchronously and publish the result safely.
  3. L3 host/deck_imu.c:168: A failed read of the original IMU setting is treated as permission to overwrite it and later restore zero. (more on the line) Do: Do not change the mode unless its previous value was successfully read, or use a device ownership mechanism that can restore the actual prior state.
  4. L5 host/deck_imu.c:169: Restoring the initially saved mode unconditionally can overwrite a later change made by Steam. (more on the line) Do: Coordinate sensor ownership with Steam, or avoid restoring a stale setting when another owner can change it during the run.
  5. L8: The check CI / Third-party parts and guide screenshots (pull_request) fails on this head and passes on the base branch: Failing after 11s.
  6. L9: The check CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) fails on this head and passes on the base branch: Failing after 3m49s.
  7. L10: The check CI / Game-free checks (run_all.py, part 2/2) (pull_request) fails on this head and passes on the base branch: Failing after 7m16s.
  8. L11: The check CI / Game-free checks (run_all.py, part 1/2) (pull_request) fails on this head and passes on the base branch: Failing after 10m20s.

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

  • L4 host/pad_sdl.c:253: The Deck reader remains open and its IMU setting remains owned after a sensor-bearing SDL pad becomes available. (more on the line) Do: Stop and restore the Deck reader when the SDL sensor path takes over, and reopen it cleanly if the fallback becomes necessary again.
  • L6 host/deck_imu.c:99: FD_SET is used without checking whether the opened descriptor fits in fd_set. (more on the line) Do: Use poll for the descriptor or reject descriptors at or above FD_SETSIZE before calling FD_SET.
  • L7 tests/test_deck_imu.py:21: The new test hard-codes gcc instead of using the compiler selected by the test runner. (more on the line) Do: Use the runner's {cc} placeholder and honor CC for direct invocation.

@fix can do L1, L2, L3, L4, L5, L6, L7, L8, L9, L10 and L11.

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

Does it help: Yes for the reported fix: the author reports no motion aim on the base and working aim on this head in Steam Deck LCD Game Mode; an OLED player also reports success. No performance gain is claimed.

Other systems: The Linux window thread also handles SDL input, so synchronous hidraw probing can affect input and window responsiveness on Linux PCs with Valve devices. A connected sensor-bearing pad changes source selection, and Steam can independently change the Deck's IMU mode. Windows uses the stub; its compile-only CI check passed.

Switches: HOS_DECK_IMU is added as an on-by-default kill switch, with a switches.def row. Both states were reported tested on the Deck, but the default-on fallback needs the device detection and ownership fixes below.

Reviewed: 728f14aec3 against 86b3b9e4f0: Read AGENTS.md, CONTRIBUTING.md, the PR template, the diff and commit, the new reader, header and test, and the changed motion and controller polling paths. Read relevant standards and build-source references; skimmed the rest of pad_sdl.c and switch table. docs/review-checklist.md and ../Tooling/AGENTS.md were absent. No generated files or translations changed.; nothing run (a code review).

Checked and fine:

  • The parser checks the report version, type and length before accessing its fixed offsets.
  • The new switch has a table row and the reported on and off runs exercise both states.
  • The reader state is accessed from the serialized pad poll and shutdown paths.

Testing: Read-only review; no tests or project code were run. The supplied CI marks four checks as failing on this head; those failures are not repeated as review items.

Overlaps and merge order: #1181 addresses the same Deck symptom by exposing Valve controllers to SDL; the PR describes complementary approaches and no textual conflict. Merge order was not established.


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

**Recommendation: Request changes.** The fallback reports a gyro for any Valve hidraw device and can block the Linux input/window thread while probing devices. It also does not reliably restore or release the Deck's sensor setting when ownership changes. The change reads the Deck's built-in motion sensors when Steam Input exposes only a virtual pad, and the reported Deck runs show motion aim working. The fallback adds device probing and shared sensor-setting ownership that need tighter handling. **Blocking (8)**: must change before merging. 1. **L1** `host/deck_imu.c:196`: Presence is reported for every Valve hidraw device, without establishing that it is a Deck controller or that its sensors can be read. (more on the line) **Do:** Report Deck sensor availability only after identifying a usable Deck state-report node, and clear it when that node cannot be read. 2. **L2** `host/deck_imu.c:102`: The fallback waits synchronously for each candidate hidraw node on the SDL polling thread. (more on the line) **Do:** Identify the correct interface without blocking the polling thread, or perform probing asynchronously and publish the result safely. 3. **L3** `host/deck_imu.c:168`: A failed read of the original IMU setting is treated as permission to overwrite it and later restore zero. (more on the line) **Do:** Do not change the mode unless its previous value was successfully read, or use a device ownership mechanism that can restore the actual prior state. 4. **L5** `host/deck_imu.c:169`: Restoring the initially saved mode unconditionally can overwrite a later change made by Steam. (more on the line) **Do:** Coordinate sensor ownership with Steam, or avoid restoring a stale setting when another owner can change it during the run. 5. **L8**: The check `CI / Third-party parts and guide screenshots (pull_request)` fails on this head and passes on the base branch: Failing after 11s. 6. **L9**: The check `CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request)` fails on this head and passes on the base branch: Failing after 3m49s. 7. **L10**: The check `CI / Game-free checks (run_all.py, part 2/2) (pull_request)` fails on this head and passes on the base branch: Failing after 7m16s. 8. **L11**: The check `CI / Game-free checks (run_all.py, part 1/2) (pull_request)` fails on this head and passes on the base branch: Failing after 10m20s. **Should fix (3)**: not blocking, but worth doing before merging. - **L4** `host/pad_sdl.c:253`: The Deck reader remains open and its IMU setting remains owned after a sensor-bearing SDL pad becomes available. (more on the line) **Do:** Stop and restore the Deck reader when the SDL sensor path takes over, and reopen it cleanly if the fallback becomes necessary again. - **L6** `host/deck_imu.c:99`: FD_SET is used without checking whether the opened descriptor fits in fd_set. (more on the line) **Do:** Use poll for the descriptor or reject descriptors at or above FD_SETSIZE before calling FD_SET. - **L7** `tests/test_deck_imu.py:21`: The new test hard-codes gcc instead of using the compiler selected by the test runner. (more on the line) **Do:** Use the runner's {cc} placeholder and honor CC for direct invocation. `@fix` can do L1, L2, L3, L4, L5, L6, L7, L8, L9, L10 and L11. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes for the reported fix: the author reports no motion aim on the base and working aim on this head in Steam Deck LCD Game Mode; an OLED player also reports success. No performance gain is claimed. **Other systems:** The Linux window thread also handles SDL input, so synchronous hidraw probing can affect input and window responsiveness on Linux PCs with Valve devices. A connected sensor-bearing pad changes source selection, and Steam can independently change the Deck's IMU mode. Windows uses the stub; its compile-only CI check passed. **Switches:** HOS_DECK_IMU is added as an on-by-default kill switch, with a switches.def row. Both states were reported tested on the Deck, but the default-on fallback needs the device detection and ownership fixes below. **Reviewed:** 728f14aec323 against 86b3b9e4f0e1: Read AGENTS.md, CONTRIBUTING.md, the PR template, the diff and commit, the new reader, header and test, and the changed motion and controller polling paths. Read relevant standards and build-source references; skimmed the rest of pad_sdl.c and switch table. docs/review-checklist.md and ../Tooling/AGENTS.md were absent. No generated files or translations changed.; nothing run (a code review). **Checked and fine:** - The parser checks the report version, type and length before accessing its fixed offsets. - The new switch has a table row and the reported on and off runs exercise both states. - The reader state is accessed from the serialized pad poll and shutdown paths. **Testing:** Read-only review; no tests or project code were run. The supplied CI marks four checks as failing on this head; those failures are not repeated as review items. **Overlaps and merge order:** #1181 addresses the same Deck symptom by exposing Valve controllers to SDL; the PR describes complementary approaches and no textual conflict. Merge order was not established. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
host/deck_imu.c Outdated
@ -0,0 +96,4 @@
fd_set set;
struct timeval tv = {0, 20000};
FD_ZERO(&set);
FD_SET(fd, &set);
Member

L6 (should fix): FD_SET is used without checking whether the opened descriptor fits in fd_set.

When: If the process already has at least FD_SETSIZE descriptors open, opening a candidate returns a descriptor outside fd_set and FD_SET writes beyond the set's bounds.

Do: Use poll for the descriptor or reject descriptors at or above FD_SETSIZE before calling FD_SET.

**L6** (should fix): FD_SET is used without checking whether the opened descriptor fits in fd_set. *When:* If the process already has at least FD_SETSIZE descriptors open, opening a candidate returns a descriptor outside fd_set and FD_SET writes beyond the set's bounds. **Do:** Use poll for the descriptor or reject descriptors at or above FD_SETSIZE before calling FD_SET.
host/deck_imu.c Outdated
@ -0,0 +99,4 @@
FD_SET(fd, &set);
if (select(fd + 1, &set, NULL, NULL, &tv) <= 0) {
close(fd);
return -1;
Member

L2 (blocking): The fallback waits synchronously for each candidate hidraw node on the SDL polling thread.

When: On Linux with a Valve device whose hidraw interfaces do not stream Deck reports, each candidate can wait 20 ms; the failed scan repeats every three seconds. The Linux window thread runs this poll, so input and window event processing pause for the sum of those waits.

Do: Identify the correct interface without blocking the polling thread, or perform probing asynchronously and publish the result safely.

**L2** (blocking): The fallback waits synchronously for each candidate hidraw node on the SDL polling thread. *When:* On Linux with a Valve device whose hidraw interfaces do not stream Deck reports, each candidate can wait 20 ms; the failed scan repeats every three seconds. The Linux window thread runs this poll, so input and window event processing pause for the sum of those waits. **Do:** Identify the correct interface without blocking the polling thread, or perform probing asynchronously and publish the result safely.
host/deck_imu.c Outdated
@ -0,0 +165,4 @@
if (imu_fd < 0) return;
if (imu_writable && imu_set >= 0) {
const int back = imu_saved >= 0 ? imu_saved : 0;
deck_imu_send_setting(imu_fd, DECK_IMU_ID_SET_SETTINGS_VALUES, back);
Member

L3 (blocking): A failed read of the original IMU setting is treated as permission to overwrite it and later restore zero.

When: If the GET feature report fails but the SET succeeds, imu_saved remains -1 and closing the reader sends mode 0. A Steam layout that had enabled the gyro loses its prior setting when Motion controls are disabled or the game exits.

Do: Do not change the mode unless its previous value was successfully read, or use a device ownership mechanism that can restore the actual prior state.

**L3** (blocking): A failed read of the original IMU setting is treated as permission to overwrite it and later restore zero. *When:* If the GET feature report fails but the SET succeeds, imu_saved remains -1 and closing the reader sends mode 0. A Steam layout that had enabled the gyro loses its prior setting when Motion controls are disabled or the game exits. **Do:** Do not change the mode unless its previous value was successfully read, or use a device ownership mechanism that can restore the actual prior state.
host/deck_imu.c Outdated
@ -0,0 +166,4 @@
if (imu_writable && imu_set >= 0) {
const int back = imu_saved >= 0 ? imu_saved : 0;
deck_imu_send_setting(imu_fd, DECK_IMU_ID_SET_SETTINGS_VALUES, back);
}
Member

L5 (blocking): Restoring the initially saved mode unconditionally can overwrite a later change made by Steam.

When: Start with Steam's gyro layout off, so the reader saves mode 0 and enables the IMU; then switch Steam to a layout that uses its gyro. When Longshot stops the reader it writes the old 0, disabling the sensor mode Steam now needs.

Do: Coordinate sensor ownership with Steam, or avoid restoring a stale setting when another owner can change it during the run.

**L5** (blocking): Restoring the initially saved mode unconditionally can overwrite a later change made by Steam. *When:* Start with Steam's gyro layout off, so the reader saves mode 0 and enables the IMU; then switch Steam to a layout that uses its gyro. When Longshot stops the reader it writes the old 0, disabling the sensor mode Steam now needs. **Do:** Coordinate sensor ownership with Steam, or avoid restoring a stale setting when another owner can change it during the run.
host/deck_imu.c Outdated
@ -0,0 +193,4 @@
if (deck_imu_valve_uevent(uevent)) {
present = 1;
break;
}
Member

L1 (blocking): Presence is reported for every Valve hidraw device, without establishing that it is a Deck controller or that its sensors can be read.

When: On a Linux desktop with a Valve device but no Deck, or with a Deck node that cannot be opened, deck_imu_present returns 1. motion_poll then reports gyro_status 2 even though deck_imu_open finds no usable sensor, so the Motion controls row claims a gyro exists and aim still receives no motion.

Do: Report Deck sensor availability only after identifying a usable Deck state-report node, and clear it when that node cannot be read.

**L1** (blocking): Presence is reported for every Valve hidraw device, without establishing that it is a Deck controller or that its sensors can be read. *When:* On a Linux desktop with a Valve device but no Deck, or with a Deck node that cannot be opened, deck_imu_present returns 1. motion_poll then reports gyro_status 2 even though deck_imu_open finds no usable sensor, so the Motion controls row claims a gyro exists and aim still receives no motion. **Do:** Report Deck sensor availability only after identifying a usable Deck state-report node, and clear it when that node cannot be read.
host/pad_sdl.c Outdated
@ -245,1 +251,3 @@
InterlockedExchange(&gyro_status, any ? 2 : count ? 1 : 0);
/* (longshot) the Deck's own sensors when no open pad has any: Steam Input's stand-in pad has none, and the Deck's
controls keep theirs (host/deck_imu.h). The pad path above stays the one used wherever a pad has a gyroscope */
const int deck = !any && deck_imu_present(now);
Member

L4 (should fix): The Deck reader remains open and its IMU setting remains owned after a sensor-bearing SDL pad becomes available.

When: Start with the Deck fallback active, then connect a gyro-equipped pad. any becomes true, so deck_imu_poll is no longer called, but deck_imu_stop is called only when motion is off or at shutdown. The Deck stays enabled and its queued reports are not drained; disconnecting the pad later can initially consume stale readings.

Do: Stop and restore the Deck reader when the SDL sensor path takes over, and reopen it cleanly if the fallback becomes necessary again.

**L4** (should fix): The Deck reader remains open and its IMU setting remains owned after a sensor-bearing SDL pad becomes available. *When:* Start with the Deck fallback active, then connect a gyro-equipped pad. any becomes true, so deck_imu_poll is no longer called, but deck_imu_stop is called only when motion is off or at shutdown. The Deck stays enabled and its queued reports are not drained; disconnecting the pad later can initially consume stale readings. **Do:** Stop and restore the Deck reader when the SDL sensor path takes over, and reopen it cleanly if the fallback becomes necessary again.
@ -0,0 +18,4 @@
import subprocess
import tempfile
RUN_ALL_ARGS = ["--cc", "gcc"]
Member

L7 (should fix): The new test hard-codes gcc instead of using the compiler selected by the test runner.

When: With CC set to clang, or on a supported test machine with clang but no gcc, run_all selects the configured compiler but this test requests gcc and is skipped or cannot run.

Do: Use the runner's {cc} placeholder and honor CC for direct invocation.

**L7** (should fix): The new test hard-codes gcc instead of using the compiler selected by the test runner. *When:* With CC set to clang, or on a supported test machine with clang but no gcc, run_all selects the configured compiler but this test requests gcc and is skipped or cannot run. **Do:** Use the runner's {cc} placeholder and honor CC for direct invocation.
omgitsgela force-pushed deck-imu from 728f14aec3
Some checks failed
CI / What the change needs (pull_request) Successful in 7s
CI / Third-party parts and guide screenshots (pull_request) Failing after 11s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 1m31s
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Successful in 2m37s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Successful in 3m28s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Failing after 3m49s
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Successful in 5m41s
CI / Website build and checks (pull_request) Successful in 3m48s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Failing after 7m16s
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Failing after 10m20s
beanstalk/approval not approved yet
PR description / Title and description (pull_request_target) Successful in 5s
to 72117fa8c6
Some checks failed
CI / What the change needs (pull_request) Successful in 12s
CI / Third-party parts and guide screenshots (pull_request) Failing after 15s
beanstalk/approval not approved yet
PR description / Title and description (pull_request_target) Successful in 13s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Failing after 1m48s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Failing after 5m16s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Successful in 2m24s
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Successful in 3m31s
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Successful in 2m48s
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Successful in 10m17s
CI / Website build and checks (pull_request) Successful in 3m17s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Failing after 21m34s
2026-11-27 21:04:02 +00:00
Compare
Author
Member

All seven code items are fixed in 72117fa8c. The four CI items need a re-read, with the links below.

L1 — presence is no longer a vendor scan. deck_imu_present() now answers from the reader's own state: a state report read in the last three seconds. The first valid packet is what validates the node, so a Valve mouse or keyboard interface can no longer make the Motion controls row claim a gyro, and gyro_status in motion_poll() is set from the reading rather than from the device's presence.

L2 — the blocking select() is gone. One candidate is tried per poll with a single non-blocking read, at most one candidate per 100 ms, and the directory scan happens at most once per 2 s. Nothing on the poll thread waits on the device, and a machine with no Valve controller costs one directory look every two seconds.

L3 — the mode is written only when the previous value was read successfully. When that read fails, the reader logs one line and leaves Steam's value alone.

L4 — the reader is released whenever a pad with sensors of its own is open, not only when Motion controls goes off, and it reopens if the fallback is needed again. The setting goes back with it.

L5 — the setting is restored only when the value read at close is the one this reader wrote. If Steam changed it during the run, Steam's value is kept.

L6 — FD_SET is gone with select(); the node is only used with open, read, write and ioctl.

L7 — the test takes the runner's {cc} and honours CC for a direct run.

Controller checks pass after the change, including the updated invariants.

L8 to L11 — these do not pass on the base. On main's own push run at 86b3b9e4f (run 55611):

  • Game-free part 2/2 fails there too, on tests/test_lifter.py: "this expression creates a reference which is immediately dereferenced by the compiler" (job 8).
  • Rust (job 3) and Third-party parts (job 2) are marked failing on that same push.
  • Game-free part 1/2 passed there and failed here on tests/test_present_semaphores.py with no output at all. That check compiles a C++ fixture of the swapchain code with clang++ and runs it with no GPU, no game and no host code, and this diff does not touch gpu/vk/, so it reads as a flake on that run. This push has triggered a fresh run of it.

The Deck the fallback was built and played on is offline right now (no route over its network), so the game run of this head is pending; I will add it here as soon as it is back up rather than leave the testing claim standing on the previous head.

All seven code items are fixed in `72117fa8c`. The four CI items need a re-read, with the links below. **L1** — presence is no longer a vendor scan. `deck_imu_present()` now answers from the reader's own state: a state report read in the last three seconds. The first valid packet is what validates the node, so a Valve mouse or keyboard interface can no longer make the Motion controls row claim a gyro, and `gyro_status` in `motion_poll()` is set from the reading rather than from the device's presence. **L2** — the blocking `select()` is gone. One candidate is tried per poll with a single non-blocking read, at most one candidate per 100 ms, and the directory scan happens at most once per 2 s. Nothing on the poll thread waits on the device, and a machine with no Valve controller costs one directory look every two seconds. **L3** — the mode is written only when the previous value was read successfully. When that read fails, the reader logs one line and leaves Steam's value alone. **L4** — the reader is released whenever a pad with sensors of its own is open, not only when Motion controls goes off, and it reopens if the fallback is needed again. The setting goes back with it. **L5** — the setting is restored only when the value read at close is the one this reader wrote. If Steam changed it during the run, Steam's value is kept. **L6** — `FD_SET` is gone with `select()`; the node is only used with `open`, `read`, `write` and `ioctl`. **L7** — the test takes the runner's `{cc}` and honours `CC` for a direct run. Controller checks pass after the change, including the updated invariants. **L8 to L11 — these do not pass on the base.** On `main`'s own push run at `86b3b9e4f` (run 55611): - Game-free part 2/2 fails there too, on `tests/test_lifter.py`: "this expression creates a reference which is immediately dereferenced by the compiler" (job 8). - Rust (job 3) and Third-party parts (job 2) are marked failing on that same push. - Game-free part 1/2 passed there and failed here on `tests/test_present_semaphores.py` with no output at all. That check compiles a C++ fixture of the swapchain code with `clang++` and runs it with no GPU, no game and no host code, and this diff does not touch `gpu/vk/`, so it reads as a flake on that run. This push has triggered a fresh run of it. The Deck the fallback was built and played on is offline right now (no route over its network), so the game run of this head is pending; I will add it here as soon as it is back up rather than leave the testing claim standing on the previous head.
Owner
@review
BeanBot left a comment

Recommendation: Request changes. The new probe closes a candidate immediately when its first nonblocking read finds no packet, so the Deck controller can remain undiscovered and motion aim unavailable. The earlier in-game results predate this probe.

The change adds a fallback for the Steam Deck’s built-in motion sensors while leaving SDL pads first. It removes the previous synchronous probe wait, but the replacement can discard the controller before its first report arrives.

Blocking (1): must change before merging.

  1. L12 host/deck_imu.c:130: The probe discards a newly opened candidate when no report has arrived at the instant of its first nonblocking read. (more on the line) Do: Keep the candidate descriptor open across polls for a bounded interval, reading it nonblockingly until a valid report arrives or the probe expires, then advance to the next candidate.

@fix can do L12.

Since the last review (on 728f14aec3)
Resolved: L1 (Presence is reported for every Valve hidraw device, without establishing that it is a Deck…); L2 (The fallback waits synchronously for each candidate hidraw node on the SDL polling thread.); L3 (A failed read of the original IMU setting is treated as permission to overwrite it and lat…); L4 (The Deck reader remains open and its IMU setting remains owned after a sensor-bearing SDL…); L5 (Restoring the initially saved mode unconditionally can overwrite a later change made by St…); L6 (FD_SET is used without checking whether the opened descriptor fits in fd_set.); L7 (The new test hard-codes gcc instead of using the compiler selected by the test runner.); L11 (The check CI / Game-free checks (run_all.py, part 1/2) (pull_request) fails on this head…)
Still open: L8 (The check CI / Third-party parts and guide screenshots (pull_request) fails on this head…); L9 (The check CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) fails on th…); L10 (The check CI / Game-free checks (run_all.py, part 2/2) (pull_request) fails on this head…)
New: L12 (The probe discards a newly opened candidate when no report has arrived at the instant of i…)

Checks: Failing on this head, which is behind its base, where they pass: CI / Third-party parts and guide screenshots (pull_request), CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request), CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request), CI / Game-free checks (run_all.py, part 2/2) (pull_request). @rebase (or @fix) brings it up to date and runs them again; not held against it.

Also noticed (2; not asked for, not blocking)
  • The pull request says Still to test is None although its own Testing section says the current head’s Deck run is pending.
  • The reader can re-enable sensors after detecting unchanged readings, including after Steam turns them off during the run.
More: does it help, other systems, switches, what was read

Does it help: Unproven on this head. The author reports working gyro aim on an LCD Deck and an OLED report on the earlier implementation; the revised discovery and setting ownership have not been run in game.

Other systems: SDL sensor-bearing pads retain priority; Windows uses the no-op fallback. Linux hidraw discovery and feature reports affect the Deck path, whose revised behavior needs an in-game run.

Switches: HOS_DECK_IMU is added, on by default; =0 disables the fallback. The table documents it, but the on default’s behavior needs validation on this head.

Reviewed: 72117fa8c6 against 86b3b9e4f0: Read the diff, commit, host/deck_imu.c, host/deck_imu.h, tests/test_deck_imu.py, AGENTS.md, CONTRIBUTING.md and the pull request template; inspected the changed motion path in host/pad_sdl.c. The switch table and remainder of pad_sdl.c were skimmed.; nothing run (a code review).

Checked and fine:

  • The parser checks the report version, type and length before extracting sensor fields.
  • The Deck source has its own motion-filter identity and the reader is stopped at shutdown.

Testing: No commands from the project or tests were run. The author reports parser and controller checks and in-game runs on the previous head; the revised head still needs a Deck Game Mode run after the probe is corrected.

Overlaps and merge order: #1181 addresses the same visible issue through SDL and is described as nonconflicting; no merge order was established.


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

**Recommendation: Request changes.** The new probe closes a candidate immediately when its first nonblocking read finds no packet, so the Deck controller can remain undiscovered and motion aim unavailable. The earlier in-game results predate this probe. The change adds a fallback for the Steam Deck’s built-in motion sensors while leaving SDL pads first. It removes the previous synchronous probe wait, but the replacement can discard the controller before its first report arrives. **Blocking (1)**: must change before merging. 1. **L12** `host/deck_imu.c:130`: The probe discards a newly opened candidate when no report has arrived at the instant of its first nonblocking read. (more on the line) **Do:** Keep the candidate descriptor open across polls for a bounded interval, reading it nonblockingly until a valid report arrives or the probe expires, then advance to the next candidate. `@fix` can do L12. **Since the last review** (on 728f14aec323) Resolved: L1 (Presence is reported for every Valve hidraw device, without establishing that it is a Deck…); L2 (The fallback waits synchronously for each candidate hidraw node on the SDL polling thread.); L3 (A failed read of the original IMU setting is treated as permission to overwrite it and lat…); L4 (The Deck reader remains open and its IMU setting remains owned after a sensor-bearing SDL…); L5 (Restoring the initially saved mode unconditionally can overwrite a later change made by St…); L6 (FD_SET is used without checking whether the opened descriptor fits in fd_set.); L7 (The new test hard-codes gcc instead of using the compiler selected by the test runner.); L11 (The check `CI / Game-free checks (run_all.py, part 1/2) (pull_request)` fails on this head…) Still open: L8 (The check `CI / Third-party parts and guide screenshots (pull_request)` fails on this head…); L9 (The check `CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request)` fails on th…); L10 (The check `CI / Game-free checks (run_all.py, part 2/2) (pull_request)` fails on this head…) New: L12 (The probe discards a newly opened candidate when no report has arrived at the instant of i…) **Checks:** Failing on this head, which is behind its base, where they pass: `CI / Third-party parts and guide screenshots (pull_request)`, `CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request)`, `CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request)`, `CI / Game-free checks (run_all.py, part 2/2) (pull_request)`. `@rebase` (or `@fix`) brings it up to date and runs them again; not held against it. <details> <summary>Also noticed (2; not asked for, not blocking)</summary> - The pull request says Still to test is None although its own Testing section says the current head’s Deck run is pending. - The reader can re-enable sensors after detecting unchanged readings, including after Steam turns them off during the run. </details> <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven on this head. The author reports working gyro aim on an LCD Deck and an OLED report on the earlier implementation; the revised discovery and setting ownership have not been run in game. **Other systems:** SDL sensor-bearing pads retain priority; Windows uses the no-op fallback. Linux hidraw discovery and feature reports affect the Deck path, whose revised behavior needs an in-game run. **Switches:** HOS_DECK_IMU is added, on by default; =0 disables the fallback. The table documents it, but the on default’s behavior needs validation on this head. **Reviewed:** 72117fa8c652 against 86b3b9e4f0e1: Read the diff, commit, host/deck_imu.c, host/deck_imu.h, tests/test_deck_imu.py, AGENTS.md, CONTRIBUTING.md and the pull request template; inspected the changed motion path in host/pad_sdl.c. The switch table and remainder of pad_sdl.c were skimmed.; nothing run (a code review). **Checked and fine:** - The parser checks the report version, type and length before extracting sensor fields. - The Deck source has its own motion-filter identity and the reader is stopped at shutdown. **Testing:** No commands from the project or tests were run. The author reports parser and controller checks and in-game runs on the previous head; the revised head still needs a Deck Game Mode run after the probe is corrected. **Overlaps and merge order:** #1181 addresses the same visible issue through SDL and is described as nonconflicting; no merge order was established. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
host/deck_imu.c Outdated
@ -0,0 +127,4 @@
uint8_t pkt[DECK_IMU_REPORT_BYTES];
float a[3], g[3];
const ssize_t n = read(fd, pkt, sizeof pkt);
if (n != (ssize_t)sizeof pkt || !deck_imu_parse(pkt, (int)n, a, g)) {
Member

L12 (blocking): The probe discards a newly opened candidate when no report has arrived at the instant of its first nonblocking read.

When: A hidraw file’s report queue starts empty at open. If the Deck’s next state report arrives after this immediate read, read returns EAGAIN and the descriptor is closed; subsequent attempts reopen an empty queue, so the fallback can fail to find the controller and gyro aim remains unavailable.

Do: Keep the candidate descriptor open across polls for a bounded interval, reading it nonblockingly until a valid report arrives or the probe expires, then advance to the next candidate.

**L12** (blocking): The probe discards a newly opened candidate when no report has arrived at the instant of its first nonblocking read. *When:* A hidraw file’s report queue starts empty at open. If the Deck’s next state report arrives after this immediate read, read returns EAGAIN and the descriptor is closed; subsequent attempts reopen an empty queue, so the fallback can fail to find the controller and gyro aim remains unavailable. **Do:** Keep the candidate descriptor open across polls for a bounded interval, reading it nonblockingly until a valid report arrives or the probe expires, then advance to the next candidate.
Owner
@fix
BeanBot force-pushed deck-imu from 72117fa8c6
Some checks failed
CI / What the change needs (pull_request) Successful in 12s
CI / Third-party parts and guide screenshots (pull_request) Failing after 15s
beanstalk/approval not approved yet
PR description / Title and description (pull_request_target) Successful in 13s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Failing after 1m48s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Failing after 5m16s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Successful in 2m24s
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Successful in 3m31s
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Successful in 2m48s
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Successful in 10m17s
CI / Website build and checks (pull_request) Successful in 3m17s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Failing after 21m34s
to 0293c11553
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website preview, built by CI (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
PR description / Title and description (pull_request_target) Failing after 9s
CI / What the change needs (pull_request) Successful in 12s
CI / Third-party parts and guide screenshots (pull_request) Successful in 18s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 22s
beanstalk/approval not approved yet
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Successful in 2m26s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Successful in 1m14s
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Successful in 1m22s
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Successful in 1m55s
CI / Website build and checks (pull_request) Failing after 2m4s
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Failing after 17m43s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Failing after 26m46s
2026-11-27 23:06:07 +00:00
Compare
BeanBot left a comment

Recommendation: Approve. The probe now keeps a candidate open across polls, allowing its first report to arrive without waiting on the device. The current probe and setting-ownership changes still need the planned in-game Steam Deck run. Nothing blocking is left. Recommend approval; not approved on the forge.

What @fix changed
I changed this pull request: the new head is 0293c11553. I rebased it onto main (9b7aaea4a0). I edited its description to match the change.

Changed

  • Keep Deck IMU probe candidates open across polls: In host/deck_imu.c:116, candidates remain open for a bounded probe period and are read nonblockingly until a valid report arrives; expired candidates and stopped readers close their descriptors. Builds and tests were not run, as requested.

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

The change gives Deck players gyro aim when Steam Input exposes only a virtual pad, while retaining SDL's sensor path for other controllers. The fallback adds a hidraw reader and feature-report handling.

Checks: they run again on this head (CI / Third-party parts and guide screenshots (pull_request), CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request), CI / Game-free checks (run_all.py, part 2/2) (pull_request), CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) failed on the last one); a failure shows on the pull request.

Also noticed (4; not asked for, not blocking)
  • The PR description says there is nothing still to test, although its testing section says the revised discovery and ownership paths have not yet run in game.
  • The retained-candidate behavior has no game-free behavioral test for an initially empty read followed by a valid report.
  • The current head needs an in-game Deck run covering candidate discovery and gyro aim; CI has not run on it yet.
  • The supplied base diff includes unrelated upstream changes beyond the five files described in the pull request.
More: does it help, other systems, switches, what was read

Does it help: Unproven on the current head. The author reports working gyro aim on an LCD Deck and an OLED on an earlier revision, but the revised probe has not yet been run in the game.

Other systems: The reader is Linux-only; other platforms use the existing SDL path. A sensor-bearing SDL pad takes precedence and closes the fallback. The current head has not yet been tested on Deck hardware.

Switches: HOS_DECK_IMU is added, defaults on, and is listed in switches.def. Its off state was tested on the earlier revision; the current default still needs the planned Deck run.

Reviewed: 0293c11553 against 9b7aaea4a0: Read AGENTS.md, CONTRIBUTING.md, docs/dev/standards.md, the PR template, host/deck_imu.c, host/deck_imu.h, tests/test_deck_imu.py, the probe fix diff, and the relevant pad and switch changes. Skimmed the wider base diff and commit list; the base diff includes many unrelated upstream changes. Tooling's AGENTS.md was not present locally.; nothing run (a code review).

Checked and fine:

  • A candidate stays open across polls until a valid report, an error, or the probe deadline; stopping the reader closes a pending candidate.
  • The fix retains nonblocking reads and does not remove the Deck fallback.
  • The SDL sensor path remains preferred, and the fallback is released when a sensor-bearing pad takes over or motion controls are disabled.

Testing: No commands that build or run tests were executed. The author reports passing game-free checks and earlier Deck runs; the current head's game run and CI are pending.

Overlaps and merge order: #1181 addresses the same Steam Input gyro problem through SDL; the description says the two changes do not conflict.


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 probe now keeps a candidate open across polls, allowing its first report to arrive without waiting on the device. The current probe and setting-ownership changes still need the planned in-game Steam Deck run. Nothing blocking is left. Recommend approval; not approved on the forge. **What `@fix` changed** I changed this pull request: the new head is 0293c1155335. I rebased it onto `main` (9b7aaea4a0e2). I edited its description to match the change. **Changed** - **Keep Deck IMU probe candidates open across polls**: In host/deck_imu.c:116, candidates remain open for a bounded probe period and are read nonblockingly until a valid report arrives; expired candidates and stopped readers close their descriptors. Builds and tests were not run, as requested. Nothing was built or run: the checks run again on the new head. The change gives Deck players gyro aim when Steam Input exposes only a virtual pad, while retaining SDL's sensor path for other controllers. The fallback adds a hidraw reader and feature-report handling. **Checks:** they run again on this head (`CI / Third-party parts and guide screenshots (pull_request)`, `CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request)`, `CI / Game-free checks (run_all.py, part 2/2) (pull_request)`, `CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request)` failed on the last one); a failure shows on the pull request. <details> <summary>Also noticed (4; not asked for, not blocking)</summary> - The PR description says there is nothing still to test, although its testing section says the revised discovery and ownership paths have not yet run in game. - The retained-candidate behavior has no game-free behavioral test for an initially empty read followed by a valid report. - The current head needs an in-game Deck run covering candidate discovery and gyro aim; CI has not run on it yet. - The supplied base diff includes unrelated upstream changes beyond the five files described in the pull request. </details> <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven on the current head. The author reports working gyro aim on an LCD Deck and an OLED on an earlier revision, but the revised probe has not yet been run in the game. **Other systems:** The reader is Linux-only; other platforms use the existing SDL path. A sensor-bearing SDL pad takes precedence and closes the fallback. The current head has not yet been tested on Deck hardware. **Switches:** HOS_DECK_IMU is added, defaults on, and is listed in switches.def. Its off state was tested on the earlier revision; the current default still needs the planned Deck run. **Reviewed:** 0293c1155335 against 9b7aaea4a0e2: Read AGENTS.md, CONTRIBUTING.md, docs/dev/standards.md, the PR template, host/deck_imu.c, host/deck_imu.h, tests/test_deck_imu.py, the probe fix diff, and the relevant pad and switch changes. Skimmed the wider base diff and commit list; the base diff includes many unrelated upstream changes. Tooling's AGENTS.md was not present locally.; nothing run (a code review). **Checked and fine:** - A candidate stays open across polls until a valid report, an error, or the probe deadline; stopping the reader closes a pending candidate. - The fix retains nonblocking reads and does not remove the Deck fallback. - The SDL sensor path remains preferred, and the fallback is released when a sensor-bearing pad takes over or motion controls are disabled. **Testing:** No commands that build or run tests were executed. The author reports passing game-free checks and earlier Deck runs; the current head's game run and CI are pending. **Overlaps and merge order:** #1181 addresses the same Steam Input gyro problem through SDL; the description says the two changes do not conflict. </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>
HumanBean deleted branch deck-imu 2026-11-27 23:08:34 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
4 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!2660
No description provided.