multi-touch-protocol.txt 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. Multi-touch (MT) Protocol
  2. -------------------------
  3. Copyright (C) 2009 Henrik Rydberg <rydberg@euromail.se>
  4. Introduction
  5. ------------
  6. In order to utilize the full power of the new multi-touch devices, a way to
  7. report detailed finger data to user space is needed. This document
  8. describes the multi-touch (MT) protocol which allows kernel drivers to
  9. report details for an arbitrary number of fingers.
  10. Usage
  11. -----
  12. Anonymous finger details are sent sequentially as separate packets of ABS
  13. events. Only the ABS_MT events are recognized as part of a finger
  14. packet. The end of a packet is marked by calling the input_mt_sync()
  15. function, which generates a SYN_MT_REPORT event. The end of multi-touch
  16. transfer is marked by calling the usual input_sync() function.
  17. A set of ABS_MT events with the desired properties is defined. The events
  18. are divided into categories, to allow for partial implementation. The
  19. minimum set consists of ABS_MT_TOUCH_MAJOR, ABS_MT_POSITION_X and
  20. ABS_MT_POSITION_Y, which allows for multiple fingers to be tracked. If the
  21. device supports it, the ABS_MT_WIDTH_MAJOR may be used to provide the size
  22. of the approaching finger. Anisotropy and direction may be specified with
  23. ABS_MT_TOUCH_MINOR, ABS_MT_WIDTH_MINOR and ABS_MT_ORIENTATION. Devices with
  24. more granular information may specify general shapes as blobs, i.e., as a
  25. sequence of rectangular shapes grouped together by an
  26. ABS_MT_BLOB_ID. Finally, the ABS_MT_TOOL_TYPE may be used to specify
  27. whether the touching tool is a finger or a pen or something else.
  28. Event Semantics
  29. ---------------
  30. The word "contact" is used to describe a tool which is in direct contact
  31. with the surface. A finger, a pen or a rubber all classify as contacts.
  32. ABS_MT_TOUCH_MAJOR
  33. The length of the major axis of the contact. The length should be given in
  34. surface units. If the surface has an X times Y resolution, the largest
  35. possible value of ABS_MT_TOUCH_MAJOR is sqrt(X^2 + Y^2), the diagonal.
  36. ABS_MT_TOUCH_MINOR
  37. The length, in surface units, of the minor axis of the contact. If the
  38. contact is circular, this event can be omitted.
  39. ABS_MT_WIDTH_MAJOR
  40. The length, in surface units, of the major axis of the approaching
  41. tool. This should be understood as the size of the tool itself. The
  42. orientation of the contact and the approaching tool are assumed to be the
  43. same.
  44. ABS_MT_WIDTH_MINOR
  45. The length, in surface units, of the minor axis of the approaching
  46. tool. Omit if circular.
  47. The above four values can be used to derive additional information about
  48. the contact. The ratio ABS_MT_TOUCH_MAJOR / ABS_MT_WIDTH_MAJOR approximates
  49. the notion of pressure. The fingers of the hand and the palm all have
  50. different characteristic widths [1].
  51. ABS_MT_ORIENTATION
  52. The orientation of the ellipse. The value should describe half a revolution
  53. clockwise around the touch center. The scale of the value is arbitrary, but
  54. zero should be returned for an ellipse aligned along the Y axis of the
  55. surface. As an example, an index finger placed straight onto the axis could
  56. return zero orientation, something negative when twisted to the left, and
  57. something positive when twisted to the right. This value can be omitted if
  58. the touching object is circular, or if the information is not available in
  59. the kernel driver.
  60. ABS_MT_POSITION_X
  61. The surface X coordinate of the center of the touching ellipse.
  62. ABS_MT_POSITION_Y
  63. The surface Y coordinate of the center of the touching ellipse.
  64. ABS_MT_TOOL_TYPE
  65. The type of approaching tool. A lot of kernel drivers cannot distinguish
  66. between different tool types, such as a finger or a pen. In such cases, the
  67. event should be omitted. The protocol currently supports MT_TOOL_FINGER and
  68. MT_TOOL_PEN [2].
  69. ABS_MT_BLOB_ID
  70. The BLOB_ID groups several packets together into one arbitrarily shaped
  71. contact. This is a low-level anonymous grouping, and should not be confused
  72. with the high-level contactID, explained below. Most kernel drivers will
  73. not have this capability, and can safely omit the event.
  74. Finger Tracking
  75. ---------------
  76. The kernel driver should generate an arbitrary enumeration of the set of
  77. anonymous contacts currently on the surface. The order in which the packets
  78. appear in the event stream is not important.
  79. The process of finger tracking, i.e., to assign a unique contactID to each
  80. initiated contact on the surface, is left to user space; preferably the
  81. multi-touch X driver [3]. In that driver, the contactID stays the same and
  82. unique until the contact vanishes (when the finger leaves the surface). The
  83. problem of assigning a set of anonymous fingers to a set of identified
  84. fingers is a euclidian bipartite matching problem at each event update, and
  85. relies on a sufficiently rapid update rate.
  86. Notes
  87. -----
  88. In order to stay compatible with existing applications, the data
  89. reported in a finger packet must not be recognized as single-touch
  90. events. In addition, all finger data must bypass input filtering,
  91. since subsequent events of the same type refer to different fingers.
  92. The first kernel driver to utilize the MT protocol is the bcm5974 driver,
  93. where examples can be found.
  94. [1] With the extension ABS_MT_APPROACH_X and ABS_MT_APPROACH_Y, the
  95. difference between the contact position and the approaching tool position
  96. could be used to derive tilt.
  97. [2] The list can of course be extended.
  98. [3] The multi-touch X driver is currently in the prototyping stage. At the
  99. time of writing (April 2009), the MT protocol is not yet merged, and the
  100. prototype implements finger matching, basic mouse support and two-finger
  101. scrolling. The project aims at improving the quality of current multi-touch
  102. functionality available in the synaptics X driver, and in addition
  103. implement more advanced gestures.