23 #if SDL_VIDEO_DRIVER_X11
27 #include "../../events/SDL_keyboard_c.h"
28 #include "../../events/scancodes_darwin.h"
29 #include "../../events/scancodes_xfree86.h"
31 #include <X11/keysym.h>
39 } KeySymToSDLScancode[] = {
149 X11_KeyCodeToSDLScancode(Display *
display, KeyCode keycode)
154 #if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
155 keysym = XkbKeycodeToKeysym(display, keycode, 0, 0);
157 keysym = XKeycodeToKeysym(display, keycode, 0);
159 if (keysym == NoSymbol) {
163 if (keysym >= XK_A && keysym <= XK_Z) {
167 if (keysym >= XK_0 && keysym <= XK_9) {
172 if (keysym == KeySymToSDLScancode[i].keysym) {
173 return KeySymToSDLScancode[
i].scancode;
180 X11_KeyCodeToUcs4(Display *display, KeyCode keycode)
184 #if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
185 keysym = XkbKeycodeToKeysym(display, keycode, 0, 0);
187 keysym = XKeycodeToKeysym(display, keycode, 0);
189 if (keysym == NoSymbol) {
202 int min_keycode, max_keycode;
218 XDisplayKeycodes(
data->display, &min_keycode, &max_keycode);
220 fingerprint[
i].value =
221 XKeysymToKeycode(
data->display, fingerprint[i].keysym) -
226 if ((max_keycode - min_keycode + 1) <= scancode_set[
i].table_size) {
230 if (fingerprint[
j].
value < 0
231 || fingerprint[
j].
value >= scancode_set[i].table_size) {
235 fingerprint[
j].scancode) {
240 #ifdef DEBUG_KEYBOARD
241 printf(
"Using scancode set %d, min_keycode = %d, max_keycode = %d, table_size = %d\n", i, min_keycode, max_keycode, scancode_set[i].table_size);
250 if (!fingerprint_detected) {
254 (
"Keyboard layout unknown, please send the following to the SDL mailing list (sdl@libsdl.org):\n");
258 for (i = min_keycode; i <= max_keycode; ++
i) {
260 #if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
261 sym = XkbKeycodeToKeysym(
data->display, i, 0, 0);
263 sym = XKeycodeToKeysym(
data->display, i, 0);
265 if (sym != NoSymbol) {
267 printf(
"code = %d, sym = 0x%X (%s) ", i - min_keycode,
269 scancode = X11_KeyCodeToSDLScancode(
data->display, i);
270 data->key_layout[
i] = scancode;
272 printf(
"scancode not found\n");
306 key = X11_KeyCodeToUcs4(data->
display, (KeyCode)i);
308 keymap[scancode] = key;
GLenum GLsizei GLenum GLenum const GLvoid * table
void SDL_GetDefaultKeymap(SDL_Keycode *keymap)
void X11_QuitKeyboard(_THIS)
static const SDL_Scancode xfree86_scancode_table[]
static const SDL_Scancode xfree86_scancode_table2[]
Sint32 SDL_Keycode
The SDL virtual key representation.
static SDL_VideoDevice * _this
uint32_t Uint32
An unsigned 32-bit integer type.
void SDL_SetKeymap(int start, SDL_Keycode *keys, int length)
static const SDL_Scancode darwin_scancode_table[]
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
unsigned int X11_KeySymToUcs4(KeySym keysym)
void X11_UpdateKeymap(_THIS)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int return Display return Display Cursor return Display GC return XModifierKeymap return char Display Window int return Display return Display Atom return Display Window XWindowAttributes return Display Window return Display XEvent Bool(*) XPointer return Display Window Bool unsigned int int int Window Cursor Time return Display Window int retur XKeysymToString)
void SDL_SetScancodeName(SDL_Scancode scancode, const char *name)
DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_Scancode scancode)
Get a human-readable name for a scancode.
#define SDL_arraysize(array)
EGLSurface EGLint void ** value
DECLSPEC void *SDLCALL SDL_memcpy(void *dst, const void *src, size_t len)
int X11_InitKeyboard(_THIS)
SDL_Scancode
The SDL keyboard scancode representation.