Multitouch tracking ID defines the touch starting and touch end ( one touch session from start to end ).
So, For example, when I put my finger on touchscreen the driver should report the tracking id “n” and when finger is lifted it should report the tracking id as “0xffffffff” or “-1”.
Now, for the next touch the tracking id should be increased by 1 and it should report tracking id “n+1” and so on…
To make it more clear, below is an example of how values should be reported by driver for two touch sessions.. (here tracking id 45 and 46 are taken as an example )
SYN_MT_SLOT 0
ABS_MT_TRACKING_ID 45
ABS_MT_POSITION_X xVal
ABS_MT_POSITION_Y yVal
ABS_MT_POSITION_X xVal
ABS_MT_POSITION_Y yVal
ABS_MT_POSITION_X xVal
ABS_MT_POSITION_Y yVal
SYN_REPORT
SYN_MT_SLOT 0
ABS_MT_TRACKING_ID 46
ABS_MT_POSITION_X xVal
ABS_MT_POSITION_Y yVal
ABS_MT_POSITION_X xVal
ABS_MT_POSITION_Y yVal
SYN_REPORT
So, the first touch session is started with driver reporting “tracking id” as 45 , then we report 3 touch values with xVal and yVal and report the session 45 end with SYN_REPORT
As per Linux kernel documentation, following is the more information about ABS_MT_TRACKING_ID
ABS_MT_TRACKING_ID The TRACKING_ID identifies an initiated contact throughout its life cycle ( "Finger Tracking" as below ). The value range of the TRACKING_ID should be large enough to ensure unique identification of a contact maintained over an extended period of time.
Finger Tracking --------------- The process of finger tracking, i.e., to assign a unique trackingID to each initiated contact on the surface, is a Euclidian Bipartite Matching problem. At each event synchronization, the set of actual contacts is matched to the set of contacts from the previous synchronization.
Linux input device driver can send the ABS_MT_TRACKING_ID using below API
int trackingID = 0;
"when received new touch session, increment trackingID and send it as"
input_report_abs(ts_data1->input_dev, ABS_MT_TRACKING_ID, trackingID++);
Reference : https://www.kernel.org/doc/Documentation/input/multi-touch-protocol.txt
https://lkml.indiana.edu/hypermail/linux/kernel/1005.2/01567.html