| Commit | Line | Data |
|---|---|---|
| 984263bc MD |
1 | .\" |
| 2 | .\" Copyright (c) 1997 | |
| 3 | .\" Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp> | |
| 4 | .\" All rights reserved. | |
| 5 | .\" | |
| 6 | .\" Redistribution and use in source and binary forms, with or without | |
| 7 | .\" modification, are permitted provided that the following conditions | |
| 8 | .\" are met: | |
| 9 | .\" 1. Redistributions of source code must retain the above copyright | |
| 10 | .\" notice, this list of conditions and the following disclaimer as | |
| 11 | .\" the first lines of this file unmodified. | |
| 12 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
| 13 | .\" notice, this list of conditions and the following disclaimer in the | |
| 14 | .\" documentation and/or other materials provided with the distribution. | |
| 15 | .\" | |
| 16 | .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
| 17 | .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
| 18 | .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
| 19 | .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
| 20 | .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
| 21 | .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 22 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 23 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 24 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
| 25 | .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 26 | .\" | |
| 27 | .\" $FreeBSD: src/share/man/man4/mouse.4,v 1.8.2.3 2001/12/17 11:30:12 ru Exp $ | |
| 28 | .\" | |
| 29 | .Dd December 3, 1997 | |
| 30 | .Dt MOUSE 4 | |
| 31 | .Os | |
| 32 | .Sh NAME | |
| 33 | .Nm mouse | |
| 34 | .Nd mouse and pointing device drivers | |
| 35 | .Sh SYNOPSIS | |
| 62770245 | 36 | .In sys/mouse.h |
| 984263bc MD |
37 | .Sh DESCRIPTION |
| 38 | The mouse drivers | |
| 984263bc MD |
39 | .Xr psm 4 , |
| 40 | .Xr ums 4 | |
| 41 | and | |
| 42 | .Xr sysmouse 4 | |
| 43 | provide user programs with movement and button state information of the mouse. | |
| 44 | Currently there are specific device drivers for bus, InPort, PS/2, and USB mice. | |
| 45 | The serial mouse is not directly supported by a dedicated driver, but | |
| 46 | it is accessible via the serial device driver or via | |
| 47 | .Xr moused 8 | |
| 48 | and | |
| 49 | .Xr sysmouse 4 . | |
| 50 | .Pp | |
| 51 | The user program simply opens a mouse device with a | |
| 52 | .Xr open 2 | |
| 53 | call and reads | |
| 54 | mouse data from the device via | |
| 55 | .Xr read 2 . | |
| 56 | Movement and button states are usually encoded in fixed-length data packets. | |
| 57 | Some mouse devices may send data in variable length of packets. | |
| 58 | Actual protocol (data format) used by each driver differs widely. | |
| 59 | .Pp | |
| 60 | The mouse drivers may have ``non-blocking'' attribute which will make | |
| 61 | the driver return immediately if mouse data is not available. | |
| 62 | .Pp | |
| 63 | Mouse device drivers often offer several levels of operation. | |
| 64 | The current operation level can be examined and changed via | |
| 65 | .Xr ioctl 2 | |
| 66 | commands. | |
| 67 | The level zero is the lowest level at which the driver offers the basic | |
| 68 | service to user programs. | |
| 69 | Most drivers provide horizontal and vertical movement of the mouse | |
| 70 | and state of up to three buttons at this level. | |
| 71 | At the level one, if supported by the driver, mouse data is encoded | |
| 72 | in the standard format | |
| 73 | .Dv MOUSE_PROTO_SYSMOUSE | |
| 74 | as follows: | |
| 75 | .Pp | |
| 76 | .Bl -tag -width Byte_1 -compact | |
| 77 | .It Byte 1 | |
| 78 | .Bl -tag -width bit_7 -compact | |
| 79 | .It bit 7 | |
| 80 | Always one. | |
| 81 | .It bit 6..3 | |
| 82 | Always zero. | |
| 83 | .It bit 2 | |
| 84 | Left button status; cleared if pressed, otherwise set. | |
| 85 | .It bit 1 | |
| 86 | Middle button status; cleared if pressed, otherwise set. | |
| 87 | Always one, | |
| 88 | if the device does not have the middle button. | |
| 89 | .It bit 0 | |
| 90 | Right button status; cleared if pressed, otherwise set. | |
| 91 | .El | |
| 92 | .It Byte 2 | |
| 93 | The first half of horizontal movement count in two's complement; | |
| 94 | -128 through 127. | |
| 95 | .It Byte 3 | |
| 96 | The first half of vertical movement count in two's complement; | |
| 97 | -128 through 127. | |
| 98 | .It Byte 4 | |
| 99 | The second half of the horizontal movement count in two's complement; | |
| 100 | -128 through 127. To obtain the full horizontal movement count, add | |
| 101 | the byte 2 and 4. | |
| 102 | .It Byte 5 | |
| 103 | The second half of the vertical movement count in two's complement; | |
| 104 | -128 through 127. To obtain the full vertical movement count, add | |
| 105 | the byte 3 and 5. | |
| 106 | .It Byte 6 | |
| 107 | The bit 7 is always zero. | |
| 108 | The lower 7 bits encode the first half of | |
| 109 | Z axis movement count in two's complement; -64 through 63. | |
| 110 | .It Byte 7 | |
| 111 | The bit 7 is always zero. | |
| 112 | The lower 7 bits encode the second half of | |
| 113 | the Z axis movement count in two's complement; -64 through 63. | |
| 114 | To obtain the full Z axis movement count, add the byte 6 and 7. | |
| 115 | .It Byte 8 | |
| 116 | The bit 7 is always zero. | |
| 117 | The bits 0 through 6 reflect the state | |
| 118 | of the buttons 4 through 10. | |
| 119 | If a button is pressed, the corresponding bit is cleared. | |
| 120 | Otherwise | |
| 121 | the bit is set. | |
| 122 | .El | |
| 123 | .Pp | |
| 124 | The first 5 bytes of this format is compatible with the MouseSystems | |
| 125 | format. | |
| 126 | The additional 3 bytes have their MSBs always set to zero. | |
| 127 | Thus, if the user program can interpret the MouseSystems data format and | |
| 128 | tries to find the first byte of the format by detecting the bit pattern | |
| 129 | 10000xxxb, | |
| 130 | it will discard the additional bytes, thus, be able to decode x, y | |
| 131 | and states of 3 buttons correctly. | |
| 132 | .Pp | |
| 133 | Device drivers may offer operation levels higher than one. | |
| 134 | Refer to manual pages of individual drivers for details. | |
| 135 | .Sh IOCTLS | |
| 136 | The following | |
| 137 | .Xr ioctl 2 | |
| 138 | commands are defined for the mouse drivers. | |
| 139 | The degree of support | |
| 140 | varies from one driver to another. | |
| 141 | This section gives general | |
| 142 | description of the commands. | |
| 143 | Refer to manual pages of individual drivers for specific details. | |
| 144 | .Pp | |
| 145 | .Bl -tag -width MOUSE -compact | |
| 146 | .It Dv MOUSE_GETLEVEL Ar int *level | |
| 147 | .It Dv MOUSE_SETLEVEL Ar int *level | |
| 148 | These commands manipulate the operation level of the mouse driver. | |
| 149 | .Pp | |
| 150 | .It Dv MOUSE_GETHWINFO Ar mousehw_t *hw | |
| 151 | Returns the hardware information of the attached device in the following | |
| 152 | Except for the | |
| 153 | .Dv iftype | |
| 154 | field, the device driver may not always fill the structure with correct | |
| 155 | values. | |
| 156 | Consult manual pages of individual drivers for details of support. | |
| 157 | .Bd -literal | |
| 158 | typedef struct mousehw { | |
| 159 | int buttons; /* number of buttons */ | |
| 160 | int iftype; /* I/F type */ | |
| 161 | int type; /* mouse/track ball/pad... */ | |
| 162 | int model; /* I/F dependent model ID */ | |
| 163 | int hwid; /* I/F dependent hardware ID */ | |
| 164 | } mousehw_t; | |
| 165 | .Ed | |
| 166 | .Pp | |
| 167 | The | |
| 168 | .Dv buttons | |
| 169 | field holds the number of buttons detected by the driver. | |
| 170 | The driver | |
| 171 | may put an arbitrary value, such as two, in this field, if it cannot | |
| 172 | determine the exact number. | |
| 173 | .Pp | |
| 174 | The | |
| 175 | .Dv iftype | |
| 176 | is the type of interface: | |
| 177 | .Dv MOUSE_IF_SERIAL , | |
| 178 | .Dv MOUSE_IF_BUS , | |
| 179 | .Dv MOUSE_IF_INPORT , | |
| 180 | .Dv MOUSE_IF_PS2 , | |
| 181 | .Dv MOUSE_IF_USB , | |
| 182 | .Dv MOUSE_IF_SYSMOUSE | |
| 183 | or | |
| 184 | .Dv MOUSE_IF_UNKNOWN . | |
| 185 | .Pp | |
| 186 | The | |
| 187 | .Dv type | |
| 188 | tells the device type: | |
| 189 | .Dv MOUSE_MOUSE , | |
| 190 | .Dv MOUSE_TRACKBALL , | |
| 191 | .Dv MOUSE_STICK , | |
| 192 | .Dv MOUSE_PAD , | |
| 193 | or | |
| 194 | .Dv MOUSE_UNKNOWN . | |
| 195 | .Pp | |
| 196 | The | |
| 197 | .Dv model | |
| 198 | may be | |
| 199 | .Dv MOUSE_MODEL_GENERIC | |
| 200 | or one of | |
| 201 | .Dv MOUSE_MODEL_XXX | |
| 202 | constants. | |
| 203 | .Pp | |
| 204 | The | |
| 205 | .Dv hwid | |
| 206 | is the ID value returned by the pointing device. | |
| 207 | It | |
| 208 | depend on the interface type; refer to the manual page of | |
| 209 | specific mouse drivers for possible values. | |
| 210 | .Pp | |
| 211 | .It Dv MOUSE_GETMODE Ar mousemode_t *mode | |
| 212 | The command reports the current operation parameters of the mouse driver. | |
| 213 | .Bd -literal | |
| 214 | typedef struct mousemode { | |
| 215 | int protocol; /* MOUSE_PROTO_XXX */ | |
| 216 | int rate; /* report rate (per sec) */ | |
| 217 | int resolution; /* MOUSE_RES_XXX, -1 if unknown */ | |
| 218 | int accelfactor; /* acceleration factor */ | |
| 219 | int level; /* driver operation level */ | |
| 220 | int packetsize; /* the length of the data packet */ | |
| 221 | unsigned char syncmask[2]; /* sync. bits */ | |
| 222 | } mousemode_t; | |
| 223 | .Ed | |
| 224 | .Pp | |
| 225 | The | |
| 226 | .Dv protocol | |
| 227 | field tells the format in which the device status is returned | |
| 228 | when the mouse data is read by the user program. | |
| 229 | It is one of | |
| 230 | .Dv MOUSE_PROTO_XXX | |
| 231 | constants. | |
| 232 | .Pp | |
| 233 | The | |
| 234 | .Dv rate | |
| 235 | field is the status report rate (reports/sec) at which the device will send | |
| 236 | movement reports to the host computer. -1 if unknown or not applicable. | |
| 237 | .Pp | |
| 238 | The | |
| 239 | .Dv resolution | |
| 240 | field holds a value specifying resolution of the pointing device. | |
| 241 | It is a positive value or one of | |
| 242 | .Dv MOUSE_RES_XXX | |
| 243 | constants. | |
| 244 | .Pp | |
| 245 | The | |
| 246 | .Dv accelfactor | |
| 247 | field holds a value to control acceleration feature. | |
| 248 | It must be zero or greater. | |
| 249 | If it is zero, acceleration is disabled. | |
| 250 | .Pp | |
| 251 | The | |
| 252 | .Dv packetsize | |
| 253 | field tells the length of the fixed-size data packet or the length | |
| 254 | of the fixed part of the variable-length packet. | |
| 255 | The size depends on the interface type, the device type and model, the | |
| 256 | protocol and the operation level of the driver. | |
| 257 | .Pp | |
| 258 | The array | |
| 259 | .Dv syncmask | |
| 260 | holds a bit mask and pattern to detect the first byte of the | |
| 261 | data packet. | |
| 262 | .Dv syncmask[0] | |
| 263 | is the bit mask to be ANDed with a byte. | |
| 264 | If the result is equal to | |
| 265 | .Dv syncmask[1] , | |
| 266 | the byte is likely to be the first byte of the data packet. | |
| 267 | Note that this method of detecting the first byte is not 100% reliable, | |
| 268 | thus, should be taken only as an advisory measure. | |
| 269 | .Pp | |
| 270 | .It Dv MOUSE_SETMODE Ar mousemode_t *mode | |
| 271 | The command changes the current operation parameters of the mouse driver | |
| 272 | as specified in | |
| 273 | .Ar mode . | |
| 274 | Only | |
| 275 | .Dv rate , | |
| 276 | .Dv resolution , | |
| 277 | .Dv level | |
| 278 | and | |
| 279 | .Dv accelfactor | |
| 280 | may be modifiable. | |
| 281 | Setting values in the other field does not generate | |
| 282 | error and has no effect. | |
| 283 | .Pp | |
| 284 | If you do not want to change the current setting of a field, put -1 | |
| 285 | there. | |
| 286 | You may also put zero in | |
| 287 | .Dv resolution | |
| 288 | and | |
| 289 | .Dv rate , | |
| 290 | and the default value for the fields will be selected. | |
| 291 | .\" .Pp | |
| 292 | .\" .It Dv MOUSE_GETVARS Ar mousevar_t *vars | |
| 293 | .\" Get internal variables of the mouse driver. | |
| 294 | .\" The variables which can be manipulated through these commands | |
| 295 | .\" are specific to each driver. | |
| 296 | .\" This command may not be supported by all drivers. | |
| 297 | .\" .Bd -literal | |
| 298 | .\" typedef struct mousevar { | |
| 299 | .\" int var[16]; /* internal variables */ | |
| 300 | .\" } mousevar_t; | |
| 301 | .\" .Ed | |
| 302 | .\" .Pp | |
| 303 | .\" If the commands are supported, the first element of the array is | |
| 304 | .\" filled with a signature value. | |
| 305 | .\" Apart from the signature data, there is currently no standard concerning | |
| 306 | .\" the other elements of the buffer. | |
| 307 | .\" .Pp | |
| 308 | .\" .It Dv MOUSE_SETVARS Ar mousevar_t *vars | |
| 309 | .\" Get internal variables of the mouse driver. | |
| 310 | .\" The first element of the array must be a signature value. | |
| 311 | .\" This command may not be supported by all drivers. | |
| 312 | .Pp | |
| 313 | .It Dv MOUSE_READDATA Ar mousedata_t *data | |
| 314 | The command reads the raw data from the device. | |
| 315 | .Bd -literal | |
| 316 | typedef struct mousedata { | |
| 317 | int len; /* # of data in the buffer */ | |
| 318 | int buf[16]; /* data buffer */ | |
| 319 | } mousedata_t; | |
| 320 | .Ed | |
| 321 | .Pp | |
| 322 | The calling process must fill the | |
| 323 | .Dv len | |
| 324 | field with the number of bytes to be read into the buffer. | |
| 325 | This command may not be supported by all drivers. | |
| 326 | .Pp | |
| 327 | .It Dv MOUSE_READSTATE Ar mousedata_t *state | |
| 328 | The command reads the raw state data from the device. | |
| 329 | It uses the same structure as above. | |
| 330 | This command may not be supported by all drivers. | |
| 331 | .Pp | |
| 332 | .It Dv MOUSE_GETSTATUS Ar mousestatus_t *status | |
| 333 | The command returns the current state of buttons and | |
| 334 | movement counts in the following structure. | |
| 335 | .Bd -literal | |
| 336 | typedef struct mousestatus { | |
| 337 | int flags; /* state change flags */ | |
| 338 | int button; /* button status */ | |
| 339 | int obutton; /* previous button status */ | |
| 340 | int dx; /* x movement */ | |
| 341 | int dy; /* y movement */ | |
| 342 | int dz; /* z movement */ | |
| 343 | } mousestatus_t; | |
| 344 | .Ed | |
| 345 | .Pp | |
| 346 | The | |
| 347 | .Dv button | |
| 348 | and | |
| 349 | .Dv obutton | |
| 350 | fields hold the current and the previous state of the mouse buttons. | |
| 351 | When a button is pressed, the corresponding bit is set. | |
| 352 | The mouse drivers may support up to 31 buttons with the bit 0 through 31. | |
| 353 | Few button bits are defined as | |
| 354 | .Dv MOUSE_BUTTON1DOWN | |
| 355 | through | |
| 356 | .Dv MOUSE_BUTTON8DOWN . | |
| 357 | The first three buttons correspond to left, middle and right buttons. | |
| 358 | .Pp | |
| 359 | If the state of the button has changed since the last | |
| 360 | .Dv MOUSE_GETSTATUS | |
| 361 | call, the corresponding bit in the | |
| 362 | .Dv flags | |
| 363 | field will be set. | |
| 364 | If the mouse has moved since the last call, the | |
| 365 | .Dv MOUSE_POSCHANGED | |
| 366 | bit in the | |
| 367 | .Dv flags | |
| 368 | field will also be set. | |
| 369 | .Pp | |
| 370 | The other fields hold movement counts since the last | |
| 371 | .Dv MOUSE_GETSTATUS | |
| 372 | call. | |
| 373 | The internal counters will be reset after every call to this | |
| 374 | command. | |
| 375 | .El | |
| 376 | .Sh FILES | |
| 377 | .Bl -tag -width /dev/sysmouseXX -compact | |
| 378 | .It Pa /dev/cuaa%d | |
| 379 | serial ports | |
| 984263bc MD |
380 | .It Pa /dev/psm%d |
| 381 | PS/2 mouse device | |
| 382 | .It Pa /dev/sysmouse | |
| 383 | virtual mouse device | |
| 384 | .It Pa /dev/ums%d | |
| 385 | USB mouse device | |
| 386 | .El | |
| 387 | .Sh SEE ALSO | |
| 388 | .Xr ioctl 2 , | |
| 984263bc MD |
389 | .Xr psm 4 , |
| 390 | .Xr sysmouse 4 , | |
| 391 | .Xr ums 4 , | |
| 392 | .Xr moused 8 | |
| 393 | .\".Sh HISTORY | |
| 394 | .Sh AUTHORS | |
| 395 | This manual page was written by | |
| 396 | .An Kazutaka Yokota Aq yokota@FreeBSD.org . |