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