Port-hpcsh archive

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

XKB keymap patch.



I prepared the patch that setting XKB keymap from which determined by
builtin keyboard. This patch useful for non KB_US machines.  If there
are no objections, I'd like to commit this.


Index: atKeynames.h
===================================================================
RCS file: /cvsroot/xsrc/xfree/xc/programs/Xserver/hw/netbsd/hpc/atKeynames.h,v
retrieving revision 1.1
diff -u -r1.1 atKeynames.h
--- atKeynames.h        3 Jan 2004 01:09:19 -0000       1.1
+++ atKeynames.h        14 Jul 2004 16:08:18 -0000
@@ -1,5 +1,4 @@
-/* $XConsortium: atKeynames.h,v 1.6 95/01/13 19:19:20 kaleb Exp $ */
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/atKeynames.h,v 3.5 
1995/06/24 10:28:16 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/atKeynames.h,v 3.22 
2004/02/13 23:58:35 dawes Exp $ */
 /*
  * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
  *
@@ -22,19 +21,67 @@
  * PERFORMANCE OF THIS SOFTWARE.
  *
  */
+/*
+ * Copyright (c) 1994-2003 by The XFree86 Project, Inc.
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ *
+ *   1.  Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions, and the following disclaimer.
+ *
+ *   2.  Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer
+ *       in the documentation and/or other materials provided with the
+ *       distribution, and in the same place and form as other copyright,
+ *       license and disclaimer information.
+ *
+ *   3.  The end-user documentation included with the redistribution,
+ *       if any, must include the following acknowledgment: "This product
+ *       includes software developed by The XFree86 Project, Inc
+ *       (http://www.xfree86.org/) and its contributors", in the same
+ *       place and form as other third-party acknowledgments.  Alternately,
+ *       this acknowledgment may appear in the software itself, in the
+ *       same form and location as other such third-party acknowledgments.
+ *
+ *   4.  Except as contained in this notice, the name of The XFree86
+ *       Project, Inc shall not be used in advertising or otherwise to
+ *       promote the sale, use or other dealings in this Software without
+ *       prior written authorization from The XFree86 Project, Inc.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE XFREE86 PROJECT, INC OR ITS CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* $XConsortium: atKeynames.h /main/11 1996/03/09 11:17:41 kaleb $ */
 
 #ifndef _ATKEYNAMES_H
 #define _ATKEYNAMES_H
 
 #define XK_TECHNICAL
+#define        XK_KATAKANA
 #include "keysym.h"
+#include "XF86keysym.h"
 
 #define GLYPHS_PER_KEY 4
-#define NUM_KEYCODES   150
-#define NUM_STD_KEYCODES 127
+#define NUM_KEYCODES   (255 - MIN_KEYCODE)
 #define MIN_KEYCODE     8
 #define MAX_KEYCODE     (NUM_KEYCODES + MIN_KEYCODE - 1)
-#define MAX_STD_KEYCODE (NUM_STD_KEYCODES + MIN_KEYCODE - 1)
 
 #define AltMask                Mod1Mask
 #define NumLockMask    Mod2Mask
@@ -45,8 +92,6 @@
 #define KeyPressed(k) (keyc->down[k >> 3] & (1 << (k & 7)))
 #define ModifierDown(k) ((keyc->state & (k)) == (k))
 
-#define XF86XK_ModeLock        0x1008FF01                 /* Mode Switch Lock 
*/
-
 /*
  * NOTE: The AT/MF keyboards can generate (via the 8042) two (MF: three)
  *       sets of scancodes. Set3 can only be generated by a MF keyboard.
@@ -70,6 +115,7 @@
  *      Key Name            Main       Also       (hex)    (dec)
  *      ----------------   ---------- -------    ------    ------
  */
+
 #define KEY_Escape       /* Escape                0x01  */    1  
 #define KEY_1            /* 1           !         0x02  */    2 
 #define KEY_2            /* 2           @         0x03  */    3 
@@ -181,7 +227,7 @@
 #define KEY_RCtrl        /* Ctrl(right)           0x65  */  101
 #define KEY_Pause        /* Pause                 0x66  */  102
 #define KEY_Print        /* Print                 0x67  */  103
