tech-x11 archive

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

Re: Xorg keymap and wskbd keymap



I wrote back on June:

> > So if someone wants to grab the flag, and start implementing a wscons
> > specific X input driver, you'll have my support.
 :
> My first compromise^W goal is to implement a generic Xorg wscons
> driver that doesn't require independent keymap settings for various
> machines to reduce maintainance cost for our orphaned^W favorite ports.
> I thought it could be done by replacing KbdGetMapping() function
> assigned in xf86-input-keyboard/dist/src/bsd_kbd.c.
> 
> We already have keymap files in kernel and we can get it
> via WSKBDIO_GETMAP ioctl(), so I think we can generate mappings
> between wscons keycode <-> XK_foo keysym at run time once we prepare
> a function which translates wscons keysym to X keysym.

Recently I noticed our old XFree86 based Xhpc server already had
some code that generated XKB keymap from WSKBDIO_GETMAP ioctl():
 
http://cvsweb.NetBSD.org/bsdweb.cgi/xsrc/xfree/xc/programs/Xserver/hw/netbsd/hpc/hpcKeymap.c.diff?r1=1.1&r2=1.2
so I've just pulled this to xf86-input-keyboard driver. (patch attached)

The patch includes the following changes:

xsrc/external/mit/xf86-input-keyboard/dist/src/ws_KbdMap.c
 - new file which includes conversion from wsksym to XKB keysyms,
   based on the above old hpcKeymap.c written by uch@
 (XXX: local file should be put into reachover dir rather than dist dir?)
 - assume using /dev/wskbdN (not /dev/wskbd mux) since there is
   no way to see which keymap should be applicable for raw keycode
   in each wskbd event from wsmux (due to bad wsmux(4) design)

- src/external/mit/xorg/server/drivers/xf86-input-keyboard/Makefile
 - use -DUSE_WSKBD_GETMAP to enable the new WSKBDIO_GETMAP feature
 - pull a new file ws_KbdMap.c
 (XXX: similar changes should be in dist/Makefile.in?)

xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_KbdMap.
 - disable all wskbd to AT scancodeMaps in USE_WSKBD_GETMAP case
 - call a new KbdGetMappingFromWsksym() (which is in ws_KbdMap.c)
   for USE_WSKBD_GETMAP

xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_kbd.c
 - make unknown wskbd type not fatal
   (XXX: should we have/provide a wskbd type name table?)

xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_kbd.h
 - add KbdGetMappingFromWsksym() prototype


Xorg server with this xf86-input-keyboard driver just works fine
on my Dreamcast. I'll also update ews4800mips and newsmips to switch
to using Xorg server with this keyboard driver.
A sample xorg.conf file and Xorg.0.log output are also attached.

Comments?

---
Index: src/share/mk/bsd.own.mk
===================================================================
RCS file: /cvsroot/src/share/mk/bsd.own.mk,v
retrieving revision 1.641
diff -u -p -r1.641 bsd.own.mk
--- src/share/mk/bsd.own.mk     4 Sep 2010 12:17:58 -0000       1.641
+++ src/share/mk/bsd.own.mk     24 Oct 2010 08:52:46 -0000
@@ -742,7 +742,6 @@ ${var}?=no
     ${MACHINE} == "acorn32"    || \
     ${MACHINE} == "alpha"      || \
     ${MACHINE} == "amiga"      || \
-    ${MACHINE} == "dreamcast"  || \
     ${MACHINE} == "ews4800mips"        || \
     ${MACHINE} == "mac68k"     || \
     ${MACHINE} == "newsmips"   || \
Index: src/external/mit/xorg/server/drivers/xf86-input-keyboard/Makefile
===================================================================
RCS file: 
/cvsroot/src/external/mit/xorg/server/drivers/xf86-input-keyboard/Makefile,v
retrieving revision 1.10
diff -u -p -r1.10 Makefile
--- src/external/mit/xorg/server/drivers/xf86-input-keyboard/Makefile   11 Jun 
2009 15:32:38 -0000      1.10
+++ src/external/mit/xorg/server/drivers/xf86-input-keyboard/Makefile   24 Oct 
2010 08:04:16 -0000
@@ -13,6 +13,15 @@ CPPFLAGS+=   -DWSCONS_SUPPORT
 CPPFLAGS+=     -DXKB
 CPPFLAGS.kbd.c=        -D__XKBDEFRULES__=${__XKBDEFRULES__}
 
+.if \
+    ${MACHINE} == "dreamcast"  || \
+    ${MACHINE} == "ews4800mips"        || \
+    ${MACHINE} == "newsmips"   || \
+    0
+CPPFLAGS+=     -DUSE_WSKBD_GETMAP
+SRCS+=         ws_KbdMap.c
+.endif
+
 X11EXTRAMANDEFS+=      -e 's,__xkb_path__,${X11LIBDIR}/xkb,g'
 
 COPTS.kbd.c=      -Wno-error   # XXX deprecated
