fix(input): a Steam Deck at rest no longer has its motion sensors turned off and on every few seconds #1796

Merged
HumanBean merged 2 commits from zeldaootr/Longshot:gyro-rest-guard into main 2026-11-20 22:57:16 +00:00
Contributor

Summary

A Steam Deck lying still had its motion sensors switched off and on again every few seconds, because the game took a gyroscope that reads the same values at rest for a broken one. This PR only does that when the accelerometer is frozen too, which a working one never is. On a Deck at rest for ten minutes that is 0 switch-offs instead of 5; a new game-free test fails on main and passes here. It helps Steam Deck players whose built-in gyro the game reads (Motion controls On), and any pad whose gyroscope reads exactly the same values while it lies still. The rule's 1.2 s threshold and 3 s wait, the pads it applies to, and every setting and default do not change.

Why: when the game reads a Steam Deck's built-in gyro, its frozen-gyro rule (from MagicBeanDev/Hookshot#2036, made for a Steam Controller whose gyro died after Alt+Tab under Steam) fires on a healthy Deck that is simply lying still: each time it turns the motion sensors off and on, and the motion filter starts again. omgitsgela saw it on a Steam Deck LCD with the built-in pad opened through SDL: the rule "fired 102 times in ten minutes" (#1477, their comment of 2026-11-19 06:34). On this PC's earlier headless Deck runs it wrote 32,490 such lines across 746 distinct Deck run logs. It matters more once #1181 lets the game read the Deck's gyro when Steam starts it: with that PR alone, a Deck at rest re-arms 5 times in ten minutes (Measurements). The tracker was searched (gyro, motion, frozen, re-arm, "stopped changing"): issue 1477's comment above is the only report; no issue or pull request covers the fix.

The bug on main: on a Steam Deck (seen on a Steam Deck OLED, SteamOS 3.9.5, RADV VANGOGH, Mesa 26.2.0-devel; also on a Steam Deck LCD by omgitsgela), with Motion controls On (the default) and the Deck's built-in pad opened through SDL (the game started outside Steam, or with #1181 from Steam), HOS_MOTION_DEBUG=1 optional: load a save, put the Deck down and leave it still for ten minutes, then count stopped changing in longshot_log.txt. Expected none: the gyro works. Instead there are lines like hid: "Steam Deck Controller": its gyroscope stopped changing: motion sensors turned off and on again, 5 in ten minutes in the stand below, 102 in omgitsgela's.

Read first:

  • input: motion_poll in host/pad_sdl.c keeps the last accelerometer reading beside the gyroscope's and compares both; the rule calls the sensors stopped only when both read the very same values, and the log line reads its gyroscope and accelerometer stopped changing.
  • tests: tests/test_gyro_rearm.py gets the Deck's case (the gyroscope repeating, the accelerometer moving by its last bit: no re-arm) and keeps the frozen-both case re-arming.

See #1477

Testing

Tested: in the game, three headless stands on a Steam Deck OLED (SteamOS 3.9.5, RADV Mesa 26.2.0-devel), 600 s each in Kokiri Forest with Motion controls On, the game started over ssh with Steam's controller variables set by hand, the Deck at rest: the fix's build reads the Deck's gyro throughout and writes no re-arm line, where the build without it writes 5. Those builds were this change on main plus #1181 (7e1a68a43, the same diff), not this branch alone, built on main 9ea65c7bf.

Game-free, on Linux x86-64, in the PC's job queue, at this head (0181f7357 on main 068fb8ebe): tests/test_gyro_rearm.py fails at the test-only commit 3dc2ae618 (FAIL:46 offs == 0 && pads[0].motion_on == 1 && logs == 0) and passes here. the 16 checks that read its files (run_all.py --changed forge/main): all pass; and the whole python3 -I -B tests/run_all.py (not --strict) here and on main 068fb8ebe, back to back in the same environment: here 781 passed, 61 failed, 28 skipped; main 782 passed, 60 failed, 28 skipped. Every check that fails here fails on main too, but test_prepare_stall, a timed check that failed here in the loaded 16-way run and passes alone (twice); main's failures are this PC's environment (tools, modules and timing). host/pad_sdl.c compiled (-c, the build's host flags, -Wall) with gcc and clang for Linux and llvm-mingw 20261104 for Windows, at this head and on main 068fb8ebe: the same one warning on both, from a generated header, none of its own.

The 59 checks that fail both here (0181f7357) and on main 068fb8ebe

test_appimage_player_build, test_bug_report_defaults, test_capture_read_once, test_capture_readback_visibility, test_crash_dialog, test_crt_options, test_damage_debug_menu, test_dev_ab, test_dev_packs, test_discover, test_display_startup_failure, test_dlss_feature_size, test_draw_stream_visibility, test_failed_compile_keeps_objects, test_frame_overlap, test_fsr3fi_hud_layer, test_fsr_image_retirement, test_fsr_uniform_ownership, test_guest_imported, test_high_fps_fixes, test_host_guest_writes, test_hud_layout_row, test_libc_hooks, test_lift_cache, test_lift_lookups, test_linux_preflight, test_linux_pressure, test_linux_tools, test_linux_update, test_log_open_failure, test_make_game_cache, test_make_game_ngx, test_mise_build, test_missing_nup, test_mods_list, test_mods_size_table, test_ngx_sdk, test_nonuniform_image_arrays, test_parallel_init_order, test_pending_guest_import, test_pipeline_play_cache, test_prepare_cache_save, test_present_queue_default, test_present_source_crop, test_present_thread, test_profiling_mode, test_psychov35_fsr3_fg, test_readback_timeout_source, test_replay_write_order, test_slow_frames, test_song_note_cue, test_staging_burst, test_texel_buffer_ownership, test_thinlto_tls, test_upscaler_rows, test_vcore_escape, test_vk_occlusion_queries, test_walk, test_walk_key

