Subject: RAW keyboard mode support
To: NetBSD port-hpcmips <port-hpcmips@netbsd.org>
From: TAKEMURA Shin <takemura@netbsd.org>
List: port-hpcmips
Date: 05/04/2000 17:39:58
I've added raw keyboard mode support to the kernel as same as NetBSD/i386.
Key codes are compatible with PC keyboard.
Here is tiny sample program. You can push ESC key to quit the program.

Takemura

----- begin
#define COMPAT_USL

#include <stdio.h>
#include <termios.h>
#include <sys/ioctl.h>
#ifdef COMPAT_USL
#include <dev/wscons/wsdisplay_usl_io.h>
#else
#include <time.h>
#include <dev/wscons/wsconsio.h>
#endif

main()
{
        struct termios kbdtty, tkbdtty;
        int c;
        int fd = 0; /* standard input */
        int kbmode;

#ifdef COMPAT_USL
        if (ioctl(fd, KDSKBMODE, K_RAW) < 0)
#else
        kbmode = WSKBD_RAW;
        if (ioctl(fd, WSKBDIO_SETMODE, &kbmode) < 0)
#endif
        {
                perror("ioctl");
                exit(1);
        }

        tcgetattr(fd, &kbdtty);
        tkbdtty = kbdtty;
        tkbdtty.c_iflag = IGNPAR | IGNBRK;
        tkbdtty.c_oflag = 0;
        tkbdtty.c_cflag = CREAD | CS8;
        tkbdtty.c_lflag = 0;
        tkbdtty.c_cc[VTIME] = 0;
        tkbdtty.c_cc[VMIN] = 1;
        cfsetispeed(&tkbdtty, 9600);
        cfsetospeed(&tkbdtty, 9600);
        tcsetattr(fd, TCSANOW, &tkbdtty);

        while ((c = getc(stdin)) != 0x81 /* release ESC */) {
                printf("%02x\n", c);
        }

        tcsetattr(fd, TCSANOW, &kbdtty);
}
----- end