From 1fe3a18cb6fa39369ee17bb19ba27fd2f62ac346 Mon Sep 17 00:00:00 2001 From: Brice Gros Date: Thu, 1 Aug 2024 19:22:48 +0200 Subject: [PATCH 1/2] Make displayIndex usable for PenState --- Packages/com.unity.inputsystem/InputSystem/Devices/Pen.cs | 7 +++++-- .../InputSystem/Plugins/InputForUI/InputSystemProvider.cs | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) 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 98e06a7bea..a6afbf9d68 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; From d090e356b4412109a0994f11849d849b92e06201 Mon Sep 17 00:00:00 2001 From: Brice Gros Date: Wed, 2 Oct 2024 17:42:31 +0200 Subject: [PATCH 2/2] Update 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 01be12e01b..60bca3be68 100644 --- a/Packages/com.unity.inputsystem/CHANGELOG.md +++ b/Packages/com.unity.inputsystem/CHANGELOG.md @@ -17,6 +17,7 @@ however, it has to be formatted properly to pass verification tests. - Fixed "MissingReferenceException" errors when closing an in-game dropdown field [ISXB-1081](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1081). - 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 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.