love
love copied to clipboard
Multi-touch support for trackpads and touch displays
Allowing the trackpad under macOS to trigger pre-exisiting love.touch functionality through SDL's native SDL_TouchFingerEvent (which already supports it) would make testing mobile applications on desktop a breeze, and allow gestures for interface navigation (which would be a godsend).
Trackpads don't behave like touch screens at all, because there's no correlation between where the user presses the trackpad and a location on the screen.
I added this functionality to SDL relatively recently to account for that difference https://hg.libsdl.org/SDL/rev/eb60e952b13f - I wouldn't feel good about exposing trackpad touches in love without making sure the API made that touch type distinction very clear, so people don't write code that will break when a trackpad is used (especially since end users actually use their trackpad to move the mouse cursor).
I described the problem a bit more here https://bugzilla.libsdl.org/show_bug.cgi?id=3542#c1 (although I wrote that before the above APIs were added to SDL).
Thank you for the detailed explanation, I understand what you mean.
Trackpads don't behave like touch screens at all, because there's no correlation between where the user presses the trackpad and a location on the screen.
My hypothetical case of testing mobile apps in Love doesn't make a whole lot of sense, I realise now. Still, I think this is worth including just for the sake of location-agnostic gestures like pinch to zoom or drawing with multi touch. I personally know of a lot of people (myself included) whose programs could benefit from this weird hybrid place the trackpad sits in. Maybe only allowing ignoring the mouse data in favour of trackpad when the mouse has been captured and hidden by the window? Like how Preview accepts signatures.

And in the other case keeping the two separate, that is, if the trackpad has multiple fingers on it, it no longer sending any love.mouse signals, only multitouch info, which can be manually sifted by the coder (I think this happens automatically at OS level though.)
I added this functionality to SDL relatively recently to account for that difference https://hg.libsdl.org/SDL/rev/eb60e952b13f - I wouldn't feel good about exposing trackpad touches in love without making sure the API made that touch type distinction very clear, so people don't write code that will break when a trackpad is used (especially since end users actually use their trackpad to move the mouse cursor).
Is API naming the biggest hurdle here? I'm guessing a love.trackpad class might be too much fragmentation for your liking, which I understand. If so, I would be glad to draft documentation that could fit it into love.touch or love.mouse.
For the sake of cross-platform feature compatibility, how would this work on windows and linux?
For the sake of cross-platform feature compatibility, how would this work on windows and linux?
I was unable to find documentation for a multitouch API in either for trackpads but... found someone talking about it here, about SDL_MultiGestureEvent.
Looks to me that Mac has trackpads triggering MultiGestureEvent natively, while Windows and Linux have touch panels doing the same. So it would benefit all three platforms. :)
@slime73 Is the Touch FFI from love-snippets still expected to be functional? I can't get it to work with 11.3. Otherwise, would it be non-trivial to get it running with the new SDL functionality you added?
I have the Touch FFI and therefore trackpad multitouch working when I build love2d with SDL_SetHint(SDL_HINT_MOUSE_TOUCH_EVENTS, "1") added to the int main() in love.cpp.
AFAIK there's no equivalent API in Windows and Linux for this one, so having it working in all platforms that LOVE supports would be next to impossible.
Multitouch on touch displays has been supported since 0.10.0. However multitouch (and absolute coordinate) for trackpads are another story.
But surely there isn't a downside to having the SDL hint enabled by default, since it needs FFI to be usable anyway?
Not sure but after checking it, SDL_HINT_MOUSE_TOUCH_EVENTS
is responsible whetever LOVE will also fire mousepressed
/moved
/released
when the input comes from touchscreen and this is enabled by default.