If you are interested in getting touch information richer than position, you can use a private framework to do that.


Objective C

  1. Link your target with the framework (/System/Library/PrivateFrameworks/MultitouchSupport.framework/MultitouchSupport)
  2. Add MTDeviceDeclarations.h to your project.
  3. Query list of available devices:
+
NSMutableArray* deviceList = (NSMutableArray*)MTDeviceCreateList(); 
  1. Register callback:
+
MTRegisterContactFrameCallback(deviceList objectAtIndex:i, touchCallback);
  1. Starts receiving events:
+
MTDeviceStart(deviceList objectAtIndex:i, 0); //start sending events
  1. 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)
  1. 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.

Example projects:



Utility

Attachments:
File Description File size Downloads Last modified
MTDeviceDeclarations.h MTDeviceDeclarations.h 2 kB 961 2011-04-11 21:29
TestMultitouchFramework.zip Objective-C 24 kB 454 2011-04-11 21:33
MultitouchPython.py Python 3 kB 1006 2011-04-11 21:33
FingerMgmt.app.zip Finger visualization 36 kB 456 2011-04-11 21:34