1 /* $OpenBSD: mouse_protocols.h,v 1.1 2001/04/14 04:47:41 aaron Exp $ */ 2 3 /* 4 * Copyright (c) 2001 Jean-Baptiste Marchand, Julien Montagne and Jerome Verdon 5 * 6 * Copyright (c) 1998 by Kazutaka Yokota 7 * 8 * Copyright (c) 1995 Michael Smith 9 * 10 * Copyright (c) 1993 by David Dawes <dawes@xfree86.org> 11 * 12 * Copyright (c) 1990,91 by Thomas Roell, Dinkelscherben, Germany. 13 * 14 * All rights reserved. 15 * 16 * Most of this code was taken from the FreeBSD moused daemon, written by 17 * Michael Smith. The FreeBSD moused daemon already contained code from the 18 * Xfree Project, written by David Dawes and Thomas Roell and Kazutaka Yokota. 19 * 20 * Adaptation to OpenBSD was done by Jean-Baptiste Marchand, Julien Montagne 21 * and Jerome Verdon. 22 * 23 * Redistribution and use in source and binary forms, with or without 24 * modification, are permitted provided that the following conditions 25 * are met: 26 * 1. Redistributions of source code must retain the above copyright 27 * notice, this list of conditions and the following disclaimer. 28 * 2. Redistributions in binary form must reproduce the above copyright 29 * notice, this list of conditions and the following disclaimer in the 30 * documentation and/or other materials provided with the distribution. 31 * 3. All advertising materials mentioning features or use of this software 32 * must display the following acknowledgement: 33 * This product includes software developed by 34 * David Dawes, Jean-Baptiste Marchand, Julien Montagne, Thomas Roell, 35 * Michael Smith, Jerome Verdon and Kazutaka Yokota. 36 * 4. The name authors may not be used to endorse or promote products 37 * derived from this software without specific prior written permission. 38 * 39 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR 40 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 41 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 42 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, 43 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 44 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 45 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 46 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 47 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 48 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 49 * 50 * 51 */ 52 53 54 /* Mouse protocols */ 55 56 #define P_UNKNOWN (-1) 57 #define P_MS 0 /* Microsoft Serial, 3 bytes */ 58 #define P_MSC 1 /* Mouse Systems, 5 bytes */ 59 #define P_LOGI 2 /* Logitech, 3 bytes */ 60 #define P_MM 3 /* MM series, 3 bytes */ 61 #define P_LOGIMAN 4 /* Logitech MouseMan 3/4 bytes */ 62 #define P_MMHIT 5 /* Hitachi Tablet 3 bytes */ 63 #define P_GLIDEPOINT 6 /* ALPS GlidePoint, 3/4 bytes */ 64 #define P_IMSERIAL 7 /* MS IntelliMouse, 4 bytes */ 65 #define P_THINKING 8 /* Kensignton Thinking Mouse, 3/4 bytes */ 66 67 /* flags */ 68 69 #define MOUSE_BUTTON1DOWN 0x0001 /* left */ 70 #define MOUSE_BUTTON2DOWN 0x0002 /* middle */ 71 #define MOUSE_BUTTON3DOWN 0x0004 /* right */ 72 #define MOUSE_BUTTON4DOWN 0x0008 73 #define MOUSE_BUTTON5DOWN 0x0010 74 #define MOUSE_BUTTON6DOWN 0x0020 75 #define MOUSE_BUTTON7DOWN 0x0040 76 #define MOUSE_BUTTON8DOWN 0x0080 77 78 #define MOUSE_BUTTONS 0x00FF 79 #define MOUSE_POSCHANGED 0x0100 80 81 /* 82 * List of all the protocols parameters 83 * The parameters are : 84 * - size of the packet 85 * - synchronization mask 86 * - synchronization value (must be equal to data ANDed with SYNCMASK) 87 * - mask of buttons 88 * - mask of each button separetely 89 */ 90 91 /* Microsoft Serial mouse data packet */ 92 #define MOUSE_MSS_PACKETSIZE 3 93 #define MOUSE_MSS_SYNCMASK 0x40 94 #define MOUSE_MSS_SYNC 0x40 95 #define MOUSE_MSS_BUTTONS 0x30 96 #define MOUSE_MSS_BUTTON1DOWN 0x20 /* left */ 97 #define MOUSE_MSS_BUTTON2DOWN 0x00 /* no middle button */ 98 #define MOUSE_MSS_BUTTON3DOWN 0x10 /* right */ 99 100 /* Logitech MouseMan data packet (M+ protocol) */ 101 #define MOUSE_LMAN_BUTTON2DOWN 0x20 /* middle button, the 4th byte */ 102 103 /* ALPS GlidePoint extention (variant of M+ protocol) */ 104 #define MOUSE_ALPS_BUTTON2DOWN 0x20 /* middle button, the 4th byte */ 105 #define MOUSE_ALPS_TAP 0x10 /* `tapping' action, the 4th byte */ 106 107 /* Kinsington Thinking Mouse extention (variant of M+ protocol) */ 108 #define MOUSE_THINK_BUTTON2DOWN 0x20 /* lower-left button, the 4th byte */ 109 #define MOUSE_THINK_BUTTON4DOWN 0x10 /* lower-right button, the 4th byte */ 110 111 /* MS IntelliMouse (variant of MS Serial) */ 112 #define MOUSE_INTELLI_PACKETSIZE 4 113 #define MOUSE_INTELLI_BUTTON2DOWN 0x10 /* middle button the 4th byte */ 114 115 /* Mouse Systems Corp. mouse data packet */ 116 #define MOUSE_MSC_PACKETSIZE 5 117 #define MOUSE_MSC_SYNCMASK 0xf8 118 #define MOUSE_MSC_SYNC 0x80 119 #define MOUSE_MSC_BUTTONS 0x07 120 #define MOUSE_MSC_BUTTON1UP 0x04 /* left */ 121 #define MOUSE_MSC_BUTTON2UP 0x02 /* middle */ 122 #define MOUSE_MSC_BUTTON3UP 0x01 /* right */ 123 #define MOUSE_MSC_MAXBUTTON 3 124 125 /* MM series mouse data packet */ 126 #define MOUSE_MM_PACKETSIZE 3 127 #define MOUSE_MM_SYNCMASK 0xe0 128 #define MOUSE_MM_SYNC 0x80 129 #define MOUSE_MM_BUTTONS 0x07 130 #define MOUSE_MM_BUTTON1DOWN 0x04 /* left */ 131 #define MOUSE_MM_BUTTON2DOWN 0x02 /* middle */ 132 #define MOUSE_MM_BUTTON3DOWN 0x01 /* right */ 133 #define MOUSE_MM_XPOSITIVE 0x10 134 #define MOUSE_MM_YPOSITIVE 0x08 135 136 /* Interlink VersaPad (serial I/F) data packet */ 137 #define MOUSE_VERSA_PACKETSIZE 6 138 #define MOUSE_VERSA_IN_USE 0x04 139 #define MOUSE_VERSA_SYNCMASK 0xc3 140 #define MOUSE_VERSA_SYNC 0xc0 141 #define MOUSE_VERSA_BUTTONS 0x30 142 #define MOUSE_VERSA_BUTTON1DOWN 0x20 /* left */ 143 #define MOUSE_VERSA_BUTTON2DOWN 0x00 /* middle */ 144 #define MOUSE_VERSA_BUTTON3DOWN 0x10 /* right */ 145 #define MOUSE_VERSA_TAP 0x08 146 147 /* Mouse resolutions */ 148 149 #define MOUSE_RES_DEFAULT 254 150 #define MOUSE_RES_UNKNOWN 255 151 #define MOUSE_RES_LOW 0 152 #define MOUSE_RES_MEDIUMLOW 1 153 #define MOUSE_RES_MEDIUMHIGH 2 154 #define MOUSE_RES_HIGH 3 155 156 /* Mouse report rates */ 157 158 #define MOUSE_RATE_UNKNOWN 255 159 #define MOUSE_RATE_DEFAULT 80 160 #define MOUSE_RATE_VERY_LOW 20 161 #define MOUSE_RATE_LOW 40 162 #define MOUSE_RATE_MEDIUM_LOW 60 163 #define MOUSE_RATE_MEDIUM_HIGH 80 164 #define MOUSE_RATE_HIGH 100 165 #define MOUSE_RATE_VERY_HIGH 200 166 167 /* serial PnP ID string */ 168 typedef struct { 169 int revision; /* PnP revision, 100 for 1.00 */ 170 char *eisaid; /* EISA ID including mfr ID and product ID */ 171 char *serial; /* serial No, optional */ 172 char *class; /* device class, optional */ 173 char *compat; /* list of compatible drivers, optional */ 174 char *description; /* product description, optional */ 175 int neisaid; /* length of the above fields... */ 176 int nserial; 177 int nclass; 178 int ncompat; 179 int ndescription; 180 } pnpid_t; 181 182 /* symbol table entry */ 183 typedef struct { 184 char *name; 185 int val; 186 } symtab_t; 187 188 /* current status of the mouse */ 189 typedef struct mousestatus { 190 int flags; /* state change flags */ 191 int button; /* button status */ 192 int obutton; /* previous button status */ 193 int dx; /* x movement */ 194 int dy; /* y movement */ 195 int dz; /* z movement */ 196 } mousestatus_t; 197 198 /* Prototypes */ 199 200 void mouse_init(void); 201 int mouse_identify(void); 202 int mouse_protocol(unsigned char, mousestatus_t *); 203 204