fix(input): a Steam Deck at rest no longer has its motion sensors turned off and on every few seconds #1796
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1796
Loading…
Reference in a new issue
No description provided.
Delete branch "zeldaootr/Longshot:gyro-rest-guard"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
mainand 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=1optional: load a save, put the Deck down and leave it still for ten minutes, then countstopped changinginlongshot_log.txt. Expected none: the gyro works. Instead there are lines likehid: "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:
motion_pollinhost/pad_sdl.ckeeps 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 readsits gyroscope and accelerometer stopped changing.tests/test_gyro_rearm.pygets 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 (
0181f7357on main068fb8ebe):tests/test_gyro_rearm.pyfails at the test-only commit3dc2ae618(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 wholepython3 -I -B tests/run_all.py(not--strict) here and on main068fb8ebe, 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, buttest_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.ccompiled (-c, the build's host flags,-Wall) with gcc and clang for Linux and llvm-mingw 20261104 for Windows, at this head and on main068fb8ebe: the same one warning on both, from a generated header, none of its own.The 59 checks that fail both here (
0181f7357) and on main068fb8ebetest_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_keyThe 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:
hid: "Steam Controller": its gyroscope and accelerometer stopped changing: motion sensors turned off and on againline inlongshot_log.txt(by hand: someone with a Steam Controller; look at the aim after Alt+Tab and the log)stopped changingline and the gyro aiming after (by hand)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
mainand 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 main068fb8ebe, whose changes tohost/pad_sdl.csince (vibration, and comments) do not touchmotion_pollor 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 theHOS_MOTION_DEBUG=1motion 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 withHOS_DECK_GYRO=0as 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.motion controls from "Steam Deck Controller"tests/test_gyro_rearm.py068fb8ebewith this PR's test,3dc2ae618)0181f7357)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 changinglines in 746 distinct runs (counted once perrun_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 forgyroscope stopped changingno longer matches it, whilestopped changingstill does.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure. [against main plus pull 1181, which the Baseline line explains]third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.Ready to merge
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]Possibly related, for context:
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.
WIP: fix(input): a Steam Deck at rest no longer has its motion sensors turned off and on every few secondsto fix(input): a Steam Deck at rest no longer has its motion sensors turned off and on every few secondsf1259b4ac70181f73573Rebased onto main
068fb8ebe, the docs and tools revamp (head0181f7357), 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 twodocs/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.pyfails 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.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 changinglines (617 in one soak). The code gets better: one extramemcmpand 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_pollis 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.longshot_options.iniare untouched. The log line's wording changes, butstopped changingstill matches it.Switches: none added, changed or removed. The 1.2 s threshold and the 3 s back-off stay as they are.
Reviewed:
0181f73573against main068fb8ebe2(the PR's base; main@origin3df5c13ed2since then changeshost/pad_sdl.conly in vibration, notmotion_poll). I read thehost/pad_sdl.cdiff and all ofmotion_pollaround it, plus all oftests/test_gyro_rearm.py. Nothing run (a code review).Fixed in this review: nothing.
Checked and fine:
last_aandlast_gare always written together and only on a read, so the two can't fall out of step.same_sincestill resets as before.rearm_nsback-off are unchanged.FAIL:46, per the PR), and it would fail again if the newmemcmp(a, last_a…)were removed. If thelast_acopy were dropped, the frozen-both cases would fail instead.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.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:
Overlaps and merge order:
if (read && ...)line (!deck_imu) and the samestep()intests/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.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 realaccelerometer always moves a little, while a gyroscope may read exactly 0 at rest, as a Steam Deck's in its dockNit: 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 */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.