Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/macppc akbd's now have a raw mode, and implement th...



details:   https://anonhg.NetBSD.org/src/rev/a98146cad22b
branches:  trunk
changeset: 535283:a98146cad22b
user:      aymeric <aymeric%NetBSD.org@localhost>
date:      Tue Aug 13 15:00:42 2002 +0000

description:
akbd's now have a raw mode, and implement the WSKBDIO_SETMODE ioctl.
Adapted from OpenBSD.

diffstat:

 sys/arch/macppc/dev/akbd.c         |   78 ++++++++++-
 sys/arch/macppc/dev/akbdvar.h      |   15 +-
 sys/arch/macppc/include/keyboard.h |  272 +++++++++++++++++++-----------------
 3 files changed, 230 insertions(+), 135 deletions(-)

diffs (truncated from 455 to 300 lines):

diff -r 7c3e7f430fb9 -r a98146cad22b sys/arch/macppc/dev/akbd.c
--- a/sys/arch/macppc/dev/akbd.c        Tue Aug 13 14:05:41 2002 +0000
+++ b/sys/arch/macppc/dev/akbd.c        Tue Aug 13 15:00:42 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: akbd.c,v 1.25 2002/06/14 22:43:38 itojun Exp $ */
+/*     $NetBSD: akbd.c,v 1.26 2002/08/13 15:00:42 aymeric Exp $        */
 
 /*
  * Copyright (C) 1998  Colin Wood
@@ -33,6 +33,7 @@
 #include <sys/param.h>
 #include <sys/device.h>
 #include <sys/fcntl.h>
+#include <sys/kernel.h>
 #include <sys/poll.h>
 #include <sys/select.h>
 #include <sys/proc.h>
@@ -81,6 +82,9 @@
 int akbd_enable __P((void *, int));
 void akbd_set_leds __P((void *, int));
 int akbd_ioctl __P((void *, u_long, caddr_t, int, struct proc *));
+#ifdef WSDISPLAY_COMPAT_RAWKBD
+static void akbd_rawrepeat __P((void *));
+#endif
 
 struct wskbd_accessops akbd_accessops = {
        akbd_enable,
@@ -136,6 +140,10 @@
        u_char buffer[9];
        struct wskbddev_attach_args a;
 
+#ifdef WSDISPLAY_COMPAT_RAWKBD
+       callout_init(&sc->sc_rawrepeat_ch);
+#endif
+
        /* ohare based models have soft ejectable card slot. */
        if (OF_finddevice("/bandit/ohare") != -1)
                pcmcia_soft_eject = 1;
@@ -452,6 +460,10 @@
        int flag;
        struct proc *p;
 {
+#ifdef WSDISPLAY_COMPAT_RAWKBD
+       struct akbd_softc *sc = (struct akbd_softc *) v;
+#endif
+
        switch (cmd) {
 
        case WSKBDIO_GTYPE:
@@ -462,12 +474,39 @@
        case WSKBDIO_GETLEDS:
                *(int *)data = 0;
                return 0;
+#ifdef WSDISPLAY_COMPAT_RAWKBD
+       case WSKBDIO_SETMODE:
+               sc->sc_rawkbd = *(int *)data == WSKBD_RAW;
+               callout_stop(&sc->sc_rawrepeat_ch);
+               return 0;
+#endif
        }
        /* kbdioctl(...); */
 
        return EPASSTHROUGH;
 }
 
+#ifdef WSDISPLAY_COMPAT_RAWKBD
+static void
+akbd_rawrepeat(v)
+       void *v;
+{
+       struct akbd_softc *sc = (struct akbd_softc *) v;
+       int s = spltty();
+
+       /* check for race condition and avoid it */
+       if (sc->sc_nrep == 0) {
+               splx(s);
+               return;
+       }
+
+       wskbd_rawinput(sc->sc_wskbddev, sc->sc_rep, sc->sc_nrep);
+       splx(s);
+       callout_reset(&sc->sc_rawrepeat_ch, hz * AKBD_RAW_REPEAT_DELAYN / 1000,
+               akbd_rawrepeat, sc);
+}
+#endif
+
 extern int adb_polling;
 
 void
