This implements /dev/kbmap, to allow the keyboard map to be changed.

Based on C H Forsyth's work [see end].

Latin-1 support added by:

    Boyd Roberts <boyd@insultant.net>

	RESTRICTIONS
i've currently modified only the /sys/src/9/pc/kbd.c driver
to support kbmap's interface.
partly because of that, the declarations for the interface routines
are in /sys/src/9/pc/fns.h instead of /sys/src/9/port/portfns.h.

my use of values in the Unicode private use area to encode
certain `Special' keys in the driver might not be the best approach.

arguably kbmap might become a kbdctl device in devcons.c

	INSTALLATION

cp port/devkbmap.c /sys/src/9/port
cp man/kbmap /sys/man/3
cp pc/kbd.c /sys/src/9/pc

add the following lines to /sys/src/9/pc/fns.h:

int	kbdgetmap(int, int*, int*, Rune*);
void	kbdputmap(ushort, ushort, Rune);

put them after:

void	kbdinit(void);

	CONFIGURATION

add the line
	kbmap	κ
to /sys/src/9/port/master
for kernels in which you'd like to configure the driver.
The device character is 03BA  *k          κ	greek small letter kappa
by the way.
Rebuild and install the kernels (be sensible and save the previous copy).

	USE

To configure a UK keyboard, I run the following script:

echo 0 43 ''''^'#'
echo 1 43 ''''^'~'
echo 1 3 ''''^'"'
echo 1 4 ''''^£
echo 1 40 ''''^'@'
echo 0 86 ''''\
echo 1 86 ''''^'|'

with output redirected to #κ/kbmap .
Note that a write must send complete records, so
	cp '#κ/kbmap' /tmp/kbmap
	cp /tmp/kbmap 'κ/kbmap'
won't work because one of the lines is split across writes.

Tables:
	0	unshifted
	1	shifted
	2	e0 x or e0 e1 x
it's possible the latter table should be split in two.
if you haven't a table of scan codes to hand, you can try
	cat /dev/klog&
and then type keys.  the hex value of any unrecognised code
(one mapped to 0) will be printed in /dev/klog.

C H Forsyth
forsyth@plan9.cs.york.ac.uk
Mon Sep 23 14:57:41 BST 1996
