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