SFML community forums

Help => Window => Topic started by: Herb on October 20, 2016, 05:51:07 pm

Title: No touch events on Surface devices
Post by: Herb on October 20, 2016, 05:51:07 pm
On a MS Surface 3, all touch events come in as mouse events:

- sf::EventType::MouseButtonPressed
- sf::EventType::MouseButtonReleased  <-- rarely receive this one
- sf::EventType::MouseMoved

This would be okay if the Released messages were reliable, but rarely receive them.

Also tried using sf::Touch::isDown() but it never returns true.  It's like SFML is completely unable to hook the touchscreen at all on these Surface devices.

I searched the forum before posting this.  Does anyone know of a reliable workaround?

Thanks.
Title: Re: No touch events on Surface devices
Post by: Mario on October 20, 2016, 10:45:52 pm
If possible, try using a debug build and step through related window messages. Don't think any of us has a Surface 3 for testing (unless anyone is up for buying me one… :P).
Title: Re: No touch events on Surface devices
Post by: Herb on October 21, 2016, 01:24:04 am
Hi Mario,

Yes, I did step through with a debugger, and set breakpoints.  That is how I verified that only mouse events are coming in.  Besides events, the sf::Touch class is not returning any activity at all.  Am I missing an SFML setup or initialization call for touchscreen?

Thanks.
Title: Re: No touch events on Surface devices
Post by: Laurent on October 21, 2016, 07:38:36 am
Touch events are not implemented in the Windows back-end. So unless the OS correctly maps them to mouse events, you won't get anything.
Title: Re: No touch events on Surface devices
Post by: Herb on October 21, 2016, 04:41:47 pm
Thanks for the reply, Laurent.  *Please* add that to the documentation.  I spent about 16 hours on this unnecessarily.
Title: Re: No touch events on Surface devices
Post by: Mario on October 21, 2016, 07:16:14 pm
Argh, right, now I remember that pull request still isn't merged!

You can check out SFML's branch "feature/windows_touch", which includes touch support for Windows – although it's untested on actual devices.

You can find the details in this pull request. (https://github.com/SFML/SFML/pull/912)

If you want to give it a spin, leave your feedback in the PR. :)

Just keep in mind this branch implements the touch events but not the functions to check directly (i.e. sf::Touch*()).