InputSystem icon indicating copy to clipboard operation
InputSystem copied to clipboard

[Windows] touchscreen.current.activeTouches does not correctly report multiple touches

Open jackpr-unity opened this issue 8 years ago • 7 comments

ActiveTouchTest.zip

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.

jackpr-unity avatar Apr 26 '18 21:04 jackpr-unity

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.

Rene-Damm avatar Apr 30 '18 17:04 Rene-Damm

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.

todi1856 avatar May 08 '18 11:05 todi1856

Hey @jackpr-unity, could you give the fix above a spin and see if this resolves the issue for you?

Rene-Damm avatar May 15 '18 00:05 Rene-Damm

Multiple touches now register, but I still get ghost touches.

2018.2.0b4, changeset 08c87fc4c6268bcc2d9644f828d98fc6736e4e85

jackpr-unity avatar May 16 '18 19:05 jackpr-unity

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));
}

`

todi1856 avatar Jun 14 '18 13:06 todi1856

Still present with 2018.3.5f1 and commit 5d0704c

jackpr-unity avatar Feb 08 '19 22:02 jackpr-unity

It seems the multiple-touch handling is fixed long time ago. Closing.

JiaUnity avatar Mar 06 '19 00:03 JiaUnity