
Objective C
- Link your target with the framework (/System/Library/PrivateFrameworks/MultitouchSupport.framework/MultitouchSupport)
- Add MTDeviceDeclarations.h to your project.
- Query list of available devices:
NSMutableArray* deviceList = (NSMutableArray*)MTDeviceCreateList();
- Register callback:
MTRegisterContactFrameCallback(deviceList objectAtIndex:i, touchCallback);
- Starts receiving events:
MTDeviceStart(deviceList objectAtIndex:i, 0); //start sending events
- The callback function should have this signature (maximum number of fingers can be detected is 11):
int touchCallback(int device, Touch *data, int nFingers, double timestamp, int frame)
- Touch struct has this structure:
typedef struct
{
int frame; //the current frame
double timestamp; //event timestamp
int identifier; //identifier guaranteed unique for life of touch per device
int state; //the current state (not sure what the values mean)
int unknown1; //no idea what this does
int unknown2; //no idea what this does either
mtVector normalized; //the normalized position and vector of the touch (0,0 to 1,1)
float size; //the size of the touch (the area of your finger being tracked)
int unknown3; //no idea what this does
float angle; //the angle of the touch in radian -|
float majorAxis; //the major axis of the touch -|-- an ellipsoid. you can track the angle of each finger!
float minorAxis; //the minor axis of the touch -|
mtVector unknown4; //not sure what this is for
int unknown52; //no clue
float unknown6; //no clue
}Touch;
Another way to deal with touches (currently less rich, but without a private framework) is explained here.