[Windows] touchscreen.current.activeTouches does not correctly report multiple touches
Reproduce using the scene in the attached project. The UI will indicate when a touch is active and its reported screen position. (1) Multitouch does not seem to work (2) By tapping 2 separate fingers in quick succession, you can get a additional touches to appear, but the originial touches become "dead." Dead touches do not update their position and are not removed from the activeTouch list.
Found in commit b03c6f23b74b76596966a634a67ff74f354f8e17 with editor commit 725fd26e2382 on a Razer laptop with touchscreen.
I see touch behaving properly outside of play mode so my thinking is that this is a bug in the state maintenance code itself. I.e. rather than Touchscreen doing something wrong, it's probably InputManager's handling of IStateCallbackReceiver where things blow up.
Test showing the issue.
`
public void Devices_TouchscreenPhasesResets()
{
var device = InputSystem.AddDevice
InputSystem.QueueStateEvent(device,
new TouchState
{
phase = PointerPhase.Began,
touchId = 92,
});
InputSystem.QueueStateEvent(device,
new TouchState
{
phase = PointerPhase.Moved,
touchId = 92,
});
InputSystem.Update();
InputSystem.QueueStateEvent(device,
new TouchState
{
phase = PointerPhase.Ended,
touchId = 92,
});
InputSystem.QueueStateEvent(device,
new TouchState
{
phase = PointerPhase.Began,
touchId = 93,
});
InputSystem.QueueStateEvent(device,
new TouchState
{
phase = PointerPhase.Moved,
touchId = 93,
});
InputSystem.Update();
InputSystem.QueueStateEvent(device,
new TouchState
{
phase = PointerPhase.Ended,
touchId = 93,
});
InputSystem.Update();
InputSystem.Update();
Assert.That(device.allTouchControls[0].phase.ReadValue(), Is.EqualTo(PointerPhase.None));
Assert.That(device.allTouchControls[1].phase.ReadValue(), Is.EqualTo(PointerPhase.None));
Assert.That(device.activeTouches.Count, Is.Zero);
}`
Seems the issue is with OnCarryStateForward, waiting for @Rene-Damm to try out the test.
Hey @jackpr-unity, could you give the fix above a spin and see if this resolves the issue for you?
Multiple touches now register, but I still get ghost touches.
2018.2.0b4, changeset 08c87fc4c6268bcc2d9644f828d98fc6736e4e85
Found a test which reproduces this:
`
[Test]
[Category("Devices")]
public void Devices_FastTouchesDontGetStuck()
{
var device = InputSystem.AddDevice
InputSystem.QueueStateEvent(device,
new TouchState
{
phase = PointerPhase.Began,
touchId = 0,
});
InputSystem.QueueStateEvent(device,
new TouchState
{
phase = PointerPhase.Ended,
touchId = 0,
});
InputSystem.QueueStateEvent(device,
new TouchState
{
phase = PointerPhase.Began,
touchId = 0,
});
InputSystem.QueueStateEvent(device,
new TouchState
{
phase = PointerPhase.Ended,
touchId = 0,
});
InputSystem.Update();
InputSystem.Update();
Assert.That(device.activeTouches.Count, Is.EqualTo(0));
Assert.That(device.allTouchControls[0].phase.ReadValue(), Is.EqualTo(PointerPhase.None));
}
`
Still present with 2018.3.5f1 and commit 5d0704c
It seems the multiple-touch handling is fixed long time ago. Closing.