Esempio n. 1
0
static Uint32
X11_KeyCodeToUcs4(_THIS, KeyCode keycode, unsigned char group)
{
    KeySym keysym = X11_KeyCodeToSym(_this, keycode, group);

    if (keysym == NoSymbol) {
        return 0;
    }

    return X11_KeySymToUcs4(keysym);
}
Esempio n. 2
0
static int x11ScancodeToDDKey(int scancode)
{
    Display* disp = QX11Info::display();
    KeySym sym = XKeycodeToKeysym(disp, scancode, 0);
    if(sym == NoSymbol) return 0;
    unsigned int ucs4 = X11_KeySymToUcs4(sym);
    if(ucs4)
    {
        // ASCII range.
        if(ucs4 > ' ' && ucs4 < 128) return ucs4;
        //qDebug() << "ucs4:" << ucs4 << hex << ucs4 << dec;
        return 0;
    }
    //qDebug() << "sym:" << hex << sym << dec;
    switch(sym)
    {
    case XK_KP_Insert:          return DDKEY_NUMPAD0;
    case XK_KP_End:             return DDKEY_NUMPAD1;
    case XK_KP_Down:            return DDKEY_NUMPAD2;
    case XK_KP_Page_Down:       return DDKEY_NUMPAD3;
    case XK_KP_Left:            return DDKEY_NUMPAD4;
    case XK_KP_Begin:           return DDKEY_NUMPAD5;
    case XK_KP_Right:           return DDKEY_NUMPAD6;
    case XK_KP_Home:            return DDKEY_NUMPAD7;
    case XK_KP_Up:              return DDKEY_NUMPAD8;
    case XK_KP_Page_Up:         return DDKEY_NUMPAD9;

    case XK_KP_0:               return DDKEY_NUMPAD0;
    case XK_KP_1:               return DDKEY_NUMPAD1;
    case XK_KP_2:               return DDKEY_NUMPAD2;
    case XK_KP_3:               return DDKEY_NUMPAD3;
    case XK_KP_4:               return DDKEY_NUMPAD4;
    case XK_KP_5:               return DDKEY_NUMPAD5;
    case XK_KP_6:               return DDKEY_NUMPAD6;
    case XK_KP_7:               return DDKEY_NUMPAD7;
    case XK_KP_8:               return DDKEY_NUMPAD8;
    case XK_KP_9:               return DDKEY_NUMPAD9;

    case XK_KP_Equal:           return '=';
    case XK_KP_Multiply:        return DDKEY_MULTIPLY;
    case XK_KP_Add:             return DDKEY_ADD;
    case XK_KP_Separator:       return DDKEY_DECIMAL;
    case XK_KP_Delete:          return DDKEY_DECIMAL;
    case XK_KP_Subtract:        return DDKEY_SUBTRACT;
    case XK_KP_Decimal:         return DDKEY_DECIMAL;
    case XK_KP_Divide:          return DDKEY_DIVIDE;

    default:
        break;
    }
    //qDebug() << "=>failed to map";
    return 0;
}
static Uint32
X11_KeyCodeToUcs4(Display *display, KeyCode keycode)
{
    KeySym keysym;

#if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
    keysym = X11_XkbKeycodeToKeysym(display, keycode, 0, 0);
#else
    keysym = X11_XKeycodeToKeysym(display, keycode, 0);
#endif
    if (keysym == NoSymbol) {
        return 0;
    }

    return X11_KeySymToUcs4(keysym);
}