Skip to content

Commit cab7fac

Browse files
committed
Input: MT - Include win8 support
The newly released HID protocol for win8 multitouch devices is capable of transmitting more information about each touch. In particular, it includes details useful for touch alignment. This patch completes the MT protocol with the ABS_MT_TOOL_X/Y events, and documents how to map win8 devices. Cc: Stephane Chatty <chatty@enac.fr> Cc: Benjamin Tissoires <benjamin.tissoires@enac.fr> Cc: Peter Hutterer <peter.hutterer@who-t.net> Acked-by: Chase Douglas <chase.douglas@canonical.com> Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
1 parent fdf8042 commit cab7fac

2 files changed

Lines changed: 97 additions & 29 deletions

File tree

‎Documentation/input/multi-touch-protocol.txt‎

Lines changed: 92 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -162,26 +162,48 @@ are divided into categories, to allow for partial implementation. The
162162
minimum set consists of ABS_MT_POSITION_X and ABS_MT_POSITION_Y, which
163163
allows for multiple contacts to be tracked. If the device supports it, the
164164
ABS_MT_TOUCH_MAJOR and ABS_MT_WIDTH_MAJOR may be used to provide the size
165-
of the contact area and approaching contact, respectively.
165+
of the contact area and approaching tool, respectively.
166166

167167
The TOUCH and WIDTH parameters have a geometrical interpretation; imagine
168168
looking through a window at someone gently holding a finger against the
169169
glass. You will see two regions, one inner region consisting of the part
170170
of the finger actually touching the glass, and one outer region formed by
171-
the perimeter of the finger. The diameter of the inner region is the
172-
ABS_MT_TOUCH_MAJOR, the diameter of the outer region is
173-
ABS_MT_WIDTH_MAJOR. Now imagine the person pressing the finger harder
174-
against the glass. The inner region will increase, and in general, the
175-
ratio ABS_MT_TOUCH_MAJOR / ABS_MT_WIDTH_MAJOR, which is always smaller than
176-
unity, is related to the contact pressure. For pressure-based devices,
171+
the perimeter of the finger. The center of the touching region (a) is
172+
ABS_MT_POSITION_X/Y and the center of the approaching finger (b) is
173+
ABS_MT_TOOL_X/Y. The touch diameter is ABS_MT_TOUCH_MAJOR and the finger
174+
diameter is ABS_MT_WIDTH_MAJOR. Now imagine the person pressing the finger
175+
harder against the glass. The touch region will increase, and in general,
176+
the ratio ABS_MT_TOUCH_MAJOR / ABS_MT_WIDTH_MAJOR, which is always smaller
177+
than unity, is related to the contact pressure. For pressure-based devices,
177178
ABS_MT_PRESSURE may be used to provide the pressure on the contact area
178179
instead. Devices capable of contact hovering can use ABS_MT_DISTANCE to
179180
indicate the distance between the contact and the surface.
180181

181-
In addition to the MAJOR parameters, the oval shape of the contact can be
182-
described by adding the MINOR parameters, such that MAJOR and MINOR are the
183-
major and minor axis of an ellipse. Finally, the orientation of the oval
184-
shape can be describe with the ORIENTATION parameter.
182+
183+
Linux MT Win8
184+
__________ _______________________
185+
/ \ | |
186+
/ \ | |
187+
/ ____ \ | |
188+
/ / \ \ | |
189+
\ \ a \ \ | a |
190+
\ \____/ \ | |
191+
\ \ | |
192+
\ b \ | b |
193+
\ \ | |
194+
\ \ | |
195+
\ \ | |
196+
\ / | |
197+
\ / | |
198+
\ / | |
199+
\__________/ |_______________________|
200+
201+
202+
In addition to the MAJOR parameters, the oval shape of the touch and finger
203+
regions can be described by adding the MINOR parameters, such that MAJOR
204+
and MINOR are the major and minor axis of an ellipse. The orientation of
205+
the touch ellipse can be described with the ORIENTATION parameter, and the
206+
direction of the finger ellipse is given by the vector (a - b).
185207

186208
For type A devices, further specification of the touch shape is possible
187209
via ABS_MT_BLOB_ID.
@@ -224,7 +246,7 @@ tool. Omit if circular [4].
224246
The above four values can be used to derive additional information about
225247
the contact. The ratio ABS_MT_TOUCH_MAJOR / ABS_MT_WIDTH_MAJOR approximates
226248
the notion of pressure. The fingers of the hand and the palm all have
227-
different characteristic widths [1].
249+
different characteristic widths.
228250

229251
ABS_MT_PRESSURE
230252

@@ -240,17 +262,24 @@ the contact is hovering above the surface.
240262

241263
ABS_MT_ORIENTATION
242264

243-
The orientation of the ellipse. The value should describe a signed quarter
244-
of a revolution clockwise around the touch center. The signed value range
245-
is arbitrary, but zero should be returned for a finger aligned along the Y
246-
axis of the surface, a negative value when finger is turned to the left, and
247-
a positive value when finger turned to the right. When completely aligned with
248-
the X axis, the range max should be returned. Orientation can be omitted
249-
if the touching object is circular, or if the information is not available
250-
in the kernel driver. Partial orientation support is possible if the device
251-
can distinguish between the two axis, but not (uniquely) any values in
252-
between. In such cases, the range of ABS_MT_ORIENTATION should be [0, 1]
253-
[4].
265+
The orientation of the touching ellipse. The value should describe a signed
266+
quarter of a revolution clockwise around the touch center. The signed value
267+
range is arbitrary, but zero should be returned for an ellipse aligned with
268+
the Y axis of the surface, a negative value when the ellipse is turned to
269+
the left, and a positive value when the ellipse is turned to the
270+
right. When completely aligned with the X axis, the range max should be
271+
returned.
272+
273+
Touch ellipsis are symmetrical by default. For devices capable of true 360
274+
degree orientation, the reported orientation must exceed the range max to
275+
indicate more than a quarter of a revolution. For an upside-down finger,
276+
range max * 2 should be returned.
277+
278+
Orientation can be omitted if the touch area is circular, or if the
279+
information is not available in the kernel driver. Partial orientation
280+
support is possible if the device can distinguish between the two axis, but
281+
not (uniquely) any values in between. In such cases, the range of
282+
ABS_MT_ORIENTATION should be [0, 1] [4].
254283

