Skip to content

Commit c55cdd9

Browse files
authored
ADD: Enable displayIndex support to 2022.3 (#1686)
1 parent ed76202 commit c55cdd9

4 files changed

Lines changed: 18 additions & 15 deletions

File tree

Assets/Tests/InputSystem/Plugins/UITests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3829,7 +3829,7 @@ public IEnumerator UI_WhenCursorIsLockedToScreenCenter_PointerEnterAndExitEvents
38293829
}
38303830

38313831
#region Multi Display Tests
3832-
#if UNITY_2023_1_OR_NEWER // displayIndex is only available from 2023.1 onwards
3832+
#if UNITY_2022_3_OR_NEWER // displayIndex is only available from 2022.3 onwards
38333833

38343834
[UnityTest]
38353835
#if UNITY_TVOS
@@ -4377,7 +4377,7 @@ private static ExtendedPointerEventData ClonePointerEventData(PointerEventData e
43774377
radius = eventData.radius,
43784378
radiusVariance = eventData.radiusVariance,
43794379
#endif
4380-
#if UNITY_2023_1_OR_NEWER
4380+
#if UNITY_2022_3_OR_NEWER
43814381
displayIndex = eventData.displayIndex,
43824382
#endif
43834383
};

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ however, it has to be formatted properly to pass verification tests.
1010

1111
## [Unreleased]
1212

13+
### Added
14+
- Enabled `displayIndex` support for Unity 2022.3.
15+
1316
### Fixed
1417
- Fixed UI clicks not registering when OS provides multiple input sources for the same event, e.g. on Samsung Dex (case ISX-1416, ISXB-342).
1518

Packages/com.unity.inputsystem/InputSystem/Plugins/UI/ExtendedPointerEventData.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public override string ToString()
9696
stringBuilder.AppendLine("altitudeAngle: " + altitudeAngle);
9797
stringBuilder.AppendLine("twist: " + twist);
9898
#endif
99-
#if UNITY_2023_1_OR_NEWER
99+
#if UNITY_2022_3_OR_NEWER
100100
stringBuilder.AppendLine("displayIndex: " + displayIndex);
101101
#endif
102102
return stringBuilder.ToString();
@@ -142,7 +142,7 @@ internal void ReadDeviceState()
142142
altitudeAngle = (pen.tilt.value.y + 1) * Mathf.PI / 2;
143143
twist = pen.twist.value * Mathf.PI * 2;
144144
#endif
145-
#if UNITY_2023_1_OR_NEWER
145+
#if UNITY_2022_3_OR_NEWER
146146
displayIndex = pen.displayIndex.ReadValue();
147147
#endif
148148
}
@@ -153,7 +153,7 @@ internal void ReadDeviceState()
153153
pressure = touchControl.pressure.magnitude;
154154
radius = touchControl.radius.value;
155155
#endif
156-
#if UNITY_2023_1_OR_NEWER
156+
#if UNITY_2022_3_OR_NEWER
157157
displayIndex = touchControl.displayIndex.ReadValue();
158158
#endif
159159
}
@@ -164,7 +164,7 @@ internal void ReadDeviceState()
164164
pressure = touchscreen.pressure.magnitude;
165165
radius = touchscreen.radius.value;
166166
#endif
167-
#if UNITY_2023_1_OR_NEWER
167+
#if UNITY_2022_3_OR_NEWER
168168
displayIndex = touchscreen.displayIndex.ReadValue();
169169
#endif
170170
}

