1e2ba5731SMauro Carvalho Chehab.. include:: <isonum.txt> 2e2ba5731SMauro Carvalho Chehab 3e2ba5731SMauro Carvalho Chehab========================= 4e2ba5731SMauro Carvalho ChehabMulti-touch (MT) Protocol 5e2ba5731SMauro Carvalho Chehab========================= 6e2ba5731SMauro Carvalho Chehab 7e2ba5731SMauro Carvalho Chehab:Copyright: |copy| 2009-2010 Henrik Rydberg <rydberg@euromail.se> 8e2ba5731SMauro Carvalho Chehab 9e2ba5731SMauro Carvalho Chehab 10e2ba5731SMauro Carvalho ChehabIntroduction 11e2ba5731SMauro Carvalho Chehab------------ 12e2ba5731SMauro Carvalho Chehab 13e2ba5731SMauro Carvalho ChehabIn order to utilize the full power of the new multi-touch and multi-user 14e2ba5731SMauro Carvalho Chehabdevices, a way to report detailed data from multiple contacts, i.e., 15e2ba5731SMauro Carvalho Chehabobjects in direct contact with the device surface, is needed. This 16e2ba5731SMauro Carvalho Chehabdocument describes the multi-touch (MT) protocol which allows kernel 17e2ba5731SMauro Carvalho Chehabdrivers to report details for an arbitrary number of contacts. 18e2ba5731SMauro Carvalho Chehab 19e2ba5731SMauro Carvalho ChehabThe protocol is divided into two types, depending on the capabilities of the 20e2ba5731SMauro Carvalho Chehabhardware. For devices handling anonymous contacts (type A), the protocol 21e2ba5731SMauro Carvalho Chehabdescribes how to send the raw data for all contacts to the receiver. For 22e2ba5731SMauro Carvalho Chehabdevices capable of tracking identifiable contacts (type B), the protocol 23e2ba5731SMauro Carvalho Chehabdescribes how to send updates for individual contacts via event slots. 24e2ba5731SMauro Carvalho Chehab 256c6d5752SDmitry Torokhov.. note:: 26ac862503SColin Ian King MT protocol type A is obsolete, all kernel drivers have been 276c6d5752SDmitry Torokhov converted to use type B. 28e2ba5731SMauro Carvalho Chehab 29e2ba5731SMauro Carvalho ChehabProtocol Usage 30e2ba5731SMauro Carvalho Chehab-------------- 31e2ba5731SMauro Carvalho Chehab 32e2ba5731SMauro Carvalho ChehabContact details are sent sequentially as separate packets of ABS_MT 33e2ba5731SMauro Carvalho Chehabevents. Only the ABS_MT events are recognized as part of a contact 34e2ba5731SMauro Carvalho Chehabpacket. Since these events are ignored by current single-touch (ST) 35e2ba5731SMauro Carvalho Chehabapplications, the MT protocol can be implemented on top of the ST protocol 36e2ba5731SMauro Carvalho Chehabin an existing driver. 37e2ba5731SMauro Carvalho Chehab 38e2ba5731SMauro Carvalho ChehabDrivers for type A devices separate contact packets by calling 39e2ba5731SMauro Carvalho Chehabinput_mt_sync() at the end of each packet. This generates a SYN_MT_REPORT 40e2ba5731SMauro Carvalho Chehabevent, which instructs the receiver to accept the data for the current 41e2ba5731SMauro Carvalho Chehabcontact and prepare to receive another. 42e2ba5731SMauro Carvalho Chehab 43e2ba5731SMauro Carvalho ChehabDrivers for type B devices separate contact packets by calling 44e2ba5731SMauro Carvalho Chehabinput_mt_slot(), with a slot as argument, at the beginning of each packet. 45e2ba5731SMauro Carvalho ChehabThis generates an ABS_MT_SLOT event, which instructs the receiver to 46e2ba5731SMauro Carvalho Chehabprepare for updates of the given slot. 47e2ba5731SMauro Carvalho Chehab 48e2ba5731SMauro Carvalho ChehabAll drivers mark the end of a multi-touch transfer by calling the usual 49e2ba5731SMauro Carvalho Chehabinput_sync() function. This instructs the receiver to act upon events 50e2ba5731SMauro Carvalho Chehabaccumulated since last EV_SYN/SYN_REPORT and prepare to receive a new set 51e2ba5731SMauro Carvalho Chehabof events/packets. 52e2ba5731SMauro Carvalho Chehab 53e2ba5731SMauro Carvalho ChehabThe main difference between the stateless type A protocol and the stateful 54e2ba5731SMauro Carvalho Chehabtype B slot protocol lies in the usage of identifiable contacts to reduce 55e2ba5731SMauro Carvalho Chehabthe amount of data sent to userspace. The slot protocol requires the use of 56e2ba5731SMauro Carvalho Chehabthe ABS_MT_TRACKING_ID, either provided by the hardware or computed from 57e2ba5731SMauro Carvalho Chehabthe raw data [#f5]_. 58e2ba5731SMauro Carvalho Chehab 59e2ba5731SMauro Carvalho ChehabFor type A devices, the kernel driver should generate an arbitrary 60e2ba5731SMauro Carvalho Chehabenumeration of the full set of anonymous contacts currently on the 61e2ba5731SMauro Carvalho Chehabsurface. The order in which the packets appear in the event stream is not 62e2ba5731SMauro Carvalho Chehabimportant. Event filtering and finger tracking is left to user space [#f3]_. 63e2ba5731SMauro Carvalho Chehab 64e2ba5731SMauro Carvalho ChehabFor type B devices, the kernel driver should associate a slot with each 65e2ba5731SMauro Carvalho Chehabidentified contact, and use that slot to propagate changes for the contact. 66e2ba5731SMauro Carvalho ChehabCreation, replacement and destruction of contacts is achieved by modifying 67e2ba5731SMauro Carvalho Chehabthe ABS_MT_TRACKING_ID of the associated slot. A non-negative tracking id 68e2ba5731SMauro Carvalho Chehabis interpreted as a contact, and the value -1 denotes an unused slot. A 69e2ba5731SMauro Carvalho Chehabtracking id not previously present is considered new, and a tracking id no 70e2ba5731SMauro Carvalho Chehablonger present is considered removed. Since only changes are propagated, 71e2ba5731SMauro Carvalho Chehabthe full state of each initiated contact has to reside in the receiving 72e2ba5731SMauro Carvalho Chehabend. Upon receiving an MT event, one simply updates the appropriate 73e2ba5731SMauro Carvalho Chehabattribute of the current slot. 74e2ba5731SMauro Carvalho Chehab 75e2ba5731SMauro Carvalho ChehabSome devices identify and/or track more contacts than they can report to the 76e2ba5731SMauro Carvalho Chehabdriver. A driver for such a device should associate one type B slot with each 77e2ba5731SMauro Carvalho Chehabcontact that is reported by the hardware. Whenever the identity of the 78e2ba5731SMauro Carvalho Chehabcontact associated with a slot changes, the driver should invalidate that 79e2ba5731SMauro Carvalho Chehabslot by changing its ABS_MT_TRACKING_ID. If the hardware signals that it is 80e2ba5731SMauro Carvalho Chehabtracking more contacts than it is currently reporting, the driver should use 81e2ba5731SMauro Carvalho Chehaba BTN_TOOL_*TAP event to inform userspace of the total number of contacts 82e2ba5731SMauro Carvalho Chehabbeing tracked by the hardware at that moment. The driver should do this by 83e2ba5731SMauro Carvalho Chehabexplicitly sending the corresponding BTN_TOOL_*TAP event and setting 84e2ba5731SMauro Carvalho Chehabuse_count to false when calling input_mt_report_pointer_emulation(). 85e2ba5731SMauro Carvalho ChehabThe driver should only advertise as many slots as the hardware can report. 86e2ba5731SMauro Carvalho ChehabUserspace can detect that a driver can report more total contacts than slots 87e2ba5731SMauro Carvalho Chehabby noting that the largest supported BTN_TOOL_*TAP event is larger than the 88e2ba5731SMauro Carvalho Chehabtotal number of type B slots reported in the absinfo for the ABS_MT_SLOT axis. 89e2ba5731SMauro Carvalho Chehab 90e2ba5731SMauro Carvalho ChehabThe minimum value of the ABS_MT_SLOT axis must be 0. 91e2ba5731SMauro Carvalho Chehab 92e2ba5731SMauro Carvalho ChehabProtocol Example A 93e2ba5731SMauro Carvalho Chehab------------------ 94e2ba5731SMauro Carvalho Chehab 95e2ba5731SMauro Carvalho ChehabHere is what a minimal event sequence for a two-contact touch would look 96e2ba5731SMauro Carvalho Chehablike for a type A device:: 97e2ba5731SMauro Carvalho Chehab 98e2ba5731SMauro Carvalho Chehab ABS_MT_POSITION_X x[0] 99e2ba5731SMauro Carvalho Chehab ABS_MT_POSITION_Y y[0] 100e2ba5731SMauro Carvalho Chehab SYN_MT_REPORT 101e2ba5731SMauro Carvalho Chehab ABS_MT_POSITION_X x[1] 102e2ba5731SMauro Carvalho Chehab ABS_MT_POSITION_Y y[1] 103e2ba5731SMauro Carvalho Chehab SYN_MT_REPORT 104e2ba5731SMauro Carvalho Chehab SYN_REPORT 105e2ba5731SMauro Carvalho Chehab 106e2ba5731SMauro Carvalho ChehabThe sequence after moving one of the contacts looks exactly the same; the 107e2ba5731SMauro Carvalho Chehabraw data for all present contacts are sent between every synchronization 108e2ba5731SMauro Carvalho Chehabwith SYN_REPORT. 109e2ba5731SMauro Carvalho Chehab 110e2ba5731SMauro Carvalho ChehabHere is the sequence after lifting the first contact:: 111e2ba5731SMauro Carvalho Chehab 112e2ba5731SMauro Carvalho Chehab ABS_MT_POSITION_X x[1] 113e2ba5731SMauro Carvalho Chehab ABS_MT_POSITION_Y y[1] 114e2ba5731SMauro Carvalho Chehab SYN_MT_REPORT 115e2ba5731SMauro Carvalho Chehab SYN_REPORT 116e2ba5731SMauro Carvalho Chehab 117e2ba5731SMauro Carvalho ChehabAnd here is the sequence after lifting the second contact:: 118e2ba5731SMauro Carvalho Chehab 119e2ba5731SMauro Carvalho Chehab SYN_MT_REPORT 120e2ba5731SMauro Carvalho Chehab SYN_REPORT 121e2ba5731SMauro Carvalho Chehab 122e2ba5731SMauro Carvalho ChehabIf the driver reports one of BTN_TOUCH or ABS_PRESSURE in addition to the 123e2ba5731SMauro Carvalho ChehabABS_MT events, the last SYN_MT_REPORT event may be omitted. Otherwise, the 124e2ba5731SMauro Carvalho Chehablast SYN_REPORT will be dropped by the input core, resulting in no 125e2ba5731SMauro Carvalho Chehabzero-contact event reaching userland. 126e2ba5731SMauro Carvalho Chehab 127e2ba5731SMauro Carvalho Chehab 128e2ba5731SMauro Carvalho ChehabProtocol Example B 129e2ba5731SMauro Carvalho Chehab------------------ 130e2ba5731SMauro Carvalho Chehab 131e2ba5731SMauro Carvalho ChehabHere is what a minimal event sequence for a two-contact touch would look 132e2ba5731SMauro Carvalho Chehablike for a type B device:: 133e2ba5731SMauro Carvalho Chehab 134e2ba5731SMauro Carvalho Chehab ABS_MT_SLOT 0 135e2ba5731SMauro Carvalho Chehab ABS_MT_TRACKING_ID 45 136e2ba5731SMauro Carvalho Chehab ABS_MT_POSITION_X x[0] 137e2ba5731SMauro Carvalho Chehab ABS_MT_POSITION_Y y[0] 138e2ba5731SMauro Carvalho Chehab ABS_MT_SLOT 1 139e2ba5731SMauro Carvalho Chehab ABS_MT_TRACKING_ID 46 140e2ba5731SMauro Carvalho Chehab ABS_MT_POSITION_X x[1] 141e2ba5731SMauro Carvalho Chehab ABS_MT_POSITION_Y y[1] 142e2ba5731SMauro Carvalho Chehab SYN_REPORT 143e2ba5731SMauro Carvalho Chehab 144e2ba5731SMauro Carvalho ChehabHere is the sequence after moving contact 45 in the x direction:: 145e2ba5731SMauro Carvalho Chehab 146e2ba5731SMauro Carvalho Chehab ABS_MT_SLOT 0 147e2ba5731SMauro Carvalho Chehab ABS_MT_POSITION_X x[0] 148e2ba5731SMauro Carvalho Chehab SYN_REPORT 149e2ba5731SMauro Carvalho Chehab 150e2ba5731SMauro Carvalho ChehabHere is the sequence after lifting the contact in slot 0:: 151e2ba5731SMauro Carvalho Chehab 152e2ba5731SMauro Carvalho Chehab ABS_MT_TRACKING_ID -1 153e2ba5731SMauro Carvalho Chehab SYN_REPORT 154e2ba5731SMauro Carvalho Chehab 155e2ba5731SMauro Carvalho ChehabThe slot being modified is already 0, so the ABS_MT_SLOT is omitted. The 156e2ba5731SMauro Carvalho Chehabmessage removes the association of slot 0 with contact 45, thereby 157e2ba5731SMauro Carvalho Chehabdestroying contact 45 and freeing slot 0 to be reused for another contact. 158e2ba5731SMauro Carvalho Chehab 159e2ba5731SMauro Carvalho ChehabFinally, here is the sequence after lifting the second contact:: 160e2ba5731SMauro Carvalho Chehab 161e2ba5731SMauro Carvalho Chehab ABS_MT_SLOT 1 162e2ba5731SMauro Carvalho Chehab ABS_MT_TRACKING_ID -1 163e2ba5731SMauro Carvalho Chehab SYN_REPORT 164e2ba5731SMauro Carvalho Chehab 165e2ba5731SMauro Carvalho Chehab 166e2ba5731SMauro Carvalho ChehabEvent Usage 167e2ba5731SMauro Carvalho Chehab----------- 168e2ba5731SMauro Carvalho Chehab 169e2ba5731SMauro Carvalho ChehabA set of ABS_MT events with the desired properties is defined. The events 170e2ba5731SMauro Carvalho Chehabare divided into categories, to allow for partial implementation. The 171e2ba5731SMauro Carvalho Chehabminimum set consists of ABS_MT_POSITION_X and ABS_MT_POSITION_Y, which 172e2ba5731SMauro Carvalho Chehaballows for multiple contacts to be tracked. If the device supports it, the 173e2ba5731SMauro Carvalho ChehabABS_MT_TOUCH_MAJOR and ABS_MT_WIDTH_MAJOR may be used to provide the size 174e2ba5731SMauro Carvalho Chehabof the contact area and approaching tool, respectively. 175e2ba5731SMauro Carvalho Chehab 176e2ba5731SMauro Carvalho ChehabThe TOUCH and WIDTH parameters have a geometrical interpretation; imagine 177e2ba5731SMauro Carvalho Chehablooking through a window at someone gently holding a finger against the 178e2ba5731SMauro Carvalho Chehabglass. You will see two regions, one inner region consisting of the part 179e2ba5731SMauro Carvalho Chehabof the finger actually touching the glass, and one outer region formed by 180e2ba5731SMauro Carvalho Chehabthe perimeter of the finger. The center of the touching region (a) is 181e2ba5731SMauro Carvalho ChehabABS_MT_POSITION_X/Y and the center of the approaching finger (b) is 182e2ba5731SMauro Carvalho ChehabABS_MT_TOOL_X/Y. The touch diameter is ABS_MT_TOUCH_MAJOR and the finger 183e2ba5731SMauro Carvalho Chehabdiameter is ABS_MT_WIDTH_MAJOR. Now imagine the person pressing the finger 184e2ba5731SMauro Carvalho Chehabharder against the glass. The touch region will increase, and in general, 185e2ba5731SMauro Carvalho Chehabthe ratio ABS_MT_TOUCH_MAJOR / ABS_MT_WIDTH_MAJOR, which is always smaller 186e2ba5731SMauro Carvalho Chehabthan unity, is related to the contact pressure. For pressure-based devices, 187e2ba5731SMauro Carvalho ChehabABS_MT_PRESSURE may be used to provide the pressure on the contact area 188e2ba5731SMauro Carvalho Chehabinstead. Devices capable of contact hovering can use ABS_MT_DISTANCE to 189e2ba5731SMauro Carvalho Chehabindicate the distance between the contact and the surface. 190e2ba5731SMauro Carvalho Chehab 191e2ba5731SMauro Carvalho Chehab:: 192e2ba5731SMauro Carvalho Chehab 193e2ba5731SMauro Carvalho Chehab 194e2ba5731SMauro Carvalho Chehab Linux MT Win8 195e2ba5731SMauro Carvalho Chehab __________ _______________________ 196e2ba5731SMauro Carvalho Chehab / \ | | 197e2ba5731SMauro Carvalho Chehab / \ | | 198e2ba5731SMauro Carvalho Chehab / ____ \ | | 199e2ba5731SMauro Carvalho Chehab / / \ \ | | 200e2ba5731SMauro Carvalho Chehab \ \ a \ \ | a | 201e2ba5731SMauro Carvalho Chehab \ \____/ \ | | 202e2ba5731SMauro Carvalho Chehab \ \ | | 203e2ba5731SMauro Carvalho Chehab \ b \ | b | 204e2ba5731SMauro Carvalho Chehab \ \ | | 205e2ba5731SMauro Carvalho Chehab \ \ | | 206e2ba5731SMauro Carvalho Chehab \ \ | | 207e2ba5731SMauro Carvalho Chehab \ / | | 208e2ba5731SMauro Carvalho Chehab \ / | | 209e2ba5731SMauro Carvalho Chehab \ / | | 210e2ba5731SMauro Carvalho Chehab \__________/ |_______________________| 211e2ba5731SMauro Carvalho Chehab 212e2ba5731SMauro Carvalho Chehab 213e2ba5731SMauro Carvalho ChehabIn addition to the MAJOR parameters, the oval shape of the touch and finger 214e2ba5731SMauro Carvalho Chehabregions can be described by adding the MINOR parameters, such that MAJOR 215e2ba5731SMauro Carvalho Chehaband MINOR are the major and minor axis of an ellipse. The orientation of 216e2ba5731SMauro Carvalho Chehabthe touch ellipse can be described with the ORIENTATION parameter, and the 217e2ba5731SMauro Carvalho Chehabdirection of the finger ellipse is given by the vector (a - b). 218e2ba5731SMauro Carvalho Chehab 219e2ba5731SMauro Carvalho ChehabFor type A devices, further specification of the touch shape is possible 220e2ba5731SMauro Carvalho Chehabvia ABS_MT_BLOB_ID. 221e2ba5731SMauro Carvalho Chehab 222e2ba5731SMauro Carvalho ChehabThe ABS_MT_TOOL_TYPE may be used to specify whether the touching tool is a 223e2ba5731SMauro Carvalho Chehabfinger or a pen or something else. Finally, the ABS_MT_TRACKING_ID event 224e2ba5731SMauro Carvalho Chehabmay be used to track identified contacts over time [#f5]_. 225e2ba5731SMauro Carvalho Chehab 226e2ba5731SMauro Carvalho ChehabIn the type B protocol, ABS_MT_TOOL_TYPE and ABS_MT_TRACKING_ID are 227e2ba5731SMauro Carvalho Chehabimplicitly handled by input core; drivers should instead call 228e2ba5731SMauro Carvalho Chehabinput_mt_report_slot_state(). 229e2ba5731SMauro Carvalho Chehab 230e2ba5731SMauro Carvalho Chehab 231e2ba5731SMauro Carvalho ChehabEvent Semantics 232e2ba5731SMauro Carvalho Chehab--------------- 233e2ba5731SMauro Carvalho Chehab 234e2ba5731SMauro Carvalho ChehabABS_MT_TOUCH_MAJOR 235e2ba5731SMauro Carvalho Chehab The length of the major axis of the contact. The length should be given in 236e2ba5731SMauro Carvalho Chehab surface units. If the surface has an X times Y resolution, the largest 237e2ba5731SMauro Carvalho Chehab possible value of ABS_MT_TOUCH_MAJOR is sqrt(X^2 + Y^2), the diagonal [#f4]_. 238e2ba5731SMauro Carvalho Chehab 239e2ba5731SMauro Carvalho ChehabABS_MT_TOUCH_MINOR 240e2ba5731SMauro Carvalho Chehab The length, in surface units, of the minor axis of the contact. If the 241e2ba5731SMauro Carvalho Chehab contact is circular, this event can be omitted [#f4]_. 242e2ba5731SMauro Carvalho Chehab 243e2ba5731SMauro Carvalho ChehabABS_MT_WIDTH_MAJOR 244e2ba5731SMauro Carvalho Chehab The length, in surface units, of the major axis of the approaching 245e2ba5731SMauro Carvalho Chehab tool. This should be understood as the size of the tool itself. The 246e2ba5731SMauro Carvalho Chehab orientation of the contact and the approaching tool are assumed to be the 247e2ba5731SMauro Carvalho Chehab same [#f4]_. 248e2ba5731SMauro Carvalho Chehab 249e2ba5731SMauro Carvalho ChehabABS_MT_WIDTH_MINOR 250e2ba5731SMauro Carvalho Chehab The length, in surface units, of the minor axis of the approaching 251e2ba5731SMauro Carvalho Chehab tool. Omit if circular [#f4]_. 252e2ba5731SMauro Carvalho Chehab 253e2ba5731SMauro Carvalho Chehab The above four values can be used to derive additional information about 254e2ba5731SMauro Carvalho Chehab the contact. The ratio ABS_MT_TOUCH_MAJOR / ABS_MT_WIDTH_MAJOR approximates 255e2ba5731SMauro Carvalho Chehab the notion of pressure. The fingers of the hand and the palm all have 256e2ba5731SMauro Carvalho Chehab different characteristic widths. 257e2ba5731SMauro Carvalho Chehab 258e2ba5731SMauro Carvalho ChehabABS_MT_PRESSURE 259e2ba5731SMauro Carvalho Chehab The pressure, in arbitrary units, on the contact area. May be used instead 260e2ba5731SMauro Carvalho Chehab of TOUCH and WIDTH for pressure-based devices or any device with a spatial 261e2ba5731SMauro Carvalho Chehab signal intensity distribution. 262e2ba5731SMauro Carvalho Chehab 26320ccc8ddSPeter Hutterer If the resolution is zero, the pressure data is in arbitrary units. 264338b660bSRandy Dunlap If the resolution is non-zero, the pressure data is in units/gram. See 26520ccc8ddSPeter Hutterer :ref:`input-event-codes` for details. 26620ccc8ddSPeter Hutterer 267e2ba5731SMauro Carvalho ChehabABS_MT_DISTANCE 268e2ba5731SMauro Carvalho Chehab The distance, in surface units, between the contact and the surface. Zero 269e2ba5731SMauro Carvalho Chehab distance means the contact is touching the surface. A positive number means 270e2ba5731SMauro Carvalho Chehab the contact is hovering above the surface. 271e2ba5731SMauro Carvalho Chehab 272e2ba5731SMauro Carvalho ChehabABS_MT_ORIENTATION 273e2ba5731SMauro Carvalho Chehab The orientation of the touching ellipse. The value should describe a signed 274e2ba5731SMauro Carvalho Chehab quarter of a revolution clockwise around the touch center. The signed value 275e2ba5731SMauro Carvalho Chehab range is arbitrary, but zero should be returned for an ellipse aligned with 27600720277SWei-Ning Huang the Y axis (north) of the surface, a negative value when the ellipse is 27700720277SWei-Ning Huang turned to the left, and a positive value when the ellipse is turned to the 27800720277SWei-Ning Huang right. When aligned with the X axis in the positive direction, the range 27900720277SWei-Ning Huang max should be returned; when aligned with the X axis in the negative 28000720277SWei-Ning Huang direction, the range -max should be returned. 281e2ba5731SMauro Carvalho Chehab 282338b660bSRandy Dunlap Touch ellipses are symmetrical by default. For devices capable of true 360 283e2ba5731SMauro Carvalho Chehab degree orientation, the reported orientation must exceed the range max to 284e2ba5731SMauro Carvalho Chehab indicate more than a quarter of a revolution. For an upside-down finger, 285e2ba5731SMauro Carvalho Chehab range max * 2 should be returned. 286e2ba5731SMauro Carvalho Chehab 287e2ba5731SMauro Carvalho Chehab Orientation can be omitted if the touch area is circular, or if the 288e2ba5731SMauro Carvalho Chehab information is not available in the kernel driver. Partial orientation 289338b660bSRandy Dunlap support is possible if the device can distinguish between the two axes, but 290e2ba5731SMauro Carvalho Chehab not (uniquely) any values in between. In such cases, the range of 291e2ba5731SMauro Carvalho Chehab ABS_MT_ORIENTATION should be [0, 1] [#f4]_. 292e2ba5731SMauro Carvalho Chehab 293e2ba5731SMauro Carvalho ChehabABS_MT_POSITION_X 294e2ba5731SMauro Carvalho Chehab The surface X coordinate of the center of the touching ellipse. 295e2ba5731SMauro Carvalho Chehab 296e2ba5731SMauro Carvalho ChehabABS_MT_POSITION_Y 297e2ba5731SMauro Carvalho Chehab The surface Y coordinate of the center of the touching ellipse. 298e2ba5731SMauro Carvalho Chehab 299e2ba5731SMauro Carvalho ChehabABS_MT_TOOL_X 300e2ba5731SMauro Carvalho Chehab The surface X coordinate of the center of the approaching tool. Omit if 301e2ba5731SMauro Carvalho Chehab the device cannot distinguish between the intended touch point and the 302e2ba5731SMauro Carvalho Chehab tool itself. 303e2ba5731SMauro Carvalho Chehab 304e2ba5731SMauro Carvalho ChehabABS_MT_TOOL_Y 305e2ba5731SMauro Carvalho Chehab The surface Y coordinate of the center of the approaching tool. Omit if the 306e2ba5731SMauro Carvalho Chehab device cannot distinguish between the intended touch point and the tool 307e2ba5731SMauro Carvalho Chehab itself. 308e2ba5731SMauro Carvalho Chehab 309e2ba5731SMauro Carvalho Chehab The four position values can be used to separate the position of the touch 310e2ba5731SMauro Carvalho Chehab from the position of the tool. If both positions are present, the major 311e2ba5731SMauro Carvalho Chehab tool axis points towards the touch point [#f1]_. Otherwise, the tool axes are 312e2ba5731SMauro Carvalho Chehab aligned with the touch axes. 313e2ba5731SMauro Carvalho Chehab 314e2ba5731SMauro Carvalho ChehabABS_MT_TOOL_TYPE 315e2ba5731SMauro Carvalho Chehab The type of approaching tool. A lot of kernel drivers cannot distinguish 316e2ba5731SMauro Carvalho Chehab between different tool types, such as a finger or a pen. In such cases, the 317b875a5a5SBenjamin Tissoires event should be omitted. The protocol currently mainly supports 318b875a5a5SBenjamin Tissoires MT_TOOL_FINGER, MT_TOOL_PEN, and MT_TOOL_PALM [#f2]_. 319b875a5a5SBenjamin Tissoires For type B devices, this event is handled by input core; drivers should 320b875a5a5SBenjamin Tissoires instead use input_mt_report_slot_state(). A contact's ABS_MT_TOOL_TYPE may 321b875a5a5SBenjamin Tissoires change over time while still touching the device, because the firmware may 322b875a5a5SBenjamin Tissoires not be able to determine which tool is being used when it first appears. 323e2ba5731SMauro Carvalho Chehab 324e2ba5731SMauro Carvalho ChehabABS_MT_BLOB_ID 325e2ba5731SMauro Carvalho Chehab The BLOB_ID groups several packets together into one arbitrarily shaped 326e2ba5731SMauro Carvalho Chehab contact. The sequence of points forms a polygon which defines the shape of 327e2ba5731SMauro Carvalho Chehab the contact. This is a low-level anonymous grouping for type A devices, and 328e2ba5731SMauro Carvalho Chehab should not be confused with the high-level trackingID [#f5]_. Most type A 329e2ba5731SMauro Carvalho Chehab devices do not have blob capability, so drivers can safely omit this event. 330e2ba5731SMauro Carvalho Chehab 331e2ba5731SMauro Carvalho ChehabABS_MT_TRACKING_ID 332e2ba5731SMauro Carvalho Chehab The TRACKING_ID identifies an initiated contact throughout its life cycle 333e2ba5731SMauro Carvalho Chehab [#f5]_. The value range of the TRACKING_ID should be large enough to ensure 334e2ba5731SMauro Carvalho Chehab unique identification of a contact maintained over an extended period of 335e2ba5731SMauro Carvalho Chehab time. For type B devices, this event is handled by input core; drivers 336e2ba5731SMauro Carvalho Chehab should instead use input_mt_report_slot_state(). 337e2ba5731SMauro Carvalho Chehab 338e2ba5731SMauro Carvalho Chehab 339e2ba5731SMauro Carvalho ChehabEvent Computation 340e2ba5731SMauro Carvalho Chehab----------------- 341e2ba5731SMauro Carvalho Chehab 342e2ba5731SMauro Carvalho ChehabThe flora of different hardware unavoidably leads to some devices fitting 343e2ba5731SMauro Carvalho Chehabbetter to the MT protocol than others. To simplify and unify the mapping, 344e2ba5731SMauro Carvalho Chehabthis section gives recipes for how to compute certain events. 345e2ba5731SMauro Carvalho Chehab 346e2ba5731SMauro Carvalho ChehabFor devices reporting contacts as rectangular shapes, signed orientation 347e2ba5731SMauro Carvalho Chehabcannot be obtained. Assuming X and Y are the lengths of the sides of the 348e2ba5731SMauro Carvalho Chehabtouching rectangle, here is a simple formula that retains the most 349e2ba5731SMauro Carvalho Chehabinformation possible:: 350e2ba5731SMauro Carvalho Chehab 351e2ba5731SMauro Carvalho Chehab ABS_MT_TOUCH_MAJOR := max(X, Y) 352e2ba5731SMauro Carvalho Chehab ABS_MT_TOUCH_MINOR := min(X, Y) 353e2ba5731SMauro Carvalho Chehab ABS_MT_ORIENTATION := bool(X > Y) 354e2ba5731SMauro Carvalho Chehab 355e2ba5731SMauro Carvalho ChehabThe range of ABS_MT_ORIENTATION should be set to [0, 1], to indicate that 356e2ba5731SMauro Carvalho Chehabthe device can distinguish between a finger along the Y axis (0) and a 357e2ba5731SMauro Carvalho Chehabfinger along the X axis (1). 358e2ba5731SMauro Carvalho Chehab 359338b660bSRandy DunlapFor Win8 devices with both T and C coordinates, the position mapping is:: 360e2ba5731SMauro Carvalho Chehab 361e2ba5731SMauro Carvalho Chehab ABS_MT_POSITION_X := T_X 362e2ba5731SMauro Carvalho Chehab ABS_MT_POSITION_Y := T_Y 363e2ba5731SMauro Carvalho Chehab ABS_MT_TOOL_X := C_X 364e2ba5731SMauro Carvalho Chehab ABS_MT_TOOL_Y := C_Y 365e2ba5731SMauro Carvalho Chehab 366e2ba5731SMauro Carvalho ChehabUnfortunately, there is not enough information to specify both the touching 367e2ba5731SMauro Carvalho Chehabellipse and the tool ellipse, so one has to resort to approximations. One 368e2ba5731SMauro Carvalho Chehabsimple scheme, which is compatible with earlier usage, is:: 369e2ba5731SMauro Carvalho Chehab 370e2ba5731SMauro Carvalho Chehab ABS_MT_TOUCH_MAJOR := min(X, Y) 371e2ba5731SMauro Carvalho Chehab ABS_MT_TOUCH_MINOR := <not used> 372e2ba5731SMauro Carvalho Chehab ABS_MT_ORIENTATION := <not used> 373e2ba5731SMauro Carvalho Chehab ABS_MT_WIDTH_MAJOR := min(X, Y) + distance(T, C) 374e2ba5731SMauro Carvalho Chehab ABS_MT_WIDTH_MINOR := min(X, Y) 375e2ba5731SMauro Carvalho Chehab 376e2ba5731SMauro Carvalho ChehabRationale: We have no information about the orientation of the touching 377e2ba5731SMauro Carvalho Chehabellipse, so approximate it with an inscribed circle instead. The tool 378e2ba5731SMauro Carvalho Chehabellipse should align with the vector (T - C), so the diameter must 379e2ba5731SMauro Carvalho Chehabincrease with distance(T, C). Finally, assume that the touch diameter is 380e2ba5731SMauro Carvalho Chehabequal to the tool thickness, and we arrive at the formulas above. 381e2ba5731SMauro Carvalho Chehab 382e2ba5731SMauro Carvalho ChehabFinger Tracking 383e2ba5731SMauro Carvalho Chehab--------------- 384e2ba5731SMauro Carvalho Chehab 385e2ba5731SMauro Carvalho ChehabThe process of finger tracking, i.e., to assign a unique trackingID to each 386*d56b699dSBjorn Helgaasinitiated contact on the surface, is a Euclidean Bipartite Matching 387e2ba5731SMauro Carvalho Chehabproblem. At each event synchronization, the set of actual contacts is 388e2ba5731SMauro Carvalho Chehabmatched to the set of contacts from the previous synchronization. A full 389e2ba5731SMauro Carvalho Chehabimplementation can be found in [#f3]_. 390e2ba5731SMauro Carvalho Chehab 391e2ba5731SMauro Carvalho Chehab 392e2ba5731SMauro Carvalho ChehabGestures 393e2ba5731SMauro Carvalho Chehab-------- 394e2ba5731SMauro Carvalho Chehab 395e2ba5731SMauro Carvalho ChehabIn the specific application of creating gesture events, the TOUCH and WIDTH 396e2ba5731SMauro Carvalho Chehabparameters can be used to, e.g., approximate finger pressure or distinguish 397e2ba5731SMauro Carvalho Chehabbetween index finger and thumb. With the addition of the MINOR parameters, 398e2ba5731SMauro Carvalho Chehabone can also distinguish between a sweeping finger and a pointing finger, 399e2ba5731SMauro Carvalho Chehaband with ORIENTATION, one can detect twisting of fingers. 400e2ba5731SMauro Carvalho Chehab 401e2ba5731SMauro Carvalho Chehab 402e2ba5731SMauro Carvalho ChehabNotes 403e2ba5731SMauro Carvalho Chehab----- 404e2ba5731SMauro Carvalho Chehab 405e2ba5731SMauro Carvalho ChehabIn order to stay compatible with existing applications, the data reported 406e2ba5731SMauro Carvalho Chehabin a finger packet must not be recognized as single-touch events. 407e2ba5731SMauro Carvalho Chehab 408e2ba5731SMauro Carvalho ChehabFor type A devices, all finger data bypasses input filtering, since 409e2ba5731SMauro Carvalho Chehabsubsequent events of the same type refer to different fingers. 410e2ba5731SMauro Carvalho Chehab 411e2ba5731SMauro Carvalho Chehab.. [#f1] Also, the difference (TOOL_X - POSITION_X) can be used to model tilt. 412e2ba5731SMauro Carvalho Chehab.. [#f2] The list can of course be extended. 413e2ba5731SMauro Carvalho Chehab.. [#f3] The mtdev project: http://bitmath.org/code/mtdev/. 414e2ba5731SMauro Carvalho Chehab.. [#f4] See the section on event computation. 415e2ba5731SMauro Carvalho Chehab.. [#f5] See the section on finger tracking. 416