The case the rule was made for, a Steam Controller whose gyro Steam leaves off after Alt+Tab, can't be run here: there is no Steam Controller. What stands in is tests/test_gyro_rearm.py's frozen-both case (both sensors repeating for over 1.2 s still re-arm, once, and not again within 3 s). The fix assumes that Steam turning the sensor unit off freezes the accelerometer too; that is not verified on hardware. Not run either: whether these re-arms are what made the camera move twice in omgitsgela's report (the stands had no one at the controls); SDL3's Steam Deck driver internals (why its gyro repeats at rest) were not read.

Still to test:

  • Windows or Linux, any GPU, a Steam Controller started from Steam with Motion controls On: aim with the gyro, Alt+Tab away and back, aim again, expecting the gyro to keep working, or to come back by itself with one hid: "Steam Controller": its gyroscope and accelerometer stopped changing: motion sensors turned off and on again line in longshot_log.txt (by hand: someone with a Steam Controller; look at the aim after Alt+Tab and the log)
  • Steam Deck LCD and a Deck in Game Mode from the Steam shortcut, this branch (with #1181 for the Steam start): ten minutes at rest, expecting no stopped changing line and the gyro aiming after (by hand)
  • Other pads with a gyro (DualSense, DualShock 4, Switch Pro): aim with the gyro, expecting it to behave as on main, their accelerometers being expected to keep moving (by hand)

Measurements

Verdict: fixed: on a Steam Deck OLED at rest for 600 s, 5 re-arm lines without the fix and 0 with it, motion read throughout in both; the new test fails on main and passes here.

Baseline: main plus #1181 @ 5306ca05d, not main. On main, a game started the way Steam starts it keeps the Deck's built-in pad in Steam's ignore list, so SDL never opens its gyro and the rule never runs; #1181 takes it out. The after column is the same build plus this PR's two commits (7e1a68a43, the same diff as this branch's). Both were built on main 9ea65c7bf; this branch is now on main 068fb8ebe, whose changes to host/pad_sdl.c since (vibration, and comments) do not touch motion_poll or the ignore list, so the numbers still hold.
Setup: Steam Deck OLED, SteamOS 3.9.5 (Linux 7.2.7-valve2), RADV VANGOGH Mesa 26.2.0-devel (git-5c65d4fc31), AMD Custom APU 0932, 16 GB; Kokiri Forest (child), Link standing; headless (HOS_HEADLESS=1), Game Mode running, the game started over ssh with Steam's controller variables set by hand; Motion controls On. The rule's log lines (grep -c 'stopped changing') and the HOS_MOTION_DEBUG=1 motion lines in each run's log, over 600 s standing after the save loaded, the Deck at rest tilted back (accel about (0, -0.88, -0.36) G), on AC, not touched; one stand each, back to back (no fix, fix), plus a third with HOS_DECK_GYRO=0 as a control. A count, not a timing: one run each. To reproduce: a scratch game folder with a Kokiri Forest save; SDL_GAMECONTROLLER_IGNORE_DEVICES=0x28de/0x1205 SDL_GAMECONTROLLER_ALLOW_STEAM_VIRTUAL_GAMEPAD=1 HOS_MOTION_DEBUG=1 HOS_HEADLESS=1 RX_VK_PRECOMPILE=0, load the save, leave the Deck still 600 s, grep -c 'stopped changing' longshot_log.txt.

Before: main + PR 1181 @ 5306ca05d After: main + PR 1181 + this PR @ 7e1a68a43 After, HOS_DECK_GYRO=0: main + PR 1181 @ 5306ca05d
re-arm lines in 600 s at rest 5 (about 1.5 to 5.5 min in, none after) 0 0
motion debug lines (gyro shown as +0.000) 1346 1331 0 (no gyro opened)
motion controls from "Steam Deck Controller" once once none
exit 0 0 0
tests/test_gyro_rearm.py fails (main @ 068fb8ebe with this PR's test, 3dc2ae618) passes (this PR @ 0181f7357)
before (5306ca05d), 5 of these:
[hos host] hid: "Steam Deck Controller": its gyroscope stopped changing: motion sensors turned off and on again
[hos host] hid: motion: accel (-0.00, -0.88, -0.36) G, gyro (+0.000, +0.000, +0.000) turns/s, direction rows (+1.00 -0.00 +0.00 / -0.00 +0.38 +0.93 / -0.00 -0.93 +0.38), bias (-0.0000, -0.0000, -0.0000)

after (7e1a68a43): grep -c 'stopped changing' -> 0
[hos host] hid: motion controls from "Steam Deck Controller"
[hos host] hid: motion: accel (-0.00, -0.88, -0.36) G, gyro (+0.000, +0.000, +0.000) turns/s, direction rows (+1.00 -0.00 +0.00 / -0.00 +0.38 +0.93 / -0.00 -0.93 +0.38), bias (-0.0000, +0.0000, +0.0000)

HOS_DECK_GYRO=0: only "Steam Virtual Gamepad" opened, 0 motion lines, 0 re-arm lines

tests/test_gyro_rearm.py, this PR's version on main 068fb8ebe (3dc2ae618):
FAIL:46 offs == 0 && pads[0].motion_on == 1 && logs == 0
tests/test_gyro_rearm.py on this PR (0181f7357):
PASS: a frozen gyroscope's sensors are turned off and on again, at most every 3 s; a changing one, or one at rest beside a moving accelerometer, never

Earlier logs on this PC: its logs of earlier Deck runs (2026-11-14 to 2026-11-16: performance series and soaks started over ssh, outside Steam, so SDL opened the Deck's built-in pad directly; development builds of main and of pull requests on main, v3.0.0-rc.3 to v3.0.0) hold 32,490 gyroscope stopped changing lines in 746 distinct runs (counted once per run_id, copies left out), the most 617 in one 2,195 s soak.

Risks

A pad whose gyro dies while its accelerometer keeps moving would no longer be turned off and on by itself; the player would have to toggle Motion controls in the menu, as before MagicBeanDev/Hookshot#2036. Only the Steam Controller Alt+Tab case is known to need the rule, and it is not run on hardware here: if Steam's Alt+Tab leaves a Steam Controller's accelerometer moving while its gyro is dead, that case would no longer recover by itself. A revert is enough to undo it. After updating, saves, longshot_options.ini, the caches and the vk ABI are untouched; the log line's wording changes (its gyroscope and accelerometer stopped changing), so a search for gyroscope stopped changing no longer matches it, while stopped changing still does.

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. [a Steam Deck OLED, this change on main plus pull 1181, the same diff]
  • mise run test passes (any failure that also fails on main is named).
  • Measured against main, or Measurements says why there is nothing to measure. [against main plus pull 1181, which the Baseline line explains]
  • 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 check under tests/ that reads changed source is updated, not weakened.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested. [the Steam Controller, the Deck LCD and Game Mode, other gyro pads not run]
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). [the Steam Deck OLED only, headless with Steam's variables set by hand; Windows and Linux PCs with a gyro pad not run]
  • Approved in review, every comment answered. [no review yet]
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold. [the head is not pushed yet; why the numbers still hold is in Measurements' Baseline]
## Summary A Steam Deck lying still had its motion sensors switched off and on again every few seconds, because the game took a gyroscope that reads the same values at rest for a broken one. This PR only does that when the accelerometer is frozen too, which a working one never is. On a Deck at rest for ten minutes that is 0 switch-offs instead of 5; a new game-free test fails on `main` and passes here. It helps Steam Deck players whose built-in gyro the game reads (Motion controls On), and any pad whose gyroscope reads exactly the same values while it lies still. The rule's 1.2 s threshold and 3 s wait, the pads it applies to, and every setting and default do not change. Why: when the game reads a Steam Deck's built-in gyro, its frozen-gyro rule (from https://git.magicbean.dev/MagicBeanDev/Hookshot/pulls/2036, made for a Steam Controller whose gyro died after Alt+Tab under Steam) fires on a healthy Deck that is simply lying still: each time it turns the motion sensors off and on, and the motion filter starts again. omgitsgela saw it on a Steam Deck LCD with the built-in pad opened through SDL: the rule "fired **102 times in ten minutes**" (https://git.magicbean.dev/MagicBeanDev/Longshot/issues/1477, their comment of 2026-11-19 06:34). On this PC's earlier headless Deck runs it wrote 32,490 such lines across 746 distinct Deck run logs. It matters more once https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1181 lets the game read the Deck's gyro when Steam starts it: with that PR alone, a Deck at rest re-arms 5 times in ten minutes (Measurements). The tracker was searched (gyro, motion, frozen, re-arm, "stopped changing"): issue 1477's comment above is the only report; no issue or pull request covers the fix. **The bug on `main`:** on a Steam Deck (seen on a Steam Deck OLED, SteamOS 3.9.5, RADV VANGOGH, Mesa 26.2.0-devel; also on a Steam Deck LCD by omgitsgela), with Motion controls On (the default) and the Deck's built-in pad opened through SDL (the game started outside Steam, or with https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1181 from Steam), `HOS_MOTION_DEBUG=1` optional: load a save, put the Deck down and leave it still for ten minutes, then count `stopped changing` in `longshot_log.txt`. Expected none: the gyro works. Instead there are lines like `hid: "Steam Deck Controller": its gyroscope stopped changing: motion sensors turned off and on again`, 5 in ten minutes in the stand below, 102 in omgitsgela's. Read first: - input: `motion_poll` in `host/pad_sdl.c` keeps the last accelerometer reading beside the gyroscope's and compares both; the rule calls the sensors stopped only when both read the very same values, and the log line reads `its gyroscope and accelerometer stopped changing`. - tests: `tests/test_gyro_rearm.py` gets the Deck's case (the gyroscope repeating, the accelerometer moving by its last bit: no re-arm) and keeps the frozen-both case re-arming. See https://git.magicbean.dev/MagicBeanDev/Longshot/issues/1477 ## Testing **Tested:** in the game, three headless stands on a Steam Deck OLED (SteamOS 3.9.5, RADV Mesa 26.2.0-devel), 600 s each in Kokiri Forest with Motion controls On, the game started over ssh with Steam's controller variables set by hand, the Deck at rest: the fix's build reads the Deck's gyro throughout and writes no re-arm line, where the build without it writes 5. Those builds were this change on main plus https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1181 (7e1a68a43, the same diff), not this branch alone, built on main 9ea65c7bf. Game-free, on Linux x86-64, in the PC's job queue, at this head (0181f7357 on main 068fb8ebe): `tests/test_gyro_rearm.py` fails at the test-only commit 3dc2ae618 (`FAIL:46 offs == 0 && pads[0].motion_on == 1 && logs == 0`) and passes here. the 16 checks that read its files (`run_all.py --changed forge/main`): all pass; and the whole `python3 -I -B tests/run_all.py` (not `--strict`) here and on main 068fb8ebe, back to back in the same environment: here 781 passed, 61 failed, 28 skipped; main 782 passed, 60 failed, 28 skipped. Every check that fails here fails on main too, but `test_prepare_stall`, a timed check that failed here in the loaded 16-way run and passes alone (twice); main's failures are this PC's environment (tools, modules and timing). `host/pad_sdl.c` compiled (`-c`, the build's host flags, `-Wall`) with gcc and clang for Linux and llvm-mingw 20261104 for Windows, at this head and on main 068fb8ebe: the same one warning on both, from a generated header, none of its own. <details><summary>The 59 checks that fail both here (0181f7357) and on main 068fb8ebe</summary> `test_appimage_player_build`, `test_bug_report_defaults`, `test_capture_read_once`, `test_capture_readback_visibility`, `test_crash_dialog`, `test_crt_options`, `test_damage_debug_menu`, `test_dev_ab`, `test_dev_packs`, `test_discover`, `test_display_startup_failure`, `test_dlss_feature_size`, `test_draw_stream_visibility`, `test_failed_compile_keeps_objects`, `test_frame_overlap`, `test_fsr3fi_hud_layer`, `test_fsr_image_retirement`, `test_fsr_uniform_ownership`, `test_guest_imported`, `test_high_fps_fixes`, `test_host_guest_writes`, `test_hud_layout_row`, `test_libc_hooks`, `test_lift_cache`, `test_lift_lookups`, `test_linux_preflight`, `test_linux_pressure`, `test_linux_tools`, `test_linux_update`, `test_log_open_failure`, `test_make_game_cache`, `test_make_game_ngx`, `test_mise_build`, `test_missing_nup`, `test_mods_list`, `test_mods_size_table`, `test_ngx_sdk`, `test_nonuniform_image_arrays`, `test_parallel_init_order`, `test_pending_guest_import`, `test_pipeline_play_cache`, `test_prepare_cache_save`, `test_present_queue_default`, `test_present_source_crop`, `test_present_thread`, `test_profiling_mode`, `test_psychov35_fsr3_fg`, `test_readback_timeout_source`, `test_replay_write_order`, `test_slow_frames`, `test_song_note_cue`, `test_staging_burst`, `test_texel_buffer_ownership`, `test_thinlto_tls`, `test_upscaler_rows`, `test_vcore_escape`, `test_vk_occlusion_queries`, `test_walk`, `test_walk_key` </details> The case the rule was made for, a Steam Controller whose gyro Steam leaves off after Alt+Tab, can't be run here: there is no Steam Controller. What stands in is `tests/test_gyro_rearm.py`'s frozen-both case (both sensors repeating for over 1.2 s still re-arm, once, and not again within 3 s). The fix assumes that Steam turning the sensor unit off freezes the accelerometer too; that is not verified on hardware. Not run either: whether these re-arms are what made the camera move twice in omgitsgela's report (the stands had no one at the controls); SDL3's Steam Deck driver internals (why its gyro repeats at rest) were not read. **Still to test:** - Windows or Linux, any GPU, a Steam Controller started from Steam with Motion controls On: aim with the gyro, Alt+Tab away and back, aim again, expecting the gyro to keep working, or to come back by itself with one `hid: "Steam Controller": its gyroscope and accelerometer stopped changing: motion sensors turned off and on again` line in `longshot_log.txt` (by hand: someone with a Steam Controller; look at the aim after Alt+Tab and the log) - Steam Deck LCD and a Deck in Game Mode from the Steam shortcut, this branch (with https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1181 for the Steam start): ten minutes at rest, expecting no `stopped changing` line and the gyro aiming after (by hand) - Other pads with a gyro (DualSense, DualShock 4, Switch Pro): aim with the gyro, expecting it to behave as on `main`, their accelerometers being expected to keep moving (by hand) ## Measurements **Verdict:** fixed: on a Steam Deck OLED at rest for 600 s, 5 re-arm lines without the fix and 0 with it, motion read throughout in both; the new test fails on `main` and passes here. Baseline: main plus https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1181 @ 5306ca05d, not main. On main, a game started the way Steam starts it keeps the Deck's built-in pad in Steam's ignore list, so SDL never opens its gyro and the rule never runs; https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1181 takes it out. The after column is the same build plus this PR's two commits (7e1a68a43, the same diff as this branch's). Both were built on main 9ea65c7bf; this branch is now on main 068fb8ebe, whose changes to `host/pad_sdl.c` since (vibration, and comments) do not touch `motion_poll` or the ignore list, so the numbers still hold. Setup: Steam Deck OLED, SteamOS 3.9.5 (Linux 7.2.7-valve2), RADV VANGOGH Mesa 26.2.0-devel (git-5c65d4fc31), AMD Custom APU 0932, 16 GB; Kokiri Forest (child), Link standing; headless (`HOS_HEADLESS=1`), Game Mode running, the game started over ssh with Steam's controller variables set by hand; Motion controls On. The rule's log lines (`grep -c 'stopped changing'`) and the `HOS_MOTION_DEBUG=1` motion lines in each run's log, over 600 s standing after the save loaded, the Deck at rest tilted back (accel about (0, -0.88, -0.36) G), on AC, not touched; one stand each, back to back (no fix, fix), plus a third with `HOS_DECK_GYRO=0` as a control. A count, not a timing: one run each. To reproduce: a scratch game folder with a Kokiri Forest save; `SDL_GAMECONTROLLER_IGNORE_DEVICES=0x28de/0x1205 SDL_GAMECONTROLLER_ALLOW_STEAM_VIRTUAL_GAMEPAD=1 HOS_MOTION_DEBUG=1 HOS_HEADLESS=1 RX_VK_PRECOMPILE=0`, load the save, leave the Deck still 600 s, `grep -c 'stopped changing' longshot_log.txt`. | | Before: main + PR 1181 @ 5306ca05d | After: main + PR 1181 + this PR @ 7e1a68a43 | After, HOS_DECK_GYRO=0: main + PR 1181 @ 5306ca05d | |---|---|---|---| | re-arm lines in 600 s at rest | 5 (about 1.5 to 5.5 min in, none after) | 0 | 0 | | motion debug lines (gyro shown as +0.000) | 1346 | 1331 | 0 (no gyro opened) | | `motion controls from "Steam Deck Controller"` | once | once | none | | exit | 0 | 0 | 0 | | `tests/test_gyro_rearm.py` | fails (main @ 068fb8ebe with this PR's test, 3dc2ae618) | passes (this PR @ 0181f7357) | | ``` before (5306ca05d), 5 of these: [hos host] hid: "Steam Deck Controller": its gyroscope stopped changing: motion sensors turned off and on again [hos host] hid: motion: accel (-0.00, -0.88, -0.36) G, gyro (+0.000, +0.000, +0.000) turns/s, direction rows (+1.00 -0.00 +0.00 / -0.00 +0.38 +0.93 / -0.00 -0.93 +0.38), bias (-0.0000, -0.0000, -0.0000) after (7e1a68a43): grep -c 'stopped changing' -> 0 [hos host] hid: motion controls from "Steam Deck Controller" [hos host] hid: motion: accel (-0.00, -0.88, -0.36) G, gyro (+0.000, +0.000, +0.000) turns/s, direction rows (+1.00 -0.00 +0.00 / -0.00 +0.38 +0.93 / -0.00 -0.93 +0.38), bias (-0.0000, +0.0000, +0.0000) HOS_DECK_GYRO=0: only "Steam Virtual Gamepad" opened, 0 motion lines, 0 re-arm lines tests/test_gyro_rearm.py, this PR's version on main 068fb8ebe (3dc2ae618): FAIL:46 offs == 0 && pads[0].motion_on == 1 && logs == 0 tests/test_gyro_rearm.py on this PR (0181f7357): PASS: a frozen gyroscope's sensors are turned off and on again, at most every 3 s; a changing one, or one at rest beside a moving accelerometer, never ``` Earlier logs on this PC: its logs of earlier Deck runs (2026-11-14 to 2026-11-16: performance series and soaks started over ssh, outside Steam, so SDL opened the Deck's built-in pad directly; development builds of main and of pull requests on main, v3.0.0-rc.3 to v3.0.0) hold 32,490 `gyroscope stopped changing` lines in 746 distinct runs (counted once per `run_id`, copies left out), the most 617 in one 2,195 s soak. ## Risks A pad whose gyro dies while its accelerometer keeps moving would no longer be turned off and on by itself; the player would have to toggle Motion controls in the menu, as before https://git.magicbean.dev/MagicBeanDev/Hookshot/pulls/2036. Only the Steam Controller Alt+Tab case is known to need the rule, and it is not run on hardware here: if Steam's Alt+Tab leaves a Steam Controller's accelerometer moving while its gyro is dead, that case would no longer recover by itself. A revert is enough to undo it. After updating, saves, `longshot_options.ini`, the caches and the vk ABI are untouched; the log line's wording changes (`its gyroscope and accelerometer stopped changing`), so a search for `gyroscope stopped changing` no longer matches it, while `stopped changing` still does. ## 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. [a Steam Deck OLED, this change on main plus pull 1181, the same diff] - [x] `mise run test` passes (any failure that also fails on `main` is named). - [x] Measured against `main`, or Measurements says why there is nothing to measure. [against main plus pull 1181, which the Baseline line explains] - [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 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] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. [the Steam Controller, the Deck LCD and Game Mode, other gyro pads not run] - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). [the Steam Deck OLED only, headless with Steam's variables set by hand; Windows and Linux PCs with a gyro pad not run] - [ ] Approved in review, every comment answered. [no review yet] - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. [the head is not pushed yet; why the numbers still hold is in Measurements' Baseline]
`tests/test_gyro_rearm.py` gets a case for a pad whose gyroscope reads
exactly 0 at rest while its accelerometer still moves by its last bit,
as a Steam Deck in its dock does. The frozen-gyro rule in `motion_poll`
turns its sensors off and on again every few seconds; this fails until
the rule also asks the accelerometer to be frozen.

Assisted-by: Claude
The frozen-gyro rule in `motion_poll` (`host/pad_sdl.c`) took a
gyroscope reading the very same values for over 1.2 s as stopped. A
Steam Deck's gyroscope reads the very same values when the Deck is still
(the motion filter learns a bias of 0.0000 from it), so a Deck at rest
tripped the rule as often as every 3.5 s, nearly as often as its 3 s
wait allows: 32,490 of these lines in 746 distinct Deck runs on this
PC (performance series and soaks started outside Steam), the most 617
in one 37-minute run.

The rule now also asks the accelerometer to read the very same values,
which a working one never does for a second. The case it was made for
(a Steam Controller whose sensors Steam left off after Alt+Tab) freezes
both, so it still recovers. The log line names both sensors.

Assisted-by: Claude
docs(tested): a Steam Deck OLED at rest for ten minutes, without and with the frozen-gyro fix
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 4s
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
f1259b4ac7
Two headless stands in Kokiri Forest with Steam's controller variables
set by hand: 5 re-arm lines on PR 1181's build alone (5306ca05d), 0
with this fix on top (7e1a68a43).

Assisted-by: Claude
Member

Possibly related, for context:

  • PR #1181 WIP: feat(host): the Steam Deck's gyro reaches Motion controls when Steam starts the game — Enables Steam Deck gyro; this PR fixes false re-arms and edits the same motion-poll code.
Possibly related, for context: - PR #1181 WIP: feat(host): the Steam Deck's gyro reaches Motion controls when Steam starts the game — Enables Steam Deck gyro; this PR fixes false re-arms and edits the same motion-poll code.
Author
Contributor

Tested in game: Steam Deck OLED, SteamOS 3.9.5, RADV: Kokiri Forest standing 600 s, headless over ssh with Steam's controller variables set by hand, the Deck at rest; this change on main plus pull 1181 (7e1a68a43, the same diff): 0 re-arm lines against 5 without it.

Tested in game: Steam Deck OLED, SteamOS 3.9.5, RADV: Kokiri Forest standing 600 s, headless over ssh with Steam's controller variables set by hand, the Deck at rest; this change on main plus pull 1181 (7e1a68a43, the same diff): 0 re-arm lines against 5 without it.
zeldaootr changed title from WIP: fix(input): a Steam Deck at rest no longer has its motion sensors turned off and on every few seconds to fix(input): a Steam Deck at rest no longer has its motion sensors turned off and on every few seconds 2026-11-19 21:11:25 +00:00
zeldaootr force-pushed gyro-rest-guard from f1259b4ac7
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 4s
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
to 0181f73573
Some checks are pending
CI / Website build and checks (pull_request) Blocked by required conditions
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 4s
2026-11-20 03:40:14 +00:00
Compare
Author
Contributor

Rebased onto main 068fb8ebe, the docs and tools revamp (head 0181f7357), with no conflict: both code commits are the same as before (git range-diff: =). Main removed the tested-configurations catalogue, so the commit with the two docs/tested/ stand files is dropped; their numbers stay in the description's Measurements, which now follows the new template, with the Hookshot links pointing at the archived mirror. tests/test_gyro_rearm.py fails at the test commit on this main and passes at the head, and the full game-free run fails nothing here that main doesn't also fail on this PC.

Rebased onto main 068fb8ebe, the docs and tools revamp (head 0181f7357), with no conflict: both code commits are the same as before (`git range-diff`: `=`). Main removed the tested-configurations catalogue, so the commit with the two `docs/tested/` stand files is dropped; their numbers stay in the description's Measurements, which now follows the new template, with the Hookshot links pointing at the archived mirror. `tests/test_gyro_rearm.py` fails at the test commit on this main and passes at the head, and the full game-free run fails nothing here that main doesn't also fail on this PC.
HumanBean left a comment

Recommendation: Approve. It stops a healthy Steam Deck at rest from having its motion sensors turned off and on every few seconds (5 → 0 in ten minutes here, 102 in ten minutes in a tester's report), by asking the frozen-gyro rule to see the accelerometer frozen too; the rule only gets narrower, and the one case it could now miss is unseen and still has the menu toggle. Recommend approval; not approved on the forge.

For a Deck player with Motion controls On, the gyro is no longer reset while the Deck lies still, and the log stops filling with stopped changing lines (617 in one soak). The code gets better: one extra memcmp and a saved accelerometer reading, in the same block, with nothing new to configure.

Does it help: Yes. Steam Deck OLED, SteamOS 3.9.5, RADV, 600 s at rest in Kokiri Forest: 5 re-arm lines without the fix and 0 with it, the gyro read all the way through both times (1346 / 1331 motion debug lines), one stand each, on main + #1181 because main under Steam never opens the Deck's gyro. This is a count of a deterministic event, not a timing, so one run each is enough. omgitsgela's 102-in-ten-minutes on a Deck LCD (issue #1477) and 32,490 lines over 746 earlier Deck run logs show the same thing on main when the game starts outside Steam.
Other systems: motion_poll is shared by every pad with a gyro, and the new condition is the old one plus "and the accelerometer is frozen", so the rule can only fire less often, never more.

  • DualSense, DualShock 4, Switch Pro, Joy-Con and the 2026 Steam Controller report raw, noisy gyros, so the rule hardly fired on them before. A dropped sensor stream (Bluetooth, or SDL keeping its last values) freezes both sensors, and that is still caught.
  • The original Steam Controller Alt+Tab case still re-arms if Steam's layout switch stops the IMU as a whole, which seems the likely way: SDL's Steam driver sets accel and gyro together, and #1181 sees the Deck's IMU, once Steam turns it off, read both frozen. It would no longer re-arm only if Steam left the accelerometer streaming with the gyro off. That has not been seen, the PR's Risks names it, and Motion controls in the menu still brings the gyro back. Not run on a Steam Controller.
  • Windows and Linux both run the same portable C. The present path, the GPU, saves and longshot_options.ini are untouched. The log line's wording changes, but stopped changing still matches it.
    Switches: none added, changed or removed. The 1.2 s threshold and the 3 s back-off stay as they are.

Reviewed: 0181f73573 against main 068fb8ebe2 (the PR's base; main@origin 3df5c13ed2 since then changes host/pad_sdl.c only in vibration, not motion_poll). I read the host/pad_sdl.c diff and all of motion_poll around it, plus all of tests/test_gyro_rearm.py. Nothing run (a code review).
Fixed in this review: nothing.
Checked and fine:

  • last_a and last_g are always written together and only on a read, so the two can't fall out of step.
  • On a poll with no reading, same_since still resets as before.
  • The re-arm path and the rearm_ns back-off are unchanged.
  • The test fails on main (FAIL:46, per the PR), and it would fail again if the new memcmp(a, last_a…) were removed. If the last_a copy were dropped, the frozen-both cases would fail instead.
  • The test's step() keeps the accelerometer constant, so the existing cases still mean "both frozen", and "gyro changing, accel constant" is still covered by the first case.
  • The test's block search string is the comment's unchanged first line.
  • The two commits are test-then-fix, as fix-with-test asks.

Suggestions (the author may take or leave)

  • host/pad_sdl.c:237: "as a Steam Deck's in its dock does": the stands were run with the Deck lying tilted back, not docked. "as a Steam Deck's does at rest" says what was seen.
  • tests/test_gyro_rearm.py:61: "moving by its last bit": 0.0006 on -8.6 is about 600 ulps, not 1. nextafterf(-8.6f, 0.0f) toggling would model a real one-LSB wobble and is the stricter case.

Testing:

  • Done: the author's three Deck OLED stands (headless over ssh, Steam's variables set by hand, on main + #1181), the game-free test failing on main and passing at the head, and host compiles with gcc, clang and llvm-mingw.
  • Missing, by hand: a Steam Controller under Steam with Alt+Tab, a Deck LCD or Game Mode on this branch, and the other gyro pads. None holds the merge: on those pads the change can only make the rule fire less often, and the menu toggle is still there.
  • CI is pending ("Blocked by required conditions") at this head.
    Overlaps and merge order:
  • #1181 (WIP, same author) edits the same if (read && ...) line (!deck_imu) and the same step() in tests/test_gyro_rearm.py. That is a textual conflict for whichever goes second, and the two changes compose: 1181's rule takes over a Deck whose IMU Steam turned off, and this one keeps a healthy Deck at rest from tripping the generic rule. This PR first, since it is ready and 1181 is WIP.
  • #1721, #1349, #1125 and #1690 touch other parts of host/pad_sdl.c (pad state, pads_poll, motion history, the joystick log), not this block. No order needed.
**Recommendation: Approve.** It stops a healthy Steam Deck at rest from having its motion sensors turned off and on every few seconds (5 → 0 in ten minutes here, 102 in ten minutes in a tester's report), by asking the frozen-gyro rule to see the accelerometer frozen too; the rule only gets narrower, and the one case it could now miss is unseen and still has the menu toggle. Recommend approval; not approved on the forge. For a Deck player with Motion controls On, the gyro is no longer reset while the Deck lies still, and the log stops filling with `stopped changing` lines (617 in one soak). The code gets better: one extra `memcmp` and a saved accelerometer reading, in the same block, with nothing new to configure. **Does it help:** Yes. Steam Deck OLED, SteamOS 3.9.5, RADV, 600 s at rest in Kokiri Forest: 5 re-arm lines without the fix and 0 with it, the gyro read all the way through both times (1346 / 1331 motion debug lines), one stand each, on main + https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1181 because main under Steam never opens the Deck's gyro. This is a count of a deterministic event, not a timing, so one run each is enough. omgitsgela's 102-in-ten-minutes on a Deck LCD (issue https://git.magicbean.dev/MagicBeanDev/Longshot/issues/1477) and 32,490 lines over 746 earlier Deck run logs show the same thing on main when the game starts outside Steam. **Other systems:** `motion_poll` is shared by every pad with a gyro, and the new condition is the old one plus "and the accelerometer is frozen", so the rule can only fire less often, never more. - DualSense, DualShock 4, Switch Pro, Joy-Con and the 2026 Steam Controller report raw, noisy gyros, so the rule hardly fired on them before. A dropped sensor stream (Bluetooth, or SDL keeping its last values) freezes both sensors, and that is still caught. - The original Steam Controller Alt+Tab case still re-arms if Steam's layout switch stops the IMU as a whole, which seems the likely way: SDL's Steam driver sets accel and gyro together, and https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1181 sees the Deck's IMU, once Steam turns it off, read both frozen. It would no longer re-arm only if Steam left the accelerometer streaming with the gyro off. That has not been seen, the PR's Risks names it, and Motion controls in the menu still brings the gyro back. Not run on a Steam Controller. - Windows and Linux both run the same portable C. The present path, the GPU, saves and `longshot_options.ini` are untouched. The log line's wording changes, but `stopped changing` still matches it. **Switches:** none added, changed or removed. The 1.2 s threshold and the 3 s back-off stay as they are. **Reviewed:** 0181f73573 against main 068fb8ebe2 (the PR's base; main@origin 3df5c13ed2 since then changes `host/pad_sdl.c` only in vibration, not `motion_poll`). I read the `host/pad_sdl.c` diff and all of `motion_poll` around it, plus all of `tests/test_gyro_rearm.py`. Nothing run (a code review). **Fixed in this review:** nothing. **Checked and fine:** - `last_a` and `last_g` are always written together and only on a read, so the two can't fall out of step. - On a poll with no reading, `same_since` still resets as before. - The re-arm path and the `rearm_ns` back-off are unchanged. - The test fails on main (`FAIL:46`, per the PR), and it would fail again if the new `memcmp(a, last_a…)` were removed. If the `last_a` copy were dropped, the frozen-both cases would fail instead. - The test's `step()` keeps the accelerometer constant, so the existing cases still mean "both frozen", and "gyro changing, accel constant" is still covered by the first case. - The test's block search string is the comment's unchanged first line. - The two commits are test-then-fix, as fix-with-test asks. **Suggestions** (the author may take or leave) - `host/pad_sdl.c:237`: "as a Steam Deck's in its dock does": the stands were run with the Deck lying tilted back, not docked. "as a Steam Deck's does at rest" says what was seen. - `tests/test_gyro_rearm.py:61`: "moving by its last bit": 0.0006 on -8.6 is about 600 ulps, not 1. `nextafterf(-8.6f, 0.0f)` toggling would model a real one-LSB wobble and is the stricter case. **Testing:** - Done: the author's three Deck OLED stands (headless over ssh, Steam's variables set by hand, on main + https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1181), the game-free test failing on main and passing at the head, and host compiles with gcc, clang and llvm-mingw. - Missing, by hand: a Steam Controller under Steam with Alt+Tab, a Deck LCD or Game Mode on this branch, and the other gyro pads. None holds the merge: on those pads the change can only make the rule fire less often, and the menu toggle is still there. - CI is pending ("Blocked by required conditions") at this head. **Overlaps and merge order:** - https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1181 (WIP, same author) edits the same `if (read && ...)` line (`!deck_imu`) and the same `step()` in `tests/test_gyro_rearm.py`. That is a textual conflict for whichever goes second, and the two changes compose: 1181's rule takes over a Deck whose IMU Steam turned off, and this one keeps a healthy Deck at rest from tripping the generic rule. This PR first, since it is ready and 1181 is WIP. - https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1721, https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1349, https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1125 and https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1690 touch other parts of `host/pad_sdl.c` (pad state, `pads_poll`, motion history, the joystick log), not this block. No order needed.
@ -237,2 +236,2 @@
Steam Controller under Steam after Alt+Tab, when Steam's layout switch left its sensors off while SDL still had them on.
Off and on again, as the menu's Motion controls row does, brings it back) */
/* (a gyroscope reading the very same values for over a second has stopped when its accelerometer does too: a real
accelerometer always moves a little, while a gyroscope may read exactly 0 at rest, as a Steam Deck's in its dock
Owner

Nit: the stands had the Deck at rest tilted back, not docked; "as a Steam Deck's does at rest" says what was seen.

Nit: the stands had the Deck at rest tilted back, not docked; "as a Steam Deck's does at rest" says what was seen.
@ -54,6 +58,9 @@ int main(void) {
/* changing readings: never */
for (int n = 0; n < 1000; n++, t += 4 * MS) step(t, 1, (float)(n % 7) * 0.01f);
CHECK(offs == 0 && pads[0].motion_on == 1);
/* a gyroscope at rest reading exactly 0 for 10 s, its accelerometer moving by its last bit: never */
Owner

Nit: 0.0006 on -8.6 is ~600 ulps, not the last bit; toggling with nextafterf(-8.6f, 0.0f) would model a one-LSB wobble and is the stricter case.

Nit: 0.0006 on -8.6 is ~600 ulps, not the last bit; toggling with nextafterf(-8.6f, 0.0f) would model a one-LSB wobble and is the stricter case.
HumanBean deleted branch gyro-rest-guard 2026-11-20 22:57:19 +00:00
Some checks are pending
CI / Website build and checks (pull_request) Blocked by required conditions
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 4s
Some workflows are waiting to be reviewed.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 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!1796
No description provided.