views:

756

answers:

4

Hi all,

I just bought a Magic Mouse and I like it pretty much. But as a Mac Developer it's even cooler. But there's one problem: is there already an API available for it? I want to use it for one of my applications. For, example, detect the user's finger positions, swipe or stretch gestures etc...

Does anyone know if there's an API for it (and how to use it)?

Thanks in advance.

+2  A: 

I have not tested, but I would be shocked if it didn't use NSTouch. NSTouch is the API you use to interact with the multi-touch trackpads on current MacBook Pros (and the new MacBooks that came out this week). You can check out the LightTable sample project to see how it is used.

It is part of AppKit, but it is a Snow Leopard only API.

Louis Gerbarg
I stand corrected, was not aware of that. Nice!
Mark Mayo
Have you tried it, uberRouse? I don't have a Magic Mouse yet... It would be interesting to know if devs can access the touches on this device.
Jasarien
+4  A: 

The Magic Mouse does /not/ use the NSTouch API. I have been experimenting with it and attempting to capture touch information. I've had no luck so far. The only touch method that is common to both the mouse and the trackpad is the swipeWithEvent: method. It is called for a two finger swipe on the device only.

It seems the touch input from the mouse is being interpreted somewhere else, then forwarded on to the public API. I have yet to find the private API that is actually doing the work.

Sastira
See my post here for my latest findings: http://stackoverflow.com/questions/1669909/extending-functionality-of-magic-mouse-do-i-need-a-kext
Sastira
+1  A: 

I messed around with the below app before getting my magic mouse. I was surprised to find that the app also tracked the multi touch points on the mouse.

There is a link in the comments to some source that gets the raw data similarly, but there is no source to this actual app.

http://lericson.blogg.se/code/2009/november/multitouch-on-unibody-macbooks.html

Michael Pardo
The link mentioned is http://steike.com/code/multitouch/, which shows how to use the undocumented, not for production code private Multitouch framework to detect the position and elliptical shape of the touches.
natevw
+2  A: 

get a look here: http://aladino.dmi.unict.it/?a=multitouch

there's a full working proof-of-concept using the CGEventPost method.

-- all the best!

valv0