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