XK_question generates asterisk key



  • Hi, i'm writing a keyboard simulating app and i have a problem. I use Xlib to generate fake keyboard inputs. Sample code:
    @
    void InputSimulatorPrivate::keyPress(Qt::Key key)
    {
    XKeyEvent event;
    memset(&event, 0, sizeof(XKeyEvent));

    qDebug() << "InputSimulatorPrivate::keyPress:" << keyNameMap[key];
    
    event.type = KeyPress;
    event.keycode = keyMap[key];
    event.display = QX11Info::display();
    
    qDebug() << "InputSimulatorPrivate::keyRelease: keycode:" << QString::number(event.keycode, 16);
    
    XQueryPointer(QX11Info::display(),
                  RootWindow(QX11Info::display(), DefaultScreen(QX11Info::display())),
                  &event.root,
                  &event.window,
                  &event.x_root,
                  &event.y_root,
                  &event.x,
                  &event.y,
                  &event.state);
    
    event.subwindow = event.window;
    
    while(event.subwindow) {
        event.window = event.subwindow;
        XQueryPointer(QX11Info::display(), event.window,
                      &event.root,
                      &event.subwindow,
                      &event.x_root,
                      &event.y_root,
                      &event.x,
                      &event.y,
                      &event.state);
    }
    
    event.state = modifiers;
    
    if (XSendEvent(QX11Info::display(), event.window, True, KeyPressMask, (XEvent *) &event) == 0) {
        qDebug() << "InputSimulator::keyPress: XSendEvent error";
        return;
    }
    
    if (key == Qt::Key_Shift)
        modifiers |= ShiftMask;
    else if (key == Qt::Key_Control)
        modifiers |= ControlMask;
    
    XFlush(QX11Info::display());
    

    }
    @

    I generate keyMap like this:
    @keyMap[Qt::Key_Question] = XKeysymToKeycode(QX11Info::display(), XK_question);@

    InputSimulatorPrivate::keyPress function works fine with letters, numbers and some other keys. But when i give it Qt::Key_Question, application that i sent event gets Qt::Key_Asterisk. I can't make target app to get question key input.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.