diff --git a/Packages/com.unity.inputsystem/CHANGELOG.md b/Packages/com.unity.inputsystem/CHANGELOG.md index a1969a7bd0..e41e3c38b4 100644 --- a/Packages/com.unity.inputsystem/CHANGELOG.md +++ b/Packages/com.unity.inputsystem/CHANGELOG.md @@ -55,6 +55,7 @@ however, it has to be formatted properly to pass verification tests. - Fixed potential crash on Mac when using stale references to deleted InputDevice objects [ISXB-606](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-606). - Fixed conditional compilation for non-editor analytics on platforms not enabling analytics. - Fixed simulated touch input not working with PlayerInput component [ISXB-483](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-483). +- Fixed unused PenState information to determine the displayIndex on platforms providing it. (PLAT-10123) ### Changed - Renamed editor Resources directories to PackageResources to fix package validation warnings. diff --git a/Packages/com.unity.inputsystem/InputSystem/Devices/Pen.cs b/Packages/com.unity.inputsystem/InputSystem/Devices/Pen.cs index 96b0257c67..9c0f8e5a07 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Devices/Pen.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Devices/Pen.cs @@ -98,8 +98,10 @@ public struct PenState : IInputStateTypeInfo [FieldOffset(32)] public ushort buttons; - // Not currently used, but still needed in this struct for padding, - // as il2cpp does not implement FieldOffset. + /// + /// The index of the display that was touched. + /// + [InputControl(name = "displayIndex", displayName = "Display Index", layout = "Integer")] [FieldOffset(34)] ushort displayIndex; @@ -379,6 +381,7 @@ protected override void FinishSetup() inRange = GetChildControl("inRange"); tilt = GetChildControl("tilt"); twist = GetChildControl("twist"); + displayIndex = GetChildControl("displayIndex"); base.FinishSetup(); } } diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/InputForUI/InputSystemProvider.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/InputForUI/InputSystemProvider.cs index 2af56bd88c..9cb34c56a4 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/InputForUI/InputSystemProvider.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/InputForUI/InputSystemProvider.cs @@ -420,7 +420,7 @@ void OnPointerPerformed(InputAction.CallbackContext ctx) m_SeenPenEvents = true; var positionISX = ctx.ReadValue(); - var targetDisplay = asPointerDevice != null ? asPointerDevice.displayIndex.ReadValue() : (asTouchscreenDevice != null ? asTouchscreenDevice.displayIndex.ReadValue() : 0); + var targetDisplay = asPointerDevice != null ? asPointerDevice.displayIndex.ReadValue() : (asTouchscreenDevice != null ? asTouchscreenDevice.displayIndex.ReadValue() : (asPenDevice != null ? asPenDevice.displayIndex.ReadValue() : 0)); var position = ScreenBottomLeftToPanelPosition(positionISX, targetDisplay); var delta = pointerState.LastPositionValid ? position - pointerState.LastPosition : Vector2.zero;