Packages/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModule.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1737,7 +1737,7 @@ private int GetPointerStateIndexFor(InputControl control, bool createIfNotExists
17371737
eventData.pointerType = pointerType;
17381738
eventData.pointerId = pointerId;
17391739
eventData.touchId = touchId;
1740-
#if UNITY_2023_1_OR_NEWER
1740+
#if UNITY_2022_3_OR_NEWER
17411741
eventData.displayIndex = displayIndex;
17421742
#endif
17431743

@@ -1833,7 +1833,7 @@ private int AllocatePointer(int pointerId, int displayIndex, int touchId, UIPoin
18331833
eventData = new ExtendedPointerEventData(eventSystem);
18341834

18351835
eventData.pointerId = pointerId;
1836-
#if UNITY_2023_1_OR_NEWER
1836+
#if UNITY_2022_3_OR_NEWER
18371837
eventData.displayIndex = displayIndex;
18381838
#endif
18391839
eventData.touchId = touchId;
@@ -1959,7 +1959,7 @@ private void OnPointCallback(InputAction.CallbackContext context)
19591959

19601960
ref var state = ref GetPointerStateForIndex(index);
19611961
state.screenPosition = context.ReadValue<Vector2>();
1962-
#if UNITY_2023_1_OR_NEWER
1962+
#if UNITY_2022_3_OR_NEWER
19631963
state.eventData.displayIndex = GetDisplayIndexFor(context.control);
19641964
#endif
19651965
}
@@ -1990,7 +1990,7 @@ private void OnLeftClickCallback(InputAction.CallbackContext context)
19901990
state.changedThisFrame = true;
19911991
if (IgnoreNextClick(ref context, wasPressed))
19921992
state.leftButton.ignoreNextClick = true;
1993-
#if UNITY_2023_1_OR_NEWER
1993+
#if UNITY_2022_3_OR_NEWER
19941994
state.eventData.displayIndex = GetDisplayIndexFor(context.control);
19951995
#endif
19961996
}
@@ -2007,7 +2007,7 @@ private void OnRightClickCallback(InputAction.CallbackContext context)
20072007
state.changedThisFrame = true;
20082008
if (IgnoreNextClick(ref context, wasPressed))
20092009
state.rightButton.ignoreNextClick = true;
2010-
#if UNITY_2023_1_OR_NEWER
2010+
#if UNITY_2022_3_OR_NEWER
20112011
state.eventData.displayIndex = GetDisplayIndexFor(context.control);
20122012
#endif
20132013
}
@@ -2024,7 +2024,7 @@ private void OnMiddleClickCallback(InputAction.CallbackContext context)
20242024
state.changedThisFrame = true;
20252025
if (IgnoreNextClick(ref context, wasPressed))
20262026
state.middleButton.ignoreNextClick = true;
2027-
#if UNITY_2023_1_OR_NEWER
2027+
#if UNITY_2022_3_OR_NEWER
20282028
state.eventData.displayIndex = GetDisplayIndexFor(context.control);
20292029
#endif
20302030
}
@@ -2055,7 +2055,7 @@ private void OnScrollCallback(InputAction.CallbackContext context)
20552055
// The old input system reported scroll deltas in lines, we report pixels.
20562056
// Need to scale as the UI system expects lines.
20572057
state.scrollDelta = context.ReadValue<Vector2>() * (1 / kPixelPerLine);
2058-
#if UNITY_2023_1_OR_NEWER
2058+
#if UNITY_2022_3_OR_NEWER
20592059
state.eventData.displayIndex = GetDisplayIndexFor(context.control);
20602060
#endif
20612061
}
@@ -2074,7 +2074,7 @@ private void OnTrackedDeviceOrientationCallback(InputAction.CallbackContext cont
20742074

20752075
ref var state = ref GetPointerStateForIndex(index);
20762076
state.worldOrientation = context.ReadValue<Quaternion>();
2077-
#if UNITY_2023_1_OR_NEWER
2077+
#if UNITY_2022_3_OR_NEWER
20782078
state.eventData.displayIndex = GetDisplayIndexFor(context.control);
20792079
#endif
20802080
}
@@ -2087,7 +2087,7 @@ private void OnTrackedDevicePositionCallback(InputAction.CallbackContext context
20872087

20882088
ref var state = ref GetPointerStateForIndex(index);
20892089
state.worldPosition = context.ReadValue<Vector3>();
2090-
#if UNITY_2023_1_OR_NEWER
2090+
#if UNITY_2022_3_OR_NEWER
20912091
state.eventData.displayIndex = GetDisplayIndexFor(context.control);
20922092
#endif
20932093
}

0 commit comments

Comments
 (0)