Android: motion from the controller's sensors #828

Open
aoleg94 wants to merge 3 commits from aoleg94/android-controller-motion into main
aoleg94 commented 2026-10-03 17:41:52 -05:00 (Migrated from github.com)

Summary

The app always sends the phone's motion. On Android 12+ a controller's own gyro and
accelerometer are available through InputDevice.getSensorManager(); this uses them for the
active controller (the one that sent the latest input).

Settings → Motion replaces the motion switch:

Option Controller with motion sensors Without
Auto (controller, else phone) — default controller phone
Controller only controller none (neutral)
Phone phone phone
Off none none

An existing "motion off" setting migrates to Off; on migrates to Auto.

Implementation

  • ControllerMotion takes the sensors of the active controller, or of its separate
    " Motion Sensors" input device as the kernel exposes it for DualSense and DS4
    (MotionDeviceMatcher), and re-registers when the active controller changes.
  • Orientation comes from a small JNI wrapper around the lib's existing Madgwick orientation
    tracker, the same one desktop uses, so axes and the console's motion reset behave like desktop.

Testing

  • New MotionSourceTest (selection table, migration) and MotionDeviceMatcherTest.
  • Galaxy Z Fold 4 (Android 13) + DualSense over Bluetooth, PS5: Astro's Playroom gyro demo moves
    correctly, Auto falls back to phone motion with the pad off, Controller only sends none.

Notes

Developed with the assistance of Claude Code, and tested on real hardware as described above.

🤖 Generated with Claude Code

### Summary The app always sends the **phone's** motion. On Android 12+ a controller's own gyro and accelerometer are available through `InputDevice.getSensorManager()`; this uses them for the active controller (the one that sent the latest input). **Settings → Motion** replaces the motion switch: | Option | Controller with motion sensors | Without | |---|---|---| | Auto (controller, else phone) — default | controller | phone | | Controller only | controller | none (neutral) | | Phone | phone | phone | | Off | none | none | An existing "motion off" setting migrates to Off; on migrates to Auto. ### Implementation - `ControllerMotion` takes the sensors of the active controller, or of its separate "<name> Motion Sensors" input device as the kernel exposes it for DualSense and DS4 (`MotionDeviceMatcher`), and re-registers when the active controller changes. - Orientation comes from a small JNI wrapper around the lib's existing Madgwick orientation tracker, the same one desktop uses, so axes and the console's motion reset behave like desktop. ### Testing - New `MotionSourceTest` (selection table, migration) and `MotionDeviceMatcherTest`. - Galaxy Z Fold 4 (Android 13) + DualSense over Bluetooth, PS5: Astro's Playroom gyro demo moves correctly, Auto falls back to phone motion with the pad off, Controller only sends none. ### Notes Developed with the assistance of Claude Code, and tested on real hardware as described above. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This pull request is broken due to missing fork information.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'aoleg94/android-controller-motion:aoleg94/android-controller-motion'
git switch 'aoleg94/android-controller-motion'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'aoleg94/android-controller-motion'
git switch 'aoleg94/android-controller-motion'
git rebase 'main'
git switch 'main'
git merge --ff-only 'aoleg94/android-controller-motion'
git switch 'aoleg94/android-controller-motion'
git rebase 'main'
git switch 'main'
git merge --no-ff 'aoleg94/android-controller-motion'
git switch 'main'
git merge --squash 'aoleg94/android-controller-motion'
git switch 'main'
git merge --ff-only 'aoleg94/android-controller-motion'
git switch 'main'
git merge 'aoleg94/android-controller-motion'
git push origin 'main'
Sign in to join this conversation.
No description provided.