Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Packages/com.unity.inputsystem/InputSystem/Devices/Pen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
/// <summary>
/// The index of the display that was touched.
/// </summary>
[InputControl(name = "displayIndex", displayName = "Display Index", layout = "Integer")]
[FieldOffset(34)]
ushort displayIndex;

Expand Down Expand Up @@ -379,6 +381,7 @@ protected override void FinishSetup()
inRange = GetChildControl<ButtonControl>("inRange");
tilt = GetChildControl<Vector2Control>("tilt");
twist = GetChildControl<AxisControl>("twist");
displayIndex = GetChildControl<IntegerControl>("displayIndex");
base.FinishSetup();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ void OnPointerPerformed(InputAction.CallbackContext ctx)
m_SeenPenEvents = true;

var positionISX = ctx.ReadValue<Vector2>();
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;

Expand Down