determining keyboard type

David C. Martin dcmartin at sun.com
Sat Jul 22 03:20:43 AEST 1989


I have a Sun4/110 with the new type 4 keyboard (which is actually okay,
although there are always problems w/ keyboards other than the z19).

Anyway, I wanted to determine what my keyboard type was and wrote the
following quick program to "do the right thing" so I could remap the keys.
However, I get SUN3 as my keyboard type (not SUN4).

#include <sys/file.h>
#include <sys/types.h>
#include <sundev/kbd.h>
#include <sundev/kbio.h>

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

    /* open descriptor on keyboard device */
    if ((fd = open("/dev/kbd", O_RDONLY)) == -1) {
	perror("open");
	exit(-1);
    }
    /* do ioctl on device */
    if (ioctl(fd, KIOCTYPE, &type) == -1) {
	perror("ioctl");
	exit(-1);
    }
    /* close descriptor */
    close(fd);
    /* print type of keyboard */
    switch(type) {
    case KB_KLUNK: printf("KLUNK\n"); break;
    case KB_VT100: printf("VT100\n"); break;
    case KB_ASCII: printf("ASCII\n"); break;
    case KB_SUN2: printf("SUN2\n"); break;	
    case KB_SUN3: printf("SUN3\n"); break;	
    case KB_SUN4: printf("SUN4\n"); break;	
    }
}

What I would like to know is where the keyboard type is specified...  I
tried the eeprom program and it thinks the keyboard is type 0 (Micro
Switch).  Is the type specified in the kernel conf file, or is it
determined at startup?

Thanks in advance.

dcm



More information about the Comp.sys.sun mailing list