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