Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Oleksandr Andrushchenko and committed by
Juergen Gross
f9ebfc22 8ec9dd0e

+210
+210
include/xen/interface/io/kbdif.h
··· 57 57 * Backends, which support reporting of absolute coordinates for pointer 58 58 * device should set this to 1. 59 59 * 60 + * feature-multi-touch 61 + * Values: <uint> 62 + * 63 + * Backends, which support reporting of multi-touch events 64 + * should set this to 1. 65 + * 60 66 *------------------------- Pointer Device Parameters ------------------------ 61 67 * 62 68 * width ··· 93 87 * Request backend to report absolute pointer coordinates 94 88 * (XENKBD_TYPE_POS) instead of relative ones (XENKBD_TYPE_MOTION). 95 89 * 90 + * request-multi-touch 91 + * Values: <uint> 92 + * 93 + * Request backend to report multi-touch events. 94 + * 96 95 *----------------------- Request Transport Parameters ----------------------- 97 96 * 98 97 * event-channel ··· 117 106 * 118 107 * OBSOLETE, not recommended for use. 119 108 * PFN of the shared page. 109 + * 110 + *----------------------- Multi-touch Device Parameters ----------------------- 111 + * 112 + * multi-touch-num-contacts 113 + * Values: <uint> 114 + * 115 + * Number of simultaneous touches reported. 116 + * 117 + * multi-touch-width 118 + * Values: <uint> 119 + * 120 + * Width of the touch area to be used by the frontend 121 + * while reporting input events, pixels, [0; UINT32_MAX]. 122 + * 123 + * multi-touch-height 124 + * Values: <uint> 125 + * 126 + * Height of the touch area to be used by the frontend 127 + * while reporting input events, pixels, [0; UINT32_MAX]. 120 128 */ 121 129 122 130 /* ··· 146 116 #define XENKBD_TYPE_RESERVED 2 147 117 #define XENKBD_TYPE_KEY 3 148 118 #define XENKBD_TYPE_POS 4 119 + #define XENKBD_TYPE_MTOUCH 5 120 + 121 + /* Multi-touch event sub-codes */ 122 + 123 + #define XENKBD_MT_EV_DOWN 0 124 + #define XENKBD_MT_EV_UP 1 125 + #define XENKBD_MT_EV_MOTION 2 126 + #define XENKBD_MT_EV_SYN 3 127 + #define XENKBD_MT_EV_SHAPE 4 128 + #define XENKBD_MT_EV_ORIENT 5 149 129 150 130 /* 151 131 * CONSTANTS, XENSTORE FIELD AND PATH NAME STRINGS, HELPERS. ··· 164 124 #define XENKBD_DRIVER_NAME "vkbd" 165 125 166 126 #define XENKBD_FIELD_FEAT_ABS_POINTER "feature-abs-pointer" 127 + #define XENKBD_FIELD_FEAT_MTOUCH "feature-multi-touch" 167 128 #define XENKBD_FIELD_REQ_ABS_POINTER "request-abs-pointer" 129 + #define XENKBD_FIELD_REQ_MTOUCH "request-multi-touch" 168 130 #define XENKBD_FIELD_RING_GREF "page-gref" 169 131 #define XENKBD_FIELD_EVT_CHANNEL "event-channel" 170 132 #define XENKBD_FIELD_WIDTH "width" 171 133 #define XENKBD_FIELD_HEIGHT "height" 134 + #define XENKBD_FIELD_MT_WIDTH "multi-touch-width" 135 + #define XENKBD_FIELD_MT_HEIGHT "multi-touch-height" 136 + #define XENKBD_FIELD_MT_NUM_CONTACTS "multi-touch-num-contacts" 172 137 173 138 /* OBSOLETE, not recommended for use */ 174 139 #define XENKBD_FIELD_RING_REF "page-ref" ··· 290 245 int32_t rel_z; 291 246 }; 292 247 248 + /* 249 + * Multi-touch event and its sub-types 250 + * 251 + * All multi-touch event packets have common header: 252 + * 253 + * 0 1 2 3 octet 254 + * +----------------+----------------+----------------+----------------+ 255 + * | _TYPE_MTOUCH | event_type | contact_id | reserved | 4 256 + * +----------------+----------------+----------------+----------------+ 257 + * | reserved | 8 258 + * +----------------+----------------+----------------+----------------+ 259 + * 260 + * event_type - unt8_t, multi-touch event sub-type, XENKBD_MT_EV_??? 261 + * contact_id - unt8_t, ID of the contact 262 + * 263 + * Touch interactions can consist of one or more contacts. 264 + * For each contact, a series of events is generated, starting 265 + * with a down event, followed by zero or more motion events, 266 + * and ending with an up event. Events relating to the same 267 + * contact point can be identified by the ID of the sequence: contact ID. 268 + * Contact ID may be reused after XENKBD_MT_EV_UP event and 269 + * is in the [0; XENKBD_FIELD_NUM_CONTACTS - 1] range. 270 + * 271 + * For further information please refer to documentation on Wayland [1], 272 + * Linux [2] and Windows [3] multi-touch support. 273 + * 274 + * [1] https://cgit.freedesktop.org/wayland/wayland/tree/protocol/wayland.xml 275 + * [2] https://www.kernel.org/doc/Documentation/input/multi-touch-protocol.txt 276 + * [3] https://msdn.microsoft.com/en-us/library/jj151564(v=vs.85).aspx 277 + * 278 + * 279 + * Multi-touch down event - sent when a new touch is made: touch is assigned 280 + * a unique contact ID, sent with this and consequent events related 281 + * to this touch. 282 + * 0 1 2 3 octet 283 + * +----------------+----------------+----------------+----------------+ 284 + * | _TYPE_MTOUCH | _MT_EV_DOWN | contact_id | reserved | 4 285 + * +----------------+----------------+----------------+----------------+ 286 + * | reserved | 8 287 + * +----------------+----------------+----------------+----------------+ 288 + * | abs_x | 12 289 + * +----------------+----------------+----------------+----------------+ 290 + * | abs_y | 16 291 + * +----------------+----------------+----------------+----------------+ 292 + * | reserved | 20 293 + * +----------------+----------------+----------------+----------------+ 294 + * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| 295 + * +----------------+----------------+----------------+----------------+ 296 + * | reserved | 40 297 + * +----------------+----------------+----------------+----------------+ 298 + * 299 + * abs_x - int32_t, absolute X position, in pixels 300 + * abs_y - int32_t, absolute Y position, in pixels 301 + * 302 + * Multi-touch contact release event 303 + * 0 1 2 3 octet 304 + * +----------------+----------------+----------------+----------------+ 305 + * | _TYPE_MTOUCH | _MT_EV_UP | contact_id | reserved | 4 306 + * +----------------+----------------+----------------+----------------+ 307 + * | reserved | 8 308 + * +----------------+----------------+----------------+----------------+ 309 + * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| 310 + * +----------------+----------------+----------------+----------------+ 311 + * | reserved | 40 312 + * +----------------+----------------+----------------+----------------+ 313 + * 314 + * Multi-touch motion event 315 + * 0 1 2 3 octet 316 + * +----------------+----------------+----------------+----------------+ 317 + * | _TYPE_MTOUCH | _MT_EV_MOTION | contact_id | reserved | 4 318 + * +----------------+----------------+----------------+----------------+ 319 + * | reserved | 8 320 + * +----------------+----------------+----------------+----------------+ 321 + * | abs_x | 12 322 + * +----------------+----------------+----------------+----------------+ 323 + * | abs_y | 16 324 + * +----------------+----------------+----------------+----------------+ 325 + * | reserved | 20 326 + * +----------------+----------------+----------------+----------------+ 327 + * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| 328 + * +----------------+----------------+----------------+----------------+ 329 + * | reserved | 40 330 + * +----------------+----------------+----------------+----------------+ 331 + * 332 + * abs_x - int32_t, absolute X position, in pixels, 333 + * abs_y - int32_t, absolute Y position, in pixels, 334 + * 335 + * Multi-touch input synchronization event - shows end of a set of events 336 + * which logically belong together. 337 + * 0 1 2 3 octet 338 + * +----------------+----------------+----------------+----------------+ 339 + * | _TYPE_MTOUCH | _MT_EV_SYN | contact_id | reserved | 4 340 + * +----------------+----------------+----------------+----------------+ 341 + * | reserved | 8 342 + * +----------------+----------------+----------------+----------------+ 343 + * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| 344 + * +----------------+----------------+----------------+----------------+ 345 + * | reserved | 40 346 + * +----------------+----------------+----------------+----------------+ 347 + * 348 + * Multi-touch shape event - touch point's shape has changed its shape. 349 + * Shape is approximated by an ellipse through the major and minor axis 350 + * lengths: major is the longer diameter of the ellipse and minor is the 351 + * shorter one. Center of the ellipse is reported via 352 + * XENKBD_MT_EV_DOWN/XENKBD_MT_EV_MOTION events. 353 + * 0 1 2 3 octet 354 + * +----------------+----------------+----------------+----------------+ 355 + * | _TYPE_MTOUCH | _MT_EV_SHAPE | contact_id | reserved | 4 356 + * +----------------+----------------+----------------+----------------+ 357 + * | reserved | 8 358 + * +----------------+----------------+----------------+----------------+ 359 + * | major | 12 360 + * +----------------+----------------+----------------+----------------+ 361 + * | minor | 16 362 + * +----------------+----------------+----------------+----------------+ 363 + * | reserved | 20 364 + * +----------------+----------------+----------------+----------------+ 365 + * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| 366 + * +----------------+----------------+----------------+----------------+ 367 + * | reserved | 40 368 + * +----------------+----------------+----------------+----------------+ 369 + * 370 + * major - unt32_t, length of the major axis, pixels 371 + * minor - unt32_t, length of the minor axis, pixels 372 + * 373 + * Multi-touch orientation event - touch point's shape has changed 374 + * its orientation: calculated as a clockwise angle between the major axis 375 + * of the ellipse and positive Y axis in degrees, [-180; +180]. 376 + * 0 1 2 3 octet 377 + * +----------------+----------------+----------------+----------------+ 378 + * | _TYPE_MTOUCH | _MT_EV_ORIENT | contact_id | reserved | 4 379 + * +----------------+----------------+----------------+----------------+ 380 + * | reserved | 8 381 + * +----------------+----------------+----------------+----------------+ 382 + * | orientation | reserved | 12 383 + * +----------------+----------------+----------------+----------------+ 384 + * | reserved | 16 385 + * +----------------+----------------+----------------+----------------+ 386 + * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| 387 + * +----------------+----------------+----------------+----------------+ 388 + * | reserved | 40 389 + * +----------------+----------------+----------------+----------------+ 390 + * 391 + * orientation - int16_t, clockwise angle of the major axis 392 + */ 393 + 394 + struct xenkbd_mtouch { 395 + uint8_t type; /* XENKBD_TYPE_MTOUCH */ 396 + uint8_t event_type; /* XENKBD_MT_EV_??? */ 397 + uint8_t contact_id; 398 + uint8_t reserved[5]; /* reserved for the future use */ 399 + union { 400 + struct { 401 + int32_t abs_x; /* absolute X position, pixels */ 402 + int32_t abs_y; /* absolute Y position, pixels */ 403 + } pos; 404 + struct { 405 + uint32_t major; /* length of the major axis, pixels */ 406 + uint32_t minor; /* length of the minor axis, pixels */ 407 + } shape; 408 + int16_t orientation; /* clockwise angle of the major axis */ 409 + } u; 410 + }; 411 + 293 412 #define XENKBD_IN_EVENT_SIZE 40 294 413 295 414 union xenkbd_in_event { ··· 461 252 struct xenkbd_motion motion; 462 253 struct xenkbd_key key; 463 254 struct xenkbd_position pos; 255 + struct xenkbd_mtouch mtouch; 464 256 char pad[XENKBD_IN_EVENT_SIZE]; 465 257 }; 466 258