ISX-2228: Add OrientationSensor (device orientation parity) - #2468
ISX-2228: Add OrientationSensor (device orientation parity)#2468K-Tone wants to merge 4 commits into
Conversation
Add an OrientationSensor device to the Input System package that reports the physical device orientation as a discrete value, providing feature parity with the legacy UnityEngine.Input.deviceOrientation property. - Add package-local UnityEngine.InputSystem.DeviceOrientation enum (values identical to the legacy enum, kept independent of the legacy input module). - Add OrientationControl : InputControl<DeviceOrientation>, modeled on TouchPhaseControl. - Add OrientationState (FourCC 'ORNT') and OrientationSensor : Sensor. The reported value is deliberately not compensated for screen orientation. - Register the "Orientation" control and "OrientationSensor" device layouts. - Add a mock-runtime unit test and cover OrientationSensor in Devices_CanCreateDevice. Native producers (per-platform) and docs/changelog follow in later changes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add a layout matcher so the native iOS orientation device (interface "iOS", deviceClass "Orientation") resolves to the OrientationSensor layout, following the same convention as the Gravity/Attitude/ LinearAcceleration sensors. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add a layout matcher so the native Android orientation device (interface "Android", deviceClass "Orientation") resolves to the OrientationSensor layout. Unlike the other Android sensors it is not an ASensor, so it maps directly to the base layout rather than an AndroidSensor variant. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Surface an OrientationSensor when connected to the Unity Remote so device orientation can be tested in the Editor. - Handle the existing MessageType.DeviceOrientation message (the Remote app already sends it) and queue it to an OrientationSensor added on connect. No change to the Remote app is required. - Add a DeviceOrientationMessage struct matching HandleOrientationMessage in GenericRemote.cpp (header + int32 orientation, same enum values as ours). - Remove the device on disconnect and clear it on manual removal. - Add Remote_CanReceiveDeviceOrientationFromUnityRemote test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Harness Review
The runtime integration follows the existing sensor and Unity Remote patterns, but the PR leaves the documented migration path inaccurate and adds an unrelated project-wide dependency.
The shipped documentation still says Input.deviceOrientation has “No corresponding API yet” in Documentation~/corresponding-old-new-api.md, and Documentation~/supported-sensors-reference.md omits the new sensor. Users following the migration guide or support matrix will therefore conclude this feature is unavailable. Update those references to point to OrientationSensor.current.orientation.ReadValue() and document its supported platforms.
Reviewed commit 732016b
🤖 Helpful? 👍/👎
| "com.unity.ide.rider": "3.0.39", | ||
| "com.unity.ide.visualstudio": "2.0.27", | ||
| "com.unity.multiplayer.center": "1.0.0", | ||
| "com.unity.pipeline": "0.4.0-exp.1", |
There was a problem hiding this comment.
com.unity.pipeline is not referenced anywhere else in this checkout, so this root-manifest entry is unrelated to the orientation feature. Every developer and CI checkout will now resolve and install this experimental package (and any transitive dependencies), expanding the project's dependency surface for no implementation benefit. Please remove this accidental manifest change or move an intentional pipeline integration to its own documented change.
🤖 Helpful? 👍/👎
There was a problem hiding this comment.
This comment is because the wrong base was picked by claude when opening pr, I fixed that
| /// </example> | ||
| /// </remarks> | ||
| [InputControlLayout(stateType = typeof(OrientationState), displayName = "Orientation")] | ||
| public class OrientationSensor : Sensor |
There was a problem hiding this comment.
Like mentioned in this thread: https://unity.slack.com/archives/C0BKX81LUNL/p1785848600476409?thread_ts=1785835628.354409&cid=C0BKX81LUNL
Need to name the sensor: DeviceOrientationSensor
Summary
Adds an
OrientationSensorto the Input System package, giving feature parity with the legacyUnityEngine.Input.deviceOrientation(ISX-2228, part of the IM API parity epic ISX-2108).The Input System had every raw motion sensor but no discrete physical-orientation value. This adds one, modeled on the existing sensor + enum-control patterns.
What's in this PR (managed / package side)
DeviceOrientationenum (UnityEngine.InputSystem) — package-local, values identical to the legacyUnityEngine.DeviceOrientation(Unknown=0 … FaceDown=6). Kept independent of the legacy input module so the package stays self-contained.OrientationControl : InputControl<DeviceOrientation>— enum-backed control, modeled onTouchPhaseControl.OrientationSensor : Sensor+OrientationState(FourCC'ORNT',int orientation). Reports the raw physical orientation — deliberately not run through screen-orientation compensation."Orientation"control and"OrientationSensor"device layouts.deviceClass "Orientation") toOrientationSensor. WebGL/UWP match by layout name directly (no matcher needed).DeviceOrientationmessage (type 4) — no Remote-app change required — and surface anOrientationSensorwhile connected.Tests
Devices_CanGetDeviceOrientationReading(mock runtime) +OrientationSensoradded toDevices_CanCreateDevice.Remote_CanReceiveDeviceOrientationFromUnityRemote.Companion PR
Native per-platform producers that feed this device live in
unity.git(trunk): ISX-2228 native device orientation producers. Both are needed end-to-end; this managed side also gets mirrored intounity.git/ShadowPackagesat publish time.Notes
OrientationSensor.current.orientation.ReadValue()(enable the device first, like any sensor).using UnityEngine;andusing UnityEngine.InputSystem;disambiguateDeviceOrientationwith ausingalias — the same established pattern asGyroscope/TouchPhase.🤖 Generated with Claude Code