Engine/lib/sdl/src/video/x11/SDL_x11keyboard.c
/* This function only works for keyboards in US QWERTY layout */
This function only works for keyboards in US QWERTY layout
This function only works for keyboards in US QWERTY layout
static SDL_Scancode
X11_KeyCodeToSDLScancode(Display *display, KeyCode keycode)
{
    KeySym keysym;
    int i;
#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 SDL_SCANCODE_UNKNOWN;
    }
    if (keysym >= XK_A && keysym <= XK_Z) {
        return SDL_SCANCODE_A + (keysym - XK_A);
    }
    if (keysym >= XK_0 && keysym <= XK_9) {
        return SDL_SCANCODE_0 + (keysym - XK_0);
    }
    for (i = 0; i < SDL_arraysize(KeySymToSDLScancode); ++i) {
        if (keysym == KeySymToSDLScancode[i].keysym) {
            return KeySymToSDLScancode[i].scancode;
        }
    }
    return SDL_SCANCODE_UNKNOWN;
}
static SDL_Scancode X11_KeyCodeToSDLScancode ( Display * display , KeyCode keycode ) { KeySym keysym ; int i ; #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 SDL_SCANCODE_UNKNOWN ; } if ( keysym >= XK_A && keysym <= XK_Z ) { return SDL_SCANCODE_A + ( keysym - XK_A ) ; } if ( keysym >= XK_0 && keysym <= XK_9 ) { return SDL_SCANCODE_0 + ( keysym - XK_0 ) ; } for ( i = 0 ; i < SDL_arraysize ( KeySymToSDLScancode ) ; ++ i ) { if ( keysym == KeySymToSDLScancode [ i ] . keysym ) { return KeySymToSDLScancode [ i ] . scancode ; } } return SDL_SCANCODE_UNKNOWN ; }
This function only works for keyboards in US QWERTY layout
This function only works for keyboards in US QWERTY layout