Why is XKeysymToKeycode() making all of my keys lowercase?

来源:互联网 发布:第三方软件检测 编辑:程序博客网 时间:2024/05/19 17:08

原文地址::https://stackoverflow.com/questions/28258528/why-is-xkeysymtokeycode-making-all-of-my-keys-lowercase


相关文章

1、XKeysymToKeycode, XTestFakeKeyEvent and mapping----https://stackoverflow.com/questions/15856775/xkeysymtokeycode-xtestfakekeyevent-and-mapping

2、python之模拟鼠标键盘动作具体实现----http://www.codeweblog.com/python%E4%B9%8B%E6%A8%A1%E6%8B%9F%E9%BC%A0%E6%A0%87%E9%94%AE%E7%9B%98%E5%8A%A8%E4%BD%9C%E5%85%B7%E4%BD%93%E5%AE%9E%E7%8E%B0/




1down votefavorite

I'm currently having a problem with Xlib where whenever I call XKeysymToKeycode() and pass in an uppercase KeySym, it returns a lowercase KeyCode. Google doesn't really seem to have an answer to this question, or too much documentation at all on the functions I'm using, for that matter.

Here's the code I am using:

#include <ctype.h>#include <stdio.h>#include <stdlib.h>#include <X11/Xlib.h>#include <X11/Xutil.h>#include <X11/keysym.h>#include <X11/extensions/XTest.h>int main(void) {    Display *display;    char *ptr;    char c[2] = {0, 0};    KeySym ksym;    KeyCode kcode;    display = XOpenDisplay(0);    ptr = "Test";    while (*ptr) {        c[0] = *ptr;        ksym = XStringToKeysym(c);        printf("Before XKeysymToKeycode(): %s\n", XKeysymToString(ksym));        kcode = XKeysymToKeycode(display, ksym);        printf("Key code after XKeysymToKeycode(): %s\n", XKeysymToString(XKeycodeToKeysym(display, kcode, 0)));        ptr++;    }    XCloseDisplay(display);    return 0;}    

It can be compiled with gcc -o sendkeys sendkeys_min.c -lX11 -lXtst -g -Wall -Wextra -pedantic -ansi (Assuming it has been saved as sendkeys_min.c.)

The current output is the following:

Before XKeysymToKeycode(): TKey code after XKeysymToKeycode(): tBefore XKeysymToKeycode(): eKey code after XKeysymToKeycode(): eBefore XKeysymToKeycode(): sKey code after XKeysymToKeycode(): sBefore XKeysymToKeycode(): tKey code after XKeysymToKeycode(): t

The expected output, is, of course, that the first T in "Test" is still uppercase after being ran through XKeysymToKeycode(). (Note that this is not my actual program, but a simplified version for posting here. In the actual program, I am sending key events with the resulting keycode, and the keys sent still have the problem exhibited here (They all become lowercase))






1down votefavorite

I'm currently having a problem with Xlib where whenever I call XKeysymToKeycode() and pass in an uppercase KeySym, it returns a lowercase KeyCode. Google doesn't really seem to have an answer to this question, or too much documentation at all on the functions I'm using, for that matter.

Here's the code I am using:

#include <ctype.h>#include <stdio.h>#include <stdlib.h>#include <X11/Xlib.h>#include <X11/Xutil.h>#include <X11/keysym.h>#include <X11/extensions/XTest.h>int main(void) {    Display *display;    char *ptr;    char c[2] = {0, 0};    KeySym ksym;    KeyCode kcode;    display = XOpenDisplay(0);    ptr = "Test";    while (*ptr) {        c[0] = *ptr;        ksym = XStringToKeysym(c);        printf("Before XKeysymToKeycode(): %s\n", XKeysymToString(ksym));        kcode = XKeysymToKeycode(display, ksym);        printf("Key code after XKeysymToKeycode(): %s\n", XKeysymToString(XKeycodeToKeysym(display, kcode, 0)));        ptr++;    }    XCloseDisplay(display);    return 0;}    

It can be compiled with gcc -o sendkeys sendkeys_min.c -lX11 -lXtst -g -Wall -Wextra -pedantic -ansi (Assuming it has been saved as sendkeys_min.c.)

The current output is the following:

Before XKeysymToKeycode(): TKey code after XKeysymToKeycode(): tBefore XKeysymToKeycode(): eKey code after XKeysymToKeycode(): eBefore XKeysymToKeycode(): sKey code after XKeysymToKeycode(): sBefore XKeysymToKeycode(): tKey code after XKeysymToKeycode(): t

The expected output, is, of course, that the first T in "Test" is still uppercase after being ran through XKeysymToKeycode(). (Note that this is not my actual program, but a simplified version for posting here. In the actual program, I am sending key events with the resulting keycode, and the keys sent still have the problem exhibited here (They all become lowercase))

阅读全文
0 0
原创粉丝点击