Skip to content

Commit f9ebfc2

Browse files
Oleksandr Andrushchenkojgross1
authored andcommitted
xen/kbdif: add multi-touch support
Multi-touch fields re-use the page that is used by the other features which means that you can interleave multi-touch, motion, and key events. Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com> Acked-by: Juergen Gross <jgross@suse.com> Signed-off-by: Juergen Gross <jgross@suse.com>
1 parent 8ec9dd0 commit f9ebfc2

1 file changed

Lines changed: 210 additions & 0 deletions

File tree

‎include/xen/interface/io/kbdif.h‎

Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@
5757
* Backends, which support reporting of absolute coordinates for pointer
5858
* device should set this to 1.
5959
*
60+
* feature-multi-touch
61+
* Values: <uint>
62+
*
63+
* Backends, which support reporting of multi-touch events
64+
* should set this to 1.
65+
*
6066
*------------------------- Pointer Device Parameters ------------------------
6167
*
6268
* width
@@ -87,6 +93,11 @@
8793
* Request backend to report absolute pointer coordinates
8894
* (XENKBD_TYPE_POS) instead of relative ones (XENKBD_TYPE_MOTION).
8995
*
96+
* request-multi-touch
97+
* Values: <uint>
98+
*
99+
* Request backend to report multi-touch events.
100+
*
90101
*----------------------- Request Transport Parameters -----------------------
91102
*
92103
* event-channel
@@ -106,6 +117,25 @@
106117
*
107118
* OBSOLETE, not recommended for use.
108119
* PFN of the shared page.
120+
*
121+
*----------------------- Multi-touch Device Parameters -----------------------
122+
*
123+
* multi-touch-num-contacts
124+
* Values: <uint>
125+
*
126+
* Number of simultaneous touches reported.
127+
*
128+
* multi-touch-width
129+
* Values: <uint>
130+
*
131+
* Width of the touch area to be used by the frontend
132+
* while reporting input events, pixels, [0; UINT32_MAX].
133+
*
134+
* multi-touch-height
135+
* Values: <uint>
136+
*
137+
* Height of the touch area to be used by the frontend
138+
* while reporting input events, pixels, [0; UINT32_MAX].
109139
*/
110140

111141
/*
@@ -116,6 +146,16 @@
116146
#define XENKBD_TYPE_RESERVED 2
117147
#define XENKBD_TYPE_KEY 3
118148
#define XENKBD_TYPE_POS 4
149+
#define XENKBD_TYPE_MTOUCH 5
150+
151+
/* Multi-touch event sub-codes */
152+
153+
#define XENKBD_MT_EV_DOWN 0
154+
#define XENKBD_MT_EV_UP 1
155+
#define XENKBD_MT_EV_MOTION 2
156+
#define XENKBD_MT_EV_SYN 3
157+
#define XENKBD_MT_EV_SHAPE 4
158+
#define XENKBD_MT_EV_ORIENT 5
119159

120160
/*
121161
* CONSTANTS, XENSTORE FIELD AND PATH NAME STRINGS, HELPERS.
@@ -124,11 +164,16 @@
124164
#define XENKBD_DRIVER_NAME "vkbd"
125165

126166
#define XENKBD_FIELD_FEAT_ABS_POINTER "feature-abs-pointer"
167+
#define XENKBD_FIELD_FEAT_MTOUCH "feature-multi-touch"
127168
#define XENKBD_FIELD_REQ_ABS_POINTER "request-abs-pointer"
169+
#define XENKBD_FIELD_REQ_MTOUCH "request-multi-touch"
128170
#define XENKBD_FIELD_RING_GREF "page-gref"
129171
#define XENKBD_FIELD_EVT_CHANNEL "event-channel"
130172
#define XENKBD_FIELD_WIDTH "width"
131173
#define XENKBD_FIELD_HEIGHT "height"
174+
#define XENKBD_FIELD_MT_WIDTH "multi-touch-width"
175+
#define XENKBD_FIELD_MT_HEIGHT "multi-touch-height"
176+
#define XENKBD_FIELD_MT_NUM_CONTACTS "multi-touch-num-contacts"
132177

133178
/* OBSOLETE, not recommended for use */
134179
#define XENKBD_FIELD_RING_REF "page-ref"
@@ -245,13 +290,178 @@ struct xenkbd_position {
245290
int32_t rel_z;
246291
};
247292

