xref: /dragonfly/share/man/man4/sysmouse.4 (revision 1ab20d67)
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
42The console driver, in conjunction with the mouse daemon
43.Xr moused 8 ,
44supplies mouse data to the user process in the standardized way via the
45.Nm
46driver.
47This arrangement makes it possible for the console and the user process
48(such as the
49.Tn X\ Window System )
50to share the mouse.
51.Pp
52The user process which wants to utilize mouse operation simply opens
53.Pa /dev/sysmouse
54with a
55.Xr open 2
56call and reads
57mouse data from the device via
58.Xr read 2 .
59Make sure that
60.Xr moused 8
61is running, otherwise the user process won't see any data coming from
62the mouse.
63.Pp
64.Ss Operation Levels
65The
66.Nm
67driver has two levels of operation.
68The current operation level can be referred to and changed via ioctl calls.
69.Pp
70The level zero, the basic level, is the lowest level at which the driver
71offers the basic service to user programs.
72The
73.Nm
74driver
75provides horizontal and vertical movement of the mouse
76and state of up to three buttons in the
77.Tn MouseSystems
78format 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
84Always one.
85.It bit 6..3
86Always zero.
87.It bit 2
88Left button status; cleared if pressed, otherwise set.
89.It bit 1
90Middle button status; cleared if pressed, otherwise set.
91Always one,
92if the device does not have the middle button.
93.It bit 0
94Right button status; cleared if pressed, otherwise set.
95.El
96.It Byte 2
97The first half of horizontal movement count in two's complement;
98-128 through 127.
99.It Byte 3
100The first half of vertical movement count in two's complement;
101-128 through 127.
102.It Byte 4
103The second half of the horizontal movement count in two's complement;
104-128 through 127. To obtain the full horizontal movement count, add
105the byte 2 and 4.
106.It Byte 5
107The second half of the vertical movement count in two's complement;
108-128 through 127. To obtain the full vertical movement count, add
109the byte 3 and 5.
110.El
111.Pp
112At the level one, the extended level, mouse data is encoded
113in the standard format
114.Dv MOUSE_PROTO_SYSMOUSE
115as 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
127This section describes two classes of
128.Xr ioctl 2
129commands:
130commands for the
131.Nm
132driver itself, and commands for the console and the console control drivers.
133.Ss Sysmouse Ioctls
134There are a few commands for mouse drivers.
135General description of the commands is given in
136.Xr mouse 4 .
137Following are the features specific to the
138.Nm
139driver.
140.Pp
141.Bl -tag -width MOUSE -compact
142.It Dv MOUSE_GETLEVEL Ar int *level
143.It Dv MOUSE_SETLEVEL Ar int *level
144These commands manipulate the operation level of the mouse driver.
145.Pp
146.It Dv MOUSE_GETHWINFO Ar mousehw_t *hw
147Returns the hardware information of the attached device in the following
148structure.  Only the
149.Dv iftype
150field is guaranteed to be filled with the correct value in the current
151version of the
152.Nm
153driver.
154.Bd -literal
155typedef 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
164The
165.Dv buttons
166field holds the number of buttons detected by the driver.
167.Pp
168The
169.Dv iftype
170is always
171.Dv MOUSE_IF_SYSMOUSE .
172.Pp
173The
174.Dv type
175tells the device type:
176.Dv MOUSE_MOUSE ,
177.Dv MOUSE_TRACKBALL ,
178.Dv MOUSE_STICK ,
179.Dv MOUSE_PAD ,
180or
181.Dv MOUSE_UNKNOWN .
182.Pp
183The
184.Dv model
185is always
186.Dv MOUSE_MODEL_GENERIC
187at the operation level 0.
188It may be
189.Dv MOUSE_MODEL_GENERIC
190or one of
191.Dv MOUSE_MODEL_XXX
192constants at higher operation levels.
193.Pp
194The
195.Dv hwid
196is always zero.
197.Pp
198.It Dv MOUSE_GETMODE Ar mousemode_t *mode
199The command gets the current operation parameters of the mouse
200driver.
201.Bd -literal
202typedef 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
213The
214.Dv protocol
215field tells the format in which the device status is returned
216when the mouse data is read by the user program.
217It is
218.Dv MOUSE_PROTO_MSC
219at the operation level zero.
220.Dv MOUSE_PROTO_SYSMOUSE
221at the operation level one.
222.Pp
223The
224.Dv rate
225is always set to -1.
226.Pp
227The
228.Dv resolution
229is always set to -1.
230.Pp
231The
232.Dv accelfactor
233is always 0.
234.Pp
235The
236.Dv packetsize
237field specifies the length of the data packet.
238It depends on the
239operation level.
240.Pp
241.Bl -tag -width level_0__ -compact
242.It Em level 0
2435 bytes
244.It Em level 1
2458 bytes
246.El
247.Pp
248The array
249.Dv syncmask
250holds a bit mask and pattern to detect the first byte of the
251data packet.
252.Dv syncmask[0]
253is the bit mask to be ANDed with a byte.
254If the result is equal to
255.Dv syncmask[1] ,
256the byte is likely to be the first byte of the data packet.
257Note that this method of detecting the first byte is not 100% reliable;
258thus, it should be taken only as an advisory measure.
259.Pp
260.It Dv MOUSE_SETMODE Ar mousemode_t *mode
261The command changes the current operation parameters of the mouse driver
262as specified in
263.Ar mode .
264Only
265.Dv level
266may be modifiable.
267Setting values in the other field does not generate
268error 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
278These commands are not supported by the
279.Nm
280driver.
281.Pp
282.It Dv MOUSE_GETSTATUS Ar mousestatus_t *status
283The command returns the current state of buttons and
284movement counts in the structure as defined in
285.Xr mouse 4 .
286.El
287.Ss Console and Consolectl Ioctls
288The user process issues console
289.Fn ioctl
290calls to the current virtual console in order to control
291the mouse pointer.
292The console
293.Fn ioctl
294also provides a method for the user process to receive a
295.Xr signal 3
296when a button is pressed.
297.Pp
298The mouse daemon
299.Xr moused 8
300uses
301.Fn ioctl
302calls to the console control device
303.Pa /dev/consolectl
304to inform the console of mouse actions including mouse movement
305and button status.
306.Pp
307Both classes of
308.Fn ioctl
309commands are defined as
310.Dv CONS_MOUSECTL
311which takes the following argument.
312.Bd -literal
313struct 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
325This can be one of
326.Pp
327.Bl -tag -width MOUSE_MOVEABS -compact
328.It Dv MOUSE_SHOW
329Enables and displays mouse cursor.
330.It Dv MOUSE_HIDE
331Disables and hides mouse cursor.
332.It Dv MOUSE_MOVEABS
333Moves mouse cursor to position supplied in
334.Dv u.data .
335.It Dv MOUSE_MOVEREL
336Adds position supplied in
337.Dv u.data
338to current position.
339.It Dv MOUSE_GETINFO
340Returns current mouse position in the current virtual console
341and button status in
342.Dv u.data .
343.It Dv MOUSE_MODE
344This sets the
345.Xr signal 3
346to be delivered to the current process when a button is pressed.
347The signal to be delivered is set in
348.Dv u.mode .
349.El
350.Pp
351The above operations are for virtual consoles.
352The operations defined
353below are for the console control device and are used by
354.Xr moused 8
355to 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
360These operations take the information in
361.Dv u.data
362and act upon it.  Mouse data will be sent to the
363.Nm
364driver if it is open.
365.Dv MOUSE_ACTION
366also processes button press actions and sends signal to the process if
367requested or performs cut and paste operations
368if the current console is a text interface.
369.It Dv MOUSE_BUTTONEVENT
370.Dv u.data
371specifies a button and its click count.
372The console driver will
373use this information for signal delivery if requested or
374for cut and paste operations if the console is in text mode.
375.El
376.Pp
377.Dv MOUSE_MOTIONEVENT
378and
379.Dv MOUSE_BUTTONEVENT
380are newer interface and are designed to be used together.
381They are intended to replace functions performed by
382.Dv MOUSE_ACTION
383alone.
384.Pp
385.It Dv u
386This union is one of
387.Pp
388.Bl -tag -width data -compact
389.It Dv data
390.Bd -literal
391struct 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
401and
402.Dv z
403represent movement of the mouse along respective directions.
404.Dv buttons
405tells the state of buttons.
406It encodes up to 31 buttons in the bit 0 though
407the bit 30.  If a button is held down, the corresponding bit is set.
408.Pp
409.It Dv mode
410.Bd -literal
411struct mouse_mode {
412    int mode;
413    int signal;
414};
415.Ed
416.Pp
417The
418.Dv signal
419field specifies the signal to be delivered to the process.
420It must be
421one of the values defined in
422.Ao Pa signal.h Ac .
423The
424.Dv mode
425field is currently unused.
426.Pp
427.It Dv event
428.Bd -literal
429struct mouse_event {
430    int id;
431    int value;
432};
433.Ed
434.Pp
435The
436.Dv id
437field specifies a button number as in
438.Dv u.data.buttons .
439Only one bit/button is set.
440The
441.Dv value
442field
443holds the click count: the number of times the user has clicked the button
444successively.
445.Pp
446.El
447.El
448.Sh FILES
449.Bl -tag -width /dev/consolectl -compact
450.It Pa /dev/consolectl
451device to control the console
452.It Pa /dev/sysmouse
453virtualized mouse driver
454.It Pa /dev/ttyv%d
455virtual 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
464The
465.Nm
466manual page example first appeared in
467.Fx 2.2 .
468.Sh AUTHORS
469.An -nosplit
470This
471manual page was written by
472.An John-Mark Gurney Aq gurney_j@efn.org
473and
474.An Kazutaka Yokota Aq yokota@FreeBSD.org .
475