-#define KEY_KP_Divide    /* Didive                0x68  */  104
+#define KEY_KP_Divide    /* Divide                0x68  */  104
 #define KEY_AltLang      /* AtlLang(right)        0x69  */  105
 #define KEY_Break        /* Break                 0x6a  */  106
 #define KEY_LMeta        /* Left Meta             0x6b  */  107
@@ -190,30 +236,83 @@
 #define KEY_F13          /* F13                   0x6e  */  110
 #define KEY_F14          /* F14                   0x6f  */  111
 #define KEY_F15          /* F15                   0x70  */  112
+#define KEY_HKTG         /* Hirugana/Katakana tog 0x70  */  112
 #define KEY_F16          /* F16                   0x71  */  113
 #define KEY_F17          /* F17                   0x72  */  114
 #define KEY_KP_DEC       /* KP_DEC                0x73  */  115
-#define KEY_SN_KP_7      /* ServerNumLock 7       0x80  */  128
-#define KEY_SN_KP_8      /* ServerNumLock 8       0x81  */  129
-#define KEY_SN_KP_9      /* ServerNumLock 9       0x82  */  130
-#define KEY_SN_KP_4      /* ServerNumLock 4       0x83  */  131
-#define KEY_SN_KP_5      /* ServerNumLock 5       0x84  */  132
-#define KEY_SN_KP_6      /* ServerNumLock 6       0x85  */  133
-#define KEY_SN_KP_1      /* ServerNumLock 1       0x86  */  134
-#define KEY_SN_KP_2      /* ServerNumLock 2       0x87  */  135
-#define KEY_SN_KP_3      /* ServerNumLock 4       0x88  */  136
-#define KEY_SN_KP_0      /* ServerNumLock 0       0x89  */  137
-#define KEY_SN_KP_Dec    /* ServerNumLock Decimal 0x8a  */  138
-#define KEY_SN_KP_Home   /* ServerNumLock Home    0x8b  */  139
-#define KEY_SN_KP_Up     /* ServerNumLock Up      0x8c  */  140
-#define KEY_SN_KP_Prior  /* ServerNumLock Prior   0x8d  */  141
-#define KEY_SN_KP_Left   /* ServerNumLock Left    0x8e  */  142
-#define KEY_SN_KP_Begin  /* ServerNumLock Begin   0x8f  */  143
-#define KEY_SN_KP_Right  /* ServerNumLock Right   0x90  */  144
-#define KEY_SN_KP_End    /* ServerNumLock End     0x91  */  145
-#define KEY_SN_KP_Down   /* ServerNumLock Down    0x92  */  146
-#define KEY_SN_KP_Next   /* ServerNumLock Next    0x93  */  147
-#define KEY_SN_KP_Ins    /* ServerNumLock Ins     0x94  */  148
-#define KEY_SN_KP_Del    /* ServerNumLock Del     0x95  */  149
+#define KEY_BSlash2      /* \           _         0x73  */  115
+#define KEY_KP_Equal    /* Equal (Keypad)        0x76  */  118
+#define KEY_XFER         /* Kanji Transfer        0x79  */  121
+#define KEY_NFER         /* No Kanji Transfer     0x7b  */  123
+#define KEY_Yen          /* Yen                   0x7d  */  125
+
+#define KEY_Power        /* Power Key             0x84  */  132
+#define KEY_Mute         /* Audio Mute            0x85  */  133
+#define KEY_AudioLower   /* Audio Lower           0x86  */  134
+#define KEY_AudioRaise   /* Audio Raise           0x87  */  135
+#define KEY_Help         /* Help                  0x88  */  136
+#define KEY_L1           /* Stop                  0x89  */  137
+#define KEY_L2           /* Again                 0x8a  */  138
+#define KEY_L3           /* Props                 0x8b  */  139
+#define KEY_L4           /* Undo                  0x8c  */  140
+#define KEY_L5           /* Front                 0x8d  */  141
+#define KEY_L6           /* Copy                  0x8e  */  142
+#define KEY_L7           /* Open                  0x8f  */  143
+#define KEY_L8           /* Paste                 0x90  */  144
+#define KEY_L9           /* Find                  0x91  */  145
+#define KEY_L10          /* Cut                   0x92  */  146
+
+/*
+ * Fake 'scancodes' in the following ranges are generated for 2-byte
+ * codes not handled elsewhere.  These correspond to most extended keys
+ * on so-called "Internet" keyboards:
+ *
+ *     0x79-0x93
+ *     0x96-0xa1
+ *     0xa3-0xac
+ *     0xb1-0xb4
+ *     0xba-0xbd
+ *     0xc2
+ *     0xcc-0xd2
+ *     0xd6-0xf7
+ */
+
+/*
+ * Remapped 'scancodes' are generated for single-byte codes in the range
+ * 0x59-0x5f,0x62-0x76.  These are used for some extra keys on some keyboards.
+ */
+
+#define KEY_0x59               0x95
+#define KEY_0x5A               0xA2
+#define KEY_0x5B               0xAD
+#define KEY_0x5C               KEY_KP_EQUAL
+#define KEY_0x5D               0xAE
+#define KEY_0x5E               0xAF
+#define KEY_0x5F               0xB0
+#define KEY_0x62               0xB5
+#define KEY_0x63               0xB6
+#define KEY_0x64               0xB7
+#define KEY_0x65               0xB8
+#define KEY_0x66               0xB9
+#define KEY_0x67               0xBE
+#define KEY_0x68               0xBF
+#define KEY_0x69               0xC0
+#define KEY_0x6A               0xC1
+#define KEY_0x6B               0xC3
+#define KEY_0x6C               0xC4
+#define KEY_0x6D               0xC5
+#define KEY_0x6E               0xC6
+#define KEY_0x6F               0xC7
+#define KEY_0x70               0xC8
+#define KEY_0x71               0xC9
+#define KEY_0x72               0xCA
+#define KEY_0x73               0xCB
+#define KEY_0x74               0xD3
+#define KEY_0x75               0xD4
+#define KEY_0x76               0xD5
+
+/* These are for "notused" and "unknown" entries in translation maps. */
+#define KEY_NOTUSED      0
+#define KEY_UNKNOWN    255
 
 #endif /* _ATKEYNAMES_H */
