1*9e2b3e83SJuergen Gross /* SPDX-License-Identifier: MIT */ 24ee36dc0SMarkus Armbruster /* 34ee36dc0SMarkus Armbruster * kbdif.h -- Xen virtual keyboard/mouse 44ee36dc0SMarkus Armbruster * 54ee36dc0SMarkus Armbruster * Copyright (C) 2005 Anthony Liguori <aliguori@us.ibm.com> 64ee36dc0SMarkus Armbruster * Copyright (C) 2006 Red Hat, Inc., Markus Armbruster <armbru@redhat.com> 74ee36dc0SMarkus Armbruster */ 84ee36dc0SMarkus Armbruster 94ee36dc0SMarkus Armbruster #ifndef __XEN_PUBLIC_IO_KBDIF_H__ 104ee36dc0SMarkus Armbruster #define __XEN_PUBLIC_IO_KBDIF_H__ 114ee36dc0SMarkus Armbruster 124ee36dc0SMarkus Armbruster /* 138ec9dd0eSOleksandr Andrushchenko ***************************************************************************** 148ec9dd0eSOleksandr Andrushchenko * Feature and Parameter Negotiation 158ec9dd0eSOleksandr Andrushchenko ***************************************************************************** 168ec9dd0eSOleksandr Andrushchenko * 178ec9dd0eSOleksandr Andrushchenko * The two halves of a para-virtual driver utilize nodes within 188ec9dd0eSOleksandr Andrushchenko * XenStore to communicate capabilities and to negotiate operating parameters. 198ec9dd0eSOleksandr Andrushchenko * This section enumerates these nodes which reside in the respective front and 208ec9dd0eSOleksandr Andrushchenko * backend portions of XenStore, following XenBus convention. 218ec9dd0eSOleksandr Andrushchenko * 228ec9dd0eSOleksandr Andrushchenko * All data in XenStore is stored as strings. Nodes specifying numeric 238ec9dd0eSOleksandr Andrushchenko * values are encoded in decimal. Integer value ranges listed below are 248ec9dd0eSOleksandr Andrushchenko * expressed as fixed sized integer types capable of storing the conversion 258ec9dd0eSOleksandr Andrushchenko * of a properly formated node string, without loss of information. 268ec9dd0eSOleksandr Andrushchenko * 278ec9dd0eSOleksandr Andrushchenko ***************************************************************************** 288ec9dd0eSOleksandr Andrushchenko * Backend XenBus Nodes 298ec9dd0eSOleksandr Andrushchenko ***************************************************************************** 308ec9dd0eSOleksandr Andrushchenko * 318ec9dd0eSOleksandr Andrushchenko *---------------------------- Features supported ---------------------------- 328ec9dd0eSOleksandr Andrushchenko * 338ec9dd0eSOleksandr Andrushchenko * Capable backend advertises supported features by publishing 348ec9dd0eSOleksandr Andrushchenko * corresponding entries in XenStore and puts 1 as the value of the entry. 358ec9dd0eSOleksandr Andrushchenko * If a feature is not supported then 0 must be set or feature entry omitted. 368ec9dd0eSOleksandr Andrushchenko * 37ce63b2c8SOleksandr Andrushchenko * feature-disable-keyboard 38ce63b2c8SOleksandr Andrushchenko * Values: <uint> 39ce63b2c8SOleksandr Andrushchenko * 40ce63b2c8SOleksandr Andrushchenko * If there is no need to expose a virtual keyboard device by the 41ce63b2c8SOleksandr Andrushchenko * frontend then this must be set to 1. 42ce63b2c8SOleksandr Andrushchenko * 43ce63b2c8SOleksandr Andrushchenko * feature-disable-pointer 44ce63b2c8SOleksandr Andrushchenko * Values: <uint> 45ce63b2c8SOleksandr Andrushchenko * 46ce63b2c8SOleksandr Andrushchenko * If there is no need to expose a virtual pointer device by the 47ce63b2c8SOleksandr Andrushchenko * frontend then this must be set to 1. 48ce63b2c8SOleksandr Andrushchenko * 498ec9dd0eSOleksandr Andrushchenko * feature-abs-pointer 508ec9dd0eSOleksandr Andrushchenko * Values: <uint> 518ec9dd0eSOleksandr Andrushchenko * 528ec9dd0eSOleksandr Andrushchenko * Backends, which support reporting of absolute coordinates for pointer 538ec9dd0eSOleksandr Andrushchenko * device should set this to 1. 548ec9dd0eSOleksandr Andrushchenko * 55f9ebfc22SOleksandr Andrushchenko * feature-multi-touch 56f9ebfc22SOleksandr Andrushchenko * Values: <uint> 57f9ebfc22SOleksandr Andrushchenko * 58f9ebfc22SOleksandr Andrushchenko * Backends, which support reporting of multi-touch events 59f9ebfc22SOleksandr Andrushchenko * should set this to 1. 60f9ebfc22SOleksandr Andrushchenko * 61ce63b2c8SOleksandr Andrushchenko * feature-raw-pointer 62ce63b2c8SOleksandr Andrushchenko * Values: <uint> 63ce63b2c8SOleksandr Andrushchenko * 64ce63b2c8SOleksandr Andrushchenko * Backends, which support reporting raw (unscaled) absolute coordinates 65ce63b2c8SOleksandr Andrushchenko * for pointer devices should set this to 1. Raw (unscaled) values have 66ce63b2c8SOleksandr Andrushchenko * a range of [0, 0x7fff]. 67ce63b2c8SOleksandr Andrushchenko * 68ce63b2c8SOleksandr Andrushchenko *----------------------- Device Instance Parameters ------------------------ 69ce63b2c8SOleksandr Andrushchenko * 70ce63b2c8SOleksandr Andrushchenko * unique-id 71ce63b2c8SOleksandr Andrushchenko * Values: <string> 72ce63b2c8SOleksandr Andrushchenko * 73ce63b2c8SOleksandr Andrushchenko * After device instance initialization it is assigned a unique ID, 74ce63b2c8SOleksandr Andrushchenko * so every instance of the frontend can be identified by the backend 75ce63b2c8SOleksandr Andrushchenko * by this ID. This can be UUID or such. 76ce63b2c8SOleksandr Andrushchenko * 778ec9dd0eSOleksandr Andrushchenko *------------------------- Pointer Device Parameters ------------------------ 788ec9dd0eSOleksandr Andrushchenko * 798ec9dd0eSOleksandr Andrushchenko * width 808ec9dd0eSOleksandr Andrushchenko * Values: <uint> 818ec9dd0eSOleksandr Andrushchenko * 828ec9dd0eSOleksandr Andrushchenko * Maximum X coordinate (width) to be used by the frontend 838ec9dd0eSOleksandr Andrushchenko * while reporting input events, pixels, [0; UINT32_MAX]. 848ec9dd0eSOleksandr Andrushchenko * 858ec9dd0eSOleksandr Andrushchenko * height 868ec9dd0eSOleksandr Andrushchenko * Values: <uint> 878ec9dd0eSOleksandr Andrushchenko * 888ec9dd0eSOleksandr Andrushchenko * Maximum Y coordinate (height) to be used by the frontend 898ec9dd0eSOleksandr Andrushchenko * while reporting input events, pixels, [0; UINT32_MAX]. 908ec9dd0eSOleksandr Andrushchenko * 91ce63b2c8SOleksandr Andrushchenko *----------------------- Multi-touch Device Parameters ---------------------- 92ce63b2c8SOleksandr Andrushchenko * 93ce63b2c8SOleksandr Andrushchenko * multi-touch-num-contacts 94ce63b2c8SOleksandr Andrushchenko * Values: <uint> 95ce63b2c8SOleksandr Andrushchenko * 96ce63b2c8SOleksandr Andrushchenko * Number of simultaneous touches reported. 97ce63b2c8SOleksandr Andrushchenko * 98ce63b2c8SOleksandr Andrushchenko * multi-touch-width 99ce63b2c8SOleksandr Andrushchenko * Values: <uint> 100ce63b2c8SOleksandr Andrushchenko * 101ce63b2c8SOleksandr Andrushchenko * Width of the touch area to be used by the frontend 102ce63b2c8SOleksandr Andrushchenko * while reporting input events, pixels, [0; UINT32_MAX]. 103ce63b2c8SOleksandr Andrushchenko * 104ce63b2c8SOleksandr Andrushchenko * multi-touch-height 105ce63b2c8SOleksandr Andrushchenko * Values: <uint> 106ce63b2c8SOleksandr Andrushchenko * 107ce63b2c8SOleksandr Andrushchenko * Height of the touch area to be used by the frontend 108ce63b2c8SOleksandr Andrushchenko * while reporting input events, pixels, [0; UINT32_MAX]. 109ce63b2c8SOleksandr Andrushchenko * 1108ec9dd0eSOleksandr Andrushchenko ***************************************************************************** 1118ec9dd0eSOleksandr Andrushchenko * Frontend XenBus Nodes 1128ec9dd0eSOleksandr Andrushchenko ***************************************************************************** 1138ec9dd0eSOleksandr Andrushchenko * 1148ec9dd0eSOleksandr Andrushchenko *------------------------------ Feature request ----------------------------- 1158ec9dd0eSOleksandr Andrushchenko * 1168ec9dd0eSOleksandr Andrushchenko * Capable frontend requests features from backend via setting corresponding 1178ec9dd0eSOleksandr Andrushchenko * entries to 1 in XenStore. Requests for features not advertised as supported 1188ec9dd0eSOleksandr Andrushchenko * by the backend have no effect. 1198ec9dd0eSOleksandr Andrushchenko * 1208ec9dd0eSOleksandr Andrushchenko * request-abs-pointer 1218ec9dd0eSOleksandr Andrushchenko * Values: <uint> 1228ec9dd0eSOleksandr Andrushchenko * 1238ec9dd0eSOleksandr Andrushchenko * Request backend to report absolute pointer coordinates 1248ec9dd0eSOleksandr Andrushchenko * (XENKBD_TYPE_POS) instead of relative ones (XENKBD_TYPE_MOTION). 1258ec9dd0eSOleksandr Andrushchenko * 126f9ebfc22SOleksandr Andrushchenko * request-multi-touch 127f9ebfc22SOleksandr Andrushchenko * Values: <uint> 128f9ebfc22SOleksandr Andrushchenko * 129f9ebfc22SOleksandr Andrushchenko * Request backend to report multi-touch events. 130f9ebfc22SOleksandr Andrushchenko * 131ce63b2c8SOleksandr Andrushchenko * request-raw-pointer 132ce63b2c8SOleksandr Andrushchenko * Values: <uint> 133ce63b2c8SOleksandr Andrushchenko * 134ce63b2c8SOleksandr Andrushchenko * Request backend to report raw unscaled absolute pointer coordinates. 135ce63b2c8SOleksandr Andrushchenko * This option is only valid if request-abs-pointer is also set. 136ce63b2c8SOleksandr Andrushchenko * Raw unscaled coordinates have the range [0, 0x7fff] 137ce63b2c8SOleksandr Andrushchenko * 1388ec9dd0eSOleksandr Andrushchenko *----------------------- Request Transport Parameters ----------------------- 1398ec9dd0eSOleksandr Andrushchenko * 1408ec9dd0eSOleksandr Andrushchenko * event-channel 1418ec9dd0eSOleksandr Andrushchenko * Values: <uint> 1428ec9dd0eSOleksandr Andrushchenko * 1438ec9dd0eSOleksandr Andrushchenko * The identifier of the Xen event channel used to signal activity 1448ec9dd0eSOleksandr Andrushchenko * in the ring buffer. 1458ec9dd0eSOleksandr Andrushchenko * 1468ec9dd0eSOleksandr Andrushchenko * page-gref 1478ec9dd0eSOleksandr Andrushchenko * Values: <uint> 1488ec9dd0eSOleksandr Andrushchenko * 1498ec9dd0eSOleksandr Andrushchenko * The Xen grant reference granting permission for the backend to map 1508ec9dd0eSOleksandr Andrushchenko * a sole page in a single page sized event ring buffer. 1518ec9dd0eSOleksandr Andrushchenko * 1528ec9dd0eSOleksandr Andrushchenko * page-ref 1538ec9dd0eSOleksandr Andrushchenko * Values: <uint> 1548ec9dd0eSOleksandr Andrushchenko * 1558ec9dd0eSOleksandr Andrushchenko * OBSOLETE, not recommended for use. 1568ec9dd0eSOleksandr Andrushchenko * PFN of the shared page. 1574ee36dc0SMarkus Armbruster */ 1584ee36dc0SMarkus Armbruster 1598ec9dd0eSOleksandr Andrushchenko /* 1608ec9dd0eSOleksandr Andrushchenko * EVENT CODES. 1618ec9dd0eSOleksandr Andrushchenko */ 1628ec9dd0eSOleksandr Andrushchenko 1634ee36dc0SMarkus Armbruster #define XENKBD_TYPE_MOTION 1 1648ec9dd0eSOleksandr Andrushchenko #define XENKBD_TYPE_RESERVED 2 1654ee36dc0SMarkus Armbruster #define XENKBD_TYPE_KEY 3 1664ee36dc0SMarkus Armbruster #define XENKBD_TYPE_POS 4 167f9ebfc22SOleksandr Andrushchenko #define XENKBD_TYPE_MTOUCH 5 168f9ebfc22SOleksandr Andrushchenko 169f9ebfc22SOleksandr Andrushchenko /* Multi-touch event sub-codes */ 170f9ebfc22SOleksandr Andrushchenko 171f9ebfc22SOleksandr Andrushchenko #define XENKBD_MT_EV_DOWN 0 172f9ebfc22SOleksandr Andrushchenko #define XENKBD_MT_EV_UP 1 173f9ebfc22SOleksandr Andrushchenko #define XENKBD_MT_EV_MOTION 2 174f9ebfc22SOleksandr Andrushchenko #define XENKBD_MT_EV_SYN 3 175f9ebfc22SOleksandr Andrushchenko #define XENKBD_MT_EV_SHAPE 4 176f9ebfc22SOleksandr Andrushchenko #define XENKBD_MT_EV_ORIENT 5 1774ee36dc0SMarkus Armbruster 1788ec9dd0eSOleksandr Andrushchenko /* 1798ec9dd0eSOleksandr Andrushchenko * CONSTANTS, XENSTORE FIELD AND PATH NAME STRINGS, HELPERS. 1808ec9dd0eSOleksandr Andrushchenko */ 1818ec9dd0eSOleksandr Andrushchenko 1828ec9dd0eSOleksandr Andrushchenko #define XENKBD_DRIVER_NAME "vkbd" 1838ec9dd0eSOleksandr Andrushchenko 184ce63b2c8SOleksandr Andrushchenko #define XENKBD_FIELD_FEAT_DSBL_KEYBRD "feature-disable-keyboard" 185ce63b2c8SOleksandr Andrushchenko #define XENKBD_FIELD_FEAT_DSBL_POINTER "feature-disable-pointer" 1868ec9dd0eSOleksandr Andrushchenko #define XENKBD_FIELD_FEAT_ABS_POINTER "feature-abs-pointer" 187ce63b2c8SOleksandr Andrushchenko #define XENKBD_FIELD_FEAT_RAW_POINTER "feature-raw-pointer" 188f9ebfc22SOleksandr Andrushchenko #define XENKBD_FIELD_FEAT_MTOUCH "feature-multi-touch" 1898ec9dd0eSOleksandr Andrushchenko #define XENKBD_FIELD_REQ_ABS_POINTER "request-abs-pointer" 190ce63b2c8SOleksandr Andrushchenko #define XENKBD_FIELD_REQ_RAW_POINTER "request-raw-pointer" 191f9ebfc22SOleksandr Andrushchenko #define XENKBD_FIELD_REQ_MTOUCH "request-multi-touch" 1928ec9dd0eSOleksandr Andrushchenko #define XENKBD_FIELD_RING_GREF "page-gref" 1938ec9dd0eSOleksandr Andrushchenko #define XENKBD_FIELD_EVT_CHANNEL "event-channel" 1948ec9dd0eSOleksandr Andrushchenko #define XENKBD_FIELD_WIDTH "width" 1958ec9dd0eSOleksandr Andrushchenko #define XENKBD_FIELD_HEIGHT "height" 196f9ebfc22SOleksandr Andrushchenko #define XENKBD_FIELD_MT_WIDTH "multi-touch-width" 197f9ebfc22SOleksandr Andrushchenko #define XENKBD_FIELD_MT_HEIGHT "multi-touch-height" 198f9ebfc22SOleksandr Andrushchenko #define XENKBD_FIELD_MT_NUM_CONTACTS "multi-touch-num-contacts" 199ce63b2c8SOleksandr Andrushchenko #define XENKBD_FIELD_UNIQUE_ID "unique-id" 2008ec9dd0eSOleksandr Andrushchenko 2018ec9dd0eSOleksandr Andrushchenko /* OBSOLETE, not recommended for use */ 2028ec9dd0eSOleksandr Andrushchenko #define XENKBD_FIELD_RING_REF "page-ref" 2038ec9dd0eSOleksandr Andrushchenko 2048ec9dd0eSOleksandr Andrushchenko /* 2058ec9dd0eSOleksandr Andrushchenko ***************************************************************************** 2068ec9dd0eSOleksandr Andrushchenko * Description of the protocol between frontend and backend driver. 2078ec9dd0eSOleksandr Andrushchenko ***************************************************************************** 2088ec9dd0eSOleksandr Andrushchenko * 2098ec9dd0eSOleksandr Andrushchenko * The two halves of a Para-virtual driver communicate with 2108ec9dd0eSOleksandr Andrushchenko * each other using a shared page and an event channel. 2118ec9dd0eSOleksandr Andrushchenko * Shared page contains a ring with event structures. 2128ec9dd0eSOleksandr Andrushchenko * 2138ec9dd0eSOleksandr Andrushchenko * All reserved fields in the structures below must be 0. 2148ec9dd0eSOleksandr Andrushchenko * 2158ec9dd0eSOleksandr Andrushchenko ***************************************************************************** 2168ec9dd0eSOleksandr Andrushchenko * Backend to frontend events 2178ec9dd0eSOleksandr Andrushchenko ***************************************************************************** 2188ec9dd0eSOleksandr Andrushchenko * 2198ec9dd0eSOleksandr Andrushchenko * Frontends should ignore unknown in events. 2208ec9dd0eSOleksandr Andrushchenko * All event packets have the same length (40 octets) 2218ec9dd0eSOleksandr Andrushchenko * All event packets have common header: 2228ec9dd0eSOleksandr Andrushchenko * 2238ec9dd0eSOleksandr Andrushchenko * 0 octet 2248ec9dd0eSOleksandr Andrushchenko * +-----------------+ 2258ec9dd0eSOleksandr Andrushchenko * | type | 2268ec9dd0eSOleksandr Andrushchenko * +-----------------+ 2278ec9dd0eSOleksandr Andrushchenko * type - uint8_t, event code, XENKBD_TYPE_??? 2288ec9dd0eSOleksandr Andrushchenko * 2298ec9dd0eSOleksandr Andrushchenko * 2308ec9dd0eSOleksandr Andrushchenko * Pointer relative movement event 2318ec9dd0eSOleksandr Andrushchenko * 0 1 2 3 octet 2328ec9dd0eSOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 2338ec9dd0eSOleksandr Andrushchenko * | _TYPE_MOTION | reserved | 4 2348ec9dd0eSOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 2358ec9dd0eSOleksandr Andrushchenko * | rel_x | 8 2368ec9dd0eSOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 2378ec9dd0eSOleksandr Andrushchenko * | rel_y | 12 2388ec9dd0eSOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 2398ec9dd0eSOleksandr Andrushchenko * | rel_z | 16 2408ec9dd0eSOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 2418ec9dd0eSOleksandr Andrushchenko * | reserved | 20 2428ec9dd0eSOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 2438ec9dd0eSOleksandr Andrushchenko * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| 2448ec9dd0eSOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 2458ec9dd0eSOleksandr Andrushchenko * | reserved | 40 2468ec9dd0eSOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 2478ec9dd0eSOleksandr Andrushchenko * 2488ec9dd0eSOleksandr Andrushchenko * rel_x - int32_t, relative X motion 2498ec9dd0eSOleksandr Andrushchenko * rel_y - int32_t, relative Y motion 2508ec9dd0eSOleksandr Andrushchenko * rel_z - int32_t, relative Z motion (wheel) 2518ec9dd0eSOleksandr Andrushchenko */ 2528ec9dd0eSOleksandr Andrushchenko 2534ee36dc0SMarkus Armbruster struct xenkbd_motion { 2548ec9dd0eSOleksandr Andrushchenko uint8_t type; 2558ec9dd0eSOleksandr Andrushchenko int32_t rel_x; 2568ec9dd0eSOleksandr Andrushchenko int32_t rel_y; 2578ec9dd0eSOleksandr Andrushchenko int32_t rel_z; 2584ee36dc0SMarkus Armbruster }; 2594ee36dc0SMarkus Armbruster 2608ec9dd0eSOleksandr Andrushchenko /* 2618ec9dd0eSOleksandr Andrushchenko * Key event (includes pointer buttons) 2628ec9dd0eSOleksandr Andrushchenko * 0 1 2 3 octet 2638ec9dd0eSOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 2648ec9dd0eSOleksandr Andrushchenko * | _TYPE_KEY | pressed | reserved | 4 2658ec9dd0eSOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 2668ec9dd0eSOleksandr Andrushchenko * | keycode | 8 2678ec9dd0eSOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 2688ec9dd0eSOleksandr Andrushchenko * | reserved | 12 2698ec9dd0eSOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 2708ec9dd0eSOleksandr Andrushchenko * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| 2718ec9dd0eSOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 2728ec9dd0eSOleksandr Andrushchenko * | reserved | 40 2738ec9dd0eSOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 2748ec9dd0eSOleksandr Andrushchenko * 2758ec9dd0eSOleksandr Andrushchenko * pressed - uint8_t, 1 if pressed; 0 otherwise 2768ec9dd0eSOleksandr Andrushchenko * keycode - uint32_t, KEY_* from linux/input.h 2778ec9dd0eSOleksandr Andrushchenko */ 2788ec9dd0eSOleksandr Andrushchenko 2794ee36dc0SMarkus Armbruster struct xenkbd_key { 2808ec9dd0eSOleksandr Andrushchenko uint8_t type; 2818ec9dd0eSOleksandr Andrushchenko uint8_t pressed; 2828ec9dd0eSOleksandr Andrushchenko uint32_t keycode; 2834ee36dc0SMarkus Armbruster }; 2844ee36dc0SMarkus Armbruster 2858ec9dd0eSOleksandr Andrushchenko /* 2868ec9dd0eSOleksandr Andrushchenko * Pointer absolute position event 2878ec9dd0eSOleksandr Andrushchenko * 0 1 2 3 octet 2888ec9dd0eSOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 2898ec9dd0eSOleksandr Andrushchenko * | _TYPE_POS | reserved | 4 2908ec9dd0eSOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 2918ec9dd0eSOleksandr Andrushchenko * | abs_x | 8 2928ec9dd0eSOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 2938ec9dd0eSOleksandr Andrushchenko * | abs_y | 12 2948ec9dd0eSOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 2958ec9dd0eSOleksandr Andrushchenko * | rel_z | 16 2968ec9dd0eSOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 2978ec9dd0eSOleksandr Andrushchenko * | reserved | 20 2988ec9dd0eSOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 2998ec9dd0eSOleksandr Andrushchenko * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| 3008ec9dd0eSOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 3018ec9dd0eSOleksandr Andrushchenko * | reserved | 40 3028ec9dd0eSOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 3038ec9dd0eSOleksandr Andrushchenko * 3048ec9dd0eSOleksandr Andrushchenko * abs_x - int32_t, absolute X position (in FB pixels) 3058ec9dd0eSOleksandr Andrushchenko * abs_y - int32_t, absolute Y position (in FB pixels) 3068ec9dd0eSOleksandr Andrushchenko * rel_z - int32_t, relative Z motion (wheel) 3078ec9dd0eSOleksandr Andrushchenko */ 3088ec9dd0eSOleksandr Andrushchenko 3094ee36dc0SMarkus Armbruster struct xenkbd_position { 3108ec9dd0eSOleksandr Andrushchenko uint8_t type; 3118ec9dd0eSOleksandr Andrushchenko int32_t abs_x; 3128ec9dd0eSOleksandr Andrushchenko int32_t abs_y; 3138ec9dd0eSOleksandr Andrushchenko int32_t rel_z; 3144ee36dc0SMarkus Armbruster }; 3154ee36dc0SMarkus Armbruster 316f9ebfc22SOleksandr Andrushchenko /* 317f9ebfc22SOleksandr Andrushchenko * Multi-touch event and its sub-types 318f9ebfc22SOleksandr Andrushchenko * 319f9ebfc22SOleksandr Andrushchenko * All multi-touch event packets have common header: 320f9ebfc22SOleksandr Andrushchenko * 321f9ebfc22SOleksandr Andrushchenko * 0 1 2 3 octet 322f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 323f9ebfc22SOleksandr Andrushchenko * | _TYPE_MTOUCH | event_type | contact_id | reserved | 4 324f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 325f9ebfc22SOleksandr Andrushchenko * | reserved | 8 326f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 327f9ebfc22SOleksandr Andrushchenko * 328f9ebfc22SOleksandr Andrushchenko * event_type - unt8_t, multi-touch event sub-type, XENKBD_MT_EV_??? 329f9ebfc22SOleksandr Andrushchenko * contact_id - unt8_t, ID of the contact 330f9ebfc22SOleksandr Andrushchenko * 331f9ebfc22SOleksandr Andrushchenko * Touch interactions can consist of one or more contacts. 332f9ebfc22SOleksandr Andrushchenko * For each contact, a series of events is generated, starting 333f9ebfc22SOleksandr Andrushchenko * with a down event, followed by zero or more motion events, 334f9ebfc22SOleksandr Andrushchenko * and ending with an up event. Events relating to the same 335f9ebfc22SOleksandr Andrushchenko * contact point can be identified by the ID of the sequence: contact ID. 336f9ebfc22SOleksandr Andrushchenko * Contact ID may be reused after XENKBD_MT_EV_UP event and 337f9ebfc22SOleksandr Andrushchenko * is in the [0; XENKBD_FIELD_NUM_CONTACTS - 1] range. 338f9ebfc22SOleksandr Andrushchenko * 339f9ebfc22SOleksandr Andrushchenko * For further information please refer to documentation on Wayland [1], 340f9ebfc22SOleksandr Andrushchenko * Linux [2] and Windows [3] multi-touch support. 341f9ebfc22SOleksandr Andrushchenko * 342f9ebfc22SOleksandr Andrushchenko * [1] https://cgit.freedesktop.org/wayland/wayland/tree/protocol/wayland.xml 3435fb94e9cSMauro Carvalho Chehab * [2] https://www.kernel.org/doc/Documentation/input/multi-touch-protocol.rst 344f9ebfc22SOleksandr Andrushchenko * [3] https://msdn.microsoft.com/en-us/library/jj151564(v=vs.85).aspx 345f9ebfc22SOleksandr Andrushchenko * 346f9ebfc22SOleksandr Andrushchenko * 347f9ebfc22SOleksandr Andrushchenko * Multi-touch down event - sent when a new touch is made: touch is assigned 348f9ebfc22SOleksandr Andrushchenko * a unique contact ID, sent with this and consequent events related 349f9ebfc22SOleksandr Andrushchenko * to this touch. 350f9ebfc22SOleksandr Andrushchenko * 0 1 2 3 octet 351f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 352f9ebfc22SOleksandr Andrushchenko * | _TYPE_MTOUCH | _MT_EV_DOWN | contact_id | reserved | 4 353f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 354f9ebfc22SOleksandr Andrushchenko * | reserved | 8 355f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 356f9ebfc22SOleksandr Andrushchenko * | abs_x | 12 357f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 358f9ebfc22SOleksandr Andrushchenko * | abs_y | 16 359f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 360f9ebfc22SOleksandr Andrushchenko * | reserved | 20 361f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 362f9ebfc22SOleksandr Andrushchenko * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| 363f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 364f9ebfc22SOleksandr Andrushchenko * | reserved | 40 365f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 366f9ebfc22SOleksandr Andrushchenko * 367f9ebfc22SOleksandr Andrushchenko * abs_x - int32_t, absolute X position, in pixels 368f9ebfc22SOleksandr Andrushchenko * abs_y - int32_t, absolute Y position, in pixels 369f9ebfc22SOleksandr Andrushchenko * 370f9ebfc22SOleksandr Andrushchenko * Multi-touch contact release event 371f9ebfc22SOleksandr Andrushchenko * 0 1 2 3 octet 372f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 373f9ebfc22SOleksandr Andrushchenko * | _TYPE_MTOUCH | _MT_EV_UP | contact_id | reserved | 4 374f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 375f9ebfc22SOleksandr Andrushchenko * | reserved | 8 376f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 377f9ebfc22SOleksandr Andrushchenko * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| 378f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 379f9ebfc22SOleksandr Andrushchenko * | reserved | 40 380f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 381f9ebfc22SOleksandr Andrushchenko * 382f9ebfc22SOleksandr Andrushchenko * Multi-touch motion event 383f9ebfc22SOleksandr Andrushchenko * 0 1 2 3 octet 384f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 385f9ebfc22SOleksandr Andrushchenko * | _TYPE_MTOUCH | _MT_EV_MOTION | contact_id | reserved | 4 386f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 387f9ebfc22SOleksandr Andrushchenko * | reserved | 8 388f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 389f9ebfc22SOleksandr Andrushchenko * | abs_x | 12 390f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 391f9ebfc22SOleksandr Andrushchenko * | abs_y | 16 392f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 393f9ebfc22SOleksandr Andrushchenko * | reserved | 20 394f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 395f9ebfc22SOleksandr Andrushchenko * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| 396f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 397f9ebfc22SOleksandr Andrushchenko * | reserved | 40 398f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 399f9ebfc22SOleksandr Andrushchenko * 400f9ebfc22SOleksandr Andrushchenko * abs_x - int32_t, absolute X position, in pixels, 401f9ebfc22SOleksandr Andrushchenko * abs_y - int32_t, absolute Y position, in pixels, 402f9ebfc22SOleksandr Andrushchenko * 403f9ebfc22SOleksandr Andrushchenko * Multi-touch input synchronization event - shows end of a set of events 404f9ebfc22SOleksandr Andrushchenko * which logically belong together. 405f9ebfc22SOleksandr Andrushchenko * 0 1 2 3 octet 406f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 407f9ebfc22SOleksandr Andrushchenko * | _TYPE_MTOUCH | _MT_EV_SYN | contact_id | reserved | 4 408f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 409f9ebfc22SOleksandr Andrushchenko * | reserved | 8 410f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 411f9ebfc22SOleksandr Andrushchenko * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| 412f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 413f9ebfc22SOleksandr Andrushchenko * | reserved | 40 414f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 415f9ebfc22SOleksandr Andrushchenko * 416f9ebfc22SOleksandr Andrushchenko * Multi-touch shape event - touch point's shape has changed its shape. 417f9ebfc22SOleksandr Andrushchenko * Shape is approximated by an ellipse through the major and minor axis 418f9ebfc22SOleksandr Andrushchenko * lengths: major is the longer diameter of the ellipse and minor is the 419f9ebfc22SOleksandr Andrushchenko * shorter one. Center of the ellipse is reported via 420f9ebfc22SOleksandr Andrushchenko * XENKBD_MT_EV_DOWN/XENKBD_MT_EV_MOTION events. 421f9ebfc22SOleksandr Andrushchenko * 0 1 2 3 octet 422f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 423f9ebfc22SOleksandr Andrushchenko * | _TYPE_MTOUCH | _MT_EV_SHAPE | contact_id | reserved | 4 424f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 425f9ebfc22SOleksandr Andrushchenko * | reserved | 8 426f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 427f9ebfc22SOleksandr Andrushchenko * | major | 12 428f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 429f9ebfc22SOleksandr Andrushchenko * | minor | 16 430f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 431f9ebfc22SOleksandr Andrushchenko * | reserved | 20 432f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 433f9ebfc22SOleksandr Andrushchenko * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| 434f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 435f9ebfc22SOleksandr Andrushchenko * | reserved | 40 436f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 437f9ebfc22SOleksandr Andrushchenko * 438f9ebfc22SOleksandr Andrushchenko * major - unt32_t, length of the major axis, pixels 439f9ebfc22SOleksandr Andrushchenko * minor - unt32_t, length of the minor axis, pixels 440f9ebfc22SOleksandr Andrushchenko * 441f9ebfc22SOleksandr Andrushchenko * Multi-touch orientation event - touch point's shape has changed 442f9ebfc22SOleksandr Andrushchenko * its orientation: calculated as a clockwise angle between the major axis 443f9ebfc22SOleksandr Andrushchenko * of the ellipse and positive Y axis in degrees, [-180; +180]. 444f9ebfc22SOleksandr Andrushchenko * 0 1 2 3 octet 445f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 446f9ebfc22SOleksandr Andrushchenko * | _TYPE_MTOUCH | _MT_EV_ORIENT | contact_id | reserved | 4 447f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 448f9ebfc22SOleksandr Andrushchenko * | reserved | 8 449f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 450f9ebfc22SOleksandr Andrushchenko * | orientation | reserved | 12 451f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 452f9ebfc22SOleksandr Andrushchenko * | reserved | 16 453f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 454f9ebfc22SOleksandr Andrushchenko * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| 455f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 456f9ebfc22SOleksandr Andrushchenko * | reserved | 40 457f9ebfc22SOleksandr Andrushchenko * +----------------+----------------+----------------+----------------+ 458f9ebfc22SOleksandr Andrushchenko * 459f9ebfc22SOleksandr Andrushchenko * orientation - int16_t, clockwise angle of the major axis 460f9ebfc22SOleksandr Andrushchenko */ 461f9ebfc22SOleksandr Andrushchenko 462f9ebfc22SOleksandr Andrushchenko struct xenkbd_mtouch { 463f9ebfc22SOleksandr Andrushchenko uint8_t type; /* XENKBD_TYPE_MTOUCH */ 464f9ebfc22SOleksandr Andrushchenko uint8_t event_type; /* XENKBD_MT_EV_??? */ 465f9ebfc22SOleksandr Andrushchenko uint8_t contact_id; 466f9ebfc22SOleksandr Andrushchenko uint8_t reserved[5]; /* reserved for the future use */ 467f9ebfc22SOleksandr Andrushchenko union { 468f9ebfc22SOleksandr Andrushchenko struct { 469f9ebfc22SOleksandr Andrushchenko int32_t abs_x; /* absolute X position, pixels */ 470f9ebfc22SOleksandr Andrushchenko int32_t abs_y; /* absolute Y position, pixels */ 471f9ebfc22SOleksandr Andrushchenko } pos; 472f9ebfc22SOleksandr Andrushchenko struct { 473f9ebfc22SOleksandr Andrushchenko uint32_t major; /* length of the major axis, pixels */ 474f9ebfc22SOleksandr Andrushchenko uint32_t minor; /* length of the minor axis, pixels */ 475f9ebfc22SOleksandr Andrushchenko } shape; 476f9ebfc22SOleksandr Andrushchenko int16_t orientation; /* clockwise angle of the major axis */ 477f9ebfc22SOleksandr Andrushchenko } u; 478f9ebfc22SOleksandr Andrushchenko }; 479f9ebfc22SOleksandr Andrushchenko 4804ee36dc0SMarkus Armbruster #define XENKBD_IN_EVENT_SIZE 40 4814ee36dc0SMarkus Armbruster 4824ee36dc0SMarkus Armbruster union xenkbd_in_event { 4834ee36dc0SMarkus Armbruster uint8_t type; 4844ee36dc0SMarkus Armbruster struct xenkbd_motion motion; 4854ee36dc0SMarkus Armbruster struct xenkbd_key key; 4864ee36dc0SMarkus Armbruster struct xenkbd_position pos; 487f9ebfc22SOleksandr Andrushchenko struct xenkbd_mtouch mtouch; 4884ee36dc0SMarkus Armbruster char pad[XENKBD_IN_EVENT_SIZE]; 4894ee36dc0SMarkus Armbruster }; 4904ee36dc0SMarkus Armbruster 4914ee36dc0SMarkus Armbruster /* 4928ec9dd0eSOleksandr Andrushchenko ***************************************************************************** 4938ec9dd0eSOleksandr Andrushchenko * Frontend to backend events 4948ec9dd0eSOleksandr Andrushchenko ***************************************************************************** 4958ec9dd0eSOleksandr Andrushchenko * 4964ee36dc0SMarkus Armbruster * Out events may be sent only when requested by backend, and receipt 4974ee36dc0SMarkus Armbruster * of an unknown out event is an error. 4984ee36dc0SMarkus Armbruster * No out events currently defined. 4998ec9dd0eSOleksandr Andrushchenko 5008ec9dd0eSOleksandr Andrushchenko * All event packets have the same length (40 octets) 5018ec9dd0eSOleksandr Andrushchenko * All event packets have common header: 5028ec9dd0eSOleksandr Andrushchenko * 0 octet 5038ec9dd0eSOleksandr Andrushchenko * +-----------------+ 5048ec9dd0eSOleksandr Andrushchenko * | type | 5058ec9dd0eSOleksandr Andrushchenko * +-----------------+ 5068ec9dd0eSOleksandr Andrushchenko * type - uint8_t, event code 5074ee36dc0SMarkus Armbruster */ 5084ee36dc0SMarkus Armbruster 5094ee36dc0SMarkus Armbruster #define XENKBD_OUT_EVENT_SIZE 40 5104ee36dc0SMarkus Armbruster 5114ee36dc0SMarkus Armbruster union xenkbd_out_event { 5124ee36dc0SMarkus Armbruster uint8_t type; 5134ee36dc0SMarkus Armbruster char pad[XENKBD_OUT_EVENT_SIZE]; 5144ee36dc0SMarkus Armbruster }; 5154ee36dc0SMarkus Armbruster 5168ec9dd0eSOleksandr Andrushchenko /* 5178ec9dd0eSOleksandr Andrushchenko ***************************************************************************** 5188ec9dd0eSOleksandr Andrushchenko * Shared page 5198ec9dd0eSOleksandr Andrushchenko ***************************************************************************** 5208ec9dd0eSOleksandr Andrushchenko */ 5214ee36dc0SMarkus Armbruster 5224ee36dc0SMarkus Armbruster #define XENKBD_IN_RING_SIZE 2048 5234ee36dc0SMarkus Armbruster #define XENKBD_IN_RING_LEN (XENKBD_IN_RING_SIZE / XENKBD_IN_EVENT_SIZE) 5244ee36dc0SMarkus Armbruster #define XENKBD_IN_RING_OFFS 1024 5254ee36dc0SMarkus Armbruster #define XENKBD_IN_RING(page) \ 5264ee36dc0SMarkus Armbruster ((union xenkbd_in_event *)((char *)(page) + XENKBD_IN_RING_OFFS)) 5274ee36dc0SMarkus Armbruster #define XENKBD_IN_RING_REF(page, idx) \ 5284ee36dc0SMarkus Armbruster (XENKBD_IN_RING((page))[(idx) % XENKBD_IN_RING_LEN]) 5294ee36dc0SMarkus Armbruster 5304ee36dc0SMarkus Armbruster #define XENKBD_OUT_RING_SIZE 1024 5314ee36dc0SMarkus Armbruster #define XENKBD_OUT_RING_LEN (XENKBD_OUT_RING_SIZE / XENKBD_OUT_EVENT_SIZE) 5324ee36dc0SMarkus Armbruster #define XENKBD_OUT_RING_OFFS (XENKBD_IN_RING_OFFS + XENKBD_IN_RING_SIZE) 5334ee36dc0SMarkus Armbruster #define XENKBD_OUT_RING(page) \ 5344ee36dc0SMarkus Armbruster ((union xenkbd_out_event *)((char *)(page) + XENKBD_OUT_RING_OFFS)) 5354ee36dc0SMarkus Armbruster #define XENKBD_OUT_RING_REF(page, idx) \ 5364ee36dc0SMarkus Armbruster (XENKBD_OUT_RING((page))[(idx) % XENKBD_OUT_RING_LEN]) 5374ee36dc0SMarkus Armbruster 5384ee36dc0SMarkus Armbruster struct xenkbd_page { 5394ee36dc0SMarkus Armbruster uint32_t in_cons, in_prod; 5404ee36dc0SMarkus Armbruster uint32_t out_cons, out_prod; 5414ee36dc0SMarkus Armbruster }; 5424ee36dc0SMarkus Armbruster 5438ec9dd0eSOleksandr Andrushchenko #endif /* __XEN_PUBLIC_IO_KBDIF_H__ */ 544