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.Dd Oct 31, 2020 31.Dt UHID 4 32.Os 33.Sh NAME 34.Nm uhid 35.Nd USB generic HID support 36.Sh SYNOPSIS 37To compile this driver into the kernel, 38place the following line in your 39kernel configuration file: 40.Bd -ragged -offset indent 41.Cd "device uhid" 42.Cd "device hid" 43.Cd "device usb" 44.Ed 45.Pp 46Alternatively, to load the driver as a 47module at boot time, place the following line in 48.Xr loader.conf 5 : 49.Bd -literal -offset indent 50uhid_load="YES" 51.Ed 52.Sh DESCRIPTION 53The 54.Nm 55driver provides support for all HID (Human Interface Device) interfaces 56in USB devices that do not have a special driver. 57.Pp 58The device handles the following 59.Xr ioctl 2 60calls: 61.Bl -tag -width indent 62.It Dv USB_GET_REPORT_ID Pq Vt int 63Get the report identifier used by this HID report. 64.It Dv USB_GET_REPORT_DESC Pq Vt "struct usb_gen_descriptor" 65Get the HID report descriptor. 66Copies a maximum of 67.Va ugd_maxlen 68bytes of the report descriptor data into the memory 69specified by 70.Va ugd_data . 71Upon return 72.Va ugd_actlen 73is set to the number of bytes copied. 74Using 75this descriptor the exact layout and meaning of data to/from 76the device can be found. 77The report descriptor is delivered 78without any processing. 79.Bd -literal 80struct usb_gen_descriptor { 81 void *ugd_data; 82 uint16_t ugd_maxlen; 83 uint16_t ugd_actlen; 84 uint8_t ugd_report_type; 85 ... 86}; 87.Ed 88.It Dv USB_SET_IMMED Pq Vt int 89Sets the device in a mode where each 90.Xr read 2 91will return the current value of the input report. 92Normally 93a 94.Xr read 2 95will only return the data that the device reports on its 96interrupt pipe. 97This call may fail if the device does not support 98this feature. 99.It Dv USB_GET_REPORT Pq Vt "struct usb_gen_descriptor" 100Get a report from the device without waiting for data on 101the interrupt pipe. 102Copies a maximum of 103.Va ugd_maxlen 104bytes of the report data into the memory specified by 105.Va ugd_data . 106Upon return 107.Va ugd_actlen 108is set to the number of bytes copied. 109The 110.Va ugd_report_type 111field indicates which report is requested. 112It should be 113.Dv UHID_INPUT_REPORT , 114.Dv UHID_OUTPUT_REPORT , 115or 116.Dv UHID_FEATURE_REPORT . 117This call may fail if the device does not support this feature. 118.It Dv USB_SET_REPORT Pq Vt "struct usb_gen_descriptor" 119Set a report in the device. 120The 121.Va ugd_report_type 122field indicates which report is to be set. 123It should be 124.Dv UHID_INPUT_REPORT , 125.Dv UHID_OUTPUT_REPORT , 126or 127.Dv UHID_FEATURE_REPORT . 128The value of the report is specified by the 129.Va ugd_data 130and the 131.Va ugd_maxlen 132fields. 133This call may fail if the device does not support this feature. 134.It Dv USB_GET_DEVICEINFO Pq Vt "struct usb_device_info" 135Returns information about the device, like USB vendor ID and USB product ID. 136This call will not issue any USB transactions. 137Also refer to 138.Xr ugen 4 . 139.El 140.Pp 141Use 142.Xr read 2 143to get data from the device. 144Data should be read in chunks of the 145size prescribed by the report descriptor. 146.Pp 147Use 148.Xr write 2 149to send data to the device. 150Data should be written in chunks of the 151size prescribed by the report descriptor. 152.Sh SYSCTL VARIABLES 153The following variables are available as both 154.Xr sysctl 8 155variables and 156.Xr loader 8 157tunables: 158.Bl -tag -width indent 159.It Va hw.usb.uhid.debug 160Debug output level, where 0 is debugging disabled and larger values increase 161debug message verbosity. 162Default is 0. 163.El 164.Sh FILES 165.Bl -tag -width ".Pa /dev/uhid?" 166.It Pa /dev/uhid? 167.El 168.Sh SEE ALSO 169.Xr usbhidctl 1 , 170.Xr usb 4 171.Sh HISTORY 172The 173.Nm 174driver 175appeared in 176.Nx 1.4 . 177This manual page was adopted from 178.Nx 179by 180.An Tom Rhodes Aq Mt trhodes@FreeBSD.org 181in April 2002. 182