xref: /openbsd-src/share/man/man4/uhid.4 (revision 485a803ccb3ed338c32f816c96f057ab0d3188e5)
1.\" $OpenBSD: uhid.4,v 1.20 2021/09/15 04:59:26 anton Exp $
2.\" $NetBSD: uhid.4,v 1.13 2001/12/29 14:41:59 augustss Exp $
3.\"
4.\" Copyright (c) 1999, 2001 The NetBSD Foundation, Inc.
5.\" All rights reserved.
6.\"
7.\" This code is derived from software contributed to The NetBSD Foundation
8.\" by Lennart Augustsson.
9.\"
10.\" Redistribution and use in source and binary forms, with or without
11.\" modification, are permitted provided that the following conditions
12.\" are met:
13.\" 1. Redistributions of source code must retain the above copyright
14.\"    notice, this list of conditions and the following disclaimer.
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\"    notice, this list of conditions and the following disclaimer in the
17.\"    documentation and/or other materials provided with the distribution.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29.\" POSSIBILITY OF SUCH DAMAGE.
30.\"
31.Dd $Mdocdate: September 15 2021 $
32.Dt UHID 4
33.Os
34.Sh NAME
35.Nm uhid
36.Nd USB generic HID support
37.Sh SYNOPSIS
38.Cd "uhid* at uhidev?"
39.Pp
40.In dev/usb/usb.h
41.Sh DESCRIPTION
42The
43.Nm
44driver provides support for all HID (Human Interface Device) interfaces
45in USB devices that do not have a special driver.
46.Pp
47The device handles the following
48.Xr ioctl 2
49calls:
50.Bl -tag -width indent
51.It Dv USB_GET_DEVICEINFO Fa struct usb_device_info *devinfo
52Get summarized information about the device.
53.It Dv USB_GET_REPORT_ID Fa int *repid
54Get the report identifier used by this HID report.
55.It Dv USB_GET_REPORT_DESC Fa struct usb_ctl_report_desc *repdesc
56Get the HID report descriptor.
57Using this descriptor the exact layout and meaning of data to/from
58the device can be found.
59The report descriptor is delivered without any processing.
60.Bd -literal
61struct usb_ctl_report_desc {
62    int     ucrd_size;
63    u_char  ucrd_data[1024];	/* filled data size will vary */
64};
65.Ed
66.It Dv USB_GET_REPORT Fa struct usb_ctl_report *rep
67Get a report from the device without waiting for data on
68the interrupt pipe.
69The
70.Fa ucr_report
71field indicates which report is requested.
72It should be
73.Dv UHID_INPUT_REPORT ,
74.Dv UHID_OUTPUT_REPORT ,
75or
76.Dv UHID_FEATURE_REPORT .
77.Bd -literal
78struct usb_ctl_report {
79	int	ucr_report;
80	u_char	ucr_data[1024];	/* filled data size will vary */
81};
82.Ed
83.It Dv USB_SET_REPORT Fa struct usb_ctl_report *rep
84Set a report in the device.
85The
86.Dv report
87field indicates which report is to be set.
88It should be
89.Dv UHID_INPUT_REPORT ,
90.Dv UHID_OUTPUT_REPORT ,
91or
92.Dv UHID_FEATURE_REPORT .
93.El
94.Pp
95The generic ioctls
96.Dv FIONBIO
97and
98.Dv FIOASYNC
99are supported by
100.Nm .
101.Pp
102Use
103.Xr read 2
104to get data from the device.
105Data should be read in chunks of the size prescribed by the report descriptor.
106.Pp
107Use
108.Xr write 2
109to send data to the device.
110Equivalent to issuing an
111.Xr ioctl 2
112.Dv USB_SET_REPORT
113request with the report set to
114.Dv UHID_OUTPUT_REPORT .
115Data should be written in chunks of the size prescribed by the report
116descriptor.
117.Sh FILES
118.Bl -tag -width /dev/tun* -compact
119.It Pa /dev/uhid*
120.El
121.Sh ERRORS
122If
123.Xr ioctl 2
124fails,
125.Xr errno 2
126is set to one of the following:
127.Bl -tag -width Er
128.It Bq Er EIO
129The device could not fulfill a
130.Dv USB_GET_REPORT
131or
132.Dv USB_SET_REPORT
133request.
134.It Bq Er EINVAL
135The report specified by the
136.Fa ucr_report
137field in a
138.Dv USB_GET_REPORT
139or
140.Dv USB_SET_REPORT
141request was invalid.
142.It Bq Er ENOTTY
143Unrecognized command.
144.El
145.Pp
146If
147.Xr read 2
148fails,
149.Xr errno 2
150is set to one of the following:
151.Bl -tag -width Er
152.It Bq Er EIO
153The device has already been detached.
154.It Bq Er EWOULDBLOCK
155Non-blocking I/O was selected and no data were available.
156.El
157.Pp
158If
159.Xr write 2
160fails,
161.Xr errno 2
162is set to one of the following:
163.Bl -tag -width Er
164.It Bq Er EIO
165The device has already been detached or the same device does not have a
166corresponding output report.
167.It Bq Er EMSGSIZE
168The size of the supplied data exceeds the size of the output report.
169.El
170.Sh SEE ALSO
171.Xr usbhidctl 1 ,
172.Xr usbhid 3 ,
173.Xr intro 4 ,
174.Xr uhidev 4 ,
175.Xr usb 4
176.Sh HISTORY
177The
178.Nm
179driver
180appeared in
181.Ox 2.6 .
182