xref: /freebsd/share/man/man4/uhid.4 (revision 2a63c3be158216222d89a073dcbd6a72ee4aab5a)
1.\" $NetBSD: uhid.4,v 1.13 2001/12/29 14:41:59 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.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28.\" POSSIBILITY OF SUCH DAMAGE.
29.\"
30.\" $FreeBSD$
31.\"
32.Dd Oct 31, 2020
33.Dt UHID 4
34.Os
35.Sh NAME
36.Nm uhid
37.Nd USB generic HID support
38.Sh SYNOPSIS
39To compile this driver into the kernel,
40place the following line in your
41kernel configuration file:
42.Bd -ragged -offset indent
43.Cd "device uhid"
44.Cd "device hid"
45.Cd "device usb"
46.Ed
47.Pp
48Alternatively, to load the driver as a
49module at boot time, place the following line in
50.Xr loader.conf 5 :
51.Bd -literal -offset indent
52uhid_load="YES"
53.Ed
54.Sh DESCRIPTION
55The
56.Nm
57driver provides support for all HID (Human Interface Device) interfaces
58in USB devices that do not have a special driver.
59.Pp
60The device handles the following
61.Xr ioctl 2
62calls:
63.Bl -tag -width indent
64.It Dv USB_GET_REPORT_ID Pq Vt int
65Get the report identifier used by this HID report.
66.It Dv USB_GET_REPORT_DESC Pq Vt "struct usb_gen_descriptor"
67Get the HID report descriptor.
68Copies a maximum of
69.Va ugd_maxlen
70bytes of the report descriptor data into the memory
71specified by
72.Va ugd_data .
73Upon return
74.Va ugd_actlen
75is set to the number of bytes copied.
76Using
77this descriptor the exact layout and meaning of data to/from
78the device can be found.
79The report descriptor is delivered
80without any processing.
81.Bd -literal
82struct usb_gen_descriptor {
83	void   *ugd_data;
84	uint16_t ugd_maxlen;
85	uint16_t ugd_actlen;
86	uint8_t	ugd_report_type;
87	...
88};
89.Ed
90.It Dv USB_SET_IMMED Pq Vt int
91Sets the device in a mode where each
92.Xr read 2
93will return the current value of the input report.
94Normally
95a
96.Xr read 2
97will only return the data that the device reports on its
98interrupt pipe.
99This call may fail if the device does not support
100this feature.
101.It Dv USB_GET_REPORT Pq Vt "struct usb_gen_descriptor"
102Get a report from the device without waiting for data on
103the interrupt pipe.
104Copies a maximum of
105.Va ugd_maxlen
106bytes of the report data into the memory specified by
107.Va ugd_data .
108Upon return
109.Va ugd_actlen
110is set to the number of bytes copied.
111The
112.Va ugd_report_type
113field indicates which report is requested.
114It should be
115.Dv UHID_INPUT_REPORT ,
116.Dv UHID_OUTPUT_REPORT ,
117or
118.Dv UHID_FEATURE_REPORT .
119This call may fail if the device does not support this feature.
120.It Dv USB_SET_REPORT Pq Vt "struct usb_gen_descriptor"
121Set a report in the device.
122The
123.Va ugd_report_type
124field indicates which report is to be set.
125It should be
126.Dv UHID_INPUT_REPORT ,
127.Dv UHID_OUTPUT_REPORT ,
128or
129.Dv UHID_FEATURE_REPORT .
130The value of the report is specified by the
131.Va ugd_data
132and the
133.Va ugd_maxlen
134fields.
135This call may fail if the device does not support this feature.
136.It Dv USB_GET_DEVICEINFO Pq Vt "struct usb_device_info"
137Returns information about the device, like USB vendor ID and USB product ID.
138This call will not issue any USB transactions.
139Also refer to
140.Xr ugen 4 .
141.El
142.Pp
143Use
144.Xr read 2
145to get data from the device.
146Data should be read in chunks of the
147size prescribed by the report descriptor.
148.Pp
149Use
150.Xr write 2
151to send data to the device.
152Data should be written in chunks of the
153size prescribed by the report descriptor.
154.Sh SYSCTL VARIABLES
155The following variables are available as both
156.Xr sysctl 8
157variables and
158.Xr loader 8
159tunables:
160.Bl -tag -width indent
161.It Va hw.usb.uhid.debug
162Debug output level, where 0 is debugging disabled and larger values increase
163debug message verbosity.
164Default is 0.
165.El
166.Sh FILES
167.Bl -tag -width ".Pa /dev/uhid?"
168.It Pa /dev/uhid?
169.El
170.Sh SEE ALSO
171.Xr usbhidctl 1 ,
172.Xr usb 4
173.Sh HISTORY
174The
175.Nm
176driver
177appeared in
178.Nx 1.4 .
179This manual page was adopted from
180.Nx
181by
182.An Tom Rhodes Aq Mt trhodes@FreeBSD.org
183in April 2002.
184