This is a discussion on XKeysymToKeycode() can't recognize chars like XK_space - Xwindows ; Hello, All! I'm trying to send some key events to xterm, but XKeysymToKeycode() function can't convert spaces, dots, etc. (it recognizes numbers and letters only). Why? Display* dpy; Window win; char* data; int i; for (i = 0; data[i] != ...
Hello, All!
I'm trying to send some key events to xterm, but XKeysymToKeycode()
function can't convert spaces, dots, etc. (it recognizes numbers and
letters only). Why?
Display* dpy;
Window win;
char* data;
int i;
for (i = 0; data[i] != '\0'; i++) {
XKeyEvent ev;
KeySym key;
char str[512];
ev.window = win;
ev.root = DefaultRootWindow(dpy);
ev.subwindow = win;
ev.time = CurrentTime;
ev.x = ev.y = ev.x_root = ev.y_root = 1;
ev.state = 0;
ev.same_screen = True;
sprintf(str, "%c", data[i]);
key = XStringToKeysym(str);
// ignores, for example, XK_space, XK_comma...
ev.keycode = XKeysymToKeycode(dpy, key);
if (!ev.keycode) fprintf(stderr, "cannot find matching keycode");
ev.type = KeyPress;
XSendEvent(dpy, win, True, KeyPressMask, (XEvent*)&ev);
ev.type = KeyRelease;
XSendEvent(dpy, win, True, KeyReleaseMask, (XEvent*)&ev);
}
PS Sorry for my terrible english
--
With best regards
Templar