Apple Magic Mouse Api

我怕爱的太早我们不能终老 提交于 2019-12-13 11:43:23

问题


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)?


回答1:


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.




回答2:


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.




回答3:


get a look here: http://www.iphonesmartapps.org/aladino/?a=multitouch

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

-- all the best!




回答4:


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



来源:https://stackoverflow.com/questions/1607020/apple-magic-mouse-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!