293+
/*
294+
* Multi-touch event and its sub-types
295+
*
296+
* All multi-touch event packets have common header:
297+
*
298+
* 0 1 2 3 octet
299+
* +----------------+----------------+----------------+----------------+
300+
* | _TYPE_MTOUCH | event_type | contact_id | reserved | 4
301+
* +----------------+----------------+----------------+----------------+
302+
* | reserved | 8
303+
* +----------------+----------------+----------------+----------------+
304+
*
305+
* event_type - unt8_t, multi-touch event sub-type, XENKBD_MT_EV_???
306+
* contact_id - unt8_t, ID of the contact
307+
*
308+
* Touch interactions can consist of one or more contacts.
309+
* For each contact, a series of events is generated, starting
310+
* with a down event, followed by zero or more motion events,
311+
* and ending with an up event. Events relating to the same
312+
* contact point can be identified by the ID of the sequence: contact ID.
313+
* Contact ID may be reused after XENKBD_MT_EV_UP event and
314+
* is in the [0; XENKBD_FIELD_NUM_CONTACTS - 1] range.
315+
*
316+
* For further information please refer to documentation on Wayland [1],
317+
* Linux [2] and Windows [3] multi-touch support.
318+
*
319+
* [1] https://cgit.freedesktop.org/wayland/wayland/tree/protocol/wayland.xml
320+
* [2] https://www.kernel.org/doc/Documentation/input/multi-touch-protocol.txt
321+
* [3] https://msdn.microsoft.com/en-us/library/jj151564(v=vs.85).aspx
322+
*
323+
*
324+
* Multi-touch down event - sent when a new touch is made: touch is assigned
325+
* a unique contact ID, sent with this and consequent events related
326+
* to this touch.
327+
* 0 1 2 3 octet
328+
* +----------------+----------------+----------------+----------------+
329+
* | _TYPE_MTOUCH | _MT_EV_DOWN | contact_id | reserved | 4
330+
* +----------------+----------------+----------------+----------------+
331+
* | reserved | 8
332+
* +----------------+----------------+----------------+----------------+
333+
* | abs_x | 12
334+
* +----------------+----------------+----------------+----------------+
335+
* | abs_y | 16
336+
* +----------------+----------------+----------------+----------------+
337+
* | reserved | 20
338+
* +----------------+----------------+----------------+----------------+
339+
* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
340+
* +----------------+----------------+----------------+----------------+
341+
* | reserved | 40
342+
* +----------------+----------------+----------------+----------------+
343+
*
344+
* abs_x - int32_t, absolute X position, in pixels
345+
* abs_y - int32_t, absolute Y position, in pixels
346+
*
347+
* Multi-touch contact release event
348+
* 0 1 2 3 octet
349+
* +----------------+----------------+----------------+----------------+
350+
* | _TYPE_MTOUCH | _MT_EV_UP | contact_id | reserved | 4
351+
* +----------------+----------------+----------------+----------------+
352+
* | reserved | 8
353+
* +----------------+----------------+----------------+----------------+
354+
* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
355+
* +----------------+----------------+----------------+----------------+
356+
* | reserved | 40
357+
* +----------------+----------------+----------------+----------------+
358+
*
359+
* Multi-touch motion event
360+
* 0 1 2 3 octet
361+
* +----------------+----------------+----------------+----------------+
362+
* | _TYPE_MTOUCH | _MT_EV_MOTION | contact_id | reserved | 4
363+
* +----------------+----------------+----------------+----------------+
364+
* | reserved | 8
365+
* +----------------+----------------+----------------+----------------+
366+
* | abs_x | 12
367+
* +----------------+----------------+----------------+----------------+
368+
* | abs_y | 16
369+
* +----------------+----------------+----------------+----------------+
370+
* | reserved | 20
371+
* +----------------+----------------+----------------+----------------+
372+
* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
373+
* +----------------+----------------+----------------+----------------+
374+
* | reserved | 40
375+
* +----------------+----------------+----------------+----------------+
376+
*
377+
* abs_x - int32_t, absolute X position, in pixels,
378+
* abs_y - int32_t, absolute Y position, in pixels,
379+
*
380+
* Multi-touch input synchronization event - shows end of a set of events
381+
* which logically belong together.
382+
* 0 1 2 3 octet
383+
* +----------------+----------------+----------------+----------------+
384+
* | _TYPE_MTOUCH | _MT_EV_SYN | contact_id | reserved | 4
385+
* +----------------+----------------+----------------+----------------+
386+
* | reserved | 8
387+
* +----------------+----------------+----------------+----------------+
388+
* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
389+
* +----------------+----------------+----------------+----------------+
390+
* | reserved | 40
391+
* +----------------+----------------+----------------+----------------+
392+
*
393+
* Multi-touch shape event - touch point's shape has changed its shape.
394+
* Shape is approximated by an ellipse through the major and minor axis
395+
* lengths: major is the longer diameter of the ellipse and minor is the
396+
* shorter one. Center of the ellipse is reported via
397+
* XENKBD_MT_EV_DOWN/XENKBD_MT_EV_MOTION events.
398+
* 0 1 2 3 octet
399+
* +----------------+----------------+----------------+----------------+
400+
* | _TYPE_MTOUCH | _MT_EV_SHAPE | contact_id | reserved | 4
401+
* +----------------+----------------+----------------+----------------+
402+
* | reserved | 8
403+
* +----------------+----------------+----------------+----------------+
404+
* | major | 12
405+
* +----------------+----------------+----------------+----------------+
406+
* | minor | 16
407+
* +----------------+----------------+----------------+----------------+
408+
* | reserved | 20
409+
* +----------------+----------------+----------------+----------------+
410+
* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
411+
* +----------------+----------------+----------------+----------------+
412+
* | reserved | 40
413+
* +----------------+----------------+----------------+----------------+
414+
*
415+
* major - unt32_t, length of the major axis, pixels
416+
* minor - unt32_t, length of the minor axis, pixels
417+
*
418+
* Multi-touch orientation event - touch point's shape has changed
419+
* its orientation: calculated as a clockwise angle between the major axis
420+
* of the ellipse and positive Y axis in degrees, [-180; +180].
421+
* 0 1 2 3 octet
422+
* +----------------+----------------+----------------+----------------+
423+
* | _TYPE_MTOUCH | _MT_EV_ORIENT | contact_id | reserved | 4
424+
* +----------------+----------------+----------------+----------------+
425+
* | reserved | 8
426+
* +----------------+----------------+----------------+----------------+
427+
* | orientation | reserved | 12
428+
* +----------------+----------------+----------------+----------------+
429+
* | reserved | 16
430+
* +----------------+----------------+----------------+----------------+
431+
* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
432+
* +----------------+----------------+----------------+----------------+
433+
* | reserved | 40
434+
* +----------------+----------------+----------------+----------------+
435+
*
436+
* orientation - int16_t, clockwise angle of the major axis
437+
*/
438+
439+
struct xenkbd_mtouch {
440+
uint8_t type; /* XENKBD_TYPE_MTOUCH */
441+
uint8_t event_type; /* XENKBD_MT_EV_??? */
442+
uint8_t contact_id;
443+
uint8_t reserved[5]; /* reserved for the future use */
444+
union {
445+
struct {
446+
int32_t abs_x; /* absolute X position, pixels */
447+
int32_t abs_y; /* absolute Y position, pixels */
448+
} pos;
449+
struct {
450+
uint32_t major; /* length of the major axis, pixels */
451+
uint32_t minor; /* length of the minor axis, pixels */
452+
} shape;
453+
int16_t orientation; /* clockwise angle of the major axis */
454+
} u;
455+
};
456+
248457
#define XENKBD_IN_EVENT_SIZE 40
249458

250459
union xenkbd_in_event {
251460
uint8_t type;
252461
struct xenkbd_motion motion;
253462
struct xenkbd_key key;
254463
struct xenkbd_position pos;
464+
struct xenkbd_mtouch mtouch;
255465
char pad[XENKBD_IN_EVENT_SIZE];
256466
};
257467

0 commit comments

Comments
 (0)