1*4882a593Smuzhiyun.. include:: <isonum.txt> 2*4882a593Smuzhiyun 3*4882a593Smuzhiyun========================= 4*4882a593SmuzhiyunMulti-touch (MT) Protocol 5*4882a593Smuzhiyun========================= 6*4882a593Smuzhiyun 7*4882a593Smuzhiyun:Copyright: |copy| 2009-2010 Henrik Rydberg <rydberg@euromail.se> 8*4882a593Smuzhiyun 9*4882a593Smuzhiyun 10*4882a593SmuzhiyunIntroduction 11*4882a593Smuzhiyun------------ 12*4882a593Smuzhiyun 13*4882a593SmuzhiyunIn order to utilize the full power of the new multi-touch and multi-user 14*4882a593Smuzhiyundevices, a way to report detailed data from multiple contacts, i.e., 15*4882a593Smuzhiyunobjects in direct contact with the device surface, is needed. This 16*4882a593Smuzhiyundocument describes the multi-touch (MT) protocol which allows kernel 17*4882a593Smuzhiyundrivers to report details for an arbitrary number of contacts. 18*4882a593Smuzhiyun 19*4882a593SmuzhiyunThe protocol is divided into two types, depending on the capabilities of the 20*4882a593Smuzhiyunhardware. For devices handling anonymous contacts (type A), the protocol 21*4882a593Smuzhiyundescribes how to send the raw data for all contacts to the receiver. For 22*4882a593Smuzhiyundevices capable of tracking identifiable contacts (type B), the protocol 23*4882a593Smuzhiyundescribes how to send updates for individual contacts via event slots. 24*4882a593Smuzhiyun 25*4882a593Smuzhiyun.. note:: 26*4882a593Smuzhiyun MT protocol type A is obsolete, all kernel drivers have been 27*4882a593Smuzhiyun converted to use type B. 28*4882a593Smuzhiyun 29*4882a593SmuzhiyunProtocol Usage 30*4882a593Smuzhiyun-------------- 31*4882a593Smuzhiyun 32*4882a593SmuzhiyunContact details are sent sequentially as separate packets of ABS_MT 33*4882a593Smuzhiyunevents. Only the ABS_MT events are recognized as part of a contact 34*4882a593Smuzhiyunpacket. Since these events are ignored by current single-touch (ST) 35*4882a593Smuzhiyunapplications, the MT protocol can be implemented on top of the ST protocol 36*4882a593Smuzhiyunin an existing driver. 37*4882a593Smuzhiyun 38*4882a593SmuzhiyunDrivers for type A devices separate contact packets by calling 39*4882a593Smuzhiyuninput_mt_sync() at the end of each packet. This generates a SYN_MT_REPORT 40*4882a593Smuzhiyunevent, which instructs the receiver to accept the data for the current 41*4882a593Smuzhiyuncontact and prepare to receive another. 42*4882a593Smuzhiyun 43*4882a593SmuzhiyunDrivers for type B devices separate contact packets by calling 44*4882a593Smuzhiyuninput_mt_slot(), with a slot as argument, at the beginning of each packet. 45*4882a593SmuzhiyunThis generates an ABS_MT_SLOT event, which instructs the receiver to 46*4882a593Smuzhiyunprepare for updates of the given slot. 47*4882a593Smuzhiyun 48*4882a593SmuzhiyunAll drivers mark the end of a multi-touch transfer by calling the usual 49*4882a593Smuzhiyuninput_sync() function. This instructs the receiver to act upon events 50*4882a593Smuzhiyunaccumulated since last EV_SYN/SYN_REPORT and prepare to receive a new set 51*4882a593Smuzhiyunof events/packets. 52*4882a593Smuzhiyun 53*4882a593SmuzhiyunThe main difference between the stateless type A protocol and the stateful 54*4882a593Smuzhiyuntype B slot protocol lies in the usage of identifiable contacts to reduce 55*4882a593Smuzhiyunthe amount of data sent to userspace. The slot protocol requires the use of 56*4882a593Smuzhiyunthe ABS_MT_TRACKING_ID, either provided by the hardware or computed from 57*4882a593Smuzhiyunthe raw data [#f5]_. 58*4882a593Smuzhiyun 59*4882a593SmuzhiyunFor type A devices, the kernel driver should generate an arbitrary 60*4882a593Smuzhiyunenumeration of the full set of anonymous contacts currently on the 61*4882a593Smuzhiyunsurface. The order in which the packets appear in the event stream is not 62*4882a593Smuzhiyunimportant. Event filtering and finger tracking is left to user space [#f3]_. 63*4882a593Smuzhiyun 64*4882a593SmuzhiyunFor type B devices, the kernel driver should associate a slot with each 65*4882a593Smuzhiyunidentified contact, and use that slot to propagate changes for the contact. 66*4882a593SmuzhiyunCreation, replacement and destruction of contacts is achieved by modifying 67*4882a593Smuzhiyunthe ABS_MT_TRACKING_ID of the associated slot. A non-negative tracking id 68*4882a593Smuzhiyunis interpreted as a contact, and the value -1 denotes an unused slot. A 69*4882a593Smuzhiyuntracking id not previously present is considered new, and a tracking id no 70*4882a593Smuzhiyunlonger present is considered removed. Since only changes are propagated, 71*4882a593Smuzhiyunthe full state of each initiated contact has to reside in the receiving 72*4882a593Smuzhiyunend. Upon receiving an MT event, one simply updates the appropriate 73*4882a593Smuzhiyunattribute of the current slot. 74*4882a593Smuzhiyun 75*4882a593SmuzhiyunSome devices identify and/or track more contacts than they can report to the 76*4882a593Smuzhiyundriver. A driver for such a device should associate one type B slot with each 77*4882a593Smuzhiyuncontact that is reported by the hardware. Whenever the identity of the 78*4882a593Smuzhiyuncontact associated with a slot changes, the driver should invalidate that 79*4882a593Smuzhiyunslot by changing its ABS_MT_TRACKING_ID. If the hardware signals that it is 80*4882a593Smuzhiyuntracking more contacts than it is currently reporting, the driver should use 81*4882a593Smuzhiyuna BTN_TOOL_*TAP event to inform userspace of the total number of contacts 82*4882a593Smuzhiyunbeing tracked by the hardware at that moment. The driver should do this by 83*4882a593Smuzhiyunexplicitly sending the corresponding BTN_TOOL_*TAP event and setting 84*4882a593Smuzhiyunuse_count to false when calling input_mt_report_pointer_emulation(). 85*4882a593SmuzhiyunThe driver should only advertise as many slots as the hardware can report. 86*4882a593SmuzhiyunUserspace can detect that a driver can report more total contacts than slots 87*4882a593Smuzhiyunby noting that the largest supported BTN_TOOL_*TAP event is larger than the 88*4882a593Smuzhiyuntotal number of type B slots reported in the absinfo for the ABS_MT_SLOT axis. 89*4882a593Smuzhiyun 90*4882a593SmuzhiyunThe minimum value of the ABS_MT_SLOT axis must be 0. 91*4882a593Smuzhiyun 92*4882a593SmuzhiyunProtocol Example A 93*4882a593Smuzhiyun------------------ 94*4882a593Smuzhiyun 95*4882a593SmuzhiyunHere is what a minimal event sequence for a two-contact touch would look 96*4882a593Smuzhiyunlike for a type A device:: 97*4882a593Smuzhiyun 98*4882a593Smuzhiyun ABS_MT_POSITION_X x[0] 99*4882a593Smuzhiyun ABS_MT_POSITION_Y y[0] 100*4882a593Smuzhiyun SYN_MT_REPORT 101*4882a593Smuzhiyun ABS_MT_POSITION_X x[1] 102*4882a593Smuzhiyun ABS_MT_POSITION_Y y[1] 103*4882a593Smuzhiyun SYN_MT_REPORT 104*4882a593Smuzhiyun SYN_REPORT 105*4882a593Smuzhiyun 106*4882a593SmuzhiyunThe sequence after moving one of the contacts looks exactly the same; the 107*4882a593Smuzhiyunraw data for all present contacts are sent between every synchronization 108*4882a593Smuzhiyunwith SYN_REPORT. 109*4882a593Smuzhiyun 110*4882a593SmuzhiyunHere is the sequence after lifting the first contact:: 111*4882a593Smuzhiyun 112*4882a593Smuzhiyun ABS_MT_POSITION_X x[1] 113*4882a593Smuzhiyun ABS_MT_POSITION_Y y[1] 114*4882a593Smuzhiyun SYN_MT_REPORT 115*4882a593Smuzhiyun SYN_REPORT 116*4882a593Smuzhiyun 117*4882a593SmuzhiyunAnd here is the sequence after lifting the second contact:: 118*4882a593Smuzhiyun 119*4882a593Smuzhiyun SYN_MT_REPORT 120*4882a593Smuzhiyun SYN_REPORT 121*4882a593Smuzhiyun 122*4882a593SmuzhiyunIf the driver reports one of BTN_TOUCH or ABS_PRESSURE in addition to the 123*4882a593SmuzhiyunABS_MT events, the last SYN_MT_REPORT event may be omitted. Otherwise, the 124*4882a593Smuzhiyunlast SYN_REPORT will be dropped by the input core, resulting in no 125*4882a593Smuzhiyunzero-contact event reaching userland. 126*4882a593Smuzhiyun 127*4882a593Smuzhiyun 128*4882a593SmuzhiyunProtocol Example B 129*4882a593Smuzhiyun------------------ 130*4882a593Smuzhiyun 131*4882a593SmuzhiyunHere is what a minimal event sequence for a two-contact touch would look 132*4882a593Smuzhiyunlike for a type B device:: 133*4882a593Smuzhiyun 134*4882a593Smuzhiyun ABS_MT_SLOT 0 135*4882a593Smuzhiyun ABS_MT_TRACKING_ID 45 136*4882a593Smuzhiyun ABS_MT_POSITION_X x[0] 137*4882a593Smuzhiyun ABS_MT_POSITION_Y y[0] 138*4882a593Smuzhiyun ABS_MT_SLOT 1 139*4882a593Smuzhiyun ABS_MT_TRACKING_ID 46 140*4882a593Smuzhiyun ABS_MT_POSITION_X x[1] 141*4882a593Smuzhiyun ABS_MT_POSITION_Y y[1] 142*4882a593Smuzhiyun SYN_REPORT 143*4882a593Smuzhiyun 144*4882a593SmuzhiyunHere is the sequence after moving contact 45 in the x direction:: 145*4882a593Smuzhiyun 146*4882a593Smuzhiyun ABS_MT_SLOT 0 147*4882a593Smuzhiyun ABS_MT_POSITION_X x[0] 148*4882a593Smuzhiyun SYN_REPORT 149*4882a593Smuzhiyun 150*4882a593SmuzhiyunHere is the sequence after lifting the contact in slot 0:: 151*4882a593Smuzhiyun 152*4882a593Smuzhiyun ABS_MT_TRACKING_ID -1 153*4882a593Smuzhiyun SYN_REPORT 154*4882a593Smuzhiyun 155*4882a593SmuzhiyunThe slot being modified is already 0, so the ABS_MT_SLOT is omitted. The 156*4882a593Smuzhiyunmessage removes the association of slot 0 with contact 45, thereby 157*4882a593Smuzhiyundestroying contact 45 and freeing slot 0 to be reused for another contact. 158*4882a593Smuzhiyun 159*4882a593SmuzhiyunFinally, here is the sequence after lifting the second contact:: 160*4882a593Smuzhiyun 161*4882a593Smuzhiyun ABS_MT_SLOT 1 162*4882a593Smuzhiyun ABS_MT_TRACKING_ID -1 163*4882a593Smuzhiyun SYN_REPORT 164*4882a593Smuzhiyun 165*4882a593Smuzhiyun 166*4882a593SmuzhiyunEvent Usage 167*4882a593Smuzhiyun----------- 168*4882a593Smuzhiyun 169*4882a593SmuzhiyunA set of ABS_MT events with the desired properties is defined. The events 170*4882a593Smuzhiyunare divided into categories, to allow for partial implementation. The 171*4882a593Smuzhiyunminimum set consists of ABS_MT_POSITION_X and ABS_MT_POSITION_Y, which 172*4882a593Smuzhiyunallows for multiple contacts to be tracked. If the device supports it, the 173*4882a593SmuzhiyunABS_MT_TOUCH_MAJOR and ABS_MT_WIDTH_MAJOR may be used to provide the size 174*4882a593Smuzhiyunof the contact area and approaching tool, respectively. 175*4882a593Smuzhiyun 176*4882a593SmuzhiyunThe TOUCH and WIDTH parameters have a geometrical interpretation; imagine 177*4882a593Smuzhiyunlooking through a window at someone gently holding a finger against the 178*4882a593Smuzhiyunglass. You will see two regions, one inner region consisting of the part 179*4882a593Smuzhiyunof the finger actually touching the glass, and one outer region formed by 180*4882a593Smuzhiyunthe perimeter of the finger. The center of the touching region (a) is 181*4882a593SmuzhiyunABS_MT_POSITION_X/Y and the center of the approaching finger (b) is 182*4882a593SmuzhiyunABS_MT_TOOL_X/Y. The touch diameter is ABS_MT_TOUCH_MAJOR and the finger 183*4882a593Smuzhiyundiameter is ABS_MT_WIDTH_MAJOR. Now imagine the person pressing the finger 184*4882a593Smuzhiyunharder against the glass. The touch region will increase, and in general, 185*4882a593Smuzhiyunthe ratio ABS_MT_TOUCH_MAJOR / ABS_MT_WIDTH_MAJOR, which is always smaller 186*4882a593Smuzhiyunthan unity, is related to the contact pressure. For pressure-based devices, 187*4882a593SmuzhiyunABS_MT_PRESSURE may be used to provide the pressure on the contact area 188*4882a593Smuzhiyuninstead. Devices capable of contact hovering can use ABS_MT_DISTANCE to 189*4882a593Smuzhiyunindicate the distance between the contact and the surface. 190*4882a593Smuzhiyun 191*4882a593Smuzhiyun:: 192*4882a593Smuzhiyun 193*4882a593Smuzhiyun 194*4882a593Smuzhiyun Linux MT Win8 195*4882a593Smuzhiyun __________ _______________________ 196*4882a593Smuzhiyun / \ | | 197*4882a593Smuzhiyun / \ | | 198*4882a593Smuzhiyun / ____ \ | | 199*4882a593Smuzhiyun / / \ \ | | 200*4882a593Smuzhiyun \ \ a \ \ | a | 201*4882a593Smuzhiyun \ \____/ \ | | 202*4882a593Smuzhiyun \ \ | | 203*4882a593Smuzhiyun \ b \ | b | 204*4882a593Smuzhiyun \ \ | | 205*4882a593Smuzhiyun \ \ | | 206*4882a593Smuzhiyun \ \ | | 207*4882a593Smuzhiyun \ / | | 208*4882a593Smuzhiyun \ / | | 209*4882a593Smuzhiyun \ / | | 210*4882a593Smuzhiyun \__________/ |_______________________| 211*4882a593Smuzhiyun 212*4882a593Smuzhiyun 213*4882a593SmuzhiyunIn addition to the MAJOR parameters, the oval shape of the touch and finger 214*4882a593Smuzhiyunregions can be described by adding the MINOR parameters, such that MAJOR 215*4882a593Smuzhiyunand MINOR are the major and minor axis of an ellipse. The orientation of 216*4882a593Smuzhiyunthe touch ellipse can be described with the ORIENTATION parameter, and the 217*4882a593Smuzhiyundirection of the finger ellipse is given by the vector (a - b). 218*4882a593Smuzhiyun 219*4882a593SmuzhiyunFor type A devices, further specification of the touch shape is possible 220*4882a593Smuzhiyunvia ABS_MT_BLOB_ID. 221*4882a593Smuzhiyun 222*4882a593SmuzhiyunThe ABS_MT_TOOL_TYPE may be used to specify whether the touching tool is a 223*4882a593Smuzhiyunfinger or a pen or something else. Finally, the ABS_MT_TRACKING_ID event 224*4882a593Smuzhiyunmay be used to track identified contacts over time [#f5]_. 225*4882a593Smuzhiyun 226*4882a593SmuzhiyunIn the type B protocol, ABS_MT_TOOL_TYPE and ABS_MT_TRACKING_ID are 227*4882a593Smuzhiyunimplicitly handled by input core; drivers should instead call 228*4882a593Smuzhiyuninput_mt_report_slot_state(). 229*4882a593Smuzhiyun 230*4882a593Smuzhiyun 231*4882a593SmuzhiyunEvent Semantics 232*4882a593Smuzhiyun--------------- 233*4882a593Smuzhiyun 234*4882a593SmuzhiyunABS_MT_TOUCH_MAJOR 235*4882a593Smuzhiyun The length of the major axis of the contact. The length should be given in 236*4882a593Smuzhiyun surface units. If the surface has an X times Y resolution, the largest 237*4882a593Smuzhiyun possible value of ABS_MT_TOUCH_MAJOR is sqrt(X^2 + Y^2), the diagonal [#f4]_. 238*4882a593Smuzhiyun 239*4882a593SmuzhiyunABS_MT_TOUCH_MINOR 240*4882a593Smuzhiyun The length, in surface units, of the minor axis of the contact. If the 241*4882a593Smuzhiyun contact is circular, this event can be omitted [#f4]_. 242*4882a593Smuzhiyun 243*4882a593SmuzhiyunABS_MT_WIDTH_MAJOR 244*4882a593Smuzhiyun The length, in surface units, of the major axis of the approaching 245*4882a593Smuzhiyun tool. This should be understood as the size of the tool itself. The 246*4882a593Smuzhiyun orientation of the contact and the approaching tool are assumed to be the 247*4882a593Smuzhiyun same [#f4]_. 248*4882a593Smuzhiyun 249*4882a593SmuzhiyunABS_MT_WIDTH_MINOR 250*4882a593Smuzhiyun The length, in surface units, of the minor axis of the approaching 251*4882a593Smuzhiyun tool. Omit if circular [#f4]_. 252*4882a593Smuzhiyun 253*4882a593Smuzhiyun The above four values can be used to derive additional information about 254*4882a593Smuzhiyun the contact. The ratio ABS_MT_TOUCH_MAJOR / ABS_MT_WIDTH_MAJOR approximates 255*4882a593Smuzhiyun the notion of pressure. The fingers of the hand and the palm all have 256*4882a593Smuzhiyun different characteristic widths. 257*4882a593Smuzhiyun 258*4882a593SmuzhiyunABS_MT_PRESSURE 259*4882a593Smuzhiyun The pressure, in arbitrary units, on the contact area. May be used instead 260*4882a593Smuzhiyun of TOUCH and WIDTH for pressure-based devices or any device with a spatial 261*4882a593Smuzhiyun signal intensity distribution. 262*4882a593Smuzhiyun 263*4882a593SmuzhiyunABS_MT_DISTANCE 264*4882a593Smuzhiyun The distance, in surface units, between the contact and the surface. Zero 265*4882a593Smuzhiyun distance means the contact is touching the surface. A positive number means 266*4882a593Smuzhiyun the contact is hovering above the surface. 267*4882a593Smuzhiyun 268*4882a593SmuzhiyunABS_MT_ORIENTATION 269*4882a593Smuzhiyun The orientation of the touching ellipse. The value should describe a signed 270*4882a593Smuzhiyun quarter of a revolution clockwise around the touch center. The signed value 271*4882a593Smuzhiyun range is arbitrary, but zero should be returned for an ellipse aligned with 272*4882a593Smuzhiyun the Y axis (north) of the surface, a negative value when the ellipse is 273*4882a593Smuzhiyun turned to the left, and a positive value when the ellipse is turned to the 274*4882a593Smuzhiyun right. When aligned with the X axis in the positive direction, the range 275*4882a593Smuzhiyun max should be returned; when aligned with the X axis in the negative 276*4882a593Smuzhiyun direction, the range -max should be returned. 277*4882a593Smuzhiyun 278*4882a593Smuzhiyun Touch ellipsis are symmetrical by default. For devices capable of true 360 279*4882a593Smuzhiyun degree orientation, the reported orientation must exceed the range max to 280*4882a593Smuzhiyun indicate more than a quarter of a revolution. For an upside-down finger, 281*4882a593Smuzhiyun range max * 2 should be returned. 282*4882a593Smuzhiyun 283*4882a593Smuzhiyun Orientation can be omitted if the touch area is circular, or if the 284*4882a593Smuzhiyun information is not available in the kernel driver. Partial orientation 285*4882a593Smuzhiyun support is possible if the device can distinguish between the two axis, but 286*4882a593Smuzhiyun not (uniquely) any values in between. In such cases, the range of 287*4882a593Smuzhiyun ABS_MT_ORIENTATION should be [0, 1] [#f4]_. 288*4882a593Smuzhiyun 289*4882a593SmuzhiyunABS_MT_POSITION_X 290*4882a593Smuzhiyun The surface X coordinate of the center of the touching ellipse. 291*4882a593Smuzhiyun 292*4882a593SmuzhiyunABS_MT_POSITION_Y 293*4882a593Smuzhiyun The surface Y coordinate of the center of the touching ellipse. 294*4882a593Smuzhiyun 295*4882a593SmuzhiyunABS_MT_TOOL_X 296*4882a593Smuzhiyun The surface X coordinate of the center of the approaching tool. Omit if 297*4882a593Smuzhiyun the device cannot distinguish between the intended touch point and the 298*4882a593Smuzhiyun tool itself. 299*4882a593Smuzhiyun 300*4882a593SmuzhiyunABS_MT_TOOL_Y 301*4882a593Smuzhiyun The surface Y coordinate of the center of the approaching tool. Omit if the 302*4882a593Smuzhiyun device cannot distinguish between the intended touch point and the tool 303*4882a593Smuzhiyun itself. 304*4882a593Smuzhiyun 305*4882a593Smuzhiyun The four position values can be used to separate the position of the touch 306*4882a593Smuzhiyun from the position of the tool. If both positions are present, the major 307*4882a593Smuzhiyun tool axis points towards the touch point [#f1]_. Otherwise, the tool axes are 308*4882a593Smuzhiyun aligned with the touch axes. 309*4882a593Smuzhiyun 310*4882a593SmuzhiyunABS_MT_TOOL_TYPE 311*4882a593Smuzhiyun The type of approaching tool. A lot of kernel drivers cannot distinguish 312*4882a593Smuzhiyun between different tool types, such as a finger or a pen. In such cases, the 313*4882a593Smuzhiyun event should be omitted. The protocol currently mainly supports 314*4882a593Smuzhiyun MT_TOOL_FINGER, MT_TOOL_PEN, and MT_TOOL_PALM [#f2]_. 315*4882a593Smuzhiyun For type B devices, this event is handled by input core; drivers should 316*4882a593Smuzhiyun instead use input_mt_report_slot_state(). A contact's ABS_MT_TOOL_TYPE may 317*4882a593Smuzhiyun change over time while still touching the device, because the firmware may 318*4882a593Smuzhiyun not be able to determine which tool is being used when it first appears. 319*4882a593Smuzhiyun 320*4882a593SmuzhiyunABS_MT_BLOB_ID 321*4882a593Smuzhiyun The BLOB_ID groups several packets together into one arbitrarily shaped 322*4882a593Smuzhiyun contact. The sequence of points forms a polygon which defines the shape of 323*4882a593Smuzhiyun the contact. This is a low-level anonymous grouping for type A devices, and 324*4882a593Smuzhiyun should not be confused with the high-level trackingID [#f5]_. Most type A 325*4882a593Smuzhiyun devices do not have blob capability, so drivers can safely omit this event. 326*4882a593Smuzhiyun 327*4882a593SmuzhiyunABS_MT_TRACKING_ID 328*4882a593Smuzhiyun The TRACKING_ID identifies an initiated contact throughout its life cycle 329*4882a593Smuzhiyun [#f5]_. The value range of the TRACKING_ID should be large enough to ensure 330*4882a593Smuzhiyun unique identification of a contact maintained over an extended period of 331*4882a593Smuzhiyun time. For type B devices, this event is handled by input core; drivers 332*4882a593Smuzhiyun should instead use input_mt_report_slot_state(). 333*4882a593Smuzhiyun 334*4882a593Smuzhiyun 335*4882a593SmuzhiyunEvent Computation 336*4882a593Smuzhiyun----------------- 337*4882a593Smuzhiyun 338*4882a593SmuzhiyunThe flora of different hardware unavoidably leads to some devices fitting 339*4882a593Smuzhiyunbetter to the MT protocol than others. To simplify and unify the mapping, 340*4882a593Smuzhiyunthis section gives recipes for how to compute certain events. 341*4882a593Smuzhiyun 342*4882a593SmuzhiyunFor devices reporting contacts as rectangular shapes, signed orientation 343*4882a593Smuzhiyuncannot be obtained. Assuming X and Y are the lengths of the sides of the 344*4882a593Smuzhiyuntouching rectangle, here is a simple formula that retains the most 345*4882a593Smuzhiyuninformation possible:: 346*4882a593Smuzhiyun 347*4882a593Smuzhiyun ABS_MT_TOUCH_MAJOR := max(X, Y) 348*4882a593Smuzhiyun ABS_MT_TOUCH_MINOR := min(X, Y) 349*4882a593Smuzhiyun ABS_MT_ORIENTATION := bool(X > Y) 350*4882a593Smuzhiyun 351*4882a593SmuzhiyunThe range of ABS_MT_ORIENTATION should be set to [0, 1], to indicate that 352*4882a593Smuzhiyunthe device can distinguish between a finger along the Y axis (0) and a 353*4882a593Smuzhiyunfinger along the X axis (1). 354*4882a593Smuzhiyun 355*4882a593SmuzhiyunFor win8 devices with both T and C coordinates, the position mapping is:: 356*4882a593Smuzhiyun 357*4882a593Smuzhiyun ABS_MT_POSITION_X := T_X 358*4882a593Smuzhiyun ABS_MT_POSITION_Y := T_Y 359*4882a593Smuzhiyun ABS_MT_TOOL_X := C_X 360*4882a593Smuzhiyun ABS_MT_TOOL_Y := C_Y 361*4882a593Smuzhiyun 362*4882a593SmuzhiyunUnfortunately, there is not enough information to specify both the touching 363*4882a593Smuzhiyunellipse and the tool ellipse, so one has to resort to approximations. One 364*4882a593Smuzhiyunsimple scheme, which is compatible with earlier usage, is:: 365*4882a593Smuzhiyun 366*4882a593Smuzhiyun ABS_MT_TOUCH_MAJOR := min(X, Y) 367*4882a593Smuzhiyun ABS_MT_TOUCH_MINOR := <not used> 368*4882a593Smuzhiyun ABS_MT_ORIENTATION := <not used> 369*4882a593Smuzhiyun ABS_MT_WIDTH_MAJOR := min(X, Y) + distance(T, C) 370*4882a593Smuzhiyun ABS_MT_WIDTH_MINOR := min(X, Y) 371*4882a593Smuzhiyun 372*4882a593SmuzhiyunRationale: We have no information about the orientation of the touching 373*4882a593Smuzhiyunellipse, so approximate it with an inscribed circle instead. The tool 374*4882a593Smuzhiyunellipse should align with the vector (T - C), so the diameter must 375*4882a593Smuzhiyunincrease with distance(T, C). Finally, assume that the touch diameter is 376*4882a593Smuzhiyunequal to the tool thickness, and we arrive at the formulas above. 377*4882a593Smuzhiyun 378*4882a593SmuzhiyunFinger Tracking 379*4882a593Smuzhiyun--------------- 380*4882a593Smuzhiyun 381*4882a593SmuzhiyunThe process of finger tracking, i.e., to assign a unique trackingID to each 382*4882a593Smuzhiyuninitiated contact on the surface, is a Euclidian Bipartite Matching 383*4882a593Smuzhiyunproblem. At each event synchronization, the set of actual contacts is 384*4882a593Smuzhiyunmatched to the set of contacts from the previous synchronization. A full 385*4882a593Smuzhiyunimplementation can be found in [#f3]_. 386*4882a593Smuzhiyun 387*4882a593Smuzhiyun 388*4882a593SmuzhiyunGestures 389*4882a593Smuzhiyun-------- 390*4882a593Smuzhiyun 391*4882a593SmuzhiyunIn the specific application of creating gesture events, the TOUCH and WIDTH 392*4882a593Smuzhiyunparameters can be used to, e.g., approximate finger pressure or distinguish 393*4882a593Smuzhiyunbetween index finger and thumb. With the addition of the MINOR parameters, 394*4882a593Smuzhiyunone can also distinguish between a sweeping finger and a pointing finger, 395*4882a593Smuzhiyunand with ORIENTATION, one can detect twisting of fingers. 396*4882a593Smuzhiyun 397*4882a593Smuzhiyun 398*4882a593SmuzhiyunNotes 399*4882a593Smuzhiyun----- 400*4882a593Smuzhiyun 401*4882a593SmuzhiyunIn order to stay compatible with existing applications, the data reported 402*4882a593Smuzhiyunin a finger packet must not be recognized as single-touch events. 403*4882a593Smuzhiyun 404*4882a593SmuzhiyunFor type A devices, all finger data bypasses input filtering, since 405*4882a593Smuzhiyunsubsequent events of the same type refer to different fingers. 406*4882a593Smuzhiyun 407*4882a593Smuzhiyun.. [#f1] Also, the difference (TOOL_X - POSITION_X) can be used to model tilt. 408*4882a593Smuzhiyun.. [#f2] The list can of course be extended. 409*4882a593Smuzhiyun.. [#f3] The mtdev project: http://bitmath.org/code/mtdev/. 410*4882a593Smuzhiyun.. [#f4] See the section on event computation. 411*4882a593Smuzhiyun.. [#f5] See the section on finger tracking. 412