summaryrefslogtreecommitdiff
path: root/static/freebsd/man4/mouse.4 3.html
blob: e1da512492f5fba1ba8823d8406a89692743b57e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
<table class="head">
  <tr>
    <td class="head-ltitle">MOUSE(4)</td>
    <td class="head-vol">Device Drivers Manual</td>
    <td class="head-rtitle">MOUSE(4)</td>
  </tr>
</table>
<div class="manual-text">
<section class="Sh">
<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
<p class="Pp"><code class="Nm">mouse</code> &#x2014; <span class="Nd">mouse and
    pointing device drivers</span></p>
</section>
<section class="Sh">
<h1 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1>
<p class="Pp"><code class="In">#include
    &lt;<a class="In">sys/mouse.h</a>&gt;</code></p>
</section>
<section class="Sh">
<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
<p class="Pp">The mouse drivers <a class="Xr">psm(4)</a>,
    <a class="Xr">ums(4)</a> and <a class="Xr">sysmouse(4)</a> provide user
    programs with movement and button state information of the mouse. Currently
    there are specific device drivers for bus, InPort, PS/2, and USB mice. The
    serial mouse is not directly supported by a dedicated driver, but it is
    accessible via the serial device driver or via <a class="Xr">moused(8)</a>
    and <a class="Xr">sysmouse(4)</a>.</p>
<p class="Pp">The user program simply opens a mouse device with a
    <a class="Xr">open(2)</a> call and reads mouse data from the device via
    <a class="Xr">read(2)</a>. Movement and button states are usually encoded in
    fixed-length data packets. Some mouse devices may send data in variable
    length of packets. Actual protocol (data format) used by each driver differs
    widely.</p>
<p class="Pp">The mouse drivers may have ``non-blocking'' attribute which will
    make the driver return immediately if mouse data is not available.</p>
<p class="Pp">Mouse device drivers often offer several levels of operation. The
    current operation level can be examined and changed via
    <a class="Xr">ioctl(2)</a> commands. The level zero is the lowest level at
    which the driver offers the basic service to user programs. Most drivers
    provide horizontal and vertical movement of the mouse and state of up to
    three buttons at this level. At the level one, if supported by the driver,
    mouse data is encoded in the standard format
    <code class="Dv">MOUSE_PROTO_SYSMOUSE</code> as follows:</p>
<p class="Pp"></p>
<dl class="Bl-tag Bl-compact">
  <dt>Byte 1</dt>
  <dd>
    <dl class="Bl-tag Bl-compact">
      <dt>bit 7</dt>
      <dd>Always one.</dd>
      <dt>bit 6..3</dt>
      <dd>Always zero.</dd>
      <dt>bit 2</dt>
      <dd>Left button status; cleared if pressed, otherwise set.</dd>
      <dt>bit 1</dt>
      <dd>Middle button status; cleared if pressed, otherwise set. Always one,
          if the device does not have the middle button.</dd>
      <dt>bit 0</dt>
      <dd>Right button status; cleared if pressed, otherwise set.</dd>
    </dl>
  </dd>
  <dt>Byte 2</dt>
  <dd>The first half of horizontal movement count in two's complement; -128
      through 127.</dd>
  <dt>Byte 3</dt>
  <dd>The first half of vertical movement count in two's complement; -128
      through 127.</dd>
  <dt>Byte 4</dt>
  <dd>The second half of the horizontal movement count in two's complement; -128
      through 127. To obtain the full horizontal movement count, add the byte 2
      and 4.</dd>
  <dt>Byte 5</dt>
  <dd>The second half of the vertical movement count in two's complement; -128
      through 127. To obtain the full vertical movement count, add the byte 3
      and 5.</dd>
  <dt>Byte 6</dt>
  <dd>The bit 7 is always zero. The lower 7 bits encode the first half of Z axis
      movement count in two's complement; -64 through 63.</dd>
  <dt>Byte 7</dt>
  <dd>The bit 7 is always zero. The lower 7 bits encode the second half of the Z
      axis movement count in two's complement; -64 through 63. To obtain the
      full Z axis movement count, add the byte 6 and 7.</dd>
  <dt>Byte 8</dt>
  <dd>The bit 7 is always zero. The bits 0 through 6 reflect the state of the
      buttons 4 through 10. If a button is pressed, the corresponding bit is
      cleared. Otherwise the bit is set.</dd>
