Author Topic: Windows 10 touch support  (Read 496 times)

rtauziac

  • Newbie
  • *
  • Posts: 3
    • View Profile
Windows 10 touch support
« on: March 21, 2019, 09:23:05 AM »
Hello,

I'm using the world map in a Windows 10 standalone app and I'm facing a problem with earth rotation on touch drag.
I have a computer with a touch screen and when I want to rotate the earth, the first touch doesn't work, then all the other touches works like if I have never released the finger so it's impossible to rotate the world entirely, it comes back to where you have touched the earth first. However I can still flick the globe, but the rotation cancels back when I touch it again.
The rotation works well as expected if I use a mouse on the standalone and in the editor.
I tried to remove all the UI from my app but it doesn't help.
Have you ever experienced something like that?

Thanks in advance.

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 4843
    • View Profile
Re: Windows 10 touch support
« Reply #1 on: March 21, 2019, 10:17:23 AM »
The asset has been tested on desktop, mobile and some VR devices, but not Windows 10-based touch displays.
Try latest beta and check if some late changes correctly capture the touches on those devices as well.
Regards.

rtauziac

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Windows 10 touch support
« Reply #2 on: March 22, 2019, 03:07:39 AM »
Hello,

I used the last beta version but it didn't fix the issue.
It would be nice if you can have a look at it, I'm on a tight schedule, my project needs to be released in two weeks. I can still test the changes and would be happy to contribute.
I'll also try to fix it on my side.
Regards.

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 4843
    • View Profile
Re: Windows 10 touch support
« Reply #3 on: March 22, 2019, 06:00:31 AM »
Ok, thanks for trying the latest beta, will try to fix it asap.
In order you can debug and try to fix this issue on yourself, you can take a look at Update() and CheckUserInteractionNormalMode() method inside WPMInternal.cs file.
Regards

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 4843
    • View Profile
Re: Windows 10 touch support
« Reply #4 on: March 31, 2019, 03:38:57 AM »
Hi, did you manage to improve/fix this on your end?

rtauziac

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Windows 10 touch support
« Reply #5 on: April 01, 2019, 07:53:59 AM »
Hello,

I managed to make it work.
There was no call to any Input.getTouch(), so I added some logic to detect if there's any touch every frame.

In the Update of your internal class:
Code
Touch? currentTouch = null;
if (Input.touchCount > 0)
{
    currentTouch = Input.GetTouch(0);
}
Then check the new state of leftMouseButtonPressed
Code
leftMouseButtonPressed || Input.GetMouseButton(0) || (_previousTouch.HasValue == false && currentTouch.HasValue);
_previousTouch is a instance property, we store the last touch to the next frame after all Update logic
Code
_previousTouch = currentTouch;
But most important was to update the mouseIsOver flag right after checking leftMouseButtonPressed because, unlike a mouse which is over before clicking, on a touch device it happens both at the same time.
Code
if (leftMouseButtonPressed)
{
    if (UpdateCursorLocation())
    {
        mouseIsOver = true;
    }
}

Also I had to disable Respect Other UI because it won't detect the first touch after interacting with my UI, but it was OK since my UI didn't overlap the earth.

Hope it helps.

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 4843
    • View Profile
Re: Windows 10 touch support
« Reply #6 on: April 01, 2019, 08:20:24 AM »
Glad you managed to make it work!
And thank you for the code hints. I'll review and add your suggestions into next update.