1.\" $OpenBSD: usbhidctl.1,v 1.16 2022/03/31 17:27:28 naddy Exp $ 2.\" $NetBSD: usbhidctl.1,v 1.14 2001/12/28 17:49:32 augustss Exp $ 3.\" 4.\" Copyright (c) 2001 The NetBSD Foundation, Inc. 5.\" All rights reserved. 6.\" 7.\" This code is derived from software contributed to The NetBSD Foundation 8.\" by David Sainty <David.Sainty@dtsp.co.nz> 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: March 31 2022 $ 32.Dt USBHIDCTL 1 33.Os 34.Sh NAME 35.Nm usbhidctl 36.Nd manipulate USB HID devices 37.Sh SYNOPSIS 38.Nm 39.Fl f Ar device 40.Op Fl t Ar table 41.Op Fl alv 42.Nm 43.Fl f Ar device 44.Op Fl t Ar table 45.Op Fl v 46.Fl r 47.Nm 48.Fl f Ar device 49.Op Fl t Ar table 50.Op Fl lnv 51.Ar name ... 52.Nm 53.Fl f Ar device 54.Op Fl t Ar table 55.Fl w Ar name Ns = Ns Ar value ... 56.Nm 57.Fl f Ar device 58.Fl R 59.Sh DESCRIPTION 60.Nm 61can be used to output or modify the state of a USB HID (Human Interface Device). 62If a list of items is present on the command line, then 63.Nm 64prints the current value of those items for the specified device. 65If the 66.Fl w 67flag is specified, 68.Nm 69attempts to set the specified items to the given values. 70.Pp 71The options are as follows: 72.Bl -tag -width Ds 73.It Fl a 74Show all items and their current values. 75This option fails if the device does not support the GET_REPORT command. 76This is the default, if no parameters other than 77.Fl f 78are given to 79.Nm . 80.It Fl f Ar device 81Specify a path name for the device to operate on. 82If 83.Ar device 84is numeric, it is taken to be the USB HID device number. 85If it is a relative path, it is taken to be the name of the device under 86.Pa /dev . 87An absolute path is taken to be the literal device pathname. 88.It Fl l 89Loop and dump the device data every time it changes. 90Only 'input' items are displayed in this mode. 91.It Fl n 92Suppress printing of the item name when querying specific items. 93Only output the current value. 94.It Fl R 95Dump the raw USB HID report descriptor data as hexadecimal bytes. 96.It Fl r 97Dump the USB HID report descriptor. 98.It Fl t Ar table 99Specify a path name for the HID usage table file. 100.It Fl v 101Be verbose. 102Repeating this option increases verbosity. 103.It Fl w 104Change item values. 105Only 'output' and 'feature' kinds can be set with this option. 106.El 107.Sh SYNTAX 108.Nm 109parses the names of items specified on the command line against the human 110interface items reported by the USB device. 111Each human interface item is mapped from its native form to a human readable 112name, using the HID usage table file. 113Command line items are compared with the generated item names, 114and the USB HID device is operated on when a match is found. 115.Pp 116Each human interface item is named by the 117.Qq page 118it appears in, the 119.Qq usage 120within that page, and the list of 121.Qq collections 122containing the item. 123Each collection in turn is also identified by page, and 124the usage within that page. 125.Pp 126On the 127.Nm 128command line the page name is separated from the usage name with the character 129.Sq Cm \&: . 130The collections are separated by the character 131.Sq Cm \&. . 132.Pp 133As an alternative notation in items on the command line, the native numeric 134value for the page name or usage can be used instead of the full human 135readable page name or usage name. 136Numeric values can be specified in decimal, octal or hexadecimal. 137.Sh FILES 138.Bl -tag -width "/usr/share/misc/usb_hid_usages" 139.It Pa /usr/share/misc/usb_hid_usages 140The default HID usage table. 141.El 142.Sh EXAMPLES 143On a standard USB mouse the item 144.Pp 145.Dl Generic_Desktop:Mouse.Generic_Desktop:Pointer.Button:Button_2 146.Pp 147reflects the current status of button 2. 148The 149.Qq button 2 150item is encapsulated within two collections, the 151.Qq Mouse 152collection in the 153.Qq Generic Desktop 154page, and the 155.Qq Pointer 156collection in the 157.Qq Generic Desktop 158page. 159The item itself is the usage 160.Qq Button_2 161in the 162.Qq Button 163page. 164.Pp 165An item can generally be named by omitting one or more of the page names. 166For example the 167.Qq button 2 168item would usually just be referred to on the command line as: 169.Pp 170.Dl $ usbhidctl -f /dev/wsmouse0 Mouse.Pointer.Button_2 171.Pp 172Items can also be named by referring to parts of the item name with the 173numeric representation of the native HID usage identifiers. 174This is most useful when items are missing from the HID usage table. 175The page identifier for the 176.Qq Generic Desktop 177page is 1, and the usage identifier for the usage 178.Qq Button_2 179is 2, so the following can be used to refer to the 180.Qq button 2 181item: 182.Pp 183.Dl $ usbhidctl -f /dev/wsmouse0 1:Mouse.1:Pointer.Button:2 184.Pp 185Devices with human interface outputs can be manipulated with the 186.Fl w 187option. 188For example, some USB mice have a Light Emitting Diode under software 189control as usage 2 under page 0xffff, in the 190.Qq Mouse 191collection. 192The following can be used to switch this LED off: 193.Pp 194.Dl $ usbhidctl -f /dev/wsmouse0 -w Mouse.0xffff:2=0 195.Sh SEE ALSO 196.Xr usbhidaction 1 , 197.Xr usbhid 3 , 198.Xr uhid 4 , 199.Xr usb 4 200.Sh HISTORY 201The 202.Nm 203command first appeared in 204.Ox 3.0 . 205.Sh AUTHORS 206.An David Sainty Aq Mt David.Sainty@dtsp.co.nz 207.Sh BUGS 208Some USB HID devices report multiple items with exactly the same usage 209identifiers. 210The current naming scheme does not provide the means to specify 211which of a set of identically named items you are referring to. 212