255284
ABS_MT_POSITION_X
256285

@@ -260,6 +289,23 @@ ABS_MT_POSITION_Y
260289

261290
The surface Y coordinate of the center of the touching ellipse.
262291

292+
ABS_MT_TOOL_X
293+
294+
The surface X coordinate of the center of the approaching tool. Omit if
295+
the device cannot distinguish between the intended touch point and the
296+
tool itself.
297+
298+
ABS_MT_TOOL_Y
299+
300+
The surface Y coordinate of the center of the approaching tool. Omit if the
301+
device cannot distinguish between the intended touch point and the tool
302+
itself.
303+
304+
The four position values can be used to separate the position of the touch
305+
from the position of the tool. If both positions are present, the major
306+
tool axis points towards the touch point [1]. Otherwise, the tool axes are
307+
aligned with the touch axes.
308+
263309
ABS_MT_TOOL_TYPE
264310

265311
The type of approaching tool. A lot of kernel drivers cannot distinguish
@@ -305,6 +351,28 @@ The range of ABS_MT_ORIENTATION should be set to [0, 1], to indicate that
305351
the device can distinguish between a finger along the Y axis (0) and a
306352
finger along the X axis (1).
307353

354+
For win8 devices with both T and C coordinates, the position mapping is
355+
356+
ABS_MT_POSITION_X := T_X
357+
ABS_MT_POSITION_Y := T_Y
358+
ABS_MT_TOOL_X := C_X
359+
ABS_MT_TOOL_X := C_Y
360+
361+
Unfortunately, there is not enough information to specify both the touching
362+
ellipse and the tool ellipse, so one has to resort to approximations. One
363+
simple scheme, which is compatible with earlier usage, is:
364+
365+
ABS_MT_TOUCH_MAJOR := min(X, Y)
366+
ABS_MT_TOUCH_MINOR := <not used>
367+
ABS_MT_ORIENTATION := <not used>
368+
ABS_MT_WIDTH_MAJOR := min(X, Y) + distance(T, C)
369+
ABS_MT_WIDTH_MINOR := min(X, Y)
370+
371+
Rationale: We have no information about the orientation of the touching
372+
ellipse, so approximate it with an inscribed circle instead. The tool
373+
ellipse should align with the the vector (T - C), so the diameter must
374+
increase with distance(T, C). Finally, assume that the touch diameter is
375+
equal to the tool thickness, and we arrive at the formulas above.
308376

309377
Finger Tracking
310378
---------------
@@ -338,9 +406,7 @@ subsequent events of the same type refer to different fingers.
338406
For example usage of the type A protocol, see the bcm5974 driver. For
339407
example usage of the type B protocol, see the hid-egalax driver.
340408

341-
[1] With the extension ABS_MT_APPROACH_X and ABS_MT_APPROACH_Y, the
342-
difference between the contact position and the approaching tool position
343-
could be used to derive tilt.
409+
[1] Also, the difference (TOOL_X - POSITION_X) can be used to model tilt.
344410
[2] The list can of course be extended.
345411
[3] The mtdev project: http://bitmath.org/code/mtdev/.
346412
[4] See the section on event computation.

‎include/linux/input.h‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -806,18 +806,20 @@ struct input_keymap_entry {
806806
#define ABS_MT_WIDTH_MAJOR 0x32 /* Major axis of approaching ellipse */
807807
#define ABS_MT_WIDTH_MINOR 0x33 /* Minor axis (omit if circular) */
808808
#define ABS_MT_ORIENTATION 0x34 /* Ellipse orientation */
809-
#define ABS_MT_POSITION_X 0x35 /* Center X ellipse position */
810-
#define ABS_MT_POSITION_Y 0x36 /* Center Y ellipse position */
809+
#define ABS_MT_POSITION_X 0x35 /* Center X touch position */
810+
#define ABS_MT_POSITION_Y 0x36 /* Center Y touch position */
811811
#define ABS_MT_TOOL_TYPE 0x37 /* Type of touching device */
812812
#define ABS_MT_BLOB_ID 0x38 /* Group a set of packets as a blob */
813813
#define ABS_MT_TRACKING_ID 0x39 /* Unique ID of initiated contact */
814814
#define ABS_MT_PRESSURE 0x3a /* Pressure on contact area */
815815
#define ABS_MT_DISTANCE 0x3b /* Contact hover distance */
816+
#define ABS_MT_TOOL_X 0x3c /* Center X tool position */
817+
#define ABS_MT_TOOL_Y 0x3d /* Center Y tool position */
816818

817819
#ifdef __KERNEL__
818820
/* Implementation details, userspace should not care about these */
819821
#define ABS_MT_FIRST ABS_MT_TOUCH_MAJOR
820-
#define ABS_MT_LAST ABS_MT_DISTANCE
822+
#define ABS_MT_LAST ABS_MT_TOOL_Y
821823
#endif
822824

823825
#define ABS_MAX 0x3f

0 commit comments

Comments
 (0)