Index: hpc.h
===================================================================
RCS file: /cvsroot/xsrc/xfree/xc/programs/Xserver/hw/netbsd/hpc/hpc.h,v
retrieving revision 1.1
diff -u -r1.1 hpc.h
--- hpc.h       3 Jan 2004 01:09:19 -0000       1.1
+++ hpc.h       14 Jul 2004 16:08:18 -0000
@@ -107,6 +107,7 @@
     int                        xlatestat;      /* state machine for key code 
xlation */
     Leds               leds;           /* last known LED state */
     struct termios     kbdtty;         /* previous tty settings */
+    int                        encode;         /* builtin keyboard encoding */
 } hpcKbdPrivRec, *hpcKbdPrivPtr;
 extern hpcKbdPrivRec hpcKbdPriv;
 
@@ -175,6 +176,9 @@
        FatalError a; \
 }
 
+/* alias for verbose print */
+#define        hpcPrintF(x)    hpcErrorF(x)
+
 /*
  * hpcInit.c
  */
@@ -192,6 +196,7 @@
 int hpcKbdProc __P((DeviceIntPtr pKeyboard, int what));
 hpcEvent* hpcKbdGetEvents __P((hpcKbdPrivPtr, int*, Bool*));
 void hpcKbdEnqueueEvent __P((DeviceIntPtr dev, hpcEvent* fe));
+int hpcGetBuiltinKbdEncoding(void);
 
 /*
  * hpcMouse.c
Index: hpcInit.c
===================================================================
RCS file: /cvsroot/xsrc/xfree/xc/programs/Xserver/hw/netbsd/hpc/hpcInit.c,v
retrieving revision 1.3
diff -u -r1.3 hpcInit.c
--- hpcInit.c   25 Jun 2004 20:51:59 -0000      1.3
+++ hpcInit.c   14 Jul 2004 16:08:18 -0000
@@ -31,16 +31,6 @@
     -1,                /* fd */
 };
 
