fix(host): the Deck's IMU setting is read where the reply puts it, so its sensors are turned on #2802
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
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
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2802
Loading…
Reference in a new issue
No description provided.
Delete branch "omgitsgela/Longshot:fix/deck-imu-mode-readback"
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
Started by Steam, SDL opens only Steam Input's stand-in pad, which has no sensors, so the Deck's own state report is the
only gyro there is. Its accelerometer and gyroscope fields stay zero until the controller's IMU mode says to send them.
host/deck_imu.creads that mode before writing it, so it can put it back, and that read assumed a fixed layout: thesetting number at byte 1, the
(setting, low, high)triples from byte 2. AGET_SETTINGS_VALUESreply is an id, then abyte count, then the triples, so the count sat where the setting number was read, nothing ever matched, no enable was
written, and every sample stayed zero.
The Motion controls row still said "gyro found", because the source counted as present once a report arrived rather than
from what it carried: 2,000 valid type-9 reports in 8 s, six fields zero.
The first commit reads the reply where it says its values are and by its own count, reads the mode again every three
seconds while the stream is dead, writes only the raw accel and gyro bits over the value that is current, and restores
only a value this reader wrote.
The second commit fixes presence, which the review caught: it counted only a sample that changed, so a Deck lying
still (same gravity, zero rate, again and again) lost motion after three seconds, and the SDL caller then reset the
filter and its learned bias when a sample finally did change. Presence now follows the newest report carrying a nonzero
sample, changed or not, inside the same three second window. Six zero fields mean the sensors are off, and no report at
all still means the node or Steam's hold on it changed, so the bounded mode re-read is unchanged.
To see the bug on
main: start a Deck build from a Steam shortcut with Steam running, then read the game's log. It picksthe Deck's built-in controls and prints that the IMU setting could not be read; a read-only probe of the same hidraw
node shows well-formed reports with zero accel and zero gyro, and the Motion controls row says "gyro found" anyway.
Read
deck_imu_read_setting, thendeck_imu_presentand the liveness block indeck_imu_poll.Testing
Tested: Steam Deck LCD (VANGOGH, RADV, SteamOS 7.2.7-valve2-neptune), the same build started from a Steam shortcut
in Desktop Mode with Steam running and in Game Mode. Motion controls On reports
gyro found, motion aiming works, thelog shows
motion controls from the Steam Deck's built-in controls, the IMU mode reads0x0018while the reader holdsit, and it is back to Steam's value once Motion controls is turned off. With the switch off, Deck motion is gone and
buttons and sticks still work, so the fallback is the source when it is on and nothing when it is off.
The presence rule is covered game-free rather than by holding the Deck still for three seconds:
tests/deck_imu_transport.ccompiles the production reader against simulated hidraw replies and now includes a 3.6 s still-pad stream (presence
holds, every poll returns the same reading) and a 3.6 s zero stream (presence lapses and the mode is asked about again).
Still to test:
Suite on this machine:
tests/run_all.py --strict(Linux,CXX=g++) reports the same 211 failures onmainand onthis branch, every one of them a test that needs a tool this machine does not have (
clang,clang++); this branchadds none.
mise run testitself cannot run here: its pinnedruffandpre-commitneeduv>= 0.12.10 and thismachine has 0.11.26. CI has both. The new transport check is declared Windows-skipped, which is what the Windows runner
needs, instead of being picked up and failing to compile there.
Measurements
Verdict: the bug reproduces on
mainand is gone here. The transport check fails onmainand passes on this PR;in the game the same hidraw stream that carried six zero fields on
maincarries live values here, and a still pad keepsthem.
Setup: Steam Deck LCD, RADV, SteamOS 7.2.7-valve2; Desktop Mode started from a Steam shortcut; the reader's own log, a
read-only probe of the Deck's hidraw state report, and
tests/deck_imu_transport.c(run bytests/test_deck_imu_transport.py), which compiles the production reader with the ioctls andreadreplaced.01d6878b67ed06cetests/test_deck_imu_transport.pymainand fails:deck_imu_read_settingreturns -1 for a reply that names the settingGET_SETTINGS_VALUESreply0x0030 = 0x0000on the Deck,0x0018once writtengyro foundfrom themRisks
The reader writes one controller setting that Steam also owns. It writes only the raw accel and gyro bits, over the value
it just read, and restores that value only while the setting still equals what it wrote; a value Steam changed in the
meantime is left alone.
HOS_DECK_IMU=0turns the whole fallback off. Presence needs a nonzero sample inside threeseconds, so a pad whose sensors are on but which has stopped reporting is treated as gone, as before. Nothing changes
for other pads, for sessions without Steam, or for a pad whose own sensors SDL can already read.
Nothing changes after updating: no options keys, no saves, no caches.
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.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.Tested in game: Steam Deck LCD (VANGOGH, RADV), SteamOS 7.2.7-valve2-neptune, one build started from a Steam shortcut in Desktop Mode with Steam running, and in Game Mode. Motion controls On reports gyro found and gyro aiming works; the log shows the Deck's built-in controls as the source; the IMU mode reads 0x0018 while the reader holds it and is back to Steam's value once it is off. With Motion controls off, Deck motion is gone and buttons and sticks still work.
@review — ready. The sensor path is the whole change and it is provable without a Deck:
tests/test_deck_imu_transport.pybuilds the reader against fake hidraw replies and fails onmain(deck_imu_read_settingreturns -1 for a reply that names the setting). Related: #2803, found on the same build.Recommendation: Request changes. The fix works in the reported Steam Deck LCD run, but the new test cannot build on Windows, and valid unchanged sensor readings are eventually treated as a disconnected gyro.
The change reads the Deck’s IMU setting using the reply’s count and enables raw motion data while preserving other setting bits. It also changes presence detection and adds a simulated transport test; the remaining costs are a Windows test failure and loss of motion presence for a stable sample.
Blocking (2): must change before merging.
tests/test_deck_imu_transport.py:30: The new test is selected on Windows but compiles a Linux-only source unconditionally. (more on the line) Do: Declare the test Linux-only for run_all and handle direct invocation on other platforms, or provide a portable transport harness.CI / Third-party parts and guide screenshots (pull_request)fails on this head and passes on the base branch: Failing after 25s.Should fix (1): not blocking, but worth doing before merging.
host/deck_imu.c:260: A valid nonzero reading stops counting as present if its quantized values remain unchanged for three seconds. (more on the line) Do: Distinguish a zero or otherwise known disabled stream from valid repeated nonzero samples, and add a test covering a stable live stream longer than three seconds.Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
@fixcan do L1, L2 and L4.Checks: Still running: 6 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes on the tested Steam Deck LCD: the author reports 2,000 zero-valued reports over 8 seconds on main, live sensor values and working gyro aiming on this head, and a transport test that fails on main and passes here. Steam Deck OLED remains untested.
Other systems: The production reader is Linux-only and is used when motion is enabled and SDL has no pad sensors; other pads take precedence. Windows uses the production stub, but the new test includes Linux-only headers unconditionally. OLED behavior remains to be checked.
Switches: No switches added, changed, or removed. Existing HOS_DECK_IMU defaults to enabled and can disable the fallback.
Reviewed:
c864bb0750against01d6878b3f: Read AGENTS.md, CONTRIBUTING.md, the pull request template, standards, all three changed files, the Deck IMU header, the relevant pad callers, test-runner selection, the commit, and the supplied comments and CI status. Skimmed the remainder of the test runner. docs/review-checklist.md was absent; no generated files or translations changed.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no project code, tests, or builds were run. The supplied CI status has one head-only failure, which the bot records separately, and several checks still running.
Overlaps and merge order: The supplied comment mentions related issue #2803; no overlapping pull request was identified in the available material.
Automated code review by BeanBot (gpt-6.1-terra), asked for by omgitsgela. Nothing was run; a maintainer decides.
@ -268,2 +259,2 @@imu_same_ns = 0;}const int nonzero = accel[0] || accel[1] || accel[2] || gyro[0] || gyro[1] || gyro[2];if (nonzero && (!imu_have_prev || memcmp(accel, imu_prev_a, sizeof imu_prev_a) ||L2 (should fix): A valid nonzero reading stops counting as present if its quantized values remain unchanged for three seconds.
When: With a stationary Deck producing the same gravity sample and zero angular velocity, reports continue arriving but imu_change_ns expires; polling returns no motion and presence is lost until a sample changes.
Do: Distinguish a zero or otherwise known disabled stream from valid repeated nonzero samples, and add a test covering a stable live stream longer than three seconds.
@ -0,0 +27,4 @@with tempfile.TemporaryDirectory() as d:exe = Path(d) / "deck_imu_transport"# (only -Wall: the reader carries warnings of its own that are not this check's to fail on)built = subprocess.run([a.cc, "-std=c11", "-Wall", "-I", str(ROOT / "host"), "-o", str(exe), str(SOURCE)],L1 (blocking): The new test is selected on Windows but compiles a Linux-only source unconditionally.
When: On Windows, run_all discovers this test and invokes it with the C compiler; tests/deck_imu_transport.c includes sys/ioctl.h and exercises Linux-only reader internals, so the test cannot build.
Do: Declare the test Linux-only for run_all and handle direct invocation on other platforms, or provide a portable transport harness.
CI note:
Third-party parts and guide screenshotsfails here because it fails onmaintoo.scripts/check_guide_screenshots.py --review-sourcesonorigin/main(01d6878b) saysREVIEW REQUIRED: settings-graphics.png: game/oot_cheat_items.h changed since reviewed revision 3c74597e, from #2785; neither branch touchesgame/. The rest of the checks are running.Recommendation: Request changes. The LCD run shows the reply framing fix restores motion aiming. Two issues remain before merge.
The author reports 2,000 valid reports with all six sensor fields zero on main, then live sensors and restoration of the Steam setting on the Steam Deck LCD. Repeat the Steam shortcut, aiming and setting-restoration check on OLED. The Guide failure names a changed file outside this PR and also reproduces on the base. LCD test · Guide attribution
Reviewed all three changed files at
c864bb0750d7e4d5943e00f5372b6598694a5f2cagainst01d6878b3f148e68d7a9080133d193e1fb7c2973. No game or tests run in this review.@ -206,3 +212,3 @@/* A reading, not a vendor id: a Valve node is often the mouse or the keyboard interface of the same device, sopresence follows the state report itself, and lapses when the reports stop. Nothing scans the device here. */return imu_fd >= 0 && imu_held && now_ns - imu_last_ns < 3000000000LL;return imu_fd >= 0 && imu_held && now_ns - imu_change_ns < 3000000000LL;[P2] Keep fresh, valid nonzero reports present when the samples happen to repeat. This three-second change timestamp causes motion_poll to clear motion status and reset the filter (and learned bias) on the next changing sample. Keep the settings recheck separate and add a stable nonzero stream test beyond three seconds.
@ -0,0 +13,4 @@import tempfileROOT = Path(__file__).resolve().parents[1]RUN_ALL_ARGS = ["--cc", "{cc}"][P2] Declare the transport fixture Linux-only for run_all and guard direct invocation. The fixture includes Linux ioctl headers and needs the Linux reader; native Windows strict checks will otherwise schedule a test they cannot compile. The cross-compiled production stub does not exercise the fixture.
Both review items are fixed on the head (
67ed06ce).tests/test_deck_imu_transport.pynow declaresRUN_ALL_SKIP = {"windows": ...}for the runner, and when it is run directly off Linux it says why and returns instead of trying to compile the Linux reader.tests/deck_imu_transport.cnow holds a still pad for 3.6 s (presence holds although every reading is identical), then a zero stream for 3.6 s (presence lapses and the mode is asked about again), then the ownership check.scripts/check_guide_screenshots.py --review-sourcesonorigin/main(01d6878b) saysREVIEW REQUIRED: settings-graphics.png: game/oot_cheat_items.h changed since reviewed revision 3c74597e, which is #2785; this diff touches nogame/file.@review
Recommendation: Approve. The code is ready: only testing is left. The LCD test shows that the fix restores Deck motion, and repeated nonzero samples now remain present. The Steam Deck OLED run is still needed. Recommend approval; not approved on the forge.
The reader parses the IMU setting reply correctly, enables the sensors while preserving other mode bits, and keeps motion present for a stationary Deck. The change adds a simulated hidraw transport test and bounded retries.
Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
Since the last review (on
c864bb0750)Resolved: L1 (The new test is selected on Windows but compiles a Linux-only source unconditionally.); L2 (A valid nonzero reading stops counting as present if its quantized values remain unchanged…)
Still open: L3 (The Steam Deck OLED path is still untested.); L4 (The check
CI / Third-party parts and guide screenshots (pull_request)fails on this head…)Checks: Failing on this head, which is behind its base, where they pass:
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 1/2) (pull_request),CI / Website build and checks (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.More: does it help, other systems, switches, what was read
Does it help: Yes: the author reports 2,000 all-zero reports over 8 seconds on main, followed by live sensor values and working motion aiming on the LCD Deck with this change.
Other systems: The reader is Linux-only and is used as a fallback when SDL has no sensor source. The Windows stub is unchanged; OLED hardware remains untested.
Switches: No switches added, changed or removed. The existing HOS_DECK_IMU switch defaults on and can disable the fallback.
Reviewed:
67ed06ced3against01d6878b3f: Read all three changed files, both diffs, the commits, AGENTS.md, CONTRIBUTING.md and the pull request template. Skimmed the runner declarations and caller references; the adjacent Tooling rules and docs/review-checklist.md were unavailable.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run project code were executed. The author reports successful LCD in-game testing and a passing simulated transport check; OLED remains to test.
Overlaps and merge order: None found in the supplied pull request information.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
For the record after the merge: the head that landed (
67ed06ce) was built on a Steam Deck LCD and run in the condition Steam's grab creates (SDL with no pad sensors, Steam's launch variables set).hid: motion controls from the Steam Deck's built-in controls, read from the controllerappeared once across about 150 s with the pad left alone, noIMU mode unavailable, nostopped changing, clean exit. Under the change-only rule it would have lapsed after three seconds and been selected again.