sysmouse.4 (23462) | sysmouse.4 (31606) |
---|---|
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. --- 11 unchanged lines hidden (view full) --- 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.\" | 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. --- 11 unchanged lines hidden (view full) --- 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.\" $Id$ | 28.\" $Id: sysmouse.4,v 1.5 1997/03/07 02:49:59 jmg Exp $ |
29.\" | 29.\" |
30.Dd February 14, 1997 | 30.Dd December 3, 1997 |
31.Dt SYSMOUSE 4 i386 | 31.Dt SYSMOUSE 4 i386 |
32.Os | 32.Os FreeBSD |
33.Sh NAME 34.Nm sysmouse | 33.Sh NAME 34.Nm sysmouse |
35.Nd supplies mouse data from syscons for other applications | 35.\" .Nd supplies mouse data from syscons for other applications 36.Nd virtualized mouse driver |
36.Sh SYNOPSIS | 37.Sh SYNOPSIS |
38.Fd #include <machine/mouse.h> |
|
37.Fd #include <machine/console.h> | 39.Fd #include <machine/console.h> |
38.Ft int 39.Fn ioctl cfd CONS_MOUSECTL struct\ *mouse_info | |
40.Sh DESCRIPTION | 40.Sh DESCRIPTION |
41The console driver, in conjunction with the mouse daemon 42.Xr moused 8 , 43supplies mouse data to the user process in the standardized way via the 44.Nm 45driver. 46This arrangement makes it possible for the console and the user process 47.Pq such as the Tn X\ Window System 48to share the mouse. 49.Pp 50The user process which wants to utilize mouse operation simply opens 51.Pa /dev/sysmouse 52with a 53.Xr open 2 54call and reads 55mouse data from the device via 56.Xr read 2 . 57Make sure that 58.Xr moused 8 59is running, otherwise the user process won't see any data coming from 60the mouse. 61.Pp 62.Ss Operation Levels |
|
41The | 63The |
42.Dv CONS_MOUSECTL | 64.Nm 65driver has two levels of operation. 66The current operation level can be referred to and changed via ioctl calls. 67.Pp 68The level zero, the basic level, is the lowest level at which the driver 69offers the basic service to user programs. 70The 71.Nm 72driver 73provides horizontal and vertical movement of the mouse 74and state of up to three buttons in the 75.Tn MouseSystems 76format as follows. 77.Pp 78.Bl -tag -width Byte_1 -compact 79.It Byte 1 80.Bl -tag -width bit_7 -compact 81.It bit 7 82Always one. 83.It bit 6..3 84Always zero. 85.It bit 2 86Left button status; cleared if pressed, otherwise set. 87.It bit 1 88Middle button status; cleared if pressed, otherwise set. Always one, 89if the device does not have the middle button. 90.It bit 0 91Right button status; cleared if pressed, otherwise set. 92.El 93.It Byte 2 94The first half of horizontal movement count in two's compliment; 95-128 through 127. 96.It Byte 3 97The first half of vertical movement count in two's compliment; 98-128 through 127. 99.It Byte 4 100The second half of the horizontal movement count in two's compliment; 101-128 through 127. To obtain the full horizontal movement count, add 102the byte 2 and 4. 103.It Byte 5 104The second half of the vertical movement count in two's compliment; 105-128 through 127. To obtain the full vertical movement count, add 106the byte 3 and 5. 107.El 108.Pp 109At the level one, the extended level, mouse data is encoded 110in the standard format 111.Dv MOUSE_PROTO_SYSMOUSE 112as defined in 113.Xr mouse 4 . 114.\" .Ss Acceleration 115.\" The 116.\" .Nm 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. 123.Sh IOCTLS 124This section describes two classes of 125.Xr ioctl 2 126commands: 127commands for the 128.Nm 129driver itself, and commands for the console and the console control drivers. 130.Ss Sysmouse Ioctls 131There are a few commands for mouse drivers. 132General description of the commands is given in 133.Xr mouse 4 . 134Followings are the features specific to the 135.Nm 136driver. 137.Pp 138.Bl -tag -width MOUSE -compact 139.It Dv MOUSE_GETLEVEL Ar int *level 140.It Dv MOUSE_SETLEVEL Ar int *level 141These commands manipulate the operation level of the mouse driver. 142.Pp 143.It Dv MOUSE_GETHWINFO Ar mousehw_t *hw 144Returns the hardware information of the attached device in the following 145structure. Only the 146.Dv 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.Dv buttons 163field holds the number of buttons detected by the driver. 164.Pp 165The 166.Dv iftype 167is always 168.Dv MOUSE_IF_SYSMOUSE. 169.Pp 170The 171.Dv 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.Dv 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.Dv 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.Dv 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.Dv rate 222is always set to -1. 223.Pp 224The 225.Dv resolution 226is always set to -1. 227.Pp 228The 229.Dv accelfactor 230is always 0. 231.Pp 232The 233.Dv packetsize 234field specifies the length of the data packet. It depends on the 235operation level. 236.Pp 237.Bl -tag -width level_0__ -compact 238.It Em level 0 2395 bytes 240.It Em level 1 2418 bytes 242.El 243.Pp 244The array 245.Dv syncmask 246holds a bit mask and pattern to detect the first byte of the 247data packet. 248.Dv syncmask[0] 249is the bit mask to be ANDed with a byte. If the result is equal to 250.Dv syncmask[1] , 251the byte is likely to be the first byte of the data packet. 252Note that this method of detecting the first byte is not 100% reliable, 253thus, should be taken only as an advisory measure. 254.Pp 255.It Dv MOUSE_SETMODE Ar mousemode_t *mode 256The command changes the current operation parameters of the mouse driver 257as specified in 258.Ar mode . 259Only 260.Dv level 261may be modifiable. Setting values in the other field does not generate 262error and has no effect. 263.\" .Pp 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 267.\" .Nm 268.\" driver. 269.Pp 270.It Dv MOUSE_READDATA Ar mousedata_t *data 271.It Dv MOUSE_READSTATE Ar mousedata_t *state 272These commands are not supported by the 273.Nm 274driver. 275.Pp 276.It Dv MOUSE_GETSTATE Ar mousestatus_t *status 277The command returns the current state of buttons and 278movement counts in the structure as defined in 279.Xr mouse 4 . 280.El 281.Ss Console and Consolectl Ioctls 282The user process issues console |
43.Fn ioctl | 283.Fn ioctl |
44call provides syscons with mouse information, which includes mouse movement 45and button presses. The 46.Fn ioctl 47also provides a method for a process to receive a | 284calls to the current virtual console in order to control 285the mouse pointer. 286The console 287.Fn ioctl 288also provides a method for the user process to receive a |
48.Xr signal 3 49when a button is pressed. 50.Pp | 289.Xr signal 3 290when a button is pressed. 291.Pp |
292The mouse daemon |
|
51.Xr moused 8 | 293.Xr moused 8 |
52uses this | 294uses |
53.Fn ioctl | 295.Fn ioctl |
54to inform the console of mouse actions. Applications 55.Pq such as Tn X\ Windows 56can use 57.Pa /dev/sysmouse , 58allowing syscons and the application to share the mouse. | 296calls to the console control device 297.Pa /dev/consolectl 298to inform the console of mouse actions including mouse movement 299and button status. |
59.Pp | 300.Pp |
60.Bd -literal -offset indent | 301Both classes 302.Fn ioctl 303commands are defined as 304.Dv CONS_MOUSECTL 305which takes the following argument. 306.Bd -literal |
61struct mouse_info { | 307struct mouse_info { |
62 int operation; 63 union { 64 struct mouse_data data; 65 struct mouse_mode mode; 66 }u; | 308 int operation; 309 union { 310 struct mouse_data data; 311 struct mouse_mode mode; 312 struct mouse_event event; 313 } u; |
67}; 68.Ed | 314}; 315.Ed |
69.Bl -tag -width operation | 316.Pp 317.Bl -tag -width operation -compact |
70.It Dv operation 71This can be one of | 318.It Dv operation 319This can be one of |
72.Bl -tag -width MOUSE_MOVEABS | 320.Pp 321.Bl -tag -width MOUSE_MOVEABS -compact |
73.It Dv MOUSE_SHOW 74Enables and displays mouse cursor. 75.It Dv MOUSE_HIDE 76Disables and hides mouse cursor. 77.It Dv MOUSE_MOVEABS 78Moves mouse cursor to position supplied in 79.Dv u.data . 80.It Dv MOUSE_MOVEREL | 322.It Dv MOUSE_SHOW 323Enables and displays mouse cursor. 324.It Dv MOUSE_HIDE 325Disables and hides mouse cursor. 326.It Dv MOUSE_MOVEABS 327Moves mouse cursor to position supplied in 328.Dv u.data . 329.It Dv MOUSE_MOVEREL |
81Add position supplied in | 330Adds position supplied in |
82.Dv u.data 83to current position. 84.It Dv MOUSE_GETINFO | 331.Dv u.data 332to current position. 333.It Dv MOUSE_GETINFO |
85Returns current mouse position and button status in | 334Returns current mouse position in the current virtual console 335and button status in |
86.Dv u.data . 87.It Dv MOUSE_MODE 88This sets the 89.Xr signal 3 90to be delivered to the current process when a button is pressed. 91The signal to be delivered is set in 92.Dv u.mode . | 336.Dv u.data . 337.It Dv MOUSE_MODE 338This sets the 339.Xr signal 3 340to be delivered to the current process when a button is pressed. 341The signal to be delivered is set in 342.Dv u.mode . |
343.El 344.Pp 345The above operations are for virtual consoles. The operations defined 346below are for the console control device and used by 347.Xr moused 8 348to pass mouse data to the console driver. 349.Pp 350.Bl -tag -width MOUSE_MOVEABS -compact |
|
93.It Dv MOUSE_ACTION | 351.It Dv MOUSE_ACTION |
94This takes the information in | 352.It Dv MOUSE_MOTIONEVENT 353These operations take the information in |
95.Dv u.data | 354.Dv u.data |
96and acts upon it. It includes processing button presses if the current vty 97is a text interface, and sending 98.Tn Mouse System 99protocol data to 100.Pa /dev/sysmouse 101if it is open. | 355and act upon it. Mouse data will be sent to the 356.Nm 357driver if it is open. 358.Dv MOUSE_ACTION 359also processes button press actions and sends signal to the process if 360requested or performs cut and paste operations 361if the current console is a text interface. 362.It Dv MOUSE_BUTTONEVENT 363.Dv u.data 364specifies a button and its click count. The console driver will 365use this information for signal delivery if requested or 366for cut and paste operations if the console is in text mode. |
102.El | 367.El |
368.Pp 369.Dv MOUSE_MOTIONEVENT 370and 371.Dv MOUSE_BUTTONEVENT 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 |
|
103.It Dv u 104This union is one of | 377.It Dv u 378This union is one of |
105.Bl -tag -width data | 379.Pp 380.Bl -tag -width data -compact |
106.It Dv data | 381.It Dv data |
107.Bd -literal -offset indent | 382.Bd -literal |
108struct mouse_data { | 383struct mouse_data { |
109 int x; 110 int y; 111 int buttons; | 384 int x; 385 int y; 386 int z; 387 int buttons; |
112}; 113.Ed | 388}; 389.Ed |
390.Pp 391.Dv x , 392.Dv y 393and 394.Dv z 395represent movement of the mouse along respective directions. 396.Dv buttons 397tells the state of buttons. It encodes up to 31 buttons in the bit 0 though 398the bit 30. If a button is held down, the corresponding bit is set. 399.Pp |
|
114.It Dv mode | 400.It Dv mode |
115.Bd -literal -offset indent | 401.Bd -literal |
116struct mouse_mode { | 402struct mouse_mode { |
117 int mode; 118 int signal; | 403 int mode; 404 int signal; |
119}; 120.Ed | 405}; 406.Ed |
407.Pp 408The 409.Dv signal 410field specifies the signal to be delivered to the process. It must be 411one of the values defined in 412.Ao Pa signal.h Ac . 413The 414.Dv mode 415field is currently unused. 416.Pp 417.It Dv event 418.Bd -literal 419struct mouse_event { 420 int id; 421 int value; 422}; 423.Ed 424.Pp 425The 426.Dv id 427field specifies a button number as in 428.Dv u.data.buttons . 429Only one bit/button is set. 430The 431.Dv value 432field 433holds the click count: the number of times the user has clicked the button 434successively. 435.Pp |
|
121.El 122.El 123.Sh FILES 124.Bl -tag -width /dev/consolectl -compact 125.It Pa /dev/consolectl 126device to control the console 127.It Pa /dev/sysmouse | 436.El 437.El 438.Sh FILES 439.Bl -tag -width /dev/consolectl -compact 440.It Pa /dev/consolectl 441device to control the console 442.It Pa /dev/sysmouse |
128mouse action output | 443virtualized mouse driver 444.It Pa /dev/ttyv%d 445virtual consoles |
129.El 130.Sh SEE ALSO 131.Xr vidcontrol 1 , | 446.El 447.Sh SEE ALSO 448.Xr vidcontrol 1 , |
449.Xr ioctl 2 , |
|
132.Xr signal 3 , | 450.Xr signal 3 , |
451.Xr mouse 4 , |
|
133.Xr moused 8 134.Sh HISTORY 135The 136.Nm 137manual page example first appeared in 138.Fx 2.2 . 139.Sh AUTHOR 140This | 452.Xr moused 8 453.Sh HISTORY 454The 455.Nm 456manual page example first appeared in 457.Fx 2.2 . 458.Sh AUTHOR 459This |
141manual page was written by John-Mark Gurney 142.Aq gurney_j@efn.org . | 460manual page was written by 461.An John-Mark Gurney Aq gurney_j@efn.org 462and 463.An Kazutaka YOKOTA Aq yokota@FreeBSD.org . |