</dl>
<p class="Pp">The first 5 bytes of this format is compatible with the
    MouseSystems format. The additional 3 bytes have their MSBs always set to
    zero. Thus, if the user program can interpret the MouseSystems data format
    and tries to find the first byte of the format by detecting the bit pattern
    10000xxxb, it will discard the additional bytes, thus, be able to decode x,
    y and states of 3 buttons correctly.</p>
<p class="Pp">Device drivers may offer operation levels higher than one. Refer
    to manual pages of individual drivers for details.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="IOCTLS"><a class="permalink" href="#IOCTLS">IOCTLS</a></h1>
<p class="Pp">The following <a class="Xr">ioctl(2)</a> commands are defined for
    the mouse drivers. The degree of support varies from one driver to another.
    This section gives general description of the commands. Refer to manual
    pages of individual drivers for specific details.</p>
<p class="Pp"></p>
<dl class="Bl-tag Bl-compact">
  <dt id="MOUSE_GETLEVEL"><a class="permalink" href="#MOUSE_GETLEVEL"><code class="Dv">MOUSE_GETLEVEL</code></a>
    <var class="Ar">int *level</var></dt>
  <dd style="width: auto;">&#x00A0;</dd>
  <dt id="MOUSE_SETLEVEL"><a class="permalink" href="#MOUSE_SETLEVEL"><code class="Dv">MOUSE_SETLEVEL</code></a>
    <var class="Ar">int *level</var></dt>
  <dd>These commands manipulate the operation level of the mouse driver.
    <p class="Pp"></p>
  </dd>
  <dt id="MOUSE_GETHWINFO"><a class="permalink" href="#MOUSE_GETHWINFO"><code class="Dv">MOUSE_GETHWINFO</code></a>
    <var class="Ar">mousehw_t *hw</var></dt>
  <dd>Returns the hardware information of the attached device in the following
      Except for the <code class="Dv">iftype</code> field, the device driver may
      not always fill the structure with correct values. Consult manual pages of
      individual drivers for details of support.
    <div class="Bd Pp Li">
    <pre>typedef struct mousehw {
    int buttons;    /* number of buttons */
    int iftype;     /* I/F type */
    int type;       /* mouse/track ball/pad... */
    int model;      /* I/F dependent model ID */
    int hwid;       /* I/F dependent hardware ID */
} mousehw_t;</pre>
    </div>
    <p class="Pp">The <code class="Dv">buttons</code> field holds the number of
        buttons detected by the driver. The driver may put an arbitrary value,
        such as two, in this field, if it cannot determine the exact number.</p>
    <p class="Pp">The <code class="Dv">iftype</code> is the type of interface:
        <code class="Dv">MOUSE_IF_SERIAL</code>,
        <code class="Dv">MOUSE_IF_BUS</code>,
        <code class="Dv">MOUSE_IF_INPORT</code>,
        <code class="Dv">MOUSE_IF_PS2</code>,
        <code class="Dv">MOUSE_IF_USB</code>,
        <code class="Dv">MOUSE_IF_SYSMOUSE</code> or
        <code class="Dv">MOUSE_IF_UNKNOWN</code>.</p>
    <p class="Pp">The <code class="Dv">type</code> tells the device type:
        <code class="Dv">MOUSE_MOUSE</code>,
        <code class="Dv">MOUSE_TRACKBALL</code>,
        <code class="Dv">MOUSE_STICK</code>, <code class="Dv">MOUSE_PAD</code>,
        or <code class="Dv">MOUSE_UNKNOWN</code>.</p>
    <p class="Pp">The <code class="Dv">model</code> may be
        <code class="Dv">MOUSE_MODEL_GENERIC</code> or one of
        <code class="Dv">MOUSE_MODEL_XXX</code> constants.</p>
    <p class="Pp">The <code class="Dv">hwid</code> is the ID value returned by
        the pointing device. It depend on the interface type; refer to the
        manual page of specific mouse drivers for possible values.</p>
    <p class="Pp"></p>
  </dd>
  <dt id="MOUSE_GETMODE"><a class="permalink" href="#MOUSE_GETMODE"><code class="Dv">MOUSE_GETMODE</code></a>
    <var class="Ar">mousemode_t *mode</var></dt>
  <dd>The command reports the current operation parameters of the mouse driver.
    <div class="Bd Pp Li">
    <pre>typedef struct mousemode {
    int protocol;    /* MOUSE_PROTO_XXX */
    int rate;        /* report rate (per sec) */
    int resolution;  /* MOUSE_RES_XXX, -1 if unknown */
    int accelfactor; /* acceleration factor */
    int level;       /* driver operation level */
    int packetsize;  /* the length of the data packet */
    unsigned char syncmask[2]; /* sync. bits */
} mousemode_t;</pre>
    </div>
    <p class="Pp">The <code class="Dv">protocol</code> field tells the format in
        which the device status is returned when the mouse data is read by the
        user program. It is one of <code class="Dv">MOUSE_PROTO_XXX</code>
        constants.</p>
    <p class="Pp">The <code class="Dv">rate</code> field is the status report
        rate (reports/sec) at which the device will send movement reports to the
        host computer. -1 if unknown or not applicable.</p>
    <p class="Pp">The <code class="Dv">resolution</code> field holds a value
        specifying resolution of the pointing device. It is a positive value or
        one of <code class="Dv">MOUSE_RES_XXX</code> constants.</p>
    <p class="Pp">The <code class="Dv">accelfactor</code> field holds a value to
        control acceleration feature. It must be zero or greater. If it is zero,
        acceleration is disabled.</p>
    <p class="Pp">The <code class="Dv">packetsize</code> field tells the length
        of the fixed-size data packet or the length of the fixed part of the
        variable-length packet. The size depends on the interface type, the
        device type and model, the protocol and the operation level of the
        driver.</p>
    <p class="Pp">The array <code class="Dv">syncmask</code> holds a bit mask
        and pattern to detect the first byte of the data packet.
        <code class="Dv">syncmask[0]</code> is the bit mask to be ANDed with a
        byte. If the result is equal to <code class="Dv">syncmask[1]</code>, the
        byte is likely to be the first byte of the data packet. Note that this
        method of detecting the first byte is not 100% reliable, thus, should be
        taken only as an advisory measure.</p>
    <p class="Pp"></p>
  </dd>
  <dt id="MOUSE_SETMODE"><a class="permalink" href="#MOUSE_SETMODE"><code class="Dv">MOUSE_SETMODE</code></a>
    <var class="Ar">mousemode_t *mode</var></dt>
  <dd>The command changes the current operation parameters of the mouse driver
      as specified in <var class="Ar">mode</var>. Only
      <code class="Dv">rate</code>, <code class="Dv">resolution</code>,
      <code class="Dv">level</code> and <code class="Dv">accelfactor</code> may
      be modifiable. Setting values in the other field does not generate error
      and has no effect.
    <p class="Pp">If you do not want to change the current setting of a field,
        put -1 there. You may also put zero in
        <code class="Dv">resolution</code> and <code class="Dv">rate</code>, and
        the default value for the fields will be selected.</p>
    <p class="Pp"></p>
  </dd>
  <dt id="MOUSE_READDATA"><a class="permalink" href="#MOUSE_READDATA"><code class="Dv">MOUSE_READDATA</code></a>
    <var class="Ar">mousedata_t *data</var></dt>
  <dd>The command reads the raw data from the device.
    <div class="Bd Pp Li">
    <pre>typedef struct mousedata {
    int len;        /* # of data in the buffer */
    int buf[16];    /* data buffer */
} mousedata_t;</pre>
    </div>
    <p class="Pp">The calling process must fill the <code class="Dv">len</code>
        field with the number of bytes to be read into the buffer. This command
        may not be supported by all drivers.</p>
    <p class="Pp"></p>
  </dd>
  <dt id="MOUSE_READSTATE"><a class="permalink" href="#MOUSE_READSTATE"><code class="Dv">MOUSE_READSTATE</code></a>
    <var class="Ar">mousedata_t *state</var></dt>
  <dd>The command reads the raw state data from the device. It uses the same
      structure as above. This command may not be supported by all drivers.
    <p class="Pp"></p>
  </dd>
  <dt id="MOUSE_GETSTATUS"><a class="permalink" href="#MOUSE_GETSTATUS"><code class="Dv">MOUSE_GETSTATUS</code></a>
    <var class="Ar">mousestatus_t *status</var></dt>
  <dd>The command returns the current state of buttons and movement counts in
      the following structure.
    <div class="Bd Pp Li">
    <pre>typedef struct mousestatus {
    int flags;      /* state change flags */
    int button;     /* button status */
    int obutton;    /* previous button status */
    int dx;         /* x movement */
    int dy;         /* y movement */
    int dz;         /* z movement */
} mousestatus_t;</pre>
    </div>
    <p class="Pp">The <code class="Dv">button</code> and
        <code class="Dv">obutton</code> fields hold the current and the previous
        state of the mouse buttons. When a button is pressed, the corresponding
        bit is set. The mouse drivers may support up to 31 buttons with the bit
        0 through 31. Few button bits are defined as
        <code class="Dv">MOUSE_BUTTON1DOWN</code> through
        <code class="Dv">MOUSE_BUTTON8DOWN</code>. The first three buttons
        correspond to left, middle and right buttons.</p>
    <p class="Pp">If the state of the button has changed since the last
        <code class="Dv">MOUSE_GETSTATUS</code> call, the corresponding bit in
        the <code class="Dv">flags</code> field will be set. If the mouse has
        moved since the last call, the <code class="Dv">MOUSE_POSCHANGED</code>
        bit in the <code class="Dv">flags</code> field will also be set.</p>
    <p class="Pp">The other fields hold movement counts since the last
        <code class="Dv">MOUSE_GETSTATUS</code> call. The internal counters will
        be reset after every call to this command.</p>
  </dd>
