Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 3 Sep 2001 17:20:16 +0900 (JST)
From:      Toshihiko ARAI <toshi@jp.FreeBSD.org>
To:        Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
Cc:        current@FreeBSD.org
Subject:   Re: keyboard reset (was: Re: FreeBSD's aggressive keyboard probe/attach)
Message-ID:  <200109030820.f838KGd17031.toshi@jp.FreeBSD.org>
In-Reply-To: <bulk.3581.20010816065507@hub.freebsd.org>
References:  <bulk.3581.20010816065507@hub.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
+ Kazutaka YOKOTA wrote:

> We can improve our current behavior of syscons and keyboard drivers
> in the following approaches.

> a) Remove the FAIL_IF_NO_KBD flag from /boot/device.hints.
>    Leave the AUTO_DETECT_KBD as it is now for syscons, so that
>    syscons searches for a keyboard periodically while it isn't using
>    one. Add a script to /etc/usbd.conf to switch to the USB keyboard.

I use the following scripts.  This /etc/usb_kbd was an improvement
version and became a topic with "-tech-jp ML" in Japan before a
little.  When you use it, please do "chmod +x".  And you can use
below four variables with rc.conf.

 keymap_<keyboard>
 keyrate_<keyboard>
 keybell_<keyboard>
 keychange_<keyboard>

<keyboard> is device name of an USB keyboard.

For example, when you use a "jp.106x" keymap with ukbd0, you add
keymap_ukbd0="jp.106x" line to /etc/rc.conf.  And other variable are
similar, too.

However, a case to use several USB keyboards is a testing shortage.
And keyboard device will not accord with variable name of rc.conf by
order to connect an USB keyboard to.

> I always liked the idea b), but haven't designed it yet.

I like b) plan, too.

--
Toshihiko ARAI


-----/etc/usbd.conf-----
# This entry changes a console keyboard to an USB keyboard when connected it.
# And switch back to keyboard just before that when disconnected.
#
device "USB keyboard"
	devname "ukbd[0-9]+"
	attach	"/etc/usb_kbd ${DEVNAME} start"
	detach	"/etc/usb_kbd ${DEVNAME} stop"

-----/etc/usb_kbd-----
#!/bin/sh -
#
# $FreeBSD$
#
# usb_kbd devname [start|stop]
#
# example: usb_kbd ukbd0 start
#

# Suck in the configuration variables
#
if [ -r /etc/defaults/rc.conf ]; then
        . /etc/defaults/rc.conf
        source_rc_confs
elif [ -r /etc/rc.conf ]; then
        . /etc/rc.conf
fi

kbdhist=/var/run/usb_kbd.hist
kbddev=
ttydev=/dev/ttyv0
devname=$1
shift
startstop=$1
shift

case ${startstop} in
[Ss][Tt][Aa][Rr][Tt] | '')
	# To change system console by insertion of USB keyboard.
	#
	# Acquire a keyboard device name from a message of
	# "kbd1 at ukbd0" of dmesg command.
	#
	kbddev=`dmesg | sed -n -e "/at ${devname}\\$/h" \
			       -e '${ g
				      s///p
				    }'`
	[ -z ${kbddev} ] && kbddev=kbd1	# XXX
	kbdcontrol -k /dev/${kbddev} < ${ttydev} || exit

	# Append pair of device name into history file.
	echo "${kbddev} ${devname}" >> ${kbdhist}

	# You can use following four variables.
	# For example,
	#   keymap_ukbd0="jp.106x"
	# and rc.conf(5) may be helpful for you.
	#
	eval keymap=\$keymap_${devname}
	eval keyrate=\$keyrate_${devname}
	eval keybell=\$keybell_${devname}
	eval keychange=\$keychange_${devname}

	# Reference from src/etc/rc.syscons
	# keymap
	#
	case ${keymap} in
	[Nn][Oo] | '')
		;;
	*)
		kbdcontrol < ${ttydev} -l ${keymap}
		;;
	esac

	# keyrate
	#
	case ${keyrate} in
	[Nn][Oo] | '')
		;;
	*)
		kbdcontrol < ${ttydev} -r ${keyrate}
		;;
	esac

	# keybell
	#
	case ${keybell} in
	[Nn][Oo] | '')
		;;
	*)
		kbdcontrol < ${ttydev} -b ${keybell}
		;;
	esac

	# change function keys
	#
	case ${keychange} in
	[Nn][Oo] | '')
		;;
	*)
		set - ${keychange}
		while [ $# -gt 0 ]; do
			kbdcontrol <${ttydev} -f "$1" "$2"
			shift; shift
		done
		;;
	esac
	;;
*)
	# To switch back to keyboard before one by removal of
	# USB keyboard.
	#
	if [ -s ${kbdhist} ]; then
		#
		# Delete a current keyboard from history file
		# and get a last keyboard device name.
		#
		kbddev=`sed -e "/ ${devname}\\$/d" -e "w ${kbdhist}.tmp" \
				${kbdhist} | sed -n '$s/ .*$//p'`
		mv ${kbdhist}.tmp ${kbdhist}
	fi
	[ -z ${kbddev} ] && kbddev=kbd0
	kbdcontrol -k /dev/${kbddev} < ${ttydev}
	;;
esac

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200109030820.f838KGd17031.toshi>