@@ -485,6 +524,43 @@
                        printf("akbd: dumping polled key 0x%02x\n",key);
                }
 #endif
+#ifdef WSDISPLAY_COMPAT_RAWKBD
+       } else if (sc->sc_rawkbd) {
+               char cbuf[AKBD_RAW_MAX_KEYS * 2];
+               int s;
+               int j = 0;
+               int npress = 0;
+               int c = keyboard[ADBK_KEYVAL(key)][3];
+
+               callout_stop(&sc->sc_rawrepeat_ch);
+
+               if (c == 0)                     /* XXX */
+                       return;
+
+               if (c & 0x80)
+                       cbuf[j++] = 0xe0;
+
+               cbuf[j++] = c & 0x7f;
+
+               if (!ADBK_PRESS(key))
+                       cbuf[j - 1] |= 0x80;
+               else {
+                       /* this only records last key pressed */
+                       if (c & 0x80)
+                               sc->sc_rep[npress++] = 0xe0;
+                       sc->sc_rep[npress++] = c & 0x7f;
+               }
+
+               s = spltty();
+               wskbd_rawinput(sc->sc_wskbddev, cbuf, j);
+               splx(s);
+
+               sc->sc_nrep = npress;
+               if (npress != 0)
+                       callout_reset(&sc->sc_rawrepeat_ch,
+                               hz * AKBD_RAW_REPEAT_DELAY1 / 1000,
+                               akbd_rawrepeat, sc);
+#endif
        } else {
                int press, val;
                int type;
diff -r 7c3e7f430fb9 -r a98146cad22b sys/arch/macppc/dev/akbdvar.h
--- a/sys/arch/macppc/dev/akbdvar.h     Tue Aug 13 14:05:41 2002 +0000
+++ b/sys/arch/macppc/dev/akbdvar.h     Tue Aug 13 15:00:42 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: akbdvar.h,v 1.5 2002/02/24 20:20:20 dbj Exp $  */
+/*     $OpenBSD: akbdvar.h,v 1.3 2002/03/27 21:48:12 drahn Exp $       */
 
 /*
  * Copyright (C) 1998  Colin Wood
@@ -33,6 +33,8 @@
 #ifndef _MACPPC_KBDVAR_H_
 #define _MACPPC_KBDVAR_H_
 
+#include "opt_wsdisplay_compat.h"
+
 #include <machine/adbsys.h>
 
 /*
@@ -52,7 +54,16 @@
        int sc_polling;
        int sc_npolledkeys;
        unsigned char sc_polledkeys[32];
-  
+
+#ifdef WSDISPLAY_COMPAT_RAWKBD
+#define AKBD_RAW_MAX_KEYS      20
+#define AKBD_RAW_REPEAT_DELAY1         400
+#define AKBD_RAW_REPEAT_DELAYN         100
+       int sc_rawkbd;
+       int sc_nrep;
+       char sc_rep[AKBD_RAW_MAX_KEYS];
+       struct callout sc_rawrepeat_ch;
+#endif
 };
 
 /* LED register bits, inverse of actual register value */
diff -r 7c3e7f430fb9 -r a98146cad22b sys/arch/macppc/include/keyboard.h
--- a/sys/arch/macppc/include/keyboard.h        Tue Aug 13 14:05:41 2002 +0000
+++ b/sys/arch/macppc/include/keyboard.h        Tue Aug 13 15:00:42 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: keyboard.h,v 1.3 2002/07/05 18:45:17 matt Exp $        */
+/*     $NetBSD: keyboard.h,v 1.4 2002/08/13 15:00:43 aymeric Exp $     */
 
 /*-
  * Copyright (C) 1993  Allen K. Briggs, Chris P. Caputo,
@@ -72,137 +72,145 @@
                                 (((key) & 0x7f) == ADBK_OPTION))
 
 #ifndef KEYBOARD_ARRAY
-extern unsigned char keyboard[128][3];
+extern unsigned char keyboard[128][4];
+#else
+unsigned char keyboard[128][4] = {
+         /* Scan code      Normal     Shifted     Controlled   XT */
+       { /*   0x00, */       'a',       'A',         0x01,      30 },
+       { /*   0x01, */       's',       'S',         0x13,      31 },
+       { /*   0x02, */       'd',       'D',         0x04,      32 },
+       { /*   0x03, */       'f',       'F',         0x06,      33 },
+       { /*   0x04, */       'h',       'H',         0x08,      35 },
+       { /*   0x05, */       'g',       'G',         0x07,      34 },
+       { /*   0x06, */       'z',       'Z',         0x1A,      44 },
+       { /*   0x07, */       'x',       'X',         0x18,      45 },
+       { /*   0x08, */       'c',       'C',         0x03,      46 },
+       { /*   0x09, */       'v',       'V',         0x16,      47 },
+#ifdef FIX_SV_X_KBDBUG
+       { /*   0x0A, */      0x00,      0x00,         0x00,      41 },
+#else
+       { /*   0x0A, */      0x00,      0x00,         0x00,      86 },
+#endif
+       { /*   0x0B, */       'b',       'B',         0x02,      48 },
+       { /*   0x0C, */       'q',       'Q',         0x11,      16 },
+       { /*   0x0D, */       'w',       'W',         0x17,      17 },
+       { /*   0x0E, */       'e',       'E',         0x05,      18 },
+       { /*   0x0F, */       'r',       'R',         0x12,      19 },
+       { /*   0x10, */       'y',       'Y',         0x19,      21 },
+       { /*   0x11, */       't',       'T',         0x14,      20 },
+       { /*   0x12, */       '1',       '!',         0x00,       2 },
+       { /*   0x13, */       '2',       '@',         0x00,       3 },
+       { /*   0x14, */       '3',       '#',         0x00,       4 },
+       { /*   0x15, */       '4',       '$',         0x00,       5 },
+       { /*   0x16, */       '6',       '^',         0x1E,       7 },
+       { /*   0x17, */       '5',       '%',         0x00,       6 },
+       { /*   0x18, */       '=',       '+',         0x00,      13 },
+       { /*   0x19, */       '9',       '(',         0x00,      10 },
+       { /*   0x1A, */       '7',       '&',         0x00,       8 },
+       { /*   0x1B, */       '-',       '_',         0x1F,      12 },
+       { /*   0x1C, */       '8',       '*',         0x00,       9 },
+       { /*   0x1D, */       '0',       ')',         0x00,      11 },
+       { /*   0x1E, */       ']',       '}',         0x1D,      27 },
+       { /*   0x1F, */       'o',       'O',         0x0F,      24 },
+       { /*   0x20, */       'u',       'U',         0x15,      22 },
+       { /*   0x21, */       '[',       '{',         0x1B,      26 },
+       { /*   0x22, */       'i',       'I',         0x09,      23 },
+       { /*   0x23, */       'p',       'P',         0x10,      25 },
+       { /*   0x24, */      0x0D,      0x0D,         0x0D,      28 },
+       { /*   0x25, */       'l',       'L',         0x0C,      38 },
+       { /*   0x26, */       'j',       'J',         0x0A,      36 },
+       { /*   0x27, */       '\'',      '"',         0x00,      40 },
+       { /*   0x28, */       'k',       'K',         0x0B,      37 },
+       { /*   0x29, */       ';',       ':',         0x00,      39 },
+       { /*   0x2A, */      '\\',       '|',         0x1C,      43 },
+       { /*   0x2B, */       ',',       '<',         0x00,      51 },
+       { /*   0x2C, */       '/',       '?',         0x00,      53 },
+       { /*   0x2D, */       'n',       'N',         0x0E,      49 },
+       { /*   0x2E, */       'm',       'M',         0x0D,      50 },
+       { /*   0x2F, */       '.',       '>',         0x00,      52 },
+       { /*   0x30, */      0x09,      0x09,         0x09,      15 },
+       { /*   0x31, */       ' ',       ' ',         0x00,      57 },
+#ifdef FIX_SV_X_KBDBUG
+       { /*   0x32, */       '`',       '~',         0x00,      86 },
 #else
-unsigned char keyboard[128][3] = {
-               /* Scan code      Normal     Shifted     Controlled */
-       {       /*   0x00, */       'a',       'A',         0x01 },
-       {       /*   0x01, */       's',       'S',         0x13 },
-       {       /*   0x02, */       'd',       'D',         0x04 },
-       {       /*   0x03, */       'f',       'F',         0x06 },
-       {       /*   0x04, */       'h',       'H',         0x08 },
-       {       /*   0x05, */       'g',       'G',         0x07 },
-       {       /*   0x06, */       'z',       'Z',         0x1A },
-       {       /*   0x07, */       'x',       'X',         0x18 },
-       {       /*   0x08, */       'c',       'C',         0x03 },
-       {       /*   0x09, */       'v',       'V',         0x16 },
-       {       /*   0x0A, */      0x00,      0x00,         0x00 },
-       {       /*   0x0B, */       'b',       'B',         0x02 },
-       {       /*   0x0C, */       'q',       'Q',         0x11 },
-       {       /*   0x0D, */       'w',       'W',         0x17 },
-       {       /*   0x0E, */       'e',       'E',         0x05 },
-       {       /*   0x0F, */       'r',       'R',         0x12 },
-       {       /*   0x10, */       'y',       'Y',         0x19 },
-       {       /*   0x11, */       't',       'T',         0x14 },
-       {       /*   0x12, */       '1',       '!',         0x00 },
-       {       /*   0x13, */       '2',       '@',         0x00 },
-       {       /*   0x14, */       '3',       '#',         0x00 },
-       {       /*   0x15, */       '4',       '$',         0x00 },
-       {       /*   0x16, */       '6',       '^',         0x1E },
-       {       /*   0x17, */       '5',       '%',         0x00 },
-       {       /*   0x18, */       '=',       '+',         0x00 },
-       {       /*   0x19, */       '9',       '(',         0x00 },
-       {       /*   0x1A, */       '7',       '&',         0x00 },
-       {       /*   0x1B, */       '-',       '_',         0x1F },
-       {       /*   0x1C, */       '8',       '*',         0x00 },
-       {       /*   0x1D, */       '0',       ')',         0x00 },
-       {       /*   0x1E, */       ']',       '}',         0x1D },
-       {       /*   0x1F, */       'o',       'O',         0x0F },
-       {       /*   0x20, */       'u',       'U',         0x15 },
-       {       /*   0x21, */       '[',       '{',         0x1B },
-       {       /*   0x22, */       'i',       'I',         0x09 },
-       {       /*   0x23, */       'p',       'P',         0x10 },
-       {       /*   0x24, */      0x0D,      0x0D,         0x0D },
-       {       /*   0x25, */       'l',       'L',         0x0C },
-       {       /*   0x26, */       'j',       'J',         0x0A },
-       {       /*   0x27, */      '\'',       '"',         0x00 },
-       {       /*   0x28, */       'k',       'K',         0x0B },
-       {       /*   0x29, */       ';',       ':',         0x00 },
-       {       /*   0x2A, */      '\\',       '|',         0x1C },
-       {       /*   0x2B, */       ',',       '<',         0x00 },
-       {       /*   0x2C, */       '/',       '?',         0x00 },
-       {       /*   0x2D, */       'n',       'N',         0x0E },
-       {       /*   0x2E, */       'm',       'M',         0x0D },
-       {       /*   0x2F, */       '.',       '>',         0x00 },
-       {       /*   0x30, */      0x09,      0x09,         0x09 },
-       {       /*   0x31, */       ' ',       ' ',         0x00 },
-       {       /*   0x32, */       '`',       '~',         0x00 },
-       {       /*   0x33, */      0x7F,      0x7F,         0x7F }, /* Delete */
-       {       /*   0x34, */      0x00,      0x00,         0x00 },
-       {       /*   0x35, */      0x1B,      0x1B,         0x1B },



Home | Main Index | Thread Index | Old Index