Skip to content

fix: General IMU fixes - #816

Merged
pastaq merged 9 commits into
mainfrom
pastaq/imu_validation
Nov 20, 2026
Merged

pastaq merged 9 commits into
mainfrom
pastaq/imu_validation

Conversation

@pastaq

@pastaq pastaq commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Adds multiple fixes for bugs introduced or missed during the IMU refactor. One major issue was that all updated mount matrices has an incorrect reflection built into them.

  • Some kernel sysfs provides a mount matrix in a format with no ; separation, add support.
  • Correct Legion Go 2 axis reflections and scale.
  • Correct Legion Go S axis reflections.
  • Switch to scaling vectors instead of clamping for accel magnitudes that are overflows to maintain proper direction.
  • Use proper attribute names for hid-lenovo-go udev rule. Replaces fix(Legion Go 2): enable IMU bypass and correct gyro yaw #781. (@christopherl)
  • Adjust hardware validated IMU matrices
  • Adjust calculated corrected IMU matrices for devices not in hand based on pre 0.82.0 translations and device family symmetry, if present.
  • Have IIO IMU drivers only report capabilities that were detected on startup.
  • Add device config scale override support for BMI driver, previously only enabled for accel_gyro_3d driver.

Closes #772

The kernel attribute holds a matrix either as "1,0,0;0,1,0;0,0,1" or as nine
numbers with no separators. Only the first form parsed, so a device with the
second ran without a matrix.

Assisted-by: LLM
Each handle reports its accelerometer and gyroscope in the frame its sensor is
mounted in, so the two handles disagree and consumers see the device turned.
Fix the signs per handle, average only the handles that report attached (a
detached handle reads zero and halved the result), and take the gyro scale from
the LSM6DSO datasheet: 70 mdps/LSB at +/-2000 dps is 28571 counts, not 32768.

Assisted-by: LLM
The accelerometer and gyroscope were signed and swapped differently from each
other, which no mount matrix can undo. Negate all three axes for both.

Assisted-by: LLM
Accelerometer fields are 16-bit signed counts with a fixed full scale: 2 g on
the Deck protocol, 4 g on DualSense. Handheld sensors go past that, and
clamping each axis separately rotates gravity, which consumers use to correct
gyro drift. Scale the whole vector to the report's full scale instead.

Assisted-by: LLM
The rule wrote imu_bypass_enable and vibration_enable. The driver exposes
imu_bypass_enabled and vibration_enabled, so the write failed and the IMU
stayed off.

Co-developed-by: Christopher Lott <lott.ch@googlemail.com>
Assisted-by: LLM
These devices report gravity on the wrong axis for the way they are held. The
MSI Claw A8 gyro matrix is removed: its firmware reports a correct one and a
configured value would override it.

Assisted-by: LLM
These have a determinant of -1, which mirrors the gyroscope against gravity:
gravity reads correctly but turns go the wrong way. Replaced with the matrix
used by the same sensor in other chassis. Not tested on these models.

Assisted-by: LLM
Both iio IMU sources returned one shared capability list holding an accelerometer
and a gyroscope, so a source with a single channel group advertised the other and
downstream consumers waited for events that can never arrive. The driver already
discovers which groups a device has, so let it report the events those groups
produce and let the source driver convert them into capabilities. A sensor with
both groups reports both as before.

Assisted-by: LLM
accel_gyro_3d passes corrections_from_config to the driver while bmi_imu passed
1.0 for both factors, so config.imu.accel_correction and gyro_correction had no
effect on a BMI source. The option defaults to 1.0 and no config in the tree sets
it on one, so behavior is unchanged until a device asks for it.

Assisted-by: LLM
@pastaq
pastaq force-pushed the pastaq/imu_validation branch from 6c5a3ba to 2e5a468 Compare November 20, 2026 00:54
@pastaq
pastaq merged commit b5052ee into main Nov 20, 2026
6 checks passed
@pastaq
pastaq deleted the pastaq/imu_validation branch November 20, 2026 12:51
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.85.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ROG Ally X: IMU reported upside down on both the Steam Deck and DualSense targets (rotated 180° about X), 0.83.0

1 participant