Type 4 keyboard remapping program, and comments on the Type 4

Guy Harris auspex!guy at uunet.uu.net
Tue Jun 13 03:56:19 AEST 1989


Here's a program that somebody sent me, which will remap some of the keys
and let you shuffle them to a layout that might be more convenient for
people used to the Type 3's layout - it swaps the Delete and Back Space
keys, swaps the (| \) and (~ `) keys, and makes the Caps Lock key a shift
key. 

The person who sent me the program also sends along some comments on the
Type 4 and other Sun keyboards, which include some points worth noting,
including the fact that the Type 3 had its share of problems, and that the
Type 4 was intended to address some of those problems (and, as someone
who's used both Type 3 and Type 4 keyboards, the Type 4 at least addressed
some of those problems for me), and the fact that all keyboards are
compromises - I've yet to see one at which *nobody* got annoyed.

--- Begin comments

Just as many people complained about the type 3 keyboard when it was
introduced as are now complaining about the type 4.  What they're really
complaining about is change, not the goodness or badness of the new
keyboard.

The type 3 keyboard had generated *many* complaints over its lifetime.
The type 4 keyboard was introduced to answer many of those complaints.
The biggest complaints against the type 3 keyboard had to do with
internationalization, PC compatibility, "feel" of the keys, and
"sturdiness" of the keyboard.  The type 4 keyboard was not introduced to
make people mad, it was introduced *in response to* customer complaints
about the type 3 keyboard.

All keyboards are a compromise.  The cost to offer many keyboards with
different compromises is prohibitive.

When moving from one keyboard to a second keyboard that requires a
different amount of pressure to activate the keys, or has a slightly
different key layout, you'll find that at first you make more mistakes on
the second keyboard.  This is almost always due to the *change*, not due
to any attribute of the second keyboard.

Rumor has it that the manufacturer of the type 3 keyboard is going out of
business because they sold them to Sun at too low a cost.

The best keyboard Sun ever sold was the type 2 "silent" keyboard.  The
type 3 was among the worst.  :-)

The type 4 keyboard layout is easily changed to something much more
acceptable through the use of the following program (called type4fix).
Run this from rc.boot.  In 4.1 this is done even more easily using the
"loadkeys" program.  Swap the keycaps for delete and backspace and for |\
and ~` and you'll be much happier.


--- type4fix.c
#include <stdio.h>
#include <sys/types.h>
#include <sundev/kbio.h>
#include <sundev/kbd.h>

int kbd;

int tab[] = { 0, CAPSMASK, SHIFTMASK, CTRLMASK };

main(argc, argv)
	int argc;
	char **argv;
{
	int type;
	int i;

	kbd = open("/dev/kbd", 2);
	if (kbd < 0) {
		perror("/dev/kbd");
		exit(1);
	}
	if (ioctl(kbd, KIOCTYPE, &type) < 0) {
		perror("KIOCTYPE");
		exit(1);
	}
/*
	printf("type %d\n", type);
*/
	if (type != 3 && type != 4) {
		fprintf(stderr, "Wrong keyboard type (%d)\n", type);
		exit(1);
	}
	swap(66, 43);	/* swap delete and backspace */
	swap(88, 42);	/* swap |\ and ~` */
	copy(99, 119);	/* make caps lock be a shift */
	exit(0);
}

swap(k1, k2)
	int k1, k2;
{
	struct kiockey kc1, kc2;
	int i;

	for (i = 0; i < 4; i++) {
		kc1.kio_tablemask = tab[i];
		kc1.kio_station = k1;
		if (ioctl(kbd, KIOCGETKEY, &kc1) < 0) {
			perror("KIOCGETKEY");
			exit(1);
		}
		kc2.kio_tablemask = tab[i];
		kc2.kio_station = k2;
		if (ioctl(kbd, KIOCGETKEY, &kc2) < 0) {
			perror("KIOCGETKEY");
			exit(1);
		}
		kc1.kio_station = k2;
		kc2.kio_station = k1;
		if (ioctl(kbd, KIOCSETKEY, &kc1) < 0) {
			perror("KIOCSETKEY");
			exit(1);
		}
		if (ioctl(kbd, KIOCSETKEY, &kc2) < 0) {
			perror("KIOCSETKEY");
			exit(1);
		}
	}
}

copy(k1, k2)
	int k1, k2;
{
	struct kiockey kc, kc2;
	int i;

	for (i = 0; i < 4; i++) {
		kc.kio_tablemask = tab[i];
		kc.kio_station = k1;
		if (ioctl(kbd, KIOCGETKEY, &kc) < 0) {
			perror("KIOCGETKEY");
			exit(1);
		}
		kc.kio_station = k2;
		if (ioctl(kbd, KIOCSETKEY, &kc) < 0) {
			perror("KIOCSETKEY");
			exit(1);
		}
	}
}

map(key, value, table)
	int key, value, table;
{
	struct kiockey kc;

	kc.kio_tablemask = table;
	kc.kio_station = key;
	if (ioctl(kbd, KIOCGETKEY, &kc) < 0) {
		perror("KIOCGETKEY");
		exit(1);
	}
	kc.kio_entry = value;
	if (ioctl(kbd, KIOCSETKEY, &kc) < 0) {
		perror("KIOCSETKEY");
		exit(1);
	}
}



More information about the Comp.sys.sun mailing list