1*4882a593Smuzhiyun /* 2*4882a593Smuzhiyun * kbdif.h -- Xen virtual keyboard/mouse 3*4882a593Smuzhiyun * 4*4882a593Smuzhiyun * Permission is hereby granted, free of charge, to any person obtaining a copy 5*4882a593Smuzhiyun * of this software and associated documentation files (the "Software"), to 6*4882a593Smuzhiyun * deal in the Software without restriction, including without limitation the 7*4882a593Smuzhiyun * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8*4882a593Smuzhiyun * sell copies of the Software, and to permit persons to whom the Software is 9*4882a593Smuzhiyun * furnished to do so, subject to the following conditions: 10*4882a593Smuzhiyun * 11*4882a593Smuzhiyun * The above copyright notice and this permission notice shall be included in 12*4882a593Smuzhiyun * all copies or substantial portions of the Software. 13*4882a593Smuzhiyun * 14*4882a593Smuzhiyun * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15*4882a593Smuzhiyun * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16*4882a593Smuzhiyun * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17*4882a593Smuzhiyun * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18*4882a593Smuzhiyun * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19*4882a593Smuzhiyun * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20*4882a593Smuzhiyun * DEALINGS IN THE SOFTWARE. 21*4882a593Smuzhiyun * 22*4882a593Smuzhiyun * Copyright (C) 2005 Anthony Liguori <aliguori@us.ibm.com> 23*4882a593Smuzhiyun * Copyright (C) 2006 Red Hat, Inc., Markus Armbruster <armbru@redhat.com> 24*4882a593Smuzhiyun */ 25*4882a593Smuzhiyun 26*4882a593Smuzhiyun #ifndef __XEN_PUBLIC_IO_KBDIF_H__ 27*4882a593Smuzhiyun #define __XEN_PUBLIC_IO_KBDIF_H__ 28*4882a593Smuzhiyun 29*4882a593Smuzhiyun /* 30*4882a593Smuzhiyun ***************************************************************************** 31*4882a593Smuzhiyun * Feature and Parameter Negotiation 32*4882a593Smuzhiyun ***************************************************************************** 33*4882a593Smuzhiyun * 34*4882a593Smuzhiyun * The two halves of a para-virtual driver utilize nodes within 35*4882a593Smuzhiyun * XenStore to communicate capabilities and to negotiate operating parameters. 36*4882a593Smuzhiyun * This section enumerates these nodes which reside in the respective front and 37*4882a593Smuzhiyun * backend portions of XenStore, following XenBus convention. 38*4882a593Smuzhiyun * 39*4882a593Smuzhiyun * All data in XenStore is stored as strings. Nodes specifying numeric 40*4882a593Smuzhiyun * values are encoded in decimal. Integer value ranges listed below are 41*4882a593Smuzhiyun * expressed as fixed sized integer types capable of storing the conversion 42*4882a593Smuzhiyun * of a properly formated node string, without loss of information. 43*4882a593Smuzhiyun * 44*4882a593Smuzhiyun ***************************************************************************** 45*4882a593Smuzhiyun * Backend XenBus Nodes 46*4882a593Smuzhiyun ***************************************************************************** 47*4882a593Smuzhiyun * 48*4882a593Smuzhiyun *---------------------------- Features supported ---------------------------- 49*4882a593Smuzhiyun * 50*4882a593Smuzhiyun * Capable backend advertises supported features by publishing 51*4882a593Smuzhiyun * corresponding entries in XenStore and puts 1 as the value of the entry. 52*4882a593Smuzhiyun * If a feature is not supported then 0 must be set or feature entry omitted. 53*4882a593Smuzhiyun * 54*4882a593Smuzhiyun * feature-disable-keyboard 55*4882a593Smuzhiyun * Values: <uint> 56*4882a593Smuzhiyun * 57*4882a593Smuzhiyun * If there is no need to expose a virtual keyboard device by the 58*4882a593Smuzhiyun * frontend then this must be set to 1. 59*4882a593Smuzhiyun * 60*4882a593Smuzhiyun * feature-disable-pointer 61*4882a593Smuzhiyun * Values: <uint> 62*4882a593Smuzhiyun * 63*4882a593Smuzhiyun * If there is no need to expose a virtual pointer device by the 64*4882a593Smuzhiyun * frontend then this must be set to 1. 65*4882a593Smuzhiyun * 66*4882a593Smuzhiyun * feature-abs-pointer 67*4882a593Smuzhiyun * Values: <uint> 68*4882a593Smuzhiyun * 69*4882a593Smuzhiyun * Backends, which support reporting of absolute coordinates for pointer 70*4882a593Smuzhiyun * device should set this to 1. 71*4882a593Smuzhiyun * 72*4882a593Smuzhiyun * feature-multi-touch 73*4882a593Smuzhiyun * Values: <uint> 74*4882a593Smuzhiyun * 75*4882a593Smuzhiyun * Backends, which support reporting of multi-touch events 76*4882a593Smuzhiyun * should set this to 1. 77*4882a593Smuzhiyun * 78*4882a593Smuzhiyun * feature-raw-pointer 79*4882a593Smuzhiyun * Values: <uint> 80*4882a593Smuzhiyun * 81*4882a593Smuzhiyun * Backends, which support reporting raw (unscaled) absolute coordinates 82*4882a593Smuzhiyun * for pointer devices should set this to 1. Raw (unscaled) values have 83*4882a593Smuzhiyun * a range of [0, 0x7fff]. 84*4882a593Smuzhiyun * 85*4882a593Smuzhiyun *----------------------- Device Instance Parameters ------------------------ 86*4882a593Smuzhiyun * 87*4882a593Smuzhiyun * unique-id 88*4882a593Smuzhiyun * Values: <string> 89*4882a593Smuzhiyun * 90*4882a593Smuzhiyun * After device instance initialization it is assigned a unique ID, 91*4882a593Smuzhiyun * so every instance of the frontend can be identified by the backend 92*4882a593Smuzhiyun * by this ID. This can be UUID or such. 93*4882a593Smuzhiyun * 94*4882a593Smuzhiyun *------------------------- Pointer Device Parameters ------------------------ 95*4882a593Smuzhiyun * 96*4882a593Smuzhiyun * width 97*4882a593Smuzhiyun * Values: <uint> 98*4882a593Smuzhiyun * 99*4882a593Smuzhiyun * Maximum X coordinate (width) to be used by the frontend 100*4882a593Smuzhiyun * while reporting input events, pixels, [0; UINT32_MAX]. 101*4882a593Smuzhiyun * 102*4882a593Smuzhiyun * height 103*4882a593Smuzhiyun * Values: <uint> 104*4882a593Smuzhiyun * 105*4882a593Smuzhiyun * Maximum Y coordinate (height) to be used by the frontend 106*4882a593Smuzhiyun * while reporting input events, pixels, [0; UINT32_MAX]. 107*4882a593Smuzhiyun * 108*4882a593Smuzhiyun *----------------------- Multi-touch Device Parameters ---------------------- 109*4882a593Smuzhiyun * 110*4882a593Smuzhiyun * multi-touch-num-contacts 111*4882a593Smuzhiyun * Values: <uint> 112*4882a593Smuzhiyun * 113*4882a593Smuzhiyun * Number of simultaneous touches reported. 114*4882a593Smuzhiyun * 115*4882a593Smuzhiyun * multi-touch-width 116*4882a593Smuzhiyun * Values: <uint> 117*4882a593Smuzhiyun * 118*4882a593Smuzhiyun * Width of the touch area to be used by the frontend 119*4882a593Smuzhiyun * while reporting input events, pixels, [0; UINT32_MAX]. 120*4882a593Smuzhiyun * 121*4882a593Smuzhiyun * multi-touch-height 122*4882a593Smuzhiyun * Values: <uint> 123*4882a593Smuzhiyun * 124*4882a593Smuzhiyun * Height of the touch area to be used by the frontend 125*4882a593Smuzhiyun * while reporting input events, pixels, [0; UINT32_MAX]. 126*4882a593Smuzhiyun * 127*4882a593Smuzhiyun ***************************************************************************** 128*4882a593Smuzhiyun * Frontend XenBus Nodes 129*4882a593Smuzhiyun ***************************************************************************** 130*4882a593Smuzhiyun * 131*4882a593Smuzhiyun *------------------------------ Feature request ----------------------------- 132*4882a593Smuzhiyun * 133*4882a593Smuzhiyun * Capable frontend requests features from backend via setting corresponding 134*4882a593Smuzhiyun * entries to 1 in XenStore. Requests for features not advertised as supported 135*4882a593Smuzhiyun * by the backend have no effect. 136*4882a593Smuzhiyun * 137*4882a593Smuzhiyun * request-abs-pointer 138*4882a593Smuzhiyun * Values: <uint> 139*4882a593Smuzhiyun * 140*4882a593Smuzhiyun * Request backend to report absolute pointer coordinates 141*4882a593Smuzhiyun * (XENKBD_TYPE_POS) instead of relative ones (XENKBD_TYPE_MOTION). 142*4882a593Smuzhiyun * 143*4882a593Smuzhiyun * request-multi-touch 144*4882a593Smuzhiyun * Values: <uint> 145*4882a593Smuzhiyun * 146*4882a593Smuzhiyun * Request backend to report multi-touch events. 147*4882a593Smuzhiyun * 148*4882a593Smuzhiyun * request-raw-pointer 149*4882a593Smuzhiyun * Values: <uint> 150*4882a593Smuzhiyun * 151*4882a593Smuzhiyun * Request backend to report raw unscaled absolute pointer coordinates. 152*4882a593Smuzhiyun * This option is only valid if request-abs-pointer is also set. 153*4882a593Smuzhiyun * Raw unscaled coordinates have the range [0, 0x7fff] 154*4882a593Smuzhiyun * 155*4882a593Smuzhiyun *----------------------- Request Transport Parameters ----------------------- 156*4882a593Smuzhiyun * 157*4882a593Smuzhiyun * event-channel 158*4882a593Smuzhiyun * Values: <uint> 159*4882a593Smuzhiyun * 160*4882a593Smuzhiyun * The identifier of the Xen event channel used to signal activity 161*4882a593Smuzhiyun * in the ring buffer. 162*4882a593Smuzhiyun * 163*4882a593Smuzhiyun * page-gref 164*4882a593Smuzhiyun * Values: <uint> 165*4882a593Smuzhiyun * 166*4882a593Smuzhiyun * The Xen grant reference granting permission for the backend to map 167*4882a593Smuzhiyun * a sole page in a single page sized event ring buffer. 168*4882a593Smuzhiyun * 169*4882a593Smuzhiyun * page-ref 170*4882a593Smuzhiyun * Values: <uint> 171*4882a593Smuzhiyun * 172*4882a593Smuzhiyun * OBSOLETE, not recommended for use. 173*4882a593Smuzhiyun * PFN of the shared page. 174*4882a593Smuzhiyun */ 175*4882a593Smuzhiyun 176*4882a593Smuzhiyun /* 177*4882a593Smuzhiyun * EVENT CODES. 178*4882a593Smuzhiyun */ 179*4882a593Smuzhiyun 180*4882a593Smuzhiyun #define XENKBD_TYPE_MOTION 1 181*4882a593Smuzhiyun #define XENKBD_TYPE_RESERVED 2 182*4882a593Smuzhiyun #define XENKBD_TYPE_KEY 3 183*4882a593Smuzhiyun #define XENKBD_TYPE_POS 4 184*4882a593Smuzhiyun #define XENKBD_TYPE_MTOUCH 5 185*4882a593Smuzhiyun 186*4882a593Smuzhiyun /* Multi-touch event sub-codes */ 187*4882a593Smuzhiyun 188*4882a593Smuzhiyun #define XENKBD_MT_EV_DOWN 0 189*4882a593Smuzhiyun #define XENKBD_MT_EV_UP 1 190*4882a593Smuzhiyun #define XENKBD_MT_EV_MOTION 2 191*4882a593Smuzhiyun #define XENKBD_MT_EV_SYN 3 192*4882a593Smuzhiyun #define XENKBD_MT_EV_SHAPE 4 193*4882a593Smuzhiyun #define XENKBD_MT_EV_ORIENT 5 194*4882a593Smuzhiyun 195*4882a593Smuzhiyun /* 196*4882a593Smuzhiyun * CONSTANTS, XENSTORE FIELD AND PATH NAME STRINGS, HELPERS. 197*4882a593Smuzhiyun */ 198*4882a593Smuzhiyun 199*4882a593Smuzhiyun #define XENKBD_DRIVER_NAME "vkbd" 200*4882a593Smuzhiyun 201*4882a593Smuzhiyun #define XENKBD_FIELD_FEAT_DSBL_KEYBRD "feature-disable-keyboard" 202*4882a593Smuzhiyun #define XENKBD_FIELD_FEAT_DSBL_POINTER "feature-disable-pointer" 203*4882a593Smuzhiyun #define XENKBD_FIELD_FEAT_ABS_POINTER "feature-abs-pointer" 204*4882a593Smuzhiyun #define XENKBD_FIELD_FEAT_RAW_POINTER "feature-raw-pointer" 205*4882a593Smuzhiyun #define XENKBD_FIELD_FEAT_MTOUCH "feature-multi-touch" 206*4882a593Smuzhiyun #define XENKBD_FIELD_REQ_ABS_POINTER "request-abs-pointer" 207*4882a593Smuzhiyun #define XENKBD_FIELD_REQ_RAW_POINTER "request-raw-pointer" 208*4882a593Smuzhiyun #define XENKBD_FIELD_REQ_MTOUCH "request-multi-touch" 209*4882a593Smuzhiyun #define XENKBD_FIELD_RING_GREF "page-gref" 210*4882a593Smuzhiyun #define XENKBD_FIELD_EVT_CHANNEL "event-channel" 211*4882a593Smuzhiyun #define XENKBD_FIELD_WIDTH "width" 212*4882a593Smuzhiyun #define XENKBD_FIELD_HEIGHT "height" 213*4882a593Smuzhiyun #define XENKBD_FIELD_MT_WIDTH "multi-touch-width" 214*4882a593Smuzhiyun #define XENKBD_FIELD_MT_HEIGHT "multi-touch-height" 215*4882a593Smuzhiyun #define XENKBD_FIELD_MT_NUM_CONTACTS "multi-touch-num-contacts" 216*4882a593Smuzhiyun #define XENKBD_FIELD_UNIQUE_ID "unique-id" 217*4882a593Smuzhiyun 218*4882a593Smuzhiyun /* OBSOLETE, not recommended for use */ 219*4882a593Smuzhiyun #define XENKBD_FIELD_RING_REF "page-ref" 220*4882a593Smuzhiyun 221*4882a593Smuzhiyun /* 222*4882a593Smuzhiyun ***************************************************************************** 223*4882a593Smuzhiyun * Description of the protocol between frontend and backend driver. 224*4882a593Smuzhiyun ***************************************************************************** 225*4882a593Smuzhiyun * 226*4882a593Smuzhiyun * The two halves of a Para-virtual driver communicate with 227*4882a593Smuzhiyun * each other using a shared page and an event channel. 228*4882a593Smuzhiyun * Shared page contains a ring with event structures. 229*4882a593Smuzhiyun * 230*4882a593Smuzhiyun * All reserved fields in the structures below must be 0. 231*4882a593Smuzhiyun * 232*4882a593Smuzhiyun ***************************************************************************** 233*4882a593Smuzhiyun * Backend to frontend events 234*4882a593Smuzhiyun ***************************************************************************** 235*4882a593Smuzhiyun * 236*4882a593Smuzhiyun * Frontends should ignore unknown in events. 237*4882a593Smuzhiyun * All event packets have the same length (40 octets) 238*4882a593Smuzhiyun * All event packets have common header: 239*4882a593Smuzhiyun * 240*4882a593Smuzhiyun * 0 octet 241*4882a593Smuzhiyun * +-----------------+ 242*4882a593Smuzhiyun * | type | 243*4882a593Smuzhiyun * +-----------------+ 244*4882a593Smuzhiyun * type - uint8_t, event code, XENKBD_TYPE_??? 245*4882a593Smuzhiyun * 246*4882a593Smuzhiyun * 247*4882a593Smuzhiyun * Pointer relative movement event 248*4882a593Smuzhiyun * 0 1 2 3 octet 249*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 250*4882a593Smuzhiyun * | _TYPE_MOTION | reserved | 4 251*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 252*4882a593Smuzhiyun * | rel_x | 8 253*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 254*4882a593Smuzhiyun * | rel_y | 12 255*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 256*4882a593Smuzhiyun * | rel_z | 16 257*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 258*4882a593Smuzhiyun * | reserved | 20 259*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 260*4882a593Smuzhiyun * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| 261*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 262*4882a593Smuzhiyun * | reserved | 40 263*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 264*4882a593Smuzhiyun * 265*4882a593Smuzhiyun * rel_x - int32_t, relative X motion 266*4882a593Smuzhiyun * rel_y - int32_t, relative Y motion 267*4882a593Smuzhiyun * rel_z - int32_t, relative Z motion (wheel) 268*4882a593Smuzhiyun */ 269*4882a593Smuzhiyun 270*4882a593Smuzhiyun struct xenkbd_motion { 271*4882a593Smuzhiyun uint8_t type; 272*4882a593Smuzhiyun int32_t rel_x; 273*4882a593Smuzhiyun int32_t rel_y; 274*4882a593Smuzhiyun int32_t rel_z; 275*4882a593Smuzhiyun }; 276*4882a593Smuzhiyun 277*4882a593Smuzhiyun /* 278*4882a593Smuzhiyun * Key event (includes pointer buttons) 279*4882a593Smuzhiyun * 0 1 2 3 octet 280*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 281*4882a593Smuzhiyun * | _TYPE_KEY | pressed | reserved | 4 282*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 283*4882a593Smuzhiyun * | keycode | 8 284*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 285*4882a593Smuzhiyun * | reserved | 12 286*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 287*4882a593Smuzhiyun * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| 288*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 289*4882a593Smuzhiyun * | reserved | 40 290*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 291*4882a593Smuzhiyun * 292*4882a593Smuzhiyun * pressed - uint8_t, 1 if pressed; 0 otherwise 293*4882a593Smuzhiyun * keycode - uint32_t, KEY_* from linux/input.h 294*4882a593Smuzhiyun */ 295*4882a593Smuzhiyun 296*4882a593Smuzhiyun struct xenkbd_key { 297*4882a593Smuzhiyun uint8_t type; 298*4882a593Smuzhiyun uint8_t pressed; 299*4882a593Smuzhiyun uint32_t keycode; 300*4882a593Smuzhiyun }; 301*4882a593Smuzhiyun 302*4882a593Smuzhiyun /* 303*4882a593Smuzhiyun * Pointer absolute position event 304*4882a593Smuzhiyun * 0 1 2 3 octet 305*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 306*4882a593Smuzhiyun * | _TYPE_POS | reserved | 4 307*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 308*4882a593Smuzhiyun * | abs_x | 8 309*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 310*4882a593Smuzhiyun * | abs_y | 12 311*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 312*4882a593Smuzhiyun * | rel_z | 16 313*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 314*4882a593Smuzhiyun * | reserved | 20 315*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 316*4882a593Smuzhiyun * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| 317*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 318*4882a593Smuzhiyun * | reserved | 40 319*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 320*4882a593Smuzhiyun * 321*4882a593Smuzhiyun * abs_x - int32_t, absolute X position (in FB pixels) 322*4882a593Smuzhiyun * abs_y - int32_t, absolute Y position (in FB pixels) 323*4882a593Smuzhiyun * rel_z - int32_t, relative Z motion (wheel) 324*4882a593Smuzhiyun */ 325*4882a593Smuzhiyun 326*4882a593Smuzhiyun struct xenkbd_position { 327*4882a593Smuzhiyun uint8_t type; 328*4882a593Smuzhiyun int32_t abs_x; 329*4882a593Smuzhiyun int32_t abs_y; 330*4882a593Smuzhiyun int32_t rel_z; 331*4882a593Smuzhiyun }; 332*4882a593Smuzhiyun 333*4882a593Smuzhiyun /* 334*4882a593Smuzhiyun * Multi-touch event and its sub-types 335*4882a593Smuzhiyun * 336*4882a593Smuzhiyun * All multi-touch event packets have common header: 337*4882a593Smuzhiyun * 338*4882a593Smuzhiyun * 0 1 2 3 octet 339*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 340*4882a593Smuzhiyun * | _TYPE_MTOUCH | event_type | contact_id | reserved | 4 341*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 342*4882a593Smuzhiyun * | reserved | 8 343*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 344*4882a593Smuzhiyun * 345*4882a593Smuzhiyun * event_type - unt8_t, multi-touch event sub-type, XENKBD_MT_EV_??? 346*4882a593Smuzhiyun * contact_id - unt8_t, ID of the contact 347*4882a593Smuzhiyun * 348*4882a593Smuzhiyun * Touch interactions can consist of one or more contacts. 349*4882a593Smuzhiyun * For each contact, a series of events is generated, starting 350*4882a593Smuzhiyun * with a down event, followed by zero or more motion events, 351*4882a593Smuzhiyun * and ending with an up event. Events relating to the same 352*4882a593Smuzhiyun * contact point can be identified by the ID of the sequence: contact ID. 353*4882a593Smuzhiyun * Contact ID may be reused after XENKBD_MT_EV_UP event and 354*4882a593Smuzhiyun * is in the [0; XENKBD_FIELD_NUM_CONTACTS - 1] range. 355*4882a593Smuzhiyun * 356*4882a593Smuzhiyun * For further information please refer to documentation on Wayland [1], 357*4882a593Smuzhiyun * Linux [2] and Windows [3] multi-touch support. 358*4882a593Smuzhiyun * 359*4882a593Smuzhiyun * [1] https://cgit.freedesktop.org/wayland/wayland/tree/protocol/wayland.xml 360*4882a593Smuzhiyun * [2] https://www.kernel.org/doc/Documentation/input/multi-touch-protocol.rst 361*4882a593Smuzhiyun * [3] https://msdn.microsoft.com/en-us/library/jj151564(v=vs.85).aspx 362*4882a593Smuzhiyun * 363*4882a593Smuzhiyun * 364*4882a593Smuzhiyun * Multi-touch down event - sent when a new touch is made: touch is assigned 365*4882a593Smuzhiyun * a unique contact ID, sent with this and consequent events related 366*4882a593Smuzhiyun * to this touch. 367*4882a593Smuzhiyun * 0 1 2 3 octet 368*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 369*4882a593Smuzhiyun * | _TYPE_MTOUCH | _MT_EV_DOWN | contact_id | reserved | 4 370*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 371*4882a593Smuzhiyun * | reserved | 8 372*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 373*4882a593Smuzhiyun * | abs_x | 12 374*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 375*4882a593Smuzhiyun * | abs_y | 16 376*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 377*4882a593Smuzhiyun * | reserved | 20 378*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 379*4882a593Smuzhiyun * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| 380*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 381*4882a593Smuzhiyun * | reserved | 40 382*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 383*4882a593Smuzhiyun * 384*4882a593Smuzhiyun * abs_x - int32_t, absolute X position, in pixels 385*4882a593Smuzhiyun * abs_y - int32_t, absolute Y position, in pixels 386*4882a593Smuzhiyun * 387*4882a593Smuzhiyun * Multi-touch contact release event 388*4882a593Smuzhiyun * 0 1 2 3 octet 389*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 390*4882a593Smuzhiyun * | _TYPE_MTOUCH | _MT_EV_UP | contact_id | reserved | 4 391*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 392*4882a593Smuzhiyun * | reserved | 8 393*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 394*4882a593Smuzhiyun * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| 395*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 396*4882a593Smuzhiyun * | reserved | 40 397*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 398*4882a593Smuzhiyun * 399*4882a593Smuzhiyun * Multi-touch motion event 400*4882a593Smuzhiyun * 0 1 2 3 octet 401*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 402*4882a593Smuzhiyun * | _TYPE_MTOUCH | _MT_EV_MOTION | contact_id | reserved | 4 403*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 404*4882a593Smuzhiyun * | reserved | 8 405*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 406*4882a593Smuzhiyun * | abs_x | 12 407*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 408*4882a593Smuzhiyun * | abs_y | 16 409*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 410*4882a593Smuzhiyun * | reserved | 20 411*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 412*4882a593Smuzhiyun * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| 413*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 414*4882a593Smuzhiyun * | reserved | 40 415*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 416*4882a593Smuzhiyun * 417*4882a593Smuzhiyun * abs_x - int32_t, absolute X position, in pixels, 418*4882a593Smuzhiyun * abs_y - int32_t, absolute Y position, in pixels, 419*4882a593Smuzhiyun * 420*4882a593Smuzhiyun * Multi-touch input synchronization event - shows end of a set of events 421*4882a593Smuzhiyun * which logically belong together. 422*4882a593Smuzhiyun * 0 1 2 3 octet 423*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 424*4882a593Smuzhiyun * | _TYPE_MTOUCH | _MT_EV_SYN | contact_id | reserved | 4 425*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 426*4882a593Smuzhiyun * | reserved | 8 427*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 428*4882a593Smuzhiyun * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| 429*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 430*4882a593Smuzhiyun * | reserved | 40 431*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 432*4882a593Smuzhiyun * 433*4882a593Smuzhiyun * Multi-touch shape event - touch point's shape has changed its shape. 434*4882a593Smuzhiyun * Shape is approximated by an ellipse through the major and minor axis 435*4882a593Smuzhiyun * lengths: major is the longer diameter of the ellipse and minor is the 436*4882a593Smuzhiyun * shorter one. Center of the ellipse is reported via 437*4882a593Smuzhiyun * XENKBD_MT_EV_DOWN/XENKBD_MT_EV_MOTION events. 438*4882a593Smuzhiyun * 0 1 2 3 octet 439*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 440*4882a593Smuzhiyun * | _TYPE_MTOUCH | _MT_EV_SHAPE | contact_id | reserved | 4 441*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 442*4882a593Smuzhiyun * | reserved | 8 443*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 444*4882a593Smuzhiyun * | major | 12 445*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 446*4882a593Smuzhiyun * | minor | 16 447*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 448*4882a593Smuzhiyun * | reserved | 20 449*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 450*4882a593Smuzhiyun * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| 451*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 452*4882a593Smuzhiyun * | reserved | 40 453*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 454*4882a593Smuzhiyun * 455*4882a593Smuzhiyun * major - unt32_t, length of the major axis, pixels 456*4882a593Smuzhiyun * minor - unt32_t, length of the minor axis, pixels 457*4882a593Smuzhiyun * 458*4882a593Smuzhiyun * Multi-touch orientation event - touch point's shape has changed 459*4882a593Smuzhiyun * its orientation: calculated as a clockwise angle between the major axis 460*4882a593Smuzhiyun * of the ellipse and positive Y axis in degrees, [-180; +180]. 461*4882a593Smuzhiyun * 0 1 2 3 octet 462*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 463*4882a593Smuzhiyun * | _TYPE_MTOUCH | _MT_EV_ORIENT | contact_id | reserved | 4 464*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 465*4882a593Smuzhiyun * | reserved | 8 466*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 467*4882a593Smuzhiyun * | orientation | reserved | 12 468*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 469*4882a593Smuzhiyun * | reserved | 16 470*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 471*4882a593Smuzhiyun * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| 472*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 473*4882a593Smuzhiyun * | reserved | 40 474*4882a593Smuzhiyun * +----------------+----------------+----------------+----------------+ 475*4882a593Smuzhiyun * 476*4882a593Smuzhiyun * orientation - int16_t, clockwise angle of the major axis 477*4882a593Smuzhiyun */ 478*4882a593Smuzhiyun 479*4882a593Smuzhiyun struct xenkbd_mtouch { 480*4882a593Smuzhiyun uint8_t type; /* XENKBD_TYPE_MTOUCH */ 481*4882a593Smuzhiyun uint8_t event_type; /* XENKBD_MT_EV_??? */ 482*4882a593Smuzhiyun uint8_t contact_id; 483*4882a593Smuzhiyun uint8_t reserved[5]; /* reserved for the future use */ 484*4882a593Smuzhiyun union { 485*4882a593Smuzhiyun struct { 486*4882a593Smuzhiyun int32_t abs_x; /* absolute X position, pixels */ 487*4882a593Smuzhiyun int32_t abs_y; /* absolute Y position, pixels */ 488*4882a593Smuzhiyun } pos; 489*4882a593Smuzhiyun struct { 490*4882a593Smuzhiyun uint32_t major; /* length of the major axis, pixels */ 491*4882a593Smuzhiyun uint32_t minor; /* length of the minor axis, pixels */ 492*4882a593Smuzhiyun } shape; 493*4882a593Smuzhiyun int16_t orientation; /* clockwise angle of the major axis */ 494*4882a593Smuzhiyun } u; 495*4882a593Smuzhiyun }; 496*4882a593Smuzhiyun 497*4882a593Smuzhiyun #define XENKBD_IN_EVENT_SIZE 40 498*4882a593Smuzhiyun 499*4882a593Smuzhiyun union xenkbd_in_event { 500*4882a593Smuzhiyun uint8_t type; 501*4882a593Smuzhiyun struct xenkbd_motion motion; 502*4882a593Smuzhiyun struct xenkbd_key key; 503*4882a593Smuzhiyun struct xenkbd_position pos; 504*4882a593Smuzhiyun struct xenkbd_mtouch mtouch; 505*4882a593Smuzhiyun char pad[XENKBD_IN_EVENT_SIZE]; 506*4882a593Smuzhiyun }; 507*4882a593Smuzhiyun 508*4882a593Smuzhiyun /* 509*4882a593Smuzhiyun ***************************************************************************** 510*4882a593Smuzhiyun * Frontend to backend events 511*4882a593Smuzhiyun ***************************************************************************** 512*4882a593Smuzhiyun * 513*4882a593Smuzhiyun * Out events may be sent only when requested by backend, and receipt 514*4882a593Smuzhiyun * of an unknown out event is an error. 515*4882a593Smuzhiyun * No out events currently defined. 516*4882a593Smuzhiyun 517*4882a593Smuzhiyun * All event packets have the same length (40 octets) 518*4882a593Smuzhiyun * All event packets have common header: 519*4882a593Smuzhiyun * 0 octet 520*4882a593Smuzhiyun * +-----------------+ 521*4882a593Smuzhiyun * | type | 522*4882a593Smuzhiyun * +-----------------+ 523*4882a593Smuzhiyun * type - uint8_t, event code 524*4882a593Smuzhiyun */ 525*4882a593Smuzhiyun 526*4882a593Smuzhiyun #define XENKBD_OUT_EVENT_SIZE 40 527*4882a593Smuzhiyun 528*4882a593Smuzhiyun union xenkbd_out_event { 529*4882a593Smuzhiyun uint8_t type; 530*4882a593Smuzhiyun char pad[XENKBD_OUT_EVENT_SIZE]; 531*4882a593Smuzhiyun }; 532*4882a593Smuzhiyun 533*4882a593Smuzhiyun /* 534*4882a593Smuzhiyun ***************************************************************************** 535*4882a593Smuzhiyun * Shared page 536*4882a593Smuzhiyun ***************************************************************************** 537*4882a593Smuzhiyun */ 538*4882a593Smuzhiyun 539*4882a593Smuzhiyun #define XENKBD_IN_RING_SIZE 2048 540*4882a593Smuzhiyun #define XENKBD_IN_RING_LEN (XENKBD_IN_RING_SIZE / XENKBD_IN_EVENT_SIZE) 541*4882a593Smuzhiyun #define XENKBD_IN_RING_OFFS 1024 542*4882a593Smuzhiyun #define XENKBD_IN_RING(page) \ 543*4882a593Smuzhiyun ((union xenkbd_in_event *)((char *)(page) + XENKBD_IN_RING_OFFS)) 544*4882a593Smuzhiyun #define XENKBD_IN_RING_REF(page, idx) \ 545*4882a593Smuzhiyun (XENKBD_IN_RING((page))[(idx) % XENKBD_IN_RING_LEN]) 546*4882a593Smuzhiyun 547*4882a593Smuzhiyun #define XENKBD_OUT_RING_SIZE 1024 548*4882a593Smuzhiyun #define XENKBD_OUT_RING_LEN (XENKBD_OUT_RING_SIZE / XENKBD_OUT_EVENT_SIZE) 549*4882a593Smuzhiyun #define XENKBD_OUT_RING_OFFS (XENKBD_IN_RING_OFFS + XENKBD_IN_RING_SIZE) 550*4882a593Smuzhiyun #define XENKBD_OUT_RING(page) \ 551*4882a593Smuzhiyun ((union xenkbd_out_event *)((char *)(page) + XENKBD_OUT_RING_OFFS)) 552*4882a593Smuzhiyun #define XENKBD_OUT_RING_REF(page, idx) \ 553*4882a593Smuzhiyun (XENKBD_OUT_RING((page))[(idx) % XENKBD_OUT_RING_LEN]) 554*4882a593Smuzhiyun 555*4882a593Smuzhiyun struct xenkbd_page { 556*4882a593Smuzhiyun uint32_t in_cons, in_prod; 557*4882a593Smuzhiyun uint32_t out_cons, out_prod; 558*4882a593Smuzhiyun }; 559*4882a593Smuzhiyun 560*4882a593Smuzhiyun #endif /* __XEN_PUBLIC_IO_KBDIF_H__ */ 561