From 40aaca811ec0f875d106100e096434e1b67a6081 Mon Sep 17 00:00:00 2001 From: kevin-zakszewski <99926647+kevin-zakszewski@users.noreply.github.com> Date: Thu, 2 Jul 2026 15:26:09 -0700 Subject: [PATCH 1/3] Fix pose isTracked incorrectly returning 0 --- .../InputSystem/Runtime/Plugins/XR/Controls/PoseControl.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Packages/com.unity.inputsystem/InputSystem/Runtime/Plugins/XR/Controls/PoseControl.cs b/Packages/com.unity.inputsystem/InputSystem/Runtime/Plugins/XR/Controls/PoseControl.cs index db4881f631..9d82700a83 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Runtime/Plugins/XR/Controls/PoseControl.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Runtime/Plugins/XR/Controls/PoseControl.cs @@ -60,7 +60,7 @@ public PoseState(bool isTracked, TrackingState trackingState, Vector3 position, /// /// Fully tracked means that the pose is accurate and not using any simulated or extrapolated positions, and the system tracking this pose is able to confidently track this object. /// - [FieldOffset(0), InputControl(displayName = "Is Tracked", layout = "Button", sizeInBits = 8 /* needed to ensure optimization kicks-in */)] + [FieldOffset(0), InputControl(displayName = "Is Tracked", layout = "Button", sizeInBits = 1)] public bool isTracked; /// @@ -252,7 +252,8 @@ protected override FourCC CalculateOptimizedControlDataType() if ( m_StateBlock.sizeInBits == PoseState.kSizeInBytes * 8 && m_StateBlock.bitOffset == 0 && - isTracked.optimizedControlDataType == InputStateBlock.kFormatByte && + isTracked.m_StateBlock.format == InputStateBlock.kFormatBit && + isTracked.m_StateBlock.sizeInBits == 1 && trackingState.optimizedControlDataType == InputStateBlock.kFormatInt && position.optimizedControlDataType == InputStateBlock.kFormatVector3 && rotation.optimizedControlDataType == InputStateBlock.kFormatQuaternion && From 36ec9b9afc2d7b07f18d65942f02a24a530677f2 Mon Sep 17 00:00:00 2001 From: kevin-zakszewski <99926647+kevin-zakszewski@users.noreply.github.com> Date: Thu, 2 Jul 2026 15:27:32 -0700 Subject: [PATCH 2/3] Adding test for pose is tracked fix --- Assets/Tests/InputSystem/Plugins/XRTests.cs | 46 +++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/Assets/Tests/InputSystem/Plugins/XRTests.cs b/Assets/Tests/InputSystem/Plugins/XRTests.cs index 6f0e9cd1fd..b67fd13ffa 100644 --- a/Assets/Tests/InputSystem/Plugins/XRTests.cs +++ b/Assets/Tests/InputSystem/Plugins/XRTests.cs @@ -1222,6 +1222,52 @@ public void Controls_OptimizedControls_PoseControl_IsOptimized() Assert.That((device["posecontrol"] as PoseControl).optimizedControlDataType, Is.EqualTo(InputStateBlock.FormatPose)); } + [Test] + [Category("Controls")] + [TestCase(true)] + [TestCase(false)] + public void Controls_PoseControl_IsTracked_ReadsCorrectly(bool useOptimizedControls) + { + InputSystem.settings.SetInternalFeatureFlag(InputFeatureNames.kUseOptimizedControls, useOptimizedControls); + + runtime.ReportNewInputDevice(PoseDeviceState.CreateDeviceDescription().ToJson()); + + InputSystem.Update(); + + var device = InputSystem.devices[0]; + var poseControl = device["posecontrol"] as PoseControl; + + // Queue state with isTracked = true (byte value 1) + InputSystem.QueueStateEvent(device, new PoseDeviceState + { + isTracked = 1, + trackingState = (uint)(InputTrackingState.Position | InputTrackingState.Rotation), + position = new Vector3(1, 2, 3), + rotation = Quaternion.identity, + }); + InputSystem.Update(); + + // Reading isTracked as a ButtonControl should return true + Assert.That(poseControl.isTracked.isPressed, Is.True, "isTracked.isPressed should be true when tracked"); + Assert.That(poseControl.isTracked.ReadValue(), Is.EqualTo(1.0f).Within(0.001f), "isTracked.ReadValue() should be 1.0f when tracked"); + + // Reading the full PoseState should also have isTracked = true + var poseState = poseControl.ReadValue(); + Assert.That(poseState.isTracked, Is.True, "PoseState.isTracked should be true when tracked"); + + // Queue state with isTracked = false (byte value 0) + InputSystem.QueueStateEvent(device, new PoseDeviceState + { + isTracked = 0, + trackingState = 0, + }); + InputSystem.Update(); + + Assert.That(poseControl.isTracked.isPressed, Is.False, "isTracked.isPressed should be false when not tracked"); + Assert.That(poseControl.isTracked.ReadValue(), Is.EqualTo(0.0f).Within(0.001f), "isTracked.ReadValue() should be 0.0f when not tracked"); + Assert.That(poseControl.ReadValue().isTracked, Is.False, "PoseState.isTracked should be false when not tracked"); + } + // ISXB-405 [Test] [Category("Devices")] From 1fdc5db449d9dabb5ce94a3148ea99bebdaafaee Mon Sep 17 00:00:00 2001 From: kevin-zakszewski <99926647+kevin-zakszewski@users.noreply.github.com> Date: Thu, 2 Jul 2026 15:42:56 -0700 Subject: [PATCH 3/3] Changelog --- Packages/com.unity.inputsystem/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Packages/com.unity.inputsystem/CHANGELOG.md b/Packages/com.unity.inputsystem/CHANGELOG.md index 73b3864462..ac9ae472b5 100644 --- a/Packages/com.unity.inputsystem/CHANGELOG.md +++ b/Packages/com.unity.inputsystem/CHANGELOG.md @@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed an incorrect ArraysHelper.HaveDuplicateReferences implementation that didn't use its arguments right [ISXB-1792] (https://github.com/Unity-Technologies/InputSystem/pull/2376) - Fixed `InputAction.IsPressed`, `WasPressedThisFrame`, and `WasReleasedThisFrame` using a `ButtonControl`'s `pressPoint` when a binding also had an explicit `PressInteraction` with its own `pressPoint`, which could make those APIs disagree with the interaction's press and release behavior. Action-level press APIs now follow the interaction threshold when both are set explicitly. - Fixed `IndexOutOfRangeException` in `InputDeviceBuilder` when connecting an HID gamepad whose report descriptor declares a hat switch with Report Size 8 (e.g. ESP32-BLE-Gamepad). The HID layer now anchors the hat's directional sub-controls to the hat's own byte instead of letting the layout system auto-allocate a fresh byte for each [UUM-143659](https://jira.unity3d.com/browse/UUM-143659). +- Fixed `PoseControl.isTracked` always returning false when read through non-optimized code paths (e.g. Input Debugger) due to `sizeInBits = 8` causing the bool value to be normalized as `1/255` instead of `1.0`. ### Changed - Action-level `IsPressed`, `WasPressedThisFrame`, and `WasReleasedThisFrame` for bindings to `Vector2Control` / `StickControl` no longer consult a per-control `pressPoint` on the vector (that field was removed). Use a `Press` interaction to set a custom threshold, or rely on `defaultButtonPressPoint`.