</dl>
</section>
<section class="Sh">
<h1 class="Sh" id="FILES"><a class="permalink" href="#FILES">FILES</a></h1>
<dl class="Bl-tag Bl-compact">
  <dt><span class="Pa">/dev/cuau%d</span></dt>
  <dd>serial ports</dd>
  <dt><span class="Pa">/dev/psm%d</span></dt>
  <dd>PS/2 mouse device</dd>
  <dt><span class="Pa">/dev/sysmouse</span></dt>
  <dd>virtual mouse device</dd>
  <dt><span class="Pa">/dev/ums%d</span></dt>
  <dd>USB mouse device</dd>
</dl>
</section>
<section class="Sh">
<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
  ALSO</a></h1>
<p class="Pp"><a class="Xr">ioctl(2)</a>, <a class="Xr">psm(4)</a>,
    <a class="Xr">sysmouse(4)</a>, <a class="Xr">ums(4)</a>,
    <a class="Xr">moused(8)</a></p>
</section>
<section class="Sh">
<h1 class="Sh" id="AUTHORS"><a class="permalink" href="#AUTHORS">AUTHORS</a></h1>
<p class="Pp">This manual page was written by <span class="An">Kazutaka
    Yokota</span>
    &lt;<a class="Mt" href="mailto:yokota@FreeBSD.org">yokota@FreeBSD.org</a>&gt;.</p>
</section>
</div>
<table class="foot">
  <tr>
    <td class="foot-date">December 3, 1997</td>
    <td class="foot-os">FreeBSD 15.0</td>
  </tr>
</table>