From owner-freebsd-mobile@FreeBSD.ORG Tue Jan 27 07:53:31 2004 Return-Path: Delivered-To: freebsd-mobile@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 371C516A4CF; Tue, 27 Jan 2004 07:53:31 -0800 (PST) Received: from smtp.des.no (flood.des.no [217.116.83.31]) by mx1.FreeBSD.org (Postfix) with ESMTP id 77E3743D72; Tue, 27 Jan 2004 07:52:35 -0800 (PST) (envelope-from des@des.no) Received: by smtp.des.no (Pony Express, from userid 666) id AA00B530A; Tue, 27 Jan 2004 16:52:33 +0100 (CET) Received: from dwp.des.no (des.no [80.203.228.37]) by smtp.des.no (Pony Express) with ESMTP id 9F4895308; Tue, 27 Jan 2004 16:52:22 +0100 (CET) Received: by dwp.des.no (Postfix, from userid 2602) id 189ED33C6A; Tue, 27 Jan 2004 16:52:22 +0100 (CET) To: src-committers@FreeBSD.org References: <200401271540.i0RFeUfB017996@repoman.freebsd.org> From: des@des.no (Dag-Erling =?iso-8859-1?q?Sm=F8rgrav?=) Date: Tue, 27 Jan 2004 16:52:22 +0100 In-Reply-To: <200401271540.i0RFeUfB017996@repoman.freebsd.org> (Dag-Erling Smorgrav's message of "Tue, 27 Jan 2004 07:40:30 -0800 (PST)") Message-ID: User-Agent: Gnus/5.090024 (Oort Gnus v0.24) Emacs/21.3 (berkeley-unix) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Checker-Version: SpamAssassin 2.61 (1.212.2.1-2003-12-09-exp) on flood.des.no X-Spam-Level: ss X-Spam-Status: No, hits=2.6 required=5.0 tests=RCVD_IN_DYNABLOCK, RCVD_IN_SORBS autolearn=no version=2.61 cc: mobile@freebsd.org Subject: Re: cvs commit: src/sys/dev/kbd kbd.c X-BeenThere: freebsd-mobile@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Mobile computing with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Jan 2004 15:53:31 -0000 --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Dag-Erling Smorgrav writes: > des 2004/01/27 07:40:30 PST > > FreeBSD src repository > > Modified files: > sys/dev/kbd kbd.c=20 > Log: > While USB keyboards attach as ukbd[0-9]+, the device node created by > kbd_attach() is called kbd[0-9]+, with a different unit number. This > makes it impossible to write a devd rule which will automatically > switch to a USB keyboard when one is attached, because there is no way > to guess the correct device node to pass to kbdcontrol. >=20=20=20 > Therefore, change kbd_attach() to create a device node using the > keyboard device's real name (atkbd0, ukbd0...), and create the > kbd[0-9]+ node as an alias for backward compatibility. >=20=20=20 > Revision Changes Path > 1.37 +2 -1 src/sys/dev/kbd/kbd.c I use the following in /etc/devd.conf on my laptop to make it DTRT regardless of whether it's in the docking station (USB keyboard and mouse), on my lap (PS/2 keyboard and trackpoint), or on my desk at home (PS/2 keyboard, USB mouse). attach 0 { device-name "ums[0-9]+"; action "/root/bin/usbmouse start $device-name"; }; detach 0 { device-name "ums[0-9]+"; action "/root/bin/usbmouse stop $device-name"; }; attach 0 { device-name "ukbd[0-9]+"; action "/root/bin/usbkeyboard start $device-name"; }; detach 0 { device-name "ukbd[0-9]+"; action "/root/bin/usbkeyboard stop $device-name"; }; The scripts are attached. Note that usbkeyboard will be confused if more than one USB keyboard are attached at any one time; my next project is to make it possible to have multiple keyboards active at the same time, just like we can have multiple mice active at the same time. DES --=20 Dag-Erling Sm=F8rgrav - des@des.no --=-=-= Content-Type: application/octet-stream Content-Disposition: attachment; filename=usbkeyboard #!/bin/sh usage() { echo 'usage: $0 start|stop ' 1>&2 exit 1 } [ $# -eq 2 ] || usage cmd="$1" device="$2" log="/root/usb.log" case "${cmd}" in start) exec >>"${log}" 2>&1 date "+[%F %T] attaching $device" /usr/sbin/kbdcontrol -k "/dev/$device" >"${log}" 2>&1 date "+[%F %T] detaching $device" /usr/sbin/kbdcontrol -k /dev/kbd0 ' 1>&2 exit 1 } [ $# -eq 2 ] || usage cmd="$1" device="$2" pidfile="/var/run/moused.$device" log="/root/usb.log" case "${cmd}" in start) exec >>"${log}" 2>&1 date "+[%F %T] attaching $device" /usr/sbin/moused -I "${pidfile}" -z 4 -p "/dev/$device" -t auto ;; stop) exec >>"${log}" 2>&1 date "+[%F %T] detaching $device" if [ -f "${pidfile}" ] ; then kill $(cat "${pidfile}") rm "${pidfile}" fi ;; *) usage ;; esac --=-=-=--