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

原文地址::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/




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(): T
Key code after XKeysymToKeycode(): t
Before XKeysymToKeycode(): e
Key code after XKeysymToKeycode(): e
Before XKeysymToKeycode(): s
Key code after XKeysymToKeycode(): s
Before XKeysymToKeycode(): t
Key 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))






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(): T
Key code after XKeysymToKeycode(): t
Before XKeysymToKeycode(): e
Key code after XKeysymToKeycode(): e
Before XKeysymToKeycode(): s
Key code after XKeysymToKeycode(): s
Before XKeysymToKeycode(): t
Key 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))

展开阅读全文

Why My C program got error???

10-07

这是题目:rn---------------------------------------------------------------------rnWrite an interactive C program which will process test, assignment and final exam marks for the Java programming course. Full marks for test is 20%, assignment 20% and final exam is 60%. Enter the students name and their marks for the continuous assessment above repetitively. The marks’ grade are shown in the table below:rnGrade marksrn A 80-100rn B+ 75-79rn B 70-74rn B- 65-69rn C+ 60-64rn C 55-59rn C- 50-54rn D 40-49rn E 35-39rn F 0-34rnrn(a) Count and display total number of studentsrn(b) For each assignment, test and final exam component, which have been obtained by the class, determine:rn• Total marks for assignment, total marks for test and total marks for final examrn• Average marks for assignment, total marks for test and total marks for final examrnrnFor every student, display the following information:rn(i) Student name, total marks for assignment, test and final exam for every student (marks over hundred)rn(ii) Mark’s grade Use array concept to solve the problem above.. Make sure the labels for output are clear. rnrn---------------------------------------------------------------------rnrn这是我的答案:rnrn#includern#includern#define no 2rnmain()rnrn int i,test[no],assign[no],exam[no],total_marks[no];rn char stud_name[no],grade[no];rn int total_test=0;rn int total_assign=0;rn int total_exam=0;rn float ave_assign,ave_test,ave_exam;rnrn clrscr();rn for(i=0;i ");rn gets(stud_name[i]);rn printf("Assignment Marks (20%) > ");rn scanf("%d", &assign[i]);rn printf("Test Marks (20%) > ");rn scanf("%d", &test[i]);rn printf("Final Exam Marks (60%) > ");rn scanf("%d", &exam[i]);rnrn total_test+=test[i];rn total_assign+=assign[i];rn total_exam+=exam[i];rn total_marks[i]=test[i]+assign[i]+exam[i];rnrn if(total_marks[i]>=80 && total_marks[i]<=100)rn strcpy(grade[i],"A");rn else if(total_marks[i]>=75 && total_marks[i]<=79)rn strcpy(grade[i],"B+");rn else if(total_marks[i]>=70 && total_marks[i]<=74)rn strcpy(grade[i],"B");rn else if(total_marks[i]>=65 && total_marks[i]<=69)rn strcpy(grade[i],"B-");rn else if(total_marks[i]>=60 && total_marks[i]<=64)rn strcpy(grade[i],"C+");rn else if(total_marks[i]>=55 && total_marks[i]<=59)rn strcpy(grade[i],"C");rn else if(total_marks[i]>=50 && total_marks[i]<=54)rn strcpy(grade[i],"C-");rn else if(total_marks[i]>=40 && total_marks[i]<=49)rn strcpy(grade[i],"D");rn else if(total_marks[i]>=35 && total_marks[i]<=39)rn strcpy(grade[i],"E");rn else if(total_marks[i]>=0 && total_marks[i]<=34)rn strcpy(grade[i],"F");rn elsern strcpy(grade[i],"Error");rnrn rn ave_test=(float)total_test/no;rn ave_assign=(float)total_assign/no;rn ave_exam=(float)total_exam/no;rnrn printf("\nTotal Number of Students >> %d",no);rn printf("\nTotal Marks for Assignment >> %d",total_assign);rn printf("\nTotal Marks for Test >> %d",total_test);rn printf("\nTotal Marks for Final Exam >> %d",total_exam);rn printf("\n\nAverage Marks for Assignment >> %.2f",ave_assign);rn printf("\nAverage Marks for Test >> %.2f",ave_test);rn printf("\nAverage Marks for Final Exam >> %.2f",ave_exam);rnrn printf("\n---------------------------------------------------------");rn printf("\n no Student Name Assignment Test Exam Total Grade");rn printf("\n---------------------------------------------------------");rn for(i=0;i 论坛

没有更多推荐了,返回首页