I’m trying to write a library to get the touch events from an Apple Magic Mouse. I’m using the private framework MultitouchSupport.framework and use the code below to get a list of multitouch devices. This works great, and my library works well, except for the fact that it gets touch events from all multitouch devices, such as the laptops trackpad, while I’d like to only get events from a Magic Mouse. How can I tell what type of devices I am looking at to only monitor the mouse?
The code I use to listen for events is
NSMutableArray* deviceList = (__bridge NSMutableArray*)MTDeviceCreateList(); //grab our device list
for(int i = 0; i<[deviceList count]; i++) //iterate available devices
{
MTRegisterContactFrameCallback([deviceList objectAtIndex:i], touchCallback); //assign callback for device
MTDeviceStart([deviceList objectAtIndex:i], 0); //start sending events
}
so how can i filter out the MTDeviceRefs returned from MTDeviceCreateList to only start listening to magic mouse devices? Or at the very least, filter out the default laptop trackpad? Is there any documentation for using this MultitouchSupport.framework?
There are at least four other ways to obtain a
MTDeviceRef:MTDeviceCreateDefaultMTDeviceCreateFromDeviceIDMTDeviceCreateFromGUIDMTDeviceCreateFromServiceMultitouchSupport.framework being a private framework, you will have to reverse engineer it in order to understand what are the parameters you should pass to these functions.
Also, if you obtain a reference from one of these function, you should probably release the device ref with the
MTDeviceReleasefunction.Or you could try to filter out the trackpad with the
MTDeviceIsBuiltInfunction. Maybe BuiltIn means laptop trackpad. This is just a wild guess, I just looked at the symbols in the MultitouchSupport framework binary. Given the function name its signature is probablyBOOL MTDeviceIsBuiltIn(MTDeviceRef device)Again, this is just a guess, I haven’t actually tried.