Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions Packages/com.unity.inputsystem/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ however, it has to be formatted properly to pass verification tests.
- Fixed an issue where batch jobs would fail with "Error: Error building Player because scripts are compiling" if a source generated .inputactions asset is out of sync with its generated source code (ISXB-1300).
- Fixed multiple `OnScreenStick` Components that does not work together when using them simultaneously in isolation mode. [ISXB-813](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-813)
- Fixed an issue in input actions editor window that caused certain fields in custom input composite bindings to require multiple clicks to action / focus. [ISXB-1171](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1171)
- Fixed an editor/player hang in `InputSystemUIInputModule` due to an infinite loop. This was caused by the assumption that `RemovePointerAtIndex` would _always_ successfully remove the pointer, which is not the case with touch based pointers. [ISXB-1258](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1258)

### Changed
- Changed location of the link xml file (code stripping rules), from a temporary directory to the project Library folder (ISX-2140).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1662,9 +1662,11 @@ protected override void OnDisable()

private void ResetPointers()
{
var numPointers = m_PointerStates.length;
for (var i = 0; i < numPointers; ++i)
SendPointerExitEventsAndRemovePointer(0);
for (var i = 0; i < m_PointerStates.length; ++i)
{
if (SendPointerExitEventsAndRemovePointer(i))
--i;
}

m_CurrentPointerId = -1;
m_CurrentPointerIndex = -1;
Expand Down Expand Up @@ -2021,24 +2023,26 @@ private int AllocatePointer(int pointerId, int displayIndex, int touchId, UIPoin
return m_PointerStates.AppendWithCapacity(new PointerModel(eventData));
}

private void SendPointerExitEventsAndRemovePointer(int index)
// Returns true if the pointer was successfully removed (ISXB-1258)
private bool SendPointerExitEventsAndRemovePointer(int index)
{
var eventData = m_PointerStates[index].eventData;
if (eventData.pointerEnter != null)
ProcessPointerMovement(eventData, null);

RemovePointerAtIndex(index);
return RemovePointerAtIndex(index);
}

private void RemovePointerAtIndex(int index)
private bool RemovePointerAtIndex(int index)
{
Debug.Assert(m_PointerStates[index].eventData.pointerEnter == null, "Pointer should have exited all objects before being removed");

// We don't want to release touch pointers on the same frame they are released (unpressed). They get cleaned up one frame later in Process()
ref var state = ref GetPointerStateForIndex(index);
if (state.pointerType == UIPointerType.Touch && (state.leftButton.isPressed || state.leftButton.wasReleasedThisFrame))
{
return;
// The pointer was not removed
return false;
}

// Retain event data so that we can reuse the event the next time we allocate a PointerModel record.
Expand Down Expand Up @@ -2086,6 +2090,8 @@ private void RemovePointerAtIndex(int index)
m_PointerStates.firstValue.eventData = eventData;
else
m_PointerStates.additionalValues[m_PointerStates.length - 1].eventData = eventData;

return true;
}

// Remove any pointer that no longer has the ability to point.
Expand All @@ -2100,8 +2106,9 @@ private void PurgeStalePointers()
!HaveControlForDevice(device, trackedDevicePosition) &&
!HaveControlForDevice(device, trackedDeviceOrientation)))
{
SendPointerExitEventsAndRemovePointer(i);
--i;
// Only decrement 'i' if the pointer was successfully removed
if (SendPointerExitEventsAndRemovePointer(i))
--i;
}
}

Expand Down Expand Up @@ -2310,8 +2317,8 @@ private void FilterPointerStatesByType()
}
if (m_PointerStates[i].pointerType != UIPointerType.MouseOrPen && m_PointerStates[i].pointerType != UIPointerType.Touch || (m_PointerStates[i].pointerType == UIPointerType.Touch && !state.leftButton.isPressed && !state.leftButton.wasReleasedThisFrame))
{
SendPointerExitEventsAndRemovePointer(i);
--i;
if (SendPointerExitEventsAndRemovePointer(i))
--i;
}
}
}
Expand All @@ -2322,8 +2329,8 @@ private void FilterPointerStatesByType()
{
if (m_PointerStates[i].pointerType == UIPointerType.MouseOrPen)
{
SendPointerExitEventsAndRemovePointer(i);
--i;
if (SendPointerExitEventsAndRemovePointer(i))
--i;
}
}
}
Expand Down
Loading