Sync BSD family tree with FreeBSD.
[dragonfly.git] / share / man / man4 / sysmouse.4
1 .\" Copyright (c) 1997
2 .\"     John-Mark Gurney.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
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.
15 .\"
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
26 .\" SUCH DAMAGE.
27 .\"
28 .\" $FreeBSD: src/share/man/man4/sysmouse.4,v 1.12.2.5 2001/12/17 11:30:12 ru Exp $
29 .\" $DragonFly: src/share/man/man4/sysmouse.4,v 1.2 2003/06/17 04:36:59 dillon Exp $
30 .\"
31 .Dd December 3, 1997
32 .Dt SYSMOUSE 4
33 .Os
34 .Sh NAME
35 .Nm sysmouse
36 .\" .Nd supplies mouse data from syscons for other applications
37 .Nd virtualized mouse driver
38 .Sh SYNOPSIS
39 .In machine/mouse.h
40 .In machine/console.h
41 .Sh DESCRIPTION
42 The console driver, in conjunction with the mouse daemon
43 .Xr moused 8 ,
44 supplies mouse data to the user process in the standardized way via the
45 .Nm
46 driver.
47 This arrangement makes it possible for the console and the user process
48 (such as the
49 .Tn X\ Window System )
50 to share the mouse.
51 .Pp
52 The user process which wants to utilize mouse operation simply opens
53 .Pa /dev/sysmouse
54 with a
55 .Xr open 2
56 call and reads
57 mouse data from the device via
58 .Xr read 2 .
59 Make sure that
60 .Xr moused 8
61 is running, otherwise the user process won't see any data coming from
62 the mouse.
63 .Pp
64 .Ss Operation Levels
65 The
66 .Nm
67 driver has two levels of operation.
68 The current operation level can be referred to and changed via ioctl calls.
69 .Pp
70 The level zero, the basic level, is the lowest level at which the driver
71 offers the basic service to user programs.
72 The
73 .Nm
74 driver
75 provides horizontal and vertical movement of the mouse
76 and state of up to three buttons in the
77 .Tn MouseSystems
78 format as follows.
79 .Pp
80 .Bl -tag -width Byte_1 -compact
81 .It Byte 1
82 .Bl -tag -width bit_7 -compact
83 .It bit 7
84 Always one.
85 .It bit 6..3
86 Always zero.
87 .It bit 2
88 Left button status; cleared if pressed, otherwise set.
89 .It bit 1
90 Middle button status; cleared if pressed, otherwise set.
91 Always one,
92 if the device does not have the middle button.
93 .It bit 0
94 Right button status; cleared if pressed, otherwise set.
95 .El
96 .It Byte 2
97 The first half of horizontal movement count in two's complement;
98 -128 through 127.
99 .It Byte 3
100 The first half of vertical movement count in two's complement;
101 -128 through 127.
102 .It Byte 4
103 The second half of the horizontal movement count in two's complement;
104 -128 through 127. To obtain the full horizontal movement count, add
105 the byte 2 and 4.
106 .It Byte 5
107 The second half of the vertical movement count in two's complement;
108 -128 through 127. To obtain the full vertical movement count, add
109 the byte 3 and 5.
110 .El
111 .Pp
112 At the level one, the extended level, mouse data is encoded
113 in the standard format
114 .Dv MOUSE_PROTO_SYSMOUSE
115 as defined in
116 .Xr mouse 4 .
117 .\" .Ss Acceleration
118 .\" The
119 .\" .Nm
120 .\" driver can somewhat `accelerate' the movement of the pointing device.
121 .\" The faster you move the device, the further the pointer
122 .\" travels on the screen.
123 .\" The driver has an internal variable which governs the effect of
124 .\" the acceleration. Its value can be modified via the driver flag
125 .\" or via an ioctl call.
126 .Sh IOCTLS
127 This section describes two classes of
128 .Xr ioctl 2
129 commands:
130 commands for the
131 .Nm
132 driver itself, and commands for the console and the console control drivers.
133 .Ss Sysmouse Ioctls
134 There are a few commands for mouse drivers.
135 General description of the commands is given in
136 .Xr mouse 4 .
137 Following are the features specific to the
138 .Nm
139 driver.
140 .Pp
141 .Bl -tag -width MOUSE -compact
142 .It Dv MOUSE_GETLEVEL Ar int *level
143 .It Dv MOUSE_SETLEVEL Ar int *level
144 These commands manipulate the operation level of the mouse driver.
145 .Pp
146 .It Dv MOUSE_GETHWINFO Ar mousehw_t *hw
147 Returns the hardware information of the attached device in the following
148 structure.  Only the
149 .Dv iftype
150 field is guaranteed to be filled with the correct value in the current
151 version of the
152 .Nm
153 driver.
154 .Bd -literal
155 typedef struct mousehw {
156     int buttons;    /* number of buttons */
157     int iftype;     /* I/F type */
158     int type;       /* mouse/track ball/pad... */
159     int model;      /* I/F dependent model ID */
160     int hwid;       /* I/F dependent hardware ID */
161 } mousehw_t;
162 .Ed
163 .Pp
164 The
165 .Dv buttons
166 field holds the number of buttons detected by the driver.
167 .Pp
168 The
169 .Dv iftype
170 is always
171 .Dv MOUSE_IF_SYSMOUSE .
172 .Pp
173 The
174 .Dv type
175 tells the device type:
176 .Dv MOUSE_MOUSE ,
177 .Dv MOUSE_TRACKBALL ,
178 .Dv MOUSE_STICK ,
179 .Dv MOUSE_PAD ,
180 or
181 .Dv MOUSE_UNKNOWN .
182 .Pp
183 The
184 .Dv model
185 is always
186 .Dv MOUSE_MODEL_GENERIC
187 at the operation level 0.
188 It may be
189 .Dv MOUSE_MODEL_GENERIC
190 or one of
191 .Dv MOUSE_MODEL_XXX
192 constants at higher operation levels.
193 .Pp
194 The
195 .Dv hwid
196 is always zero.
197 .Pp
198 .It Dv MOUSE_GETMODE Ar mousemode_t *mode
199 The command gets the current operation parameters of the mouse
200 driver.
201 .Bd -literal
202 typedef struct mousemode {
203     int protocol;    /* MOUSE_PROTO_XXX */
204     int rate;        /* report rate (per sec) */
205     int resolution;  /* MOUSE_RES_XXX, -1 if unknown */
206     int accelfactor; /* acceleration factor */
207     int level;       /* driver operation level */
208     int packetsize;  /* the length of the data packet */
209     unsigned char syncmask[2]; /* sync. bits */
210 } mousemode_t;
211 .Ed
212 .Pp
213 The
214 .Dv protocol
215 field tells the format in which the device status is returned
216 when the mouse data is read by the user program.
217 It is
218 .Dv MOUSE_PROTO_MSC
219 at the operation level zero.
220 .Dv MOUSE_PROTO_SYSMOUSE
221 at the operation level one.
222 .Pp
223 The
224 .Dv rate
225 is always set to -1.
226 .Pp
227 The
228 .Dv resolution
229 is always set to -1.
230 .Pp
231 The
232 .Dv accelfactor
233 is always 0.
234 .Pp
235 The
236 .Dv packetsize
237 field specifies the length of the data packet.
238 It depends on the
239 operation level.
240 .Pp
241 .Bl -tag -width level_0__ -compact
242 .It Em level 0
243 5 bytes
244 .It Em level 1
245 8 bytes
246 .El
247 .Pp
248 The array
249 .Dv syncmask
250 holds a bit mask and pattern to detect the first byte of the
251 data packet.
252 .Dv syncmask[0]
253 is the bit mask to be ANDed with a byte.
254 If the result is equal to
255 .Dv syncmask[1] ,
256 the byte is likely to be the first byte of the data packet.
257 Note that this method of detecting the first byte is not 100% reliable;
258 thus, it should be taken only as an advisory measure.
259 .Pp
260 .It Dv MOUSE_SETMODE Ar mousemode_t *mode
261 The command changes the current operation parameters of the mouse driver
262 as specified in
263 .Ar mode .
264 Only
265 .Dv level
266 may be modifiable.
267 Setting values in the other field does not generate
268 error and has no effect.
269 .\" .Pp
270 .\" .It Dv MOUSE_GETVARS Ar mousevar_t *vars
271 .\" .It Dv MOUSE_SETVARS Ar mousevar_t *vars
272 .\" These commands are not supported by the
273 .\" .Nm
274 .\" driver.
275 .Pp
276 .It Dv MOUSE_READDATA Ar mousedata_t *data
277 .It Dv MOUSE_READSTATE Ar mousedata_t *state
278 These commands are not supported by the
279 .Nm
280 driver.
281 .Pp
282 .It Dv MOUSE_GETSTATUS Ar mousestatus_t *status
283 The command returns the current state of buttons and
284 movement counts in the structure as defined in
285 .Xr mouse 4 .
286 .El
287 .Ss Console and Consolectl Ioctls
288 The user process issues console
289 .Fn ioctl
290 calls to the current virtual console in order to control
291 the mouse pointer.
292 The console
293 .Fn ioctl
294 also provides a method for the user process to receive a
295 .Xr signal 3
296 when a button is pressed.
297 .Pp
298 The mouse daemon
299 .Xr moused 8
300 uses
301 .Fn ioctl
302 calls to the console control device
303 .Pa /dev/consolectl
304 to inform the console of mouse actions including mouse movement
305 and button status.
306 .Pp
307 Both classes of
308 .Fn ioctl
309 commands are defined as
310 .Dv CONS_MOUSECTL
311 which takes the following argument.
312 .Bd -literal
313 struct mouse_info {
314     int operation;
315     union {
316         struct mouse_data data;
317         struct mouse_mode mode;
318         struct mouse_event event;
319     } u;
320 };
321 .Ed
322 .Pp
323 .Bl -tag -width operation -compact
324 .It Dv operation
325 This can be one of
326 .Pp
327 .Bl -tag -width MOUSE_MOVEABS -compact
328 .It Dv MOUSE_SHOW
329 Enables and displays mouse cursor.
330 .It Dv MOUSE_HIDE
331 Disables and hides mouse cursor.
332 .It Dv MOUSE_MOVEABS
333 Moves mouse cursor to position supplied in
334 .Dv u.data .
335 .It Dv MOUSE_MOVEREL
336 Adds position supplied in
337 .Dv u.data
338 to current position.
339 .It Dv MOUSE_GETINFO
340 Returns current mouse position in the current virtual console
341 and button status in
342 .Dv u.data .
343 .It Dv MOUSE_MODE
344 This sets the
345 .Xr signal 3
346 to be delivered to the current process when a button is pressed.
347 The signal to be delivered is set in
348 .Dv u.mode .
349 .El
350 .Pp
351 The above operations are for virtual consoles.
352 The operations defined
353 below are for the console control device and are used by
354 .Xr moused 8
355 to pass mouse data to the console driver.
356 .Pp
357 .Bl -tag -width MOUSE_MOVEABS -compact
358 .It Dv MOUSE_ACTION
359 .It Dv MOUSE_MOTIONEVENT
360 These operations take the information in
361 .Dv u.data
362 and act upon it.  Mouse data will be sent to the
363 .Nm
364 driver if it is open.
365 .Dv MOUSE_ACTION
366 also processes button press actions and sends signal to the process if
367 requested or performs cut and paste operations
368 if the current console is a text interface.
369 .It Dv MOUSE_BUTTONEVENT
370 .Dv u.data
371 specifies a button and its click count.
372 The console driver will
373 use this information for signal delivery if requested or
374 for cut and paste operations if the console is in text mode.
375 .El
376 .Pp
377 .Dv MOUSE_MOTIONEVENT
378 and
379 .Dv MOUSE_BUTTONEVENT
380 are newer interface and are designed to be used together.
381 They are intended to replace functions performed by
382 .Dv MOUSE_ACTION
383 alone.
384 .Pp
385 .It Dv u
386 This union is one of
387 .Pp
388 .Bl -tag -width data -compact
389 .It Dv data
390 .Bd -literal
391 struct mouse_data {
392     int x;
393     int y;
394     int z;
395     int buttons;
396 };
397 .Ed
398 .Pp
399 .Dv x ,
400 .Dv y
401 and
402 .Dv z
403 represent movement of the mouse along respective directions.
404 .Dv buttons
405 tells the state of buttons.
406 It encodes up to 31 buttons in the bit 0 though
407 the bit 30.  If a button is held down, the corresponding bit is set.
408 .Pp
409 .It Dv mode
410 .Bd -literal
411 struct mouse_mode {
412     int mode;
413     int signal;
414 };
415 .Ed
416 .Pp
417 The
418 .Dv signal
419 field specifies the signal to be delivered to the process.
420 It must be
421 one of the values defined in
422 .Ao Pa signal.h Ac .
423 The
424 .Dv mode
425 field is currently unused.
426 .Pp
427 .It Dv event
428 .Bd -literal
429 struct mouse_event {
430     int id;
431     int value;
432 };
433 .Ed
434 .Pp
435 The
436 .Dv id
437 field specifies a button number as in
438 .Dv u.data.buttons .
439 Only one bit/button is set.
440 The
441 .Dv value
442 field
443 holds the click count: the number of times the user has clicked the button
444 successively.
445 .Pp
446 .El
447 .El
448 .Sh FILES
449 .Bl -tag -width /dev/consolectl -compact
450 .It Pa /dev/consolectl
451 device to control the console
452 .It Pa /dev/sysmouse
453 virtualized mouse driver
454 .It Pa /dev/ttyv%d
455 virtual consoles
456 .El
457 .Sh SEE ALSO
458 .Xr vidcontrol 1 ,
459 .Xr ioctl 2 ,
460 .Xr signal 3 ,
461 .Xr mouse 4 ,
462 .Xr moused 8
463 .Sh HISTORY
464 The
465 .Nm
466 manual page example first appeared in
467 .Fx 2.2 .
468 .Sh AUTHORS
469 .An -nosplit
470 This
471 manual page was written by
472 .An John-Mark Gurney Aq gurney_j@efn.org
473 and
474 .An Kazutaka Yokota Aq yokota@FreeBSD.org .