-/*
- * a list of devices to try if there is no environment or command
- * line list of devices
- */
-static char *fallbackList[] = {
-    "/dev/ttyE0", "/dev/ttyE1", "/dev/ttyE2", "/dev/ttyE3",
-    "/dev/ttyE4", "/dev/ttyE5", "/dev/ttyE6", "/dev/ttyE7",
-};
-#define FALLBACK_LIST_LEN sizeof fallbackList / sizeof fallbackList[0]
-
 hpcFbRec hpcFbs[MAXSCREENS];
 
 static PixmapFormatRec formats[] = {
@@ -175,16 +165,7 @@
        }
        deviceList[MAXSCREENS] = NULL;
     }
-#if 0
-    if (!deviceList) {
-       /* no environment and no cmdline, so default */
-       deviceList =
-           (char **) xalloc ((FALLBACK_LIST_LEN + 1) * sizeof (char *));
-       for (i = 0; i < FALLBACK_LIST_LEN; i++)
-           deviceList[i] = fallbackList[i];
-       deviceList[FALLBACK_LIST_LEN] = NULL;
-    }
-#endif
+
     return deviceList;
 }
 
@@ -224,10 +205,17 @@
        /*
         * use mouse multiplexer if it's available.
         */
-       hpcPtrPriv.fd = open("/dev/wsmux0", O_RDWR);
+       if ((hpcPtrPriv.fd = open("/dev/wsmouse", O_RDWR)) != -1) {
+               hpcPrintF(("mouse: /dev/wsmouse (multiplexer)\n"));
+       }
 
        /*
-        * try each mouse device
+        * Try to inquire builtin keyboard encoding type.
+        */
+       hpcKbdPriv.encode = hpcGetBuiltinKbdEncoding();
+
+       /*
+        * try each mouse/kbd device
         */
        for (i = 0; i < 8; i++) {
            char devname[16];
@@ -239,28 +227,30 @@
             */
            if (hpcKbdPriv.fd == -1) {
                sprintf(devname, "/dev/wskbd%d", i);
-               hpcKbdPriv.fd = open(devname, O_RDWR);
+               if ((hpcKbdPriv.fd = open(devname, O_RDWR)) != -1) {
+                       hpcKbdPriv.devtype = HPC_KBDDEV_WSKBD;
+                       hpcPrintF(("keyboard: %s\n", devname));
+               }
            }
 #endif
-
            if (hpcPtrPriv.fd == -1) {
                sprintf(devname, "/dev/wsmouse%d", i);
-               if ((hpcPtrPriv.fd = open(devname, O_RDWR)) < 0)
-                   hpcError(devname);
+               if ((hpcPtrPriv.fd = open(devname, O_RDWR)) != -1) {
+                       hpcPrintF(("mouse: %s\n", devname));
+               } else {
+                       hpcError(devname);
+               }
            }
        }
 
-       if (hpcKbdPriv.fd != -1) {
-           hpcKbdPriv.devtype = HPC_KBDDEV_WSKBD;
-       } else {
+       if (hpcKbdPriv.fd == -1) {
            /*
             * use keyboards which are connected wsdisplay(ttyE*).
             */
            devList = GetDeviceList (argc, argv);
            for (i = 0; devList[i] != NULL; i++) {
                if (0 <= (hpcKbdPriv.fd = open(devList[i], O_RDWR))) {
-                   /* this isn't error */
-                   hpcErrorF(("use RAW XT keyboard, %s\n", devList[i]));
+                   hpcPrintF(("keyboard: %s (RAW XT keyboard)\n", devList[i]));
                    hpcKbdPriv.devtype = HPC_KBDDEV_RAW;
                    break;
                }
@@ -284,7 +274,7 @@
                break;
        }
 
-       /* XXX, What does this mean ??? */
+       /* Index of hpcKeySyms[]. hpcKeymap.c */
        hpcKbdPriv.type = 0;
 }
 
@@ -434,3 +424,4 @@
     return FALSE;
 }
 #endif
