Default keyboard mapping
Alexander Gottwald
Alexander.Gottwald@s1999.tu-chemnitz.de
Fri Jan 24 13:41:00 GMT 2003
Harold L Hunt II wrote:
> That would be extremely cool. I have thought about doing the same thing
> myself, but I find that I simply do not know enough about keyboard
> layouts to be able to do this on my own.
>
> Hopefully you have better luck than I :)
It's quite simple. Now we only need to fill the table.
bye
ago
--
Alexander.Gottwald@informatik.tu-chemnitz.de
http://www.gotti.org ICQ: 126018723
-------------- next part --------------
Index: winconfig.c
===================================================================
RCS file: /cvs/xc/programs/Xserver/hw/xwin/winconfig.c,v
retrieving revision 1.1
diff -u -r1.1 winconfig.c
--- winconfig.c 2002/10/17 08:18:22 1.1
+++ winconfig.c 2003/01/24 12:23:01
@@ -213,9 +213,30 @@
/* Set the keyboard configuration */
+typedef struct {
+ int winlayout;
+ int winkbtype;
+ char *xkbmodel;
+ char *xkblayout;
+ char *xkbvariant;
+ char *xkboptions;
+ char *layoutname;
+} WinKBLayoutRec, *WinKBLayoutPtr;
+
+WinKBLayoutRec winKBLayouts[] = {
+ {0x406, 4, "pc105", "dk", NULL, NULL, "Danish"},
+ {0x407, 4, "pc105", "de", "nodeadkeys", NULL, "German (Germany)"},
+ {0x41d, 4, "pc105", "se", NULL, NULL, "Swedish (Sweden)"},
+ {0x809, 4, "pc105", "gb", NULL, NULL, "English (United Kingdom)"},
+ {-1, -1, NULL, NULL, NULL, NULL, NULL}
+};
+
Bool
winConfigKeyboard (DeviceIntPtr pDevice)
{
+ char layoutName[KL_NAMELENGTH];
+ int layoutNum;
+ int keyboardType;
XF86ConfInputPtr kbd = NULL;
XF86ConfInputPtr input_list = NULL;
MessageType from = X_DEFAULT;
@@ -237,6 +258,31 @@
g_winInfo.xkb.variant = NULL;
g_winInfo.xkb.options = NULL;
# endif /* PC98 */
+
+
+
+ keyboardType = GetKeyboardType(0);
+ if (keyboardType > 0 && GetKeyboardLayoutName(layoutName))
+ {
+ layoutNum = strtol(layoutName, (char **)NULL, 16);
+ WinKBLayoutPtr pLayout = winKBLayouts;
+ for (pLayout = winKBLayouts; pLayout->winlayout != -1; pLayout++) {
+ if (pLayout->winlayout != layoutNum)
+ continue;
+ if (pLayout->winkbtype > 0 && pLayout->winkbtype != keyboardType)
+ continue;
+
+ winMsg (X_DEFAULT, "Using preset keyboard for \"%s\" (%s), type \"%d\"\n",
+ pLayout->layoutname, layoutName, keyboardType);
+
+ g_winInfo.xkb.model = pLayout->xkbmodel;
+ g_winInfo.xkb.layout = pLayout->xkblayout;
+ g_winInfo.xkb.variant = pLayout->xkbvariant;
+ g_winInfo.xkb.options = pLayout->xkboptions;
+ break;
+ }
+ }
+
g_winInfo.xkb.initialMap = NULL;
g_winInfo.xkb.keymap = NULL;
g_winInfo.xkb.types = NULL;
More information about the Cygwin-xfree
mailing list