Detecting Apple Trackpad

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
randomnovice
Party member
Posts: 109
Joined: Sat May 09, 2015 9:15 pm

Detecting Apple Trackpad

Post by randomnovice » Sat Jul 25, 2020 5:03 pm

Hi folks,

My Macbook Pro trackpad appears to detect on Löve exclusively as a mouse.

For example...

Code: Select all

function love.mousepressed(x, y, button, istouch, presses) 
  if istouch == true then print("Detected a touch via mousepressed") end
end
...and...

Code: Select all

function love.touchpressed(id, x, y, dx, dy, pressure)
  print("Detected a touch via touchpressed")
end
...both result in no joy (nothing printed).

Is there any way I can detect and make use of the trackpad?

I have tried love.touch.getTouches() and it doesn't detect anything.

Thanks!

(ps: I have checked that the touch module is enabled!)
(pps: I've using Zerobrane IDE if that's relevant, but I've confirmed it also doesn't work when packaged up as a .love file.)

User avatar
ReFreezed
Party member
Posts: 212
Joined: Sun Oct 25, 2015 11:32 pm
Location: Sweden
Contact:

Re: Detecting Apple Trackpad

Post by ReFreezed » Sun Jul 26, 2020 3:05 am

The touch functionality is for touch screens, i.e. when there's no single persistent "cursor" is involved. Trackpads are mostly just used as a pointing device replacement for the mouse. Also, the coordinates you get in the *pressed events are coordinates within the program's window - not on the trackpad or anything.

I think it'd be weird for a trackpad to behave like a touch screen.
Tools: Hot Particles, LuaPreprocess, (more)
Games: Momento Temporis: Light from the Deep, Energize!
"If each mistake being made is a new one, then progress is being made."

randomnovice
Party member
Posts: 109
Joined: Sat May 09, 2015 9:15 pm

Re: Detecting Apple Trackpad

Post by randomnovice » Sun Jul 26, 2020 5:17 am

Okay, thanks. Sounds like it's not possible to get access to the multi-touch capability then? I was thinking of making use of things like the pincer movement for zoom. The two finger scroll does get picked up by love.mouse.wheelmoved at least.

User avatar
ReFreezed
Party member
Posts: 212
Joined: Sun Oct 25, 2015 11:32 pm
Location: Sweden
Contact:

Re: Detecting Apple Trackpad

Post by ReFreezed » Sun Jul 26, 2020 12:49 pm

If gestures like pinching do not produce keyboard, mouse or touchscreen events then it's probably not possible to detect those in LÖVE right now. You can add a feature request for it in the issue tracker.

There may be a way to access trackpad information through SDL (which is what LÖVE uses under the hood) using the FFI module, but I don't know more than that.
Tools: Hot Particles, LuaPreprocess, (more)
Games: Momento Temporis: Light from the Deep, Energize!
"If each mistake being made is a new one, then progress is being made."

Post Reply

Who is online

Users browsing this forum: No registered users and 45 guests