|
|
@ -15,9 +15,11 @@
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with main.cc. If not, write to:
|
|
|
|
* along with main.cc. If not, write to:
|
|
|
|
* The Free Software Foundation, Inc.,
|
|
|
|
* The Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor
|
|
|
|
* 51 Franklin Street, Fifth Floor
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
* Boston, MA 02110-1301, USA
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Updated Jay Sorg 2009
|
|
|
|
|
|
|
|
|
|
|
|
cs czech 0x405
|
|
|
|
cs czech 0x405
|
|
|
|
de german 0x407
|
|
|
|
de german 0x407
|
|
|
@ -32,92 +34,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xutil.h>
|
|
|
|
#include <X11/Xutil.h>
|
|
|
|
#include <locale.h>
|
|
|
|
#include <locale.h>
|
|
|
|
|
|
|
|
|
|
|
|
const char *ProgramName;
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
Display *dpy;
|
|
|
|
{
|
|
|
|
|
|
|
|
const char* programname;
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
char text[256];
|
|
|
|
char *displayname = NULL;
|
|
|
|
char* ksname = NULL;
|
|
|
|
char *outfname;
|
|
|
|
char* displayname = NULL;
|
|
|
|
KeySym ks;
|
|
|
|
char* outfname;
|
|
|
|
int i, idx;
|
|
|
|
char* sections[5] = {"noshift", "shift", "altgr", "capslock", "shiftcapslock"};
|
|
|
|
FILE *outf;
|
|
|
|
int states[5] = {0, 1, 0x80, 2, 3};
|
|
|
|
char *ksname = NULL;
|
|
|
|
int i;
|
|
|
|
XKeyPressedEvent e;
|
|
|
|
int idx;
|
|
|
|
char text[256];
|
|
|
|
int char_count;
|
|
|
|
wchar_t wtext[256];
|
|
|
|
int nbytes = 0;
|
|
|
|
int char_count;
|
|
|
|
int unicode;
|
|
|
|
int nbytes = 0;
|
|
|
|
Display* dpy;
|
|
|
|
int unicode;
|
|
|
|
KeySym ks;
|
|
|
|
|
|
|
|
FILE* outf;
|
|
|
|
setlocale(LC_CTYPE, "");
|
|
|
|
XKeyPressedEvent e;
|
|
|
|
|
|
|
|
wchar_t wtext[256];
|
|
|
|
/* --------------- */
|
|
|
|
|
|
|
|
|
|
|
|
setlocale(LC_CTYPE, "");
|
|
|
|
char *sections[5] = {"noshift", "shift", "altgr", "capslock", "shiftcapslock"};
|
|
|
|
programname = argv[0];
|
|
|
|
int states[5] = {0, 1, 0x80, 2, 3};
|
|
|
|
if (argc != 2)
|
|
|
|
|
|
|
|
{
|
|
|
|
/* --------------- */
|
|
|
|
fprintf(stderr, "Usage: %s out_filename\n", programname);
|
|
|
|
|
|
|
|
fprintf(stderr, "Example: %s /etc/xrdp/km-0409.ini\n", programname);
|
|
|
|
ProgramName = argv[0];
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
if (argc != 2) {
|
|
|
|
outfname = argv[1];
|
|
|
|
fprintf(stderr, "Usage: %s out_filename\n", ProgramName);
|
|
|
|
dpy = XOpenDisplay(displayname);
|
|
|
|
exit(1);
|
|
|
|
if (!dpy)
|
|
|
|
}
|
|
|
|
{
|
|
|
|
outfname = argv[1];
|
|
|
|
fprintf(stderr, "%s: unable to open display '%s'\n",
|
|
|
|
|
|
|
|
programname, XDisplayName(displayname));
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
dpy = XOpenDisplay (displayname);
|
|
|
|
}
|
|
|
|
if (!dpy) {
|
|
|
|
outf = fopen(outfname, "w");
|
|
|
|
fprintf(stderr, "%s: unable to open display '%s'\n",
|
|
|
|
if (outf == NULL)
|
|
|
|
ProgramName, XDisplayName (displayname));
|
|
|
|
{
|
|
|
|
exit(1);
|
|
|
|
fprintf(stderr, "%s: unable to create file '%s'\n", programname, outfname);
|
|
|
|
}
|
|
|
|
XCloseDisplay(dpy);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
/* --------------- */
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&e, 0, sizeof(e));
|
|
|
|
e.type = KeyPress;
|
|
|
|
e.type = KeyPress;
|
|
|
|
e.serial = 16;
|
|
|
|
e.serial = 16;
|
|
|
|
e.send_event = True;
|
|
|
|
e.send_event = True;
|
|
|
|
e.display = dpy;
|
|
|
|
e.display = dpy;
|
|
|
|
e.window = (Window) NULL;
|
|
|
|
e.same_screen = True;
|
|
|
|
e.root = (Window) NULL;
|
|
|
|
for (idx = 0; idx < 5; idx++) /* Sections and states */
|
|
|
|
e.time = 0;
|
|
|
|
{
|
|
|
|
e.x = e.y = 0;
|
|
|
|
fprintf(outf, "[%s]\n", sections[idx]);
|
|
|
|
e.x_root = e.y_root = 0;
|
|
|
|
e.state = states[idx];
|
|
|
|
e.same_screen = True;
|
|
|
|
for (i = 8; i <= 137; i++) /* Keycodes */
|
|
|
|
|
|
|
|
{
|
|
|
|
outf = fopen(outfname, "w");
|
|
|
|
e.keycode = i;
|
|
|
|
|
|
|
|
nbytes = XLookupString(&e, text, 255, &ks, NULL);
|
|
|
|
for (idx=0; idx<5; idx++) { // Sections and states
|
|
|
|
if (ks == NoSymbol)
|
|
|
|
fprintf(outf, "[%s]\n", sections[idx]);
|
|
|
|
{
|
|
|
|
e.state = states[idx];
|
|
|
|
ksname = "NoSymbol";
|
|
|
|
for (i=8; i<=137; i++) { // Keycodes
|
|
|
|
}
|
|
|
|
e.keycode = i;
|
|
|
|
else if (!(ksname = XKeysymToString(ks)))
|
|
|
|
nbytes = XLookupString (&e, text, 255, &ks, NULL);
|
|
|
|
{
|
|
|
|
|
|
|
|
ksname = "(no name)";
|
|
|
|
if (ks == NoSymbol)
|
|
|
|
}
|
|
|
|
ksname = "NoSymbol";
|
|
|
|
char_count = mbstowcs(wtext, text, 255);
|
|
|
|
else if (!(ksname = XKeysymToString (ks)))
|
|
|
|
unicode = 0;
|
|
|
|
ksname = "(no name)";
|
|
|
|
if (char_count == 1)
|
|
|
|
char_count = mbstowcs(wtext, text, 255);
|
|
|
|
{
|
|
|
|
unicode = 0;
|
|
|
|
unicode = wtext[0];
|
|
|
|
if (char_count == 1)
|
|
|
|
}
|
|
|
|
{
|
|
|
|
fprintf(outf, "Key%d=%d:%d\n", i, (int) ks, unicode);
|
|
|
|
unicode = wtext[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (idx != 4)
|
|
|
|
//printf("%s %d %x\n", text, char_count, wtext[0]);
|
|
|
|
{
|
|
|
|
fprintf(outf, "Key%d=%d:%d\n", i, (int) ks, unicode);
|
|
|
|
fprintf(outf, "\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (idx!=4) fprintf(outf, "\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
XCloseDisplay(dpy);
|
|
|
|
|
|
|
|
fclose(outf);
|
|
|
|
XCloseDisplay (dpy);
|
|
|
|
return 0;
|
|
|
|
fclose(outf);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|