summaryrefslogtreecommitdiffstats
path: root/genkeymap
diff options
context:
space:
mode:
authorJay Sorg <jay.sorg@gmail.com>2014-11-13 22:08:14 -0800
committerJay Sorg <jay.sorg@gmail.com>2014-11-13 22:08:14 -0800
commit32f172853f9763f4b046c9e5465813a0aa5e3f1c (patch)
tree8f20d0d783696e680ac37725afb0e0a62f677f47 /genkeymap
parentddfd6b8b59ae411f15622ba4e50ef895b1e23e23 (diff)
parent942cdf300edaed7fee13a78e5e1c9b9c3d9c923e (diff)
downloadxrdp-proprietary-32f172853f9763f4b046c9e5465813a0aa5e3f1c.tar.gz
xrdp-proprietary-32f172853f9763f4b046c9e5465813a0aa5e3f1c.zip
Merge branch 'devel'
Diffstat (limited to 'genkeymap')
-rw-r--r--genkeymap/Makefile.am2
-rwxr-xr-xgenkeymap/dump-keymaps.sh4
-rw-r--r--genkeymap/evdev-map.c156
-rw-r--r--genkeymap/genkeymap.c43
-rw-r--r--genkeymap/readme.txt5
5 files changed, 202 insertions, 8 deletions
diff --git a/genkeymap/Makefile.am b/genkeymap/Makefile.am
index e358c61b..aed72512 100644
--- a/genkeymap/Makefile.am
+++ b/genkeymap/Makefile.am
@@ -2,7 +2,7 @@
bin_PROGRAMS = \
xrdp-genkeymap
-xrdp_genkeymap_SOURCES = genkeymap.c
+xrdp_genkeymap_SOURCES = genkeymap.c evdev-map.c
xrdp_genkeymap_LDADD = \
-L/usr/X11R6/lib \
diff --git a/genkeymap/dump-keymaps.sh b/genkeymap/dump-keymaps.sh
index e0f3b3b2..a78caa95 100755
--- a/genkeymap/dump-keymaps.sh
+++ b/genkeymap/dump-keymaps.sh
@@ -19,6 +19,10 @@ setxkbmap -model pc104 -layout de
setxkbmap -model pc104 -layout it
./xrdp-genkeymap ../instfiles/km-0410.ini
+# Polish 'pl' 0x0415
+setxkbmap -model pc104 -layout pl
+./xrdp-genkeymap ../instfiles/km-0415.ini
+
# Russia 'ru' 0x0419
setxkbmap -model pc104 -layout ru
./xrdp-genkeymap ../instfiles/km-0419.ini
diff --git a/genkeymap/evdev-map.c b/genkeymap/evdev-map.c
new file mode 100644
index 00000000..4610eb69
--- /dev/null
+++ b/genkeymap/evdev-map.c
@@ -0,0 +1,156 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * evdev-map.c
+ * Copyright (C) Michał Górny 2014 <mgorny@gentoo.org>
+ *
+ * You may redistribute it and/or modify it under the terms of the
+ * GNU General Public License, as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * main.cc is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with main.cc. If not, write to:
+ * The Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301, USA
+ *
+ * xfree86(base)->evdev keycode mapping
+ */
+
+int xfree86_to_evdev[137-8+1] = {
+ /* MDSW */ 203,
+ /* ESC */ 9,
+ /* AE01 */ 10,
+ /* AE02 */ 11,
+ /* AE03 */ 12,
+ /* AE04 */ 13,
+ /* AE05 */ 14,
+ /* AE06 */ 15,
+ /* AE07 */ 16,
+ /* AE08 */ 17,
+ /* AE09 */ 18,
+ /* AE10 */ 19,
+ /* AE11 */ 20,
+ /* AE12 */ 21,
+ /* BKSP */ 22,
+ /* TAB */ 23,
+ /* AD01 */ 24,
+ /* AD02 */ 25,
+ /* AD03 */ 26,
+ /* AD04 */ 27,
+ /* AD05 */ 28,
+ /* AD06 */ 29,
+ /* AD07 */ 30,
+ /* AD08 */ 31,
+ /* AD09 */ 32,
+ /* AD10 */ 33,
+ /* AD11 */ 34,
+ /* AD12 */ 35,
+ /* RTRN */ 36,
+ /* LCTL */ 37,
+ /* AC01 */ 38,
+ /* AC02 */ 39,
+ /* AC03 */ 40,
+ /* AC04 */ 41,
+ /* AC05 */ 42,
+ /* AC06 */ 43,
+ /* AC07 */ 44,
+ /* AC08 */ 45,
+ /* AC09 */ 46,
+ /* AC10 */ 47,
+ /* AC11 */ 48,
+ /* TLDE */ 49,
+ /* LFSH */ 50,
+ /* BKSL */ 51,
+ /* AB01 */ 52,
+ /* AB02 */ 53,
+ /* AB03 */ 54,
+ /* AB04 */ 55,
+ /* AB05 */ 56,
+ /* AB06 */ 57,
+ /* AB07 */ 58,
+ /* AB08 */ 59,
+ /* AB09 */ 60,
+ /* AB10 */ 61,
+ /* RTSH */ 62,
+ /* KPMU */ 63,
+ /* LALT */ 64,
+ /* SPCE */ 65,
+ /* CAPS */ 66,
+ /* FK01 */ 67,
+ /* FK02 */ 68,
+ /* FK03 */ 69,
+ /* FK04 */ 70,
+ /* FK05 */ 71,
+ /* FK06 */ 72,
+ /* FK07 */ 73,
+ /* FK08 */ 74,
+ /* FK09 */ 75,
+ /* FK10 */ 76,
+ /* NMLK */ 77,
+ /* SCLK */ 78,
+ /* KP7 */ 79,
+ /* KP8 */ 80,
+ /* KP9 */ 81,
+ /* KPSU */ 82,
+ /* KP4 */ 83,
+ /* KP5 */ 84,
+ /* KP6 */ 85,
+ /* KPAD */ 86,
+ /* KP1 */ 87,
+ /* KP2 */ 88,
+ /* KP3 */ 89,
+ /* KP0 */ 90,
+ /* KPDL */ 91,
+ /* SYRQ */ 107,
+ /* II5D */ 0,
+ /* LSGT */ 94,
+ /* FK11 */ 95,
+ /* FK12 */ 96,
+ /* HOME */ 110,
+ /* UP */ 111,
+ /* PGUP */ 112,
+ /* LEFT */ 113,
+ /* II65 */ 0,
+ /* RGHT */ 114,
+ /* END */ 115,
+ /* DOWN */ 116,
+ /* PGDN */ 117,
+ /* INS */ 118,
+ /* DELE */ 119,
+ /* KPEN */ 104,
+ /* RCTL */ 105,
+ /* PAUS */ 127,
+ /* PRSC */ 107,
+ /* KPDV */ 106,
+ /* RALT */ 108,
+ /* BRK */ 419,
+ /* LWIN */ 133,
+ /* RWIN */ 134,
+ /* MENU */ 0,
+ /* FK13 */ 191,
+ /* FK14 */ 192,
+ /* FK15 */ 193,
+ /* FK16 */ 194,
+ /* FK17 */ 195,
+ /* KPDC */ 0,
+ /* LVL3 */ 92,
+ /* ALT */ 204,
+ /* KPEQ */ 125,
+ /* SUPR */ 206,
+ /* HYPR */ 207,
+ /* XFER */ 0,
+ /* I02 */ 0,
+ /* NFER */ 0,
+ /* I04 */ 0,
+ /* AE13 */ 132,
+ /* I06 */ 0,
+ /* I07 */ 0,
+ 0,
+ 0
+};
diff --git a/genkeymap/genkeymap.c b/genkeymap/genkeymap.c
index 91ec9e89..088af748 100644
--- a/genkeymap/genkeymap.c
+++ b/genkeymap/genkeymap.c
@@ -37,16 +37,19 @@
#include <string.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
+#include <X11/XKBlib.h>
#include <locale.h>
+extern int xfree86_to_evdev[137-8];
+
int main(int argc, char **argv)
{
const char *programname;
char text[256];
char *displayname = NULL;
char *outfname;
- char *sections[6] = {"noshift", "shift", "altgr", "shiftaltgr", "capslock", "shiftcapslock"};
- int states[6] = {0, 1, 0x80, 0x81, 2, 3};
+ char *sections[8] = {"noshift", "shift", "altgr", "shiftaltgr", "capslock", "capslockaltgr", "shiftcapslock", "shiftcapslockaltgr"};
+ int states[8] = {0, 1, 0x80, 0x81, 2, 0x82, 3, 0x83};
int i;
int idx;
int char_count;
@@ -57,6 +60,9 @@ int main(int argc, char **argv)
FILE *outf;
XKeyPressedEvent e;
wchar_t wtext[256];
+ XkbDescPtr kbdesc;
+ char *symatom;
+ int is_evdev;
setlocale(LC_CTYPE, "");
programname = argv[0];
@@ -78,6 +84,30 @@ int main(int argc, char **argv)
return 1;
}
+ /* check whether evdev is used */
+ kbdesc = XkbAllocKeyboard();
+ if (!kbdesc)
+ {
+ fprintf(stderr, "%s: unable to allocate keyboard desc\n",
+ programname);
+ XCloseDisplay(dpy);
+ return 1;
+ }
+
+ if (XkbGetNames(dpy, XkbKeycodesNameMask, kbdesc) != Success)
+ {
+ fprintf(stderr, "%s: unable to obtain keycode name for keyboard\n",
+ programname);
+ XkbFreeKeyboard(kbdesc, 0, True);
+ XCloseDisplay(dpy);
+ return 1;
+ }
+
+ symatom = XGetAtomName(dpy, kbdesc->names->keycodes);
+ is_evdev = !strncmp(symatom, "evdev", 5);
+ XFree(symatom);
+ XkbFreeKeyboard(kbdesc, 0, True);
+
outf = fopen(outfname, "w");
if (outf == NULL)
@@ -94,14 +124,17 @@ int main(int argc, char **argv)
e.display = dpy;
e.same_screen = True;
- for (idx = 0; idx < 6; idx++) /* Sections and states */
+ for (idx = 0; idx < 8; idx++) /* Sections and states */
{
fprintf(outf, "[%s]\n", sections[idx]);
e.state = states[idx];
for (i = 8; i <= 137; i++) /* Keycodes */
{
- e.keycode = i;
+ if (is_evdev)
+ e.keycode = xfree86_to_evdev[i-8];
+ else
+ e.keycode = i;
nbytes = XLookupString(&e, text, 255, &ks, NULL);
text[nbytes] = 0;
char_count = mbstowcs(wtext, text, 255);
@@ -115,7 +148,7 @@ int main(int argc, char **argv)
fprintf(outf, "Key%d=%d:%d\n", i, (int) ks, unicode);
}
- if (idx != 4)
+ if (idx != 7)
{
fprintf(outf, "\n");
}
diff --git a/genkeymap/readme.txt b/genkeymap/readme.txt
index d9df684d..b2b3b890 100644
--- a/genkeymap/readme.txt
+++ b/genkeymap/readme.txt
@@ -7,9 +7,10 @@ km-xxxx.ini
where the xxxx is replaced by the hex number of the layout of interest.
-The files have 6 sections;
+The files have 8 sections;
-[noshift], [shift], [altgr], [shiftaltgr], [capslock], [shiftcapslock]
+[noshift], [shift], [altgr], [shiftaltgr], [capslock], [capslockaltgr],
+[shiftcapslock], [shiftcapslockaltgr]
In each section there are multiple lines for each key.