Index: xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_KbdMap.c
===================================================================
RCS file: /cvsroot/xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_KbdMap.c,v
retrieving revision 1.2
diff -u -p -r1.2 bsd_KbdMap.c
--- xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_KbdMap.c 22 Oct 2008 
03:16:28 -0000      1.2
+++ xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_KbdMap.c 24 Oct 2010 
08:04:16 -0000
@@ -302,6 +302,7 @@ TransMapRec sysconsCODE = {
 
 #ifdef WSCONS_SUPPORT
 
+#ifndef USE_WSKBD_GETMAP
 static CARD8 wsUsbMap[] = {
        /* 0 */ KEY_NOTUSED,
        /* 1 */ KEY_NOTUSED,
@@ -1057,6 +1058,7 @@ TransMapRec wsSun = {
     wsSunMap
 };
 
+#endif /* !USE_WSKBD_GETMAP */
 #endif /* WSCONS_SUPPORT */
 
 /*ARGSUSED*/
@@ -1291,6 +1293,7 @@ KbdGetMapping (InputInfoPtr pInfo, KeySy
 #ifdef WSCONS_SUPPORT
       case WSCONS:
        if (!pKbd->isConsole) {
+#ifndef USE_WSKBD_GETMAP
            switch (pKbd->wsKbdType) {
               case WSKBD_TYPE_PC_XT:
               case WSKBD_TYPE_PC_AT:
@@ -1315,6 +1318,10 @@ KbdGetMapping (InputInfoPtr pInfo, KeySy
               default:
                    ErrorF("Unknown wskbd type %d\n", pKbd->wsKbdType);
            }
+#else /* USE_WSKBD_GETMAP */
+          if (KbdGetMappingFromWsksym(pInfo, pKeySyms, pModMap) != 0)
+             ErrorF("can't get wskbd map for KbdType %d\n", pKbd->wsKbdType);
+#endif
        } else {
            pKbd->RemapScanCode = ATScancode;
        }
Index: xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_kbd.c
===================================================================
RCS file: /cvsroot/xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_kbd.c,v
retrieving revision 1.8
diff -u -p -r1.8 bsd_kbd.c
--- xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_kbd.c    24 Oct 2010 
07:44:19 -0000      1.8
+++ xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_kbd.c    24 Oct 2010 
08:04:16 -0000
@@ -442,10 +442,17 @@ OpenKeyboard(InputInfoPtr pInfo)
                break;
 #endif
            default:
+#ifndef USE_WSKBD_GETMAP
                xf86Msg(X_ERROR, "%s: Unsupported wskbd type \"%d\"",
                                 pInfo->name, pKbd->wsKbdType);
                close(pInfo->fd);
                return FALSE;
+#else
+               xf86Msg(X_WARNING, "%s: Unknown wskbd type \"%d\"\n",
+                                pInfo->name, pKbd->wsKbdType);
+               printWsType("Unknown wskbd", pInfo->name);
+               break;
+#endif
        }
     }
 #endif
Index: xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_kbd.h
===================================================================
RCS file: /cvsroot/xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_kbd.h,v
retrieving revision 1.2
diff -u -p -r1.2 bsd_kbd.h
--- xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_kbd.h    2 Aug 2008 
06:35:41 -0000       1.2
+++ xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_kbd.h    24 Oct 2010 
08:04:16 -0000
@@ -3,6 +3,11 @@
 extern void KbdGetMapping(InputInfoPtr pInfo, KeySymsPtr pKeySyms,
                                CARD8 *pModMap);
 
+#ifdef USE_WSKBD_GETMAP
+extern int KbdGetMappingFromWsksym(InputInfoPtr pInfo , KeySymsPtr pKeySyms,
+                                  CARD8 *pModMap);
+#endif
+
 #ifdef __NetBSD__
 #include <dev/wscons/wsconsio.h>
 #endif
--- /dev/null   2010-10-24 17:01:50.000000000 +0900
+++ xsrc/external/mit/xf86-input-keyboard/dist/src/ws_KbdMap.c  2010-10-24 
16:46:53.000000000 +0900
@@ -0,0 +1,482 @@
+/* $NetBSD$    */
+/* $XConsortium: sunKeyMap.c,v 4.22 94/05/18 11:16:07 kaleb Exp $ */
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+                    All Rights Reserved
+
+Permission  to  use,  copy,  modify,  and  distribute   this
+software  and  its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice  appear  in all copies and that both that copyright no-
+tice and this permission notice appear in  supporting  docu-
+mentation,  and  that the names of Sun or X Consortium
+not be used in advertising or publicity pertaining to 
+distribution  of  the software  without specific prior 
+written permission. Sun and X Consortium make no 
+representations about the suitability of this software for 
+any purpose. It is provided "as is" without any express or 
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO  THIS  SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE  LI-
+ABLE  FOR  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,  DATA  OR
+PROFITS,  WHETHER  IN  AN  ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+/*
+ * Generate XKB keymap from wskbd keymap provided by WSKBDIO_GETMAP ioctl
+ * 
+ * Taken from:
+ *     xsrc/xfree/xc/programs/Xserver/hw/netbsd/hpc/hpcKeymap.c
+ *     NetBSD: hpcKeymap.c,v 1.2 2004/07/22 18:08:59 uch Exp
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "xf86.h"
+#include "xf86_OSlib.h"
+#include "xf86OSKbd.h"
+#include "atKeynames.h"
+#include "bsd_kbd.h"
+
+#include <dev/wscons/wsksymdef.h>
+
+static void KeymapSetSymbol(KeySym *, CARD8 *, struct wscons_keymap *);
+
+static KeySym wsksym_to_xkeysym[] = {
+       [KS_BackSpace] = XK_BackSpace,
+       [KS_Tab] = XK_Tab,
+       [KS_Linefeed] = XK_Linefeed,
+       [KS_Clear] = XK_Clear,
+       [KS_Return] = XK_Return,
+       [KS_Escape] = XK_Escape,
+       [KS_space] = XK_space,
+       [KS_exclam] = XK_exclam,
+       [KS_quotedbl] = XK_quotedbl,
+       [KS_numbersign] = XK_numbersign,
+       [KS_dollar] = XK_dollar,
+       [KS_percent] = XK_percent,
+       [KS_ampersand] = XK_ampersand,
+       [KS_apostrophe] = XK_apostrophe,
+       [KS_parenleft] = XK_parenleft,
+       [KS_parenright] = XK_parenright,
+       [KS_asterisk] = XK_asterisk,
+       [KS_plus] = XK_plus,
+       [KS_comma] = XK_comma,
+       [KS_minus] = XK_minus,
+       [KS_period] = XK_period,
+       [KS_slash] = XK_slash,
+       [KS_0] = XK_0,
+       [KS_1] = XK_1,
+       [KS_2] = XK_2,
+       [KS_3] = XK_3,
+       [KS_4] = XK_4,
+       [KS_5] = XK_5,
+       [KS_6] = XK_6,
+       [KS_7] = XK_7,
+       [KS_8] = XK_8,
+       [KS_9] = XK_9,
+       [KS_colon] = XK_colon,
+       [KS_semicolon] = XK_semicolon,
+       [KS_less] = XK_less,
+       [KS_equal] = XK_equal,
+       [KS_greater] = XK_greater,
+       [KS_question] = XK_question,
+       [KS_at] = XK_at,
+       [KS_A] = XK_A,
+       [KS_B] = XK_B,
+       [KS_C] = XK_C,
+       [KS_D] = XK_D,
+       [KS_E] = XK_E,
+       [KS_F] = XK_F,
+       [KS_G] = XK_G,
+       [KS_H] = XK_H,
+       [KS_I] = XK_I,
+       [KS_J] = XK_J,
+       [KS_K] = XK_K,
+       [KS_L] = XK_L,
+       [KS_M] = XK_M,
+       [KS_N] = XK_N,
+       [KS_O] = XK_O,
+       [KS_P] = XK_P,
+       [KS_Q] = XK_Q,
+       [KS_R] = XK_R,
+       [KS_S] = XK_S,
+       [KS_T] = XK_T,
+       [KS_U] = XK_U,
+       [KS_V] = XK_V,
+       [KS_W] = XK_W,
+       [KS_X] = XK_X,
+       [KS_Y] = XK_Y,
+       [KS_Z] = XK_Z,
+       [KS_bracketleft] = XK_bracketleft,
+       [KS_backslash] = XK_backslash,
+       [KS_bracketright] = XK_bracketright,
+       [KS_asciicircum] = XK_asciicircum,
+       [KS_underscore] = XK_underscore,
+       [KS_grave] = XK_grave,
+       [KS_a] = XK_a,
+       [KS_b] = XK_b,
+       [KS_c] = XK_c,
+       [KS_d] = XK_d,
+       [KS_e] = XK_e,
+       [KS_f] = XK_f,
+       [KS_g] = XK_g,
+       [KS_h] = XK_h,
+       [KS_i] = XK_i,
+       [KS_j] = XK_j,
+       [KS_k] = XK_k,
+       [KS_l] = XK_l,
+       [KS_m] = XK_m,
+       [KS_n] = XK_n,
+       [KS_o] = XK_o,
+       [KS_p] = XK_p,
+       [KS_q] = XK_q,
+       [KS_r] = XK_r,
+       [KS_s] = XK_s,
+       [KS_t] = XK_t,
+       [KS_u] = XK_u,
+       [KS_v] = XK_v,
+       [KS_w] = XK_w,
+       [KS_x] = XK_x,
+       [KS_y] = XK_y,
+       [KS_z] = XK_z,
+       [KS_braceleft] = XK_braceleft,
+       [KS_bar] = XK_bar,
+       [KS_braceright] = XK_braceright,
+       [KS_asciitilde] = XK_asciitilde,
+       [KS_Delete] = XK_Delete,
+       [KS_nobreakspace] = XK_nobreakspace,
+       [KS_exclamdown] = XK_exclamdown,
+       [KS_cent] = XK_cent,
+       [KS_sterling] = XK_sterling,
+       [KS_currency] = XK_currency,
+       [KS_yen] = XK_yen,
+       [KS_brokenbar] = XK_brokenbar,
+       [KS_section] = XK_section,
+       [KS_diaeresis] = XK_diaeresis,
+       [KS_copyright] = XK_copyright,
+       [KS_ordfeminine] = XK_ordfeminine,
+       [KS_guillemotleft] = XK_guillemotleft,
+       [KS_notsign] = XK_notsign,
+       [KS_hyphen] = XK_hyphen,
+       [KS_registered] = XK_registered,
+       [KS_macron] = XK_macron,
+       [KS_degree] = XK_degree,
+       [KS_plusminus] = XK_plusminus,
+       [KS_twosuperior] = XK_twosuperior,
+       [KS_threesuperior] = XK_threesuperior,
+       [KS_acute] = XK_acute,
+       [KS_mu] = XK_mu,
+       [KS_paragraph] = XK_paragraph,
+       [KS_periodcentered] = XK_periodcentered,
+       [KS_cedilla] = XK_cedilla,
+       [KS_onesuperior] = XK_onesuperior,
+       [KS_masculine] = XK_masculine,
+       [KS_guillemotright] = XK_guillemotright,
+       [KS_onequarter] = XK_onequarter,
+       [KS_onehalf] = XK_onehalf,
+       [KS_threequarters] = XK_threequarters,
+       [KS_questiondown] = XK_questiondown,
+       [KS_Agrave] = XK_Agrave,
+       [KS_Aacute] = XK_Aacute,
+       [KS_Acircumflex] = XK_Acircumflex,
+       [KS_Atilde] = XK_Atilde,
+       [KS_Adiaeresis] = XK_Adiaeresis,
+       [KS_Aring] = XK_Aring,
+       [KS_AE] = XK_AE,
+       [KS_Ccedilla] = XK_Ccedilla,
+       [KS_Egrave] = XK_Egrave,
+       [KS_Eacute] = XK_Eacute,
+       [KS_Ecircumflex] = XK_Ecircumflex,
+       [KS_Ediaeresis] = XK_Ediaeresis,
+       [KS_Igrave] = XK_Igrave,
+       [KS_Iacute] = XK_Iacute,
+       [KS_Icircumflex] = XK_Icircumflex,
+       [KS_Idiaeresis] = XK_Idiaeresis,
+       [KS_ETH] = XK_ETH,
+       [KS_Ntilde] = XK_Ntilde,
+       [KS_Ograve] = XK_Ograve,
+       [KS_Oacute] = XK_Oacute,
+       [KS_Ocircumflex] = XK_Ocircumflex,
+       [KS_Otilde] = XK_Otilde,
+       [KS_Odiaeresis] = XK_Odiaeresis,
+       [KS_multiply] = XK_multiply,
+       [KS_Ooblique] = XK_Ooblique,
+       [KS_Ugrave] = XK_Ugrave,
+       [KS_Uacute] = XK_Uacute,
+       [KS_Ucircumflex] = XK_Ucircumflex,
+       [KS_Udiaeresis] = XK_Udiaeresis,
+       [KS_Yacute] = XK_Yacute,
+       [KS_THORN] = XK_THORN,
+       [KS_ssharp] = XK_ssharp,
+       [KS_agrave] = XK_agrave,
+       [KS_aacute] = XK_aacute,
+       [KS_acircumflex] = XK_acircumflex,
+       [KS_atilde] = XK_atilde,
+       [KS_adiaeresis] = XK_adiaeresis,
+       [KS_aring] = XK_aring,
+       [KS_ae] = XK_ae,
+       [KS_ccedilla] = XK_ccedilla,
+       [KS_egrave] = XK_egrave,
+       [KS_eacute] = XK_eacute,
+       [KS_ecircumflex] = XK_ecircumflex,
+       [KS_ediaeresis] = XK_ediaeresis,
+       [KS_igrave] = XK_igrave,
+       [KS_iacute] = XK_iacute,
+       [KS_icircumflex] = XK_icircumflex,
+       [KS_idiaeresis] = XK_idiaeresis,
+       [KS_eth] = XK_eth,
+       [KS_ntilde] = XK_ntilde,
+       [KS_ograve] = XK_ograve,
+       [KS_oacute] = XK_oacute,
+       [KS_ocircumflex] = XK_ocircumflex,
+       [KS_otilde] = XK_otilde,
+       [KS_odiaeresis] = XK_odiaeresis,
+       [KS_division] = XK_division,
+       [KS_oslash] = XK_oslash,
+       [KS_ugrave] = XK_ugrave,
+       [KS_uacute] = XK_uacute,
+       [KS_ucircumflex] = XK_ucircumflex,
+       [KS_udiaeresis] = XK_udiaeresis,
+       [KS_yacute] = XK_yacute,
+       [KS_thorn] = XK_thorn,
+       [KS_ydiaeresis] = XK_ydiaeresis,
+       [KS_Odoubleacute] = XK_Odoubleacute,
+       [KS_odoubleacute] = XK_odoubleacute,
+       [KS_Udoubleacute] = XK_Udoubleacute,
+       [KS_udoubleacute] = XK_udoubleacute,
+       [KS_dead_grave] = XK_dead_grave,
+       [KS_dead_acute] = XK_dead_acute,
+       [KS_dead_circumflex] = XK_dead_circumflex,
+       [KS_dead_tilde] = XK_dead_tilde,
+       [KS_dead_diaeresis] = XK_dead_diaeresis,
+       [KS_dead_abovering] = XK_dead_abovering,
+       [KS_dead_cedilla] = XK_dead_cedilla,
+       [KS_Shift_L] = XK_Shift_L,
+       [KS_Shift_R] = XK_Shift_R,
+       [KS_Control_L] = XK_Control_L,
+       [KS_Control_R] = XK_Control_R,
+       [KS_Caps_Lock] = XK_Caps_Lock,
+       [KS_Shift_Lock] = XK_Shift_Lock,
+       [KS_Alt_L] = XK_Alt_L,
+       [KS_Alt_R] = XK_Alt_R,
+       [KS_Multi_key] = XK_Multi_key,
+       [KS_Mode_switch] = XK_Mode_switch,
+       [KS_Num_Lock] = XK_Num_Lock,
+       [KS_Meta_L] = XK_Meta_L,
+       [KS_Meta_R] = XK_Meta_R,
+       [KS_Zenkaku_Hankaku] = XK_Zenkaku_Hankaku,
+       [KS_Hiragana_Katakana] = XK_Hiragana_Katakana,
+       [KS_Henkan_Mode] = XK_Henkan_Mode,
+       [KS_Henkan] = XK_Henkan,
+       [KS_Muhenkan] = XK_Muhenkan,
+       [KS_KP_F1] = XK_KP_F1,
+       [KS_KP_F2] = XK_KP_F2,
+       [KS_KP_F3] = XK_KP_F3,
+       [KS_KP_F4] = XK_KP_F4,
+       [KS_KP_Home] = XK_KP_Home,
+       [KS_KP_Left] = XK_KP_Left,
+       [KS_KP_Up] = XK_KP_Up,
+       [KS_KP_Right] = XK_KP_Right,
+       [KS_KP_Down] = XK_KP_Down,
+       [KS_KP_Prior] = XK_KP_Prior,
+       [KS_KP_Next] = XK_KP_Next,
+       [KS_KP_End] = XK_KP_End,
+       [KS_KP_Begin] = XK_KP_Begin,
+       [KS_KP_Insert] = XK_KP_Insert,
+       [KS_KP_Delete] = XK_KP_Delete,
+       [KS_KP_Space] = XK_KP_Space,
+       [KS_KP_Tab] = XK_KP_Tab,
+       [KS_KP_Enter] = XK_KP_Enter,
+       [KS_KP_Equal] = XK_KP_Equal,
+       [KS_KP_Numbersign] = XK_numbersign,
+       [KS_KP_Multiply] = XK_KP_Multiply,
+       [KS_KP_Add] = XK_KP_Add,
+       [KS_KP_Separator] = XK_KP_Separator,
+       [KS_KP_Subtract] = XK_KP_Subtract,
+       [KS_KP_Decimal] = XK_KP_Decimal,
+       [KS_KP_Divide] = XK_KP_Divide,
+       [KS_KP_0] = XK_KP_0,
+       [KS_KP_1] = XK_KP_1,
+       [KS_KP_2] = XK_KP_2,
+       [KS_KP_3] = XK_KP_3,
+       [KS_KP_4] = XK_KP_4,
+       [KS_KP_5] = XK_KP_5,
+       [KS_KP_6] = XK_KP_6,
+       [KS_KP_7] = XK_KP_7,
+       [KS_KP_8] = XK_KP_8,
+       [KS_KP_9] = XK_KP_9,
+       [KS_f1] = XK_F1,
+       [KS_f2] = XK_F2,
+       [KS_f3] = XK_F3,
+       [KS_f4] = XK_F4,
+       [KS_f5] = XK_F5,
+       [KS_f6] = XK_F6,
+       [KS_f7] = XK_F7,
+       [KS_f8] = XK_F8,
+       [KS_f9] = XK_F9,
+       [KS_f10] = XK_F10,
+       [KS_f11] = XK_F11,
+       [KS_f12] = XK_F12,
+       [KS_f13] = XK_F13,
+       [KS_f14] = XK_F14,
+       [KS_f15] = XK_F15,
+       [KS_f16] = XK_F16,
+       [KS_f17] = XK_F17,
+       [KS_f18] = XK_F18,
+       [KS_f19] = XK_F19,
+       [KS_f20] = XK_F20,
+       [KS_F1] = XK_F1,
+       [KS_F2] = XK_F2,
+       [KS_F3] = XK_F3,
+       [KS_F4] = XK_F4,
+       [KS_F5] = XK_F5,
+       [KS_F6] = XK_F6,
+       [KS_F7] = XK_F7,
+       [KS_F8] = XK_F8,
+       [KS_F9] = XK_F9,
+       [KS_F10] = XK_F10,
+       [KS_F11] = XK_F11,
+       [KS_F12] = XK_F12,
+       [KS_F13] = XK_F13,
+       [KS_F14] = XK_F14,
+       [KS_F15] = XK_F15,
+       [KS_F16] = XK_F16,
+       [KS_F17] = XK_F17,
+       [KS_F18] = XK_F18,
+       [KS_F19] = XK_F19,
+       [KS_F20] = XK_F20,
+       [KS_Home] = XK_Home,
+       [KS_Prior] = XK_Prior,
+       [KS_Next] = XK_Next,
+       [KS_Up] = XK_Up,
+       [KS_Down] = XK_Down,
+       [KS_Left] = XK_Left,
+       [KS_Right] = XK_Right,
+       [KS_End] = XK_End,
+       [KS_Insert] = XK_Insert,
+       [KS_Help] = XK_Help,
+       [KS_Execute] = XK_Execute,
+       [KS_Find] = XK_Find,
+       [KS_Select] = XK_Select,
+       [KS_Undo] = XK_Undo,
+       [KS_Menu] = XK_Menu,
+       [KS_Pause] = XK_Pause,
+       [0xffff] = NoSymbol,
+};
+
+int
+KbdGetMappingFromWsksym(InputInfoPtr pInfo, KeySymsPtr pKeySyms, CARD8 
*pModMap)
+{
+       struct wskbd_map_data map_data;
+       struct wscons_keymap *wscons_keymap, *wscons_key;
+       KeySym *x_key;
+       CARD8 *x_mod;
+       int i;
+
+       wscons_keymap =
+           malloc(sizeof(struct wscons_keymap) * WSKBDIO_MAXMAPLEN);
+       if (wscons_keymap == NULL) {
+               xf86Msg(X_ERROR, "%s: can't allocate wscons keymap memory\n",
+                   pInfo->name);
+               return 1;
+       }
+       memset(wscons_keymap, 0,
+           sizeof(struct wscons_keymap) * WSKBDIO_MAXMAPLEN);
+       map_data.maplen = WSKBDIO_MAXMAPLEN;
+       map_data.map = wscons_keymap;
+
+       /* Get console keymap */
+       if (ioctl(pInfo->fd, WSKBDIO_GETMAP, &map_data) == -1) {
+               xf86Msg(X_ERROR, "%s: can't get wskbd keymap\n", pInfo->name);
+               return 1;
+       }
+       pKeySyms->maxKeyCode = pKeySyms->minKeyCode + map_data.maplen - 1;
+
+       xf86Msg(X_INFO, "%s: Using keysyms via WSKBDIO_GETMAP\n", pInfo->name);
+       xf86Msg(X_INFO, "%s: wskbd keysym map length: %d\n",
+           pInfo->name, map_data.maplen);
+
+       /* Reconstruct keymap */
+       for (i = 0;
+           i < sizeof wsksym_to_xkeysym / sizeof(wsksym_to_xkeysym[0]); i++)
+               if (wsksym_to_xkeysym[i] == 0)
+                       wsksym_to_xkeysym[i] = NoSymbol;
+       x_key = &pKeySyms->map[0];
+       x_mod = &pModMap[pKeySyms->minKeyCode];
+       wscons_key = wscons_keymap;
+       for (i = 0; i < map_data.maplen; i++) {
+               if (i == NUM_KEYCODES) {
+                       xf86Msg(X_WARNING, "%s: too many wskbd keysyms\n",
+                           pInfo->name);
+                       break;
+               }
+               KeymapSetSymbol(x_key, x_mod, wscons_key);
+               x_key += GLYPHS_PER_KEY;
+               x_mod++;
+               wscons_key++;
+       }
+       free(wscons_keymap);
+
+       return 0;
+}
+
+static void
+KeymapSetSymbol(KeySym *xmap, CARD8 *pModMap, struct wscons_keymap *keymap)
+{
+
+       /* Set KeySyms */
+       /* XXX: assume GLYPHS_PER_KEY is 4 */
+       xmap[0] = wsksym_to_xkeysym[keymap->group1[0]]; /* normal       */
+       xmap[1] = wsksym_to_xkeysym[keymap->group1[1]]; /* Shift        */
+       xmap[2] = wsksym_to_xkeysym[keymap->group2[0]]; /* Alt          */
+       xmap[3] = wsksym_to_xkeysym[keymap->group2[1]]; /* Alt + Shift  */
+
+       /* Set modifier map */
+       switch (xmap[0]) {
+       case XK_Shift_L:
+       case XK_Shift_R:
+               *pModMap = ShiftMask;
+               break;
+       case XK_Control_L:
+       case XK_Control_R:
+               *pModMap = ControlMask;
+               break;
+       case XK_Caps_Lock:
+               *pModMap = LockMask;
+               break;
+       case XK_Alt_L:
+               *pModMap = AltMask;
+               xmap[1] = XK_Meta_L;
+               break;
+       case XK_Alt_R:
+               *pModMap = AltMask;
+               xmap[1] = XK_Meta_R;
+               break;
+       case XK_Num_Lock:
+               *pModMap = NumLockMask;
+               break;
+       case XK_Scroll_Lock:
+               *pModMap = ScrollLockMask;
+               break;
+       case XK_Kana_Lock:
+       case XK_Kana_Shift:
+               *pModMap = KanaMask;
+               break;
+       case XK_Mode_switch:    /* XXX correct? Should check XK_Henkan? */
+               *pModMap = AltLangMask;
+               break;
+       default:
+               *pModMap = NoSymbol;
+               break;
+       }
+}


sample xorg.conf:
---

Section "ServerLayout"
        Identifier      "wsfb"
        Screen  0       "Screen0" 0 0
        InputDevice     "Mouse0" "CorePointer"
        InputDevice     "Keyboard0" "CoreKeyboard"
EndSection
        
Section "Files"
        FontPath        "/usr/X11R7/lib/X11/fonts/misc/"
        FontPath        "/usr/X11R7/lib/X11/fonts/TTF/"
        FontPath        "/usr/X11R7/lib/X11/fonts/Type1/"
        FontPath        "/usr/X11R7/lib/X11/fonts/75dpi/"
        FontPath        "/usr/pkg/lib/X11/fonts/TTF/"
EndSection

Section "InputDevice"
        Identifier      "Keyboard0"
        Driver          "kbd"
        Option          "Protocol"      "wskbd"
        Option          "Device"        "/dev/wskbd0"
EndSection

Section "InputDevice"
        Identifier      "Mouse0"
        Driver          "mouse"
        Option          "Protocol"      "wsmouse"
        Option          "Device"        "/dev/wsmouse"
        Option          "ZAxisMapping"  "4 5 6 7"
EndSection

Section "Device"
        Identifier      "Wsdisplay0"
        Driver          "wsfb"
EndSection

Section "Monitor"
        Identifier      "Monitor"
EndSection

Section "Screen"
        Identifier      "Screen0"
        Device          "Wsdisplay0"
        Monitor         "Monitor"

        SubSection "Display"
                Viewport        0 0
                Depth           1
        EndSubSection
        SubSection "Display"
                Viewport        0 0
                Depth           8
        EndSubSection
        SubSection "Display"
                Viewport        0 0
                Depth           16
        EndSubSection
EndSection
---

Xorg.0.log output:
---
X.Org X Server 1.6.5
Release Date: 2009-10-12
X Protocol Version 11, Revision 0
Build Operating System: NetBSD/dreamcast  - 
Current Operating System: NetBSD dreamcast 5.99.39 NetBSD 5.99.39 (GENERIC) #0: 
Mon Oct 11 04:27:26 JST 2010  
tsutsui@mirage:/usr/obj.dreamcast/sys/arch/dreamcast/compile/GENERIC dreamcast
Build Date: 12 October 2009  12:14:03AM
 
        Before reporting problems, check http://wiki.X.Org
        to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
        (++) from command line, (!!) notice, (II) informational,
        (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.0.log", Time: Sun Oct 24 16:51:18 2010
(==) Using config file: "/etc/xorg.conf"
(==) ServerLayout "wsfb"
(**) |-->Screen "Screen0" (0)
(**) |   |-->Monitor "Monitor"
(**) |   |-->Device "Wsdisplay0"
(**) |-->Input Device "Mouse0"
(**) |-->Input Device "Keyboard0"
(==) Not automatically adding devices
(==) Not automatically enabling devices
(WW) The directory "/usr/pkg/lib/X11/fonts/TTF/" does not exist.
        Entry deleted from font path.
(**) FontPath set to:
        /usr/X11R7/lib/X11/fonts/misc/,
        /usr/X11R7/lib/X11/fonts/TTF/,
        /usr/X11R7/lib/X11/fonts/Type1/,
        /usr/X11R7/lib/X11/fonts/75dpi/,
        /usr/X11R7/lib/X11/fonts/misc/,
        /usr/X11R7/lib/X11/fonts/TTF/,
        /usr/X11R7/lib/X11/fonts/Type1/,
        /usr/X11R7/lib/X11/fonts/75dpi/,
        /usr/X11R7/lib/X11/fonts/100dpi/
(==) ModulePath set to "/usr/X11R7/lib/modules"
(II) Loader magic: 0x874
(II) Module ABI versions:
        X.Org ANSI C Emulation: 0.4
        X.Org Video Driver: 5.0
        X.Org XInput driver : 4.0
        X.Org Server Extension : 2.0
(II) Loader running on netbsd
(--) Using wscons driver
(II) System resource ranges:
        [0] -1  0       0x000f0000 - 0x000fffff (0x10000) MX[B]
        [1] -1  0       0x000c0000 - 0x000effff (0x30000) MX[B]
        [2] -1  0       0x00000000 - 0x0009ffff (0xa0000) MX[B]
        [3] -1  0       0x0000ffff - 0x0000ffff (0x1) IX[B]
        [4] -1  0       0x00000000 - 0x000000ff (0x100) IX[B]
(II) LoadModule: "extmod"
(II) Loading /usr/X11R7/lib/modules/extensions//libextmod.so
(II) Module extmod: vendor="X.Org Foundation"
        compiled for 1.6.5, module version = 1.0.0
        Module class: X.Org Server Extension
        ABI class: X.Org Server Extension, version 2.0
(II) Loading extension MIT-SCREEN-SAVER
(II) Loading extension XFree86-VidModeExtension
(II) Loading extension XFree86-DGA
(II) Loading extension DPMS
(II) Loading extension XVideo
(II) Loading extension XVideo-MotionCompensation
(II) Loading extension X-Resource
(II) LoadModule: "dbe"
(II) Loading /usr/X11R7/lib/modules/extensions//libdbe.so
(II) Module dbe: vendor="X.Org Foundation"
        compiled for 1.6.5, module version = 1.0.0
        Module class: X.Org Server Extension
        ABI class: X.Org Server Extension, version 2.0
(II) Loading extension DOUBLE-BUFFER
(II) LoadModule: "glx"
(II) Loading /usr/X11R7/lib/modules/extensions//libglx.so
(II) Module glx: vendor="X.Org Foundation"
        compiled for 1.6.5, module version = 1.0.0
        ABI class: X.Org Server Extension, version 2.0
(==) AIGLX enabled
(II) Loading extension GLX
(II) LoadModule: "record"
(II) Loading /usr/X11R7/lib/modules/extensions//librecord.so
(II) Module record: vendor="X.Org Foundation"
        compiled for 1.6.5, module version = 1.13.0
        Module class: X.Org Server Extension
        ABI class: X.Org Server Extension, version 2.0
(II) Loading extension RECORD
(II) LoadModule: "dri"
(II) Loading /usr/X11R7/lib/modules/extensions//libdri.so
(II) Module dri: vendor="X.Org Foundation"
        compiled for 1.6.5, module version = 1.0.0
        ABI class: X.Org Server Extension, version 2.0
(II) Loading extension XFree86-DRI
(II) LoadModule: "dri2"
(II) Loading /usr/X11R7/lib/modules/extensions//libdri2.so
(II) Module dri2: vendor="X.Org Foundation"
        compiled for 1.6.5, module version = 1.1.0
        ABI class: X.Org Server Extension, version 2.0
(II) Loading extension DRI2
(II) LoadModule: "wsfb"
(II) Loading /usr/X11R7/lib/modules/drivers//wsfb_drv.so
(II) Module wsfb: vendor="X.Org Foundation"
        compiled for 1.6.5, module version = 0.3.0
        ABI class: X.Org Video Driver, version 5.0
(II) LoadModule: "mouse"
(II) Loading /usr/X11R7/lib/modules/drivers//mouse_drv.so
(II) Module mouse: vendor="X.Org Foundation"
        compiled for 1.6.5, module version = 1.5.0
        Module class: X.Org XInput Driver
        ABI class: X.Org XInput driver, version 4.0
(II) LoadModule: "kbd"
(II) Loading /usr/X11R7/lib/modules/drivers//kbd_drv.so
(II) Module kbd: vendor="X.Org Foundation"
        compiled for 1.6.5, module version = 1.4.0
        Module class: X.Org XInput Driver
        ABI class: X.Org XInput driver, version 4.0
(II) wsfb: driver for wsdisplay framebuffer: wsfb
(WW) Falling back to old probe method for wsfb
(II) wsfb(0): using default device
(II) Running in FRAMEBUFFER Mode
(==) wsfb(0): Depth 16, (==) framebuffer bpp 16
(==) wsfb(0): RGB weight 565
(==) wsfb(0): Default visual is TrueColor
(==) wsfb(0): Using gamma correction (1.0, 1.0, 1.0)
(II) wsfb(0): Vidmem: 600k
(==) wsfb(0): DPI set to (96, 96)
(==) wsfb(0): Using HW cursor
(**) wsfb(0): Using "Shadow Framebuffer"
(II) Loading sub module "shadow"
(II) LoadModule: "shadow"
(II) Loading /usr/X11R7/lib/modules/extensions//libshadow.so
(II) Module shadow: vendor="X.Org Foundation"
        compiled for 1.6.5, module version = 1.1.0
        ABI class: X.Org ANSI C Emulation, version 0.4
(II) Loading sub module "fb"
(II) LoadModule: "fb"
(II) Loading /usr/X11R7/lib/modules//libfb.so
(II) Module fb: vendor="X.Org Foundation"
        compiled for 1.6.5, module version = 1.0.0
        ABI class: X.Org ANSI C Emulation, version 0.4
(II) Loading sub module "ramdac"
(II) LoadModule: "ramdac"
(II) Module "ramdac" already built-in
(==) wsfb(0): Backing store disabled
(WW) No HW cursor support found
(==) RandR enabled
(II) Initializing built-in extension Generic Event Extension
(II) Initializing built-in extension SHAPE
(II) Initializing built-in extension MIT-SHM
(II) Initializing built-in extension XInputExtension
(II) Initializing built-in extension XTEST
(II) Initializing built-in extension BIG-REQUESTS
(II) Initializing built-in extension SYNC
(II) Initializing built-in extension XKEYBOARD
(II) Initializing built-in extension XC-MISC
(II) Initializing built-in extension SECURITY
(II) Initializing built-in extension XINERAMA
(II) Initializing built-in extension XFIXES
(II) Initializing built-in extension XFree86-Bigfont
(II) Initializing built-in extension RENDER
(II) Initializing built-in extension RANDR
(II) Initializing built-in extension COMPOSITE
(II) Initializing built-in extension DAMAGE
(II) AIGLX: Screen 0 is not DRI capable
(II) AIGLX: Loaded and initialized /usr/X11R7/lib/modules/dri/swrast_dri.so
(II) GLX: Initialized DRISWRAST GL provider for screen 0
(**) Option "Protocol" "wsmouse"
(**) Mouse0: Protocol: wsmouse
(**) Option "CorePointer"
(**) Mouse0: always reports core events
(**) Option "Device" "/dev/wsmouse"
(==) Mouse0: Emulate3Buttons, Emulate3Timeout: 50
(**) Option "ZAxisMapping" "4 5 6 7"
(**) Mouse0: ZAxisMapping: buttons 4, 5, 6 and 7
(**) Mouse0: Buttons: 11
(II) XINPUT: Adding extended input device "Mouse0" (type: MOUSE)
(**) Mouse0: (accel) keeping acceleration scheme 1
(**) Mouse0: (accel) filter chain progression: 2.00
(**) Mouse0: (accel) filter stage 0: 20.00 ms
(**) Mouse0: (accel) set acceleration profile 0
(**) Option "CoreKeyboard"
(**) Keyboard0: always reports core events
(**) Option "Protocol" "wskbd"
(**) Keyboard0: Protocol: wskbd
(**) Option "Device" "/dev/wskbd0"
(WW) Keyboard0: Unknown wskbd type "14"
(--) Keyboard0: Keyboard type: Unknown wskbd
(**) Option "XkbRules" "base"
(**) Keyboard0: XkbRules: "base"
(**) Option "XkbModel" "pc105"
(**) Keyboard0: XkbModel: "pc105"
(**) Option "XkbLayout" "us"
(**) Keyboard0: XkbLayout: "us"
(**) Option "CustomKeycodes" "off"
(**) Keyboard0: CustomKeycodes disabled
(II) XINPUT: Adding extended input device "Keyboard0" (type: KEYBOARD)
(II) Keyboard0: Using keysyms via WSKBDIO_GETMAP
(II) Keyboard0: wskbd keysym map length: 232

---
Izumi Tsutsui


Home | Main Index | Thread Index | Old Index