xref: /netbsd-src/share/man/man4/uhid.4 (revision e5548b402ae4c44fb816de42c7bba9581ce23ef5)
1.\" $NetBSD: uhid.4,v 1.19 2005/11/23 08:56:08 augustss Exp $
2.\"
3.\" Copyright (c) 1999, 2001 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by Lennart Augustsson.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\" 3. All advertising materials mentioning features or use of this software
18.\"    must display the following acknowledgement:
19.\"        This product includes software developed by the NetBSD
20.\"        Foundation, Inc. and its contributors.
21.\" 4. Neither the name of The NetBSD Foundation nor the names of its
22.\"    contributors may be used to endorse or promote products derived
23.\"    from this software without specific prior written permission.
24.\"
25.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35.\" POSSIBILITY OF SUCH DAMAGE.
36.\"
37.Dd November 22, 2005
38.Dt UHID 4
39.Os
40.Sh NAME
41.Nm uhid
42.Nd USB generic HID support
43.Sh SYNOPSIS
44.Cd "uhid* at uhidev? reportid ? flags N"
45.Sh DESCRIPTION
46The
47.Nm
48driver provides support for all HID (Human Interface Device) interfaces
49in USB devices that do not have a special driver.
50.Pp
51Normally the
52.Nm
53driver is used when no other HID driver attaches to a device.
54If
55.Dq flags 1
56is specified, the
57.Nm
58driver will instead attach with a very high priority and always be used.
59Together with the
60.Cd vendor
61and
62.Cd product
63locators on the
64.Xr uhidev 4
65driver this can be used to force the
66.Nm
67driver to be used for a certain device.
68.Pp
69The device handles the following
70.Xr ioctl 2
71calls:
72.Pp
73.Bl -tag -width indent
74.It Dv USB_GET_REPORT_ID (int)
75Get the report identifier used by this HID report.
76.It Dv USB_GET_REPORT_DESC (struct usb_ctl_report_desc)
77Get the HID report descriptor.
78Using this descriptor the exact layout and meaning of data to/from
79the device can be found.
80The report descriptor is delivered without any processing.
81.Bd -literal
82struct usb_ctl_report_desc {
83    int     ucrd_size;
84    u_char  ucrd_data[1024];	/* filled data size will vary */
85};
86.Ed
87.It Dv USB_SET_IMMED (int)
88Sets the device in a mode where each
89.Xr read 2
90will return the current value of the input report.
91Normally a
92.Xr read 2
93will only return the data that the device reports on its
94interrupt pipe.
95This call may fail if the device does not support this feature.
96.It Dv USB_GET_REPORT (struct usb_ctl_report)
97Get a report from the device without waiting for data on
98the interrupt pipe.
99The
100.Dv report
101field indicates which report is requested.
102It should be
103.Dv UHID_INPUT_REPORT ,
104.Dv UHID_OUTPUT_REPORT ,
105or
106.Dv UHID_FEATURE_REPORT .
107This call may fail if the device does not support this feature.
108.Bd -literal
109struct usb_ctl_report {
110	int     ucr_report;
111	u_char	ucr_data[1024];	/* used data size will vary */
112};
113.Ed
114.It Dv USB_SET_REPORT (struct usb_ctl_report)
115Set a report in the device.
116The
117.Dv report
118field indicates which report is to be set.
119It should be
120.Dv UHID_INPUT_REPORT ,
121.Dv UHID_OUTPUT_REPORT ,
122or
123.Dv UHID_FEATURE_REPORT .
124This call may fail if the device does not support this feature.
125.It Dv USB_GET_DEVICEINFO (struct usb_device_info)
126Get an information summary for the device.
127This call will not issue any USB transactions.
128.It Dv USB_GET_STRING_DESC (struct usb_string_desc)
129Get a string descriptor for the given language id and
130string index.
131.Bd -literal
132struct usb_string_desc {
133	int	usd_string_index;
134	int	usd_language_id;
135	usb_string_descriptor_t usd_desc;
136};
137.Ed
138.El
139.Pp
140Use
141.Xr read 2
142to get data from the device.
143Data should be read in chunks of the size prescribed by the report
144descriptor.
145.Pp
146Use
147.Xr write 2
148send data to the device.
149Data should be written in chunks of the size prescribed by the
150report descriptor.
151.Sh FILES
152.Bl -tag -width Pa
153.It Pa /dev/uhid?
154.El
155.Sh SEE ALSO
156.Xr usbhidaction 1 ,
157.Xr usbhidctl 1 ,
158.Xr uhidev 4 ,
159.Xr usb 4
160.Sh HISTORY
161The
162.Nm
163driver
164appeared in
165.Nx 1.4 .
166Support for the
167.Dv USB_GET_DEVICEINFO
168and
169.Dv USB_GET_STRING_DESC
170ioctls appeared in
171.Nx 2.0 .
172