2 .\" John-Mark Gurney. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 3. Neither the name of the author nor the names of any co-contributors
13 .\" may be used to endorse or promote products derived from this software
14 .\" without specific prior written permission.
16 .\" THIS SOFTWARE IS PROVIDED BY John-Mark Gurney AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 .\" .Nd supplies mouse data from syscons for other applications
36 .Nd virtualized mouse driver
38 .Fd #include <machine/mouse.h>
39 .Fd #include <machine/console.h>
41 The console driver, in conjunction with the mouse daemon
43 supplies mouse data to the user process in the standardized way via the
46 This arrangement makes it possible for the console and the user process
47 .Pq such as the Tn X\ Window System
50 The user process which wants to utilize mouse operation simply opens
55 mouse data from the device via
59 is running, otherwise the user process won't see any data coming from
65 driver has two levels of operation.
66 The current operation level can be referred to and changed via ioctl calls.
68 The level zero, the basic level, is the lowest level at which the driver
69 offers the basic service to user programs.
73 provides horizontal and vertical movement of the mouse
74 and state of up to three buttons in the
78 .Bl -tag -width Byte_1 -compact
80 .Bl -tag -width bit_7 -compact
86 Left button status; cleared if pressed, otherwise set.
88 Middle button status; cleared if pressed, otherwise set. Always one,
89 if the device does not have the middle button.
91 Right button status; cleared if pressed, otherwise set.
94 The first half of horizontal movement count in two's complement;
97 The first half of vertical movement count in two's complement;
100 The second half of the horizontal movement count in two's complement;
101 -128 through 127. To obtain the full horizontal movement count, add
104 The second half of the vertical movement count in two's complement;
105 -128 through 127. To obtain the full vertical movement count, add
109 At the level one, the extended level, mouse data is encoded
110 in the standard format
111 .Dv MOUSE_PROTO_SYSMOUSE
117 .\" driver can somewhat `accelerate' the movement of the pointing device.
118 .\" The faster you move the device, the further the pointer
119 .\" travels on the screen.
120 .\" The driver has an internal variable which governs the effect of
121 .\" the acceleration. Its value can be modified via the driver flag
122 .\" or via an ioctl call.
124 This section describes two classes of
129 driver itself, and commands for the console and the console control drivers.
131 There are a few commands for mouse drivers.
132 General description of the commands is given in
134 Followings are the features specific to the
138 .Bl -tag -width MOUSE -compact
139 .It Dv MOUSE_GETLEVEL Ar int *level
140 .It Dv MOUSE_SETLEVEL Ar int *level
141 These commands manipulate the operation level of the mouse driver.
143 .It Dv MOUSE_GETHWINFO Ar mousehw_t *hw
144 Returns the hardware information of the attached device in the following
147 field is guaranteed to be filled with the correct value in the current
152 typedef struct mousehw {
153 int buttons; /* number of buttons */
154 int iftype; /* I/F type */
155 int type; /* mouse/track ball/pad... */
156 int model; /* I/F dependent model ID */
157 int hwid; /* I/F dependent hardware ID */
163 field holds the number of buttons detected by the driver.
168 .Dv MOUSE_IF_SYSMOUSE.
172 tells the device type:
174 .Dv MOUSE_TRACKBALL ,
183 .Dv MOUSE_MODEL_GENERIC
184 at the operation level 0.
186 .Dv MOUSE_MODEL_GENERIC
189 constants at higher operation levels.
195 .It Dv MOUSE_GETMODE Ar mousemode_t *mode
196 The command gets the current operation parameters of the mouse
199 typedef struct mousemode {
200 int protocol; /* MOUSE_PROTO_XXX */
201 int rate; /* report rate (per sec) */
202 int resolution; /* MOUSE_RES_XXX, -1 if unknown */
203 int accelfactor; /* acceleration factor */
204 int level; /* driver operation level */
205 int packetsize; /* the length of the data packet */
206 unsigned char syncmask[2]; /* sync. bits */
212 field tells the format in which the device status is returned
213 when the mouse data is read by the user program.
216 at the operation level zero.
217 .Dv MOUSE_PROTO_SYSMOUSE
218 at the operation level one.
234 field specifies the length of the data packet. It depends on the
237 .Bl -tag -width level_0__ -compact
246 holds a bit mask and pattern to detect the first byte of the
249 is the bit mask to be ANDed with a byte. If the result is equal to
251 the byte is likely to be the first byte of the data packet.
252 Note that this method of detecting the first byte is not 100% reliable,
253 thus, should be taken only as an advisory measure.
255 .It Dv MOUSE_SETMODE Ar mousemode_t *mode
256 The command changes the current operation parameters of the mouse driver
261 may be modifiable. Setting values in the other field does not generate
262 error and has no effect.
264 .\" .It Dv MOUSE_GETVARS Ar mousevar_t *vars
265 .\" .It Dv MOUSE_SETVARS Ar mousevar_t *vars
266 .\" These commands are not supported by the
270 .It Dv MOUSE_READDATA Ar mousedata_t *data
271 .It Dv MOUSE_READSTATE Ar mousedata_t *state
272 These commands are not supported by the
276 .It Dv MOUSE_GETSTATE Ar mousestatus_t *status
277 The command returns the current state of buttons and
278 movement counts in the structure as defined in
281 .Ss Console and Consolectl Ioctls
282 The user process issues console
284 calls to the current virtual console in order to control
288 also provides a method for the user process to receive a
290 when a button is pressed.
296 calls to the console control device
298 to inform the console of mouse actions including mouse movement
303 commands are defined as
305 which takes the following argument.
310 struct mouse_data data;
311 struct mouse_mode mode;
312 struct mouse_event event;
317 .Bl -tag -width operation -compact
321 .Bl -tag -width MOUSE_MOVEABS -compact
323 Enables and displays mouse cursor.
325 Disables and hides mouse cursor.
327 Moves mouse cursor to position supplied in
330 Adds position supplied in
334 Returns current mouse position in the current virtual console
340 to be delivered to the current process when a button is pressed.
341 The signal to be delivered is set in
345 The above operations are for virtual consoles. The operations defined
346 below are for the console control device and used by
348 to pass mouse data to the console driver.
350 .Bl -tag -width MOUSE_MOVEABS -compact
352 .It Dv MOUSE_MOTIONEVENT
353 These operations take the information in
355 and act upon it. Mouse data will be sent to the
357 driver if it is open.
359 also processes button press actions and sends signal to the process if
360 requested or performs cut and paste operations
361 if the current console is a text interface.
362 .It Dv MOUSE_BUTTONEVENT
364 specifies a button and its click count. The console driver will
365 use this information for signal delivery if requested or
366 for cut and paste operations if the console is in text mode.
369 .Dv MOUSE_MOTIONEVENT
371 .Dv MOUSE_BUTTONEVENT
372 are newer interface and are designed to be used together.
373 They are intended to replace functions performed by
380 .Bl -tag -width data -compact
395 represent movement of the mouse along respective directions.
397 tells the state of buttons. It encodes up to 31 buttons in the bit 0 though
398 the bit 30. If a button is held down, the corresponding bit is set.
410 field specifies the signal to be delivered to the process. It must be
411 one of the values defined in
415 field is currently unused.
427 field specifies a button number as in
429 Only one bit/button is set.
433 holds the click count: the number of times the user has clicked the button
439 .Bl -tag -width /dev/consolectl -compact
440 .It Pa /dev/consolectl
441 device to control the console
443 virtualized mouse driver
456 manual page example first appeared in
460 manual page was written by
461 .An John-Mark Gurney Aq gurney_j@efn.org
463 .An Kazutaka Yokota Aq yokota@FreeBSD.org .