1181624Skmacy/* 2181624Skmacy * kbdif.h -- Xen virtual keyboard/mouse 3181624Skmacy * 4181624Skmacy * Permission is hereby granted, free of charge, to any person obtaining a copy 5181624Skmacy * of this software and associated documentation files (the "Software"), to 6181624Skmacy * deal in the Software without restriction, including without limitation the 7181624Skmacy * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8181624Skmacy * sell copies of the Software, and to permit persons to whom the Software is 9181624Skmacy * furnished to do so, subject to the following conditions: 10181624Skmacy * 11181624Skmacy * The above copyright notice and this permission notice shall be included in 12181624Skmacy * all copies or substantial portions of the Software. 13181624Skmacy * 14181624Skmacy * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15181624Skmacy * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16181624Skmacy * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17181624Skmacy * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18181624Skmacy * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19181624Skmacy * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20181624Skmacy * DEALINGS IN THE SOFTWARE. 21181624Skmacy * 22181624Skmacy * Copyright (C) 2005 Anthony Liguori <aliguori@us.ibm.com> 23181624Skmacy * Copyright (C) 2006 Red Hat, Inc., Markus Armbruster <armbru@redhat.com> 24181624Skmacy */ 25181624Skmacy 26181624Skmacy#ifndef __XEN_PUBLIC_IO_KBDIF_H__ 27181624Skmacy#define __XEN_PUBLIC_IO_KBDIF_H__ 28181624Skmacy 29181624Skmacy/* In events (backend -> frontend) */ 30181624Skmacy 31181624Skmacy/* 32181624Skmacy * Frontends should ignore unknown in events. 33181624Skmacy */ 34181624Skmacy 35181624Skmacy/* Pointer movement event */ 36181624Skmacy#define XENKBD_TYPE_MOTION 1 37181624Skmacy/* Event type 2 currently not used */ 38181624Skmacy/* Key event (includes pointer buttons) */ 39181624Skmacy#define XENKBD_TYPE_KEY 3 40181624Skmacy/* 41181624Skmacy * Pointer position event 42181624Skmacy * Capable backend sets feature-abs-pointer in xenstore. 43181624Skmacy * Frontend requests ot instead of XENKBD_TYPE_MOTION by setting 44181624Skmacy * request-abs-update in xenstore. 45181624Skmacy */ 46181624Skmacy#define XENKBD_TYPE_POS 4 47181624Skmacy 48181624Skmacystruct xenkbd_motion 49181624Skmacy{ 50181624Skmacy uint8_t type; /* XENKBD_TYPE_MOTION */ 51181624Skmacy int32_t rel_x; /* relative X motion */ 52181624Skmacy int32_t rel_y; /* relative Y motion */ 53183375Skmacy int32_t rel_z; /* relative Z motion (wheel) */ 54181624Skmacy}; 55181624Skmacy 56181624Skmacystruct xenkbd_key 57181624Skmacy{ 58181624Skmacy uint8_t type; /* XENKBD_TYPE_KEY */ 59181624Skmacy uint8_t pressed; /* 1 if pressed; 0 otherwise */ 60181624Skmacy uint32_t keycode; /* KEY_* from linux/input.h */ 61181624Skmacy}; 62181624Skmacy 63181624Skmacystruct xenkbd_position 64181624Skmacy{ 65181624Skmacy uint8_t type; /* XENKBD_TYPE_POS */ 66181624Skmacy int32_t abs_x; /* absolute X position (in FB pixels) */ 67181624Skmacy int32_t abs_y; /* absolute Y position (in FB pixels) */ 68183375Skmacy int32_t rel_z; /* relative Z motion (wheel) */ 69181624Skmacy}; 70181624Skmacy 71181624Skmacy#define XENKBD_IN_EVENT_SIZE 40 72181624Skmacy 73181624Skmacyunion xenkbd_in_event 74181624Skmacy{ 75181624Skmacy uint8_t type; 76181624Skmacy struct xenkbd_motion motion; 77181624Skmacy struct xenkbd_key key; 78181624Skmacy struct xenkbd_position pos; 79181624Skmacy char pad[XENKBD_IN_EVENT_SIZE]; 80181624Skmacy}; 81181624Skmacy 82181624Skmacy/* Out events (frontend -> backend) */ 83181624Skmacy 84181624Skmacy/* 85181624Skmacy * Out events may be sent only when requested by backend, and receipt 86181624Skmacy * of an unknown out event is an error. 87181624Skmacy * No out events currently defined. 88181624Skmacy */ 89181624Skmacy 90181624Skmacy#define XENKBD_OUT_EVENT_SIZE 40 91181624Skmacy 92181624Skmacyunion xenkbd_out_event 93181624Skmacy{ 94181624Skmacy uint8_t type; 95181624Skmacy char pad[XENKBD_OUT_EVENT_SIZE]; 96181624Skmacy}; 97181624Skmacy 98181624Skmacy/* shared page */ 99181624Skmacy 100181624Skmacy#define XENKBD_IN_RING_SIZE 2048 101181624Skmacy#define XENKBD_IN_RING_LEN (XENKBD_IN_RING_SIZE / XENKBD_IN_EVENT_SIZE) 102181624Skmacy#define XENKBD_IN_RING_OFFS 1024 103181624Skmacy#define XENKBD_IN_RING(page) \ 104181624Skmacy ((union xenkbd_in_event *)((char *)(page) + XENKBD_IN_RING_OFFS)) 105181624Skmacy#define XENKBD_IN_RING_REF(page, idx) \ 106181624Skmacy (XENKBD_IN_RING((page))[(idx) % XENKBD_IN_RING_LEN]) 107181624Skmacy 108181624Skmacy#define XENKBD_OUT_RING_SIZE 1024 109181624Skmacy#define XENKBD_OUT_RING_LEN (XENKBD_OUT_RING_SIZE / XENKBD_OUT_EVENT_SIZE) 110181624Skmacy#define XENKBD_OUT_RING_OFFS (XENKBD_IN_RING_OFFS + XENKBD_IN_RING_SIZE) 111181624Skmacy#define XENKBD_OUT_RING(page) \ 112181624Skmacy ((union xenkbd_out_event *)((char *)(page) + XENKBD_OUT_RING_OFFS)) 113181624Skmacy#define XENKBD_OUT_RING_REF(page, idx) \ 114181624Skmacy (XENKBD_OUT_RING((page))[(idx) % XENKBD_OUT_RING_LEN]) 115181624Skmacy 116181624Skmacystruct xenkbd_page 117181624Skmacy{ 118181624Skmacy uint32_t in_cons, in_prod; 119181624Skmacy uint32_t out_cons, out_prod; 120181624Skmacy}; 121181624Skmacy 122181624Skmacy#endif 123181624Skmacy 124181624Skmacy/* 125181624Skmacy * Local variables: 126181624Skmacy * mode: C 127288917Sroyger * c-file-style: "BSD" 128181624Skmacy * c-basic-offset: 4 129181624Skmacy * tab-width: 4 130181624Skmacy * indent-tabs-mode: nil 131181624Skmacy * End: 132181624Skmacy */ 133