+
Index: hpcKbd.c
===================================================================
RCS file: /cvsroot/xsrc/xfree/xc/programs/Xserver/hw/netbsd/hpc/hpcKbd.c,v
retrieving revision 1.2
diff -u -r1.2 hpcKbd.c
--- hpcKbd.c    3 Jan 2004 01:23:02 -0000       1.2
+++ hpcKbd.c    14 Jul 2004 16:08:19 -0000
@@ -47,14 +47,26 @@
 #include <stdio.h>
 #include <sys/time.h>
 #include <dev/pckbc/pckbdreg.h>
+#include <dev/wscons/wsksymdef.h>
 #include "atKeynames.h"
 
+#ifdef XKB
+#include <X11/extensions/XKB.h>
+#include <X11/extensions/XKBstr.h>
+#include <X11/extensions/XKBsrv.h>
+#endif
+
 #define MOUSE_EMUL_KEY (KEY_Menu + MIN_KEYCODE)        /* menu key on windows 
keyboard */
 #define MOUSE_EMUL_KEY1        (KEY_1 + MIN_KEYCODE)
 #define MOUSE_EMUL_KEY5        (KEY_5 + MIN_KEYCODE)
 
 extern KeySymsRec hpcKeySyms[];
 extern hpcModmapRec *hpcModMaps[];
+static void hpcInitKbdNames(XkbComponentNamesRec *, hpcKbdPrivPtr);
+static int hpcKbdMuxSaveDevices(struct wsmux_device_list *);
+static int hpcKbdMuxRestoreDevices(struct wsmux_device_list *);
+static int hpcKbdGetBuiltinKeyboadEncoding(void);
+
 
 /*
  * hpcBell --
@@ -184,9 +196,19 @@
        pKeyboard->devicePrivate = (pointer)&hpcKbdPriv;
        pKeyboard->on = FALSE;
 
-       InitKeyboardDeviceStruct(pKeyboard,
-                                workingKeySyms, workingModMap,
-                                hpcBell, hpcKbdCtrl);
+#ifdef XKB
+       if (noXkbExtension) {
+#endif
+               InitKeyboardDeviceStruct(pKeyboard, workingKeySyms,
+                   workingModMap, hpcBell, hpcKbdCtrl);
+#ifdef XKB
+       } else {
+               XkbComponentNamesRec names;
+               hpcInitKbdNames(&names, &hpcKbdPriv);
+               XkbInitKeyboardDeviceStruct((DeviceIntPtr)pKeyboard, &names,
+                   workingKeySyms, workingModMap, hpcBell, hpcKbdCtrl);
+       }
+#endif
        break;
 
     case DEVICE_ON:
@@ -272,6 +294,7 @@
 {
     int fd;
     int        nBytes;     /* number of bytes of events available. */
+    struct timeval tv;
     u_char c, c2;
     static hpcEvent evBuf[MAXEVENTS];   /* Buffer for hpcEvents */
 
@@ -300,8 +323,43 @@
                        pPriv->xlatestat = HPC_KBDXSTAT_EXT1;
                        goto AGAIN;
                    } else {
-                       *pNumEvents = 1;
-                       evBuf[0].value = (c & 0x7f);
+                           switch (c & 0x7f) {
+                           case 0x59:        c2 = KEY_0x59; break;
+                           case 0x5a:        c2 = KEY_0x5A; break;
+                           case 0x5b:        c2 = KEY_0x5B; break;
+                           case 0x5c:        c2 = KEY_KP_Equal; break; /* 
Keypad Equal */
+                           case 0x5d:        c2 = KEY_0x5D; break;
+                           case 0x5e:        c2 = KEY_0x5E; break;
+                           case 0x5f:        c2 = KEY_0x5F; break;
+                           case 0x62:        c2 = KEY_0x62; break;
+                           case 0x63:        c2 = KEY_0x63; break;
+                           case 0x64:        c2 = KEY_0x64; break;
+                           case 0x65:        c2 = KEY_0x65; break;
+                           case 0x66:        c2 = KEY_0x66; break;
+                           case 0x67:        c2 = KEY_0x67; break;
+                           case 0x68:        c2 = KEY_0x68; break;
+                           case 0x69:        c2 = KEY_0x69; break;
+                           case 0x6a:        c2 = KEY_0x6A; break;
+                           case 0x6b:        c2 = KEY_0x6B; break;
+                           case 0x6c:        c2 = KEY_0x6C; break;
+                           case 0x6d:        c2 = KEY_0x6D; break;
+                           case 0x6e:        c2 = KEY_0x6E; break;
+                           case 0x6f:        c2 = KEY_0x6F; break;
+                           case 0x70:        c2 = KEY_0x70; break;
+                           case 0x71:        c2 = KEY_0x71; break;
+                           case 0x72:        c2 = KEY_0x72; break;
+                           case 0x73:        c2 = KEY_0x73; break;
+                           case 0x74:        c2 = KEY_0x74; break;
+                           case 0x75:        c2 = KEY_0x75; break;
+                           case 0x76:        c2 = KEY_0x76; break;
+                           default:          c2 = c & 0x7f; break;
+                           }
+                           *pNumEvents = 1;
+                           evBuf[0].value = c2;
+                           evBuf[0].type = (c & 0x80) ?
+                               WSCONS_EVENT_KEY_UP : WSCONS_EVENT_KEY_DOWN;
+                           TIMEVAL_TO_TIMESPEC(&tv, &evBuf[0].time);
+                           return evBuf;
                    }
                    break;
                case HPC_KBDXSTAT_EXT0:
