indent, cleanup

ulab-original
jsorg71 16 years ago
parent 10a547fd5a
commit 9f72773443

@ -17,7 +17,9 @@
* 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* ksname = NULL;
char* displayname = NULL; char* displayname = NULL;
char* outfname; char* outfname;
char* sections[5] = {"noshift", "shift", "altgr", "capslock", "shiftcapslock"};
int states[5] = {0, 1, 0x80, 2, 3};
int i;
int idx;
int char_count;
int nbytes = 0;
int unicode;
Display* dpy;
KeySym ks; KeySym ks;
int i, idx;
FILE* outf; FILE* outf;
char *ksname = NULL;
XKeyPressedEvent e; XKeyPressedEvent e;
char text[256];
wchar_t wtext[256]; wchar_t wtext[256];
int char_count;
int nbytes = 0;
int unicode;
setlocale(LC_CTYPE, ""); setlocale(LC_CTYPE, "");
programname = argv[0];
/* --------------- */ if (argc != 2)
{
char *sections[5] = {"noshift", "shift", "altgr", "capslock", "shiftcapslock"}; fprintf(stderr, "Usage: %s out_filename\n", programname);
int states[5] = {0, 1, 0x80, 2, 3}; fprintf(stderr, "Example: %s /etc/xrdp/km-0409.ini\n", programname);
return 1;
/* --------------- */
ProgramName = argv[0];
if (argc != 2) {
fprintf(stderr, "Usage: %s out_filename\n", ProgramName);
exit(1);
} }
outfname = argv[1]; outfname = argv[1];
dpy = XOpenDisplay(displayname); dpy = XOpenDisplay(displayname);
if (!dpy) { if (!dpy)
{
fprintf(stderr, "%s: unable to open display '%s'\n", fprintf(stderr, "%s: unable to open display '%s'\n",
ProgramName, XDisplayName (displayname)); programname, XDisplayName(displayname));
exit(1); return 1;
} }
outf = fopen(outfname, "w");
/* --------------- */ if (outf == NULL)
{
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.root = (Window) NULL;
e.time = 0;
e.x = e.y = 0;
e.x_root = e.y_root = 0;
e.same_screen = True; e.same_screen = True;
for (idx = 0; idx < 5; idx++) /* Sections and states */
outf = fopen(outfname, "w"); {
for (idx=0; idx<5; idx++) { // Sections and states
fprintf(outf, "[%s]\n", sections[idx]); fprintf(outf, "[%s]\n", sections[idx]);
e.state = states[idx]; e.state = states[idx];
for (i=8; i<=137; i++) { // Keycodes for (i = 8; i <= 137; i++) /* Keycodes */
{
e.keycode = i; e.keycode = i;
nbytes = XLookupString(&e, text, 255, &ks, NULL); nbytes = XLookupString(&e, text, 255, &ks, NULL);
if (ks == NoSymbol) if (ks == NoSymbol)
{
ksname = "NoSymbol"; ksname = "NoSymbol";
}
else if (!(ksname = XKeysymToString(ks))) else if (!(ksname = XKeysymToString(ks)))
{
ksname = "(no name)"; ksname = "(no name)";
}
char_count = mbstowcs(wtext, text, 255); char_count = mbstowcs(wtext, text, 255);
unicode = 0; unicode = 0;
if (char_count == 1) if (char_count == 1)
{ {
unicode = wtext[0]; unicode = wtext[0];
} }
//printf("%s %d %x\n", text, char_count, wtext[0]);
fprintf(outf, "Key%d=%d:%d\n", i, (int) ks, unicode); fprintf(outf, "Key%d=%d:%d\n", i, (int) ks, unicode);
} }
if (idx!=4) fprintf(outf, "\n"); if (idx != 4)
{
fprintf(outf, "\n");
}
} }
XCloseDisplay(dpy); XCloseDisplay(dpy);
fclose(outf); fclose(outf);
return 0;
return (0);
} }

Loading…
Cancel
Save