1.\" $FreeBSD$ 2.\" $NetBSD: usbhidaction.1,v 1.8 2003/02/25 10:35:59 wiz Exp $ 3.\" 4.\" Copyright (c) 2000 The NetBSD Foundation, Inc. 5.\" All rights reserved. 6.\" 7.\" This code is derived from software contributed to The NetBSD Foundation 8.\" by Lennart Augustsson (lennart@augustsson.net). 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.\" 3. All advertising materials mentioning features or use of this software 19.\" must display the following acknowledgement: 20.\" This product includes software developed by the NetBSD 21.\" Foundation, Inc. and its contributors. 22.\" 4. Neither the name of The NetBSD Foundation nor the names of its 23.\" contributors may be used to endorse or promote products derived 24.\" from this software without specific prior written permission. 25.\" 26.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 30.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36.\" POSSIBILITY OF SUCH DAMAGE. 37.\" 38.Dd April 9, 2003 39.Dt USBHIDACTION 1 40.Os 41.Sh NAME 42.Nm usbhidaction 43.Nd perform actions according to USB HID controls 44.Sh SYNOPSIS 45.Nm 46.Op Fl diev 47.Fl c Ar config-file 48.Fl f Ar device 49.Op Fl p Ar pidfile 50.Ar arg ... 51.Sh DESCRIPTION 52The 53.Nm 54utility 55can be used to execute commands when certain values appear on HID controls. 56The normal operation for this program is to read the configuration file 57and then become a daemon and execute commands as the HID items specify. 58If a read from the HID device fails, the program dies; this will make it 59die when the USB device is unplugged. 60.Pp 61The options are as follows: 62.Bl -tag -width indent 63.It Fl d 64Toggle the daemon flag. 65.It Fl e 66Instruct 67.Nm 68to die early. 69Useful when specified with multiple verbose options to see how files are parsed. 70.It Fl i 71Ignore HID items in the configuration file that do not exist in the device. 72.It Fl v 73Be verbose, and do not become a daemon. 74.It Fl c Ar config-file 75Specify a path name for the configuration file. 76.It Fl f Ar device 77Specify a path name for the device to operate on. 78If 79.Ar device 80is numeric, it is taken to be the USB HID device number. 81If it is a relative 82path, 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 p Ar pidfile 86Specify an alternate file in which to store the process ID. 87.El 88.Pp 89The configuration file will be re-read if the process gets a 90.Dv SIGHUP 91signal. 92.Sh CONFIGURATION 93The configuration file has a very simple format. 94Each line describes an 95action; if a line begins with a whitespace, it is considered a continuation 96of the previous line. 97Lines beginning with 98.Ql # 99are considered as comments. 100.Pp 101Each line has four parts: a name of a USB HID item, a value for that item, 102a debounce value, and an action. 103There must be whitespace between the parts. 104.Pp 105The item names are similar to those used by 106.Xr usbhidctl 1 , 107but each part must be prefixed by its page name. 108.Pp 109The value is simply a numeric value. 110When the item reports this value, 111the action will be performed. 112If the value is 113.Ql * , 114it will match any value. 115.Pp 116The debounce value is an integer not less than 0. 117The value of 0 indicates that no debouncing should occur. 118A value of 1 will only execute the action when the state changes. 119Values greater than one specify that an action should be performed 120only when the value changes by that amount. 121.Pp 122The action is a normal command that is executed with 123.Xr system 3 . 124Before it is executed some substitution will occur: 125.Ql $n 126will be replaced by the 127.Ar n Ns th 128argument on the command line, 129.Ql $V 130will be replaced by the numeric value of the HID item, 131.Ql $N 132will be replaced by the name of the control, and 133.Ql $H 134will be replaced by the name of the HID device. 135.Sh FILES 136.Bl -tag -width ".Pa /usr/share/misc/usb_hid_usages" 137.It Pa /usr/share/misc/usb_hid_usages 138The HID usage table. 139.It Pa /var/run/usbaction.pid 140The default location of the PID file. 141.El 142.Sh EXAMPLES 143The following configuration file can be used to control a pair 144of Philips USB speakers with the HID controls on the speakers. 145.Bd -literal -offset indent 146# Configuration for various Philips USB speakers 147Consumer:Volume_Up 1 0 mixer -f $1 vol +1 148Consumer:Volume_Down 1 0 mixer -f $1 vol -1 149# mute not supported 150#Consumer:Mute 1 0 mixer -f $1 mute 151Consumer:Channel_Top.Microsoft:Base_Up 1 0 mixer -f $1 bass +1 152Consumer:Channel_Top.Microsoft:Base_Down 1 0 mixer -f $1 bass -1 153.Ed 154.Pp 155A sample invocation using this configuration would be 156.Pp 157.Dl "usbhidaction -f /dev/uhid1 -c conf /dev/mixer1" 158.Pp 159The following example controls the mixer volume using a Logitech Wingman. 160Notice the debounce of 1 for buttons and 5 for the slider. 161.Bd -literal -offset indent 162Button:Button_1 1 1 mixer vol +10 163Button:Button_2 1 1 mixer vol -10 164Generic_Desktop:Z * 5 mixer vol `echo $V | awk '{print int($$1/255*100)}'` 165.Ed 166.Sh SEE ALSO 167.Xr usbhidctl 1 , 168.Xr usbhid 3 , 169.Xr uhid 4 , 170.Xr usb 4 171.Sh HISTORY 172The 173.Nm 174command first appeared in 175.Nx 1.6 . 176The 177.Nm 178command appeared in 179.Fx 5.1 . 180