@@ -380,8 +438,8 @@
                    hpcFatalError(("hpcKbdGetEvents: invalid xlate status"));
                    break;
                }
+
                if (*pNumEvents != 0) {
-                   struct timeval tv;
                    gettimeofday(&tv, NULL);
                    evBuf[0].type = (c & 0x80) ?
                                WSCONS_EVENT_KEY_UP : WSCONS_EVENT_KEY_DOWN;
@@ -556,3 +614,168 @@
 {
     return TRUE;
 }
+
+/*-
+ *-----------------------------------------------------------------------
+ * hpcInitKbdNames --
+ *     Handle the XKB initialization
+ *
+ * Results:
+ *     None.
+ *
+ * Comments:
+ *-----------------------------------------------------------------------
+ */
+#ifdef XKB
+static void hpcInitKbdNames (XkbComponentNamesRec* names, hpcKbdPrivPtr pKbd)
+{
+#ifndef XKBBUFSIZE
+#define        XKBBUFSIZE 64
+#endif
+    static char keycodesbuf[XKBBUFSIZE];
+    static char geometrybuf[XKBBUFSIZE];
+    static char symbolsbuf[XKBBUFSIZE];
+
+    names->keymap = NULL;
+    names->compat = "compat/complete";
+    names->types  = "types/complete";
+    names->keycodes = keycodesbuf;
+    names->geometry = geometrybuf;
+    names->symbols = symbolsbuf;
+    strcpy(keycodesbuf, "keycodes/");
+    strcpy(geometrybuf, "geometry/");
+    strcpy(symbolsbuf, "symbols/");
+
+    /* keycodes & geometry */
+    switch (pKbd->encode) {
+    case KB_DE:
+           strcat(names->keycodes, "xfree86");
+           strcat(names->geometry, "pc(jp102)");
+           strcat(names->symbols, "en_US(pc105)+de");
+           hpcPrintF(("keymap: en_US(pc105)+de\n"));
+           break;
+    case KB_FR:
+           strcat(names->keycodes, "xfree86");
+           strcat(names->geometry, "pc(pc102)");
+           strcat(names->symbols, "en_US(pc105)+fr");
+           hpcPrintF(("keymap: en_US(pc105)+fr\n"));
+           break;
+    case KB_JP:
+           strcat(names->keycodes, "xfree86(jp106)");
+           strcat(names->geometry, "pc(jp106)");
+           strcat(names->symbols, "jp(jp106)");
+           hpcPrintF(("keymap: jp(jp106)\n"));
+           break;
+    case KB_US:
+    default:
+           strcat(names->keycodes, "xfree86");
+           strcat(names->geometry, "pc");
+           strcat(names->symbols, "us(pc105)");
+           hpcPrintF(("keymap: us(pc105)\n"));
+           break;
+    }
+}
+#endif /* XKB */
+
+/*
+ * Inquire built-in keyboard encoding type.
+ */
+int
+hpcGetBuiltinKbdEncoding()
+{
+       struct wsmux_device_list devlist;
+       int kbdencode;
+
+       if (hpcKbdMuxSaveDevices(&devlist) != 0)
+               return KB_USER;
+       kbdencode = hpcKbdGetBuiltinKeyboadEncoding();
+       hpcKbdMuxRestoreDevices(&devlist);
+
+       return kbdencode;
+}
+
+/*
+ * Save attached device of mulitiplexer to devlist.
+ */
+int
+hpcKbdMuxSaveDevices(struct wsmux_device_list *devlist)
+{
+       struct wsmux_device *dev;
+       int i, fd;
+
+       if ((fd = open("/dev/wskbd", O_RDWR)) == -1) {
+               hpcPrintF(("can't open /dev/wskbd multiplexer (not fatal)"));
+               return 1;
+       }
+
+       if (ioctl(fd, WSMUXIO_LIST_DEVICES, devlist) == -1) {
+               hpcPrintF(("can't WSMUXIO_LIST_DEVICES (not fatal)"));
+               close(fd);
+               return 1;
+       }
+
+       for (dev = devlist->devices, i = 0; i < devlist->ndevices; i++, dev++) {
+               hpcPrintF(("[%d] type=%d idx=%d\n", i, dev->type, dev->idx));
+       }
+       close(fd);
+
+       return 0;
+}
+
+int
+hpcKbdMuxRestoreDevices(struct wsmux_device_list *odevlist)
+{
+       struct wsmux_device_list devlist;
+       struct wsmux_device *odev, *dev;
+       int fd, i, j, n;
+
+       /* Get current list */
+       if (hpcKbdMuxSaveDevices(&devlist) != 0)
+               return 1;
+
+       fd = open("/dev/wskbd", O_RDWR);
+
+       /* Compare old list, if find detatched device, reconnect again. */
+       n = devlist.ndevices;
+       for (odev = odevlist->devices,
+           i = 0; i < odevlist->ndevices; i++, odev++) {
+               for (dev = devlist.devices, j = 0; j < n; j++, dev++)
+                       if (dev->type == odev->type && dev->idx == odev->idx)
+                               break;
+               if (j != n)
+                       continue;
+               hpcPrintF(("connect %d %d\n", odev->type, odev->idx));
+               if (ioctl(fd, WSMUXIO_ADD_DEVICE, odev) == -1) {
+                       hpcPrintF(("failed to add type %d idx %d\n",
+                           odev->type, odev->idx));
+               }
+       }
+       close(fd);
+}
+
+int
+hpcKbdGetBuiltinKeyboadEncoding()
+{
+       char device[16];
+       int i, fd;
+       kbd_t kbdencoding = 0;
+       u_int kbdtype;
+
+       for (i = 0; i < 8; i++) {
+               sprintf(device, "/dev/wskbd%d", i);
+               if ((fd = open(device, O_RDWR)) == -1)
+                       continue;
+               if ((ioctl(fd, WSKBDIO_GTYPE, &kbdtype) != -1) &&
+                   (kbdtype == WSKBD_TYPE_HPC_KBD) &&
+                   (ioctl(fd, WSKBDIO_GETENCODING, &kbdencoding) != -1)) {
+                       close(fd);
+                       break;
+               }
+               close(fd);
+       }
+       if (kbdencoding == 0)
+               kbdencoding = KB_USER;
+
+       return kbdencoding;
+}
+
Index: hpcKeymap.c
===================================================================
RCS file: /cvsroot/xsrc/xfree/xc/programs/Xserver/hw/netbsd/hpc/hpcKeymap.c,v
retrieving revision 1.1
diff -u -r1.1 hpcKeymap.c
--- hpcKeymap.c 3 Jan 2004 01:09:19 -0000       1.1
+++ hpcKeymap.c 14 Jul 2004 16:08:19 -0000
@@ -37,7 +37,7 @@
 
 KeySymsRec hpcKeySyms[] = {
     /* map        minKeyCode   maxKC   width */
-    map,               0,      MAX_STD_KEYCODE,        4,
+    map,               0,      0x95,   4,
 };
 
 static hpcModmapRec modmap[] = {





Home | Main Index | Thread Index | Old Index