First pass of new SDL scancode concept for X11.
authorSam Lantinga <slouken@libsdl.org>
Thu, 07 Feb 2008 15:31:09 +0000
changeset 2305fbe8ff44c519
parent 2304 50f58ce12497
child 2306 1a8bab15a45d
First pass of new SDL scancode concept for X11.
include/SDL_keysym.h
include/SDL_scancode.h
src/events/SDL_keyboard.c
src/events/scancodes_darwin.h
src/events/scancodes_linux.h
src/events/scancodes_xfree86.h
src/video/cocoa/SDL_cocoakeyboard.m
src/video/cocoa/SDL_cocoakeys.h
src/video/x11/SDL_x11events.c
src/video/x11/SDL_x11keyboard.c
src/video/x11/SDL_x11keyboard.h
src/video/x11/SDL_x11sym.h
src/video/x11/SDL_x11video.c
src/video/x11/SDL_x11video.h
test/checkkeys.c
     1.1 --- a/include/SDL_keysym.h	Tue Feb 05 07:30:50 2008 +0000
     1.2 +++ b/include/SDL_keysym.h	Thu Feb 07 15:31:09 2008 +0000
     1.3 @@ -221,6 +221,7 @@
     1.4      SDLK_AUDIOPLAY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOPLAY),
     1.5      SDLK_AUDIOMUTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOMUTE),
     1.6      SDLK_MEDIASELECT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIASELECT),
     1.7 +    SDLK_WWW = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_WWW),
     1.8      SDLK_MAIL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MAIL),
     1.9      SDLK_CALCULATOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CALCULATOR),
    1.10      SDLK_COMPUTER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_COMPUTER),
     2.1 --- a/include/SDL_scancode.h	Tue Feb 05 07:30:50 2008 +0000
     2.2 +++ b/include/SDL_scancode.h	Thu Feb 07 15:31:09 2008 +0000
     2.3 @@ -91,7 +91,7 @@
     2.4      SDL_SCANCODE_TAB = 43,
     2.5      SDL_SCANCODE_SPACE = 44,
     2.6  
     2.7 -    SDL_SCANCODE_HYPHENMINUS = 45,
     2.8 +    SDL_SCANCODE_MINUS = 45,
     2.9      SDL_SCANCODE_EQUALS = 46,
    2.10      SDL_SCANCODE_LEFTBRACKET = 47,
    2.11      SDL_SCANCODE_RIGHTBRACKET = 48,
    2.12 @@ -286,27 +286,28 @@
    2.13      SDL_SCANCODE_AUDIOPLAY = 261,
    2.14      SDL_SCANCODE_AUDIOMUTE = 262,
    2.15      SDL_SCANCODE_MEDIASELECT = 263,
    2.16 -    SDL_SCANCODE_MAIL = 264,
    2.17 -    SDL_SCANCODE_CALCULATOR = 265,
    2.18 -    SDL_SCANCODE_COMPUTER = 266,
    2.19 -    SDL_SCANCODE_AC_SEARCH = 267,
    2.20 -    SDL_SCANCODE_AC_HOME = 268,
    2.21 -    SDL_SCANCODE_AC_BACK = 269,
    2.22 -    SDL_SCANCODE_AC_FORWARD = 270,
    2.23 -    SDL_SCANCODE_AC_STOP = 271,
    2.24 -    SDL_SCANCODE_AC_REFRESH = 272,
    2.25 -    SDL_SCANCODE_AC_BOOKMARKS = 273,
    2.26 +    SDL_SCANCODE_WWW = 264,
    2.27 +    SDL_SCANCODE_MAIL = 265,
    2.28 +    SDL_SCANCODE_CALCULATOR = 266,
    2.29 +    SDL_SCANCODE_COMPUTER = 267,
    2.30 +    SDL_SCANCODE_AC_SEARCH = 268,
    2.31 +    SDL_SCANCODE_AC_HOME = 269,
    2.32 +    SDL_SCANCODE_AC_BACK = 270,
    2.33 +    SDL_SCANCODE_AC_FORWARD = 271,
    2.34 +    SDL_SCANCODE_AC_STOP = 272,
    2.35 +    SDL_SCANCODE_AC_REFRESH = 273,
    2.36 +    SDL_SCANCODE_AC_BOOKMARKS = 274,
    2.37  
    2.38      /* These are values that Christian Walther added (for mac keyboard?) */
    2.39  
    2.40 -    SDL_SCANCODE_BRIGHTNESSDOWN = 274,
    2.41 -    SDL_SCANCODE_BRIGHTNESSUP = 275,
    2.42 -    SDL_SCANCODE_DISPLAYSWITCH = 276, /**< display mirroring/dual display switch, video mode switch */
    2.43 -    SDL_SCANCODE_KBDILLUMTOGGLE = 277,
    2.44 -    SDL_SCANCODE_KBDILLUMDOWN = 278,
    2.45 -    SDL_SCANCODE_KBDILLUMUP = 279,
    2.46 -    SDL_SCANCODE_EJECT = 280,
    2.47 -    SDL_SCANCODE_SLEEP = 281,
    2.48 +    SDL_SCANCODE_BRIGHTNESSDOWN = 275,
    2.49 +    SDL_SCANCODE_BRIGHTNESSUP = 276,
    2.50 +    SDL_SCANCODE_DISPLAYSWITCH = 277, /**< display mirroring/dual display switch, video mode switch */
    2.51 +    SDL_SCANCODE_KBDILLUMTOGGLE = 278,
    2.52 +    SDL_SCANCODE_KBDILLUMDOWN = 279,
    2.53 +    SDL_SCANCODE_KBDILLUMUP = 280,
    2.54 +    SDL_SCANCODE_EJECT = 281,
    2.55 +    SDL_SCANCODE_SLEEP = 282,
    2.56  
    2.57      /* Add any other keys here */
    2.58  
     3.1 --- a/src/events/SDL_keyboard.c	Tue Feb 05 07:30:50 2008 +0000
     3.2 +++ b/src/events/SDL_keyboard.c	Thu Feb 07 15:31:09 2008 +0000
     3.3 @@ -242,6 +242,7 @@
     3.4      SDLK_AUDIOPLAY,
     3.5      SDLK_AUDIOMUTE,
     3.6      SDLK_MEDIASELECT,
     3.7 +    SDLK_WWW,
     3.8      SDLK_MAIL,
     3.9      SDLK_CALCULATOR,
    3.10      SDLK_COMPUTER,
    3.11 @@ -473,6 +474,7 @@
    3.12      "AudioPlay",
    3.13      "AudioMute",
    3.14      "MediaSelect",
    3.15 +    "WWW",
    3.16      "Mail",
    3.17      "Calculator",
    3.18      "Computer",
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/src/events/scancodes_darwin.h	Thu Feb 07 15:31:09 2008 +0000
     4.3 @@ -0,0 +1,160 @@
     4.4 +/*
     4.5 +    SDL - Simple DirectMedia Layer
     4.6 +    Copyright (C) 1997-2006 Sam Lantinga
     4.7 +
     4.8 +    This library is free software; you can redistribute it and/or
     4.9 +    modify it under the terms of the GNU Lesser General Public
    4.10 +    License as published by the Free Software Foundation; either
    4.11 +    version 2.1 of the License, or (at your option) any later version.
    4.12 +
    4.13 +    This library is distributed in the hope that it will be useful,
    4.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    4.16 +    Lesser General Public License for more details.
    4.17 +
    4.18 +    You should have received a copy of the GNU Lesser General Public
    4.19 +    License along with this library; if not, write to the Free Software
    4.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    4.21 +
    4.22 +    Sam Lantinga
    4.23 +    slouken@libsdl.org
    4.24 +*/
    4.25 +
    4.26 +/* Mac virtual key code to SDLKey mapping table
    4.27 +   Sources:
    4.28 +   - Inside Macintosh: Text <http://developer.apple.com/documentation/mac/Text/Text-571.html>
    4.29 +   - Apple USB keyboard driver source <http://darwinsource.opendarwin.org/10.4.6.ppc/IOHIDFamily-172.8/IOHIDFamily/Cosmo_USB2ADB.c>
    4.30 +   - experimentation on various ADB and USB ISO keyboards and one ADB ANSI keyboard
    4.31 +*/
    4.32 +/* *INDENT-OFF* */
    4.33 +static SDL_scancode darwin_scancode_table[] = {
    4.34 +    /*   0 */   SDL_SCANCODE_A,
    4.35 +    /*   1 */   SDL_SCANCODE_S,
    4.36 +    /*   2 */   SDL_SCANCODE_D,
    4.37 +    /*   3 */   SDL_SCANCODE_F,
    4.38 +    /*   4 */   SDL_SCANCODE_H,
    4.39 +    /*   5 */   SDL_SCANCODE_G,
    4.40 +    /*   6 */   SDL_SCANCODE_Z,
    4.41 +    /*   7 */   SDL_SCANCODE_X,
    4.42 +    /*   8 */   SDL_SCANCODE_C,
    4.43 +    /*   9 */   SDL_SCANCODE_V,
    4.44 +    /*  10 */   SDL_SCANCODE_NONUSBACKSLASH, /* SDL_SCANCODE_NONUSBACKSLASH on ANSI and JIS keyboards (if this key would exist there), SDL_SCANCODE_GRAVE on ISO. (The USB keyboard driver actually translates these usage codes to different virtual key codes depending on whether the keyboard is ISO/ANSI/JIS. That's why you have to help it identify the keyboard type when you plug in a PC USB keyboard. It's a historical thing - ADB keyboards are wired this way.) */
    4.45 +    /*  11 */   SDL_SCANCODE_B,
    4.46 +    /*  12 */   SDL_SCANCODE_Q,
    4.47 +    /*  13 */   SDL_SCANCODE_W,
    4.48 +    /*  14 */   SDL_SCANCODE_E,
    4.49 +    /*  15 */   SDL_SCANCODE_R,
    4.50 +    /*  16 */   SDL_SCANCODE_Y,
    4.51 +    /*  17 */   SDL_SCANCODE_T,
    4.52 +    /*  18 */   SDL_SCANCODE_1,
    4.53 +    /*  19 */   SDL_SCANCODE_2,
    4.54 +    /*  20 */   SDL_SCANCODE_3,
    4.55 +    /*  21 */   SDL_SCANCODE_4,
    4.56 +    /*  22 */   SDL_SCANCODE_6,
    4.57 +    /*  23 */   SDL_SCANCODE_5,
    4.58 +    /*  24 */   SDL_SCANCODE_EQUALS,
    4.59 +    /*  25 */   SDL_SCANCODE_9,
    4.60 +    /*  26 */   SDL_SCANCODE_7,
    4.61 +    /*  27 */   SDL_SCANCODE_MINUS,
    4.62 +    /*  28 */   SDL_SCANCODE_8,
    4.63 +    /*  29 */   SDL_SCANCODE_0,
    4.64 +    /*  30 */   SDL_SCANCODE_RIGHTBRACKET,
    4.65 +    /*  31 */   SDL_SCANCODE_O,
    4.66 +    /*  32 */   SDL_SCANCODE_U,
    4.67 +    /*  33 */   SDL_SCANCODE_LEFTBRACKET,
    4.68 +    /*  34 */   SDL_SCANCODE_I,
    4.69 +    /*  35 */   SDL_SCANCODE_P,
    4.70 +    /*  36 */   SDL_SCANCODE_RETURN,
    4.71 +    /*  37 */   SDL_SCANCODE_L,
    4.72 +    /*  38 */   SDL_SCANCODE_J,
    4.73 +    /*  39 */   SDL_SCANCODE_APOSTROPHE,
    4.74 +    /*  40 */   SDL_SCANCODE_K,
    4.75 +    /*  41 */   SDL_SCANCODE_SEMICOLON,
    4.76 +    /*  42 */   SDL_SCANCODE_BACKSLASH,
    4.77 +    /*  43 */   SDL_SCANCODE_COMMA,
    4.78 +    /*  44 */   SDL_SCANCODE_SLASH,
    4.79 +    /*  45 */   SDL_SCANCODE_N,
    4.80 +    /*  46 */   SDL_SCANCODE_M,
    4.81 +    /*  47 */   SDL_SCANCODE_PERIOD,
    4.82 +    /*  48 */   SDL_SCANCODE_TAB,
    4.83 +    /*  49 */   SDL_SCANCODE_SPACE,
    4.84 +    /*  50 */   SDL_SCANCODE_GRAVE, /* SDL_SCANCODE_GRAVE on ANSI and JIS keyboards, SDL_SCANCODE_NONUSBACKSLASH on ISO (see comment about virtual key code 10 above) */
    4.85 +    /*  51 */   SDL_SCANCODE_BACKSPACE,
    4.86 +    /*  52 */   SDL_SCANCODE_KP_ENTER, /* keyboard enter on portables */
    4.87 +    /*  53 */   SDL_SCANCODE_ESCAPE,
    4.88 +    /*  54 */   SDL_SCANCODE_RGUI,
    4.89 +    /*  55 */   SDL_SCANCODE_LGUI,
    4.90 +    /*  56 */   SDL_SCANCODE_LSHIFT,
    4.91 +    /*  57 */   SDL_SCANCODE_CAPSLOCK,
    4.92 +    /*  58 */   SDL_SCANCODE_LALT,
    4.93 +    /*  59 */   SDL_SCANCODE_LCTRL,
    4.94 +    /*  60 */   SDL_SCANCODE_RSHIFT,
    4.95 +    /*  61 */   SDL_SCANCODE_RALT,
    4.96 +    /*  62 */   SDL_SCANCODE_RCTRL,
    4.97 +    /*  63 */   SDL_SCANCODE_RGUI, /* fn on portables, acts as a hardware-level modifier already, so we don't generate events for it, also XK_Meta_R */
    4.98 +    /*  64 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
    4.99 +    /*  65 */   SDL_SCANCODE_KP_PERIOD,
   4.100 +    /*  66 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
   4.101 +    /*  67 */   SDL_SCANCODE_KP_MULTIPLY,
   4.102 +    /*  68 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
   4.103 +    /*  69 */   SDL_SCANCODE_KP_PLUS,
   4.104 +    /*  70 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
   4.105 +    /*  71 */   SDL_SCANCODE_NUMLOCKCLEAR,
   4.106 +    /*  72 */   SDL_SCANCODE_VOLUMEUP,
   4.107 +    /*  73 */   SDL_SCANCODE_VOLUMEDOWN,
   4.108 +    /*  74 */   SDL_SCANCODE_MUTE,
   4.109 +    /*  75 */   SDL_SCANCODE_KP_DIVIDE,
   4.110 +    /*  76 */   SDL_SCANCODE_KP_ENTER, /* keypad enter on external keyboards, fn-return on portables */
   4.111 +    /*  77 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
   4.112 +    /*  78 */   SDL_SCANCODE_KP_MINUS,
   4.113 +    /*  79 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
   4.114 +    /*  80 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
   4.115 +    /*  81 */   SDL_SCANCODE_KP_EQUALS,
   4.116 +    /*  82 */   SDL_SCANCODE_KP_0,
   4.117 +    /*  83 */   SDL_SCANCODE_KP_1,
   4.118 +    /*  84 */   SDL_SCANCODE_KP_2,
   4.119 +    /*  85 */   SDL_SCANCODE_KP_3,
   4.120 +    /*  86 */   SDL_SCANCODE_KP_4,
   4.121 +    /*  87 */   SDL_SCANCODE_KP_5,
   4.122 +    /*  88 */   SDL_SCANCODE_KP_6,
   4.123 +    /*  89 */   SDL_SCANCODE_KP_7,
   4.124 +    /*  90 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
   4.125 +    /*  91 */   SDL_SCANCODE_KP_8,
   4.126 +    /*  92 */   SDL_SCANCODE_KP_9,
   4.127 +    /*  93 */   SDL_SCANCODE_INTERNATIONAL3, /* Cosmo_USB2ADB.c says "Yen (JIS)" */
   4.128 +    /*  94 */   SDL_SCANCODE_INTERNATIONAL1, /* Cosmo_USB2ADB.c says "Ro (JIS)" */
   4.129 +    /*  95 */   SDL_SCANCODE_KP_COMMA, /* Cosmo_USB2ADB.c says ", JIS only" */
   4.130 +    /*  96 */   SDL_SCANCODE_F5,
   4.131 +    /*  97 */   SDL_SCANCODE_F6,
   4.132 +    /*  98 */   SDL_SCANCODE_F7,
   4.133 +    /*  99 */   SDL_SCANCODE_F3,
   4.134 +    /* 100 */   SDL_SCANCODE_F8,
   4.135 +    /* 101 */   SDL_SCANCODE_F9,
   4.136 +    /* 102 */   SDL_SCANCODE_LANG2, /* Cosmo_USB2ADB.c says "Eisu" */
   4.137 +    /* 103 */   SDL_SCANCODE_F11,
   4.138 +    /* 104 */   SDL_SCANCODE_LANG1, /* Cosmo_USB2ADB.c says "Kana" */
   4.139 +    /* 105 */   SDL_SCANCODE_PRINTSCREEN, /* On ADB keyboards, this key is labeled "F13/print screen". Problem: USB has different usage codes for these two functions. On Apple USB keyboards, the key is labeled "F13" and sends the F13 usage code (SDL_SCANCODE_F13). I decided to use SDL_SCANCODE_PRINTSCREEN here nevertheless since SDL applications are more likely to assume the presence of a print screen key than an F13 key. */
   4.140 +    /* 106 */   SDL_SCANCODE_F16,
   4.141 +    /* 107 */   SDL_SCANCODE_SCROLLLOCK, /* F14/scroll lock, see comment about F13/print screen above */
   4.142 +    /* 108 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
   4.143 +    /* 109 */   SDL_SCANCODE_F10,
   4.144 +    /* 110 */   SDL_SCANCODE_APPLICATION, /* windows contextual menu key, fn-enter on portables */
   4.145 +    /* 111 */   SDL_SCANCODE_F12,
   4.146 +    /* 112 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
   4.147 +    /* 113 */   SDL_SCANCODE_PAUSE, /* F15/pause, see comment about F13/print screen above */
   4.148 +    /* 114 */   SDL_SCANCODE_INSERT, /* the key is actually labeled "help" on Apple keyboards, and works as such in Mac OS, but it sends the "insert" usage code even on Apple USB keyboards */
   4.149 +    /* 115 */   SDL_SCANCODE_HOME,
   4.150 +    /* 116 */   SDL_SCANCODE_PAGEUP,
   4.151 +    /* 117 */   SDL_SCANCODE_DELETE,
   4.152 +    /* 118 */   SDL_SCANCODE_F4,
   4.153 +    /* 119 */   SDL_SCANCODE_END,
   4.154 +    /* 120 */   SDL_SCANCODE_F2,
   4.155 +    /* 121 */   SDL_SCANCODE_PAGEDOWN,
   4.156 +    /* 122 */   SDL_SCANCODE_F1,
   4.157 +    /* 123 */   SDL_SCANCODE_LEFT,
   4.158 +    /* 124 */   SDL_SCANCODE_RIGHT,
   4.159 +    /* 125 */   SDL_SCANCODE_DOWN,
   4.160 +    /* 126 */   SDL_SCANCODE_UP,
   4.161 +    /* 127 */   SDL_SCANCODE_POWER
   4.162 +};
   4.163 +/* *INDENT-ON* */
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/src/events/scancodes_linux.h	Thu Feb 07 15:31:09 2008 +0000
     5.3 @@ -0,0 +1,264 @@
     5.4 +/*
     5.5 +    SDL - Simple DirectMedia Layer
     5.6 +    Copyright (C) 1997-2006 Sam Lantinga
     5.7 +
     5.8 +    This library is free software; you can redistribute it and/or
     5.9 +    modify it under the terms of the GNU Lesser General Public
    5.10 +    License as published by the Free Software Foundation; either
    5.11 +    version 2.1 of the License, or (at your option) any later version.
    5.12 +
    5.13 +    This library is distributed in the hope that it will be useful,
    5.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    5.16 +    Lesser General Public License for more details.
    5.17 +
    5.18 +    You should have received a copy of the GNU Lesser General Public
    5.19 +    License along with this library; if not, write to the Free Software
    5.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    5.21 +
    5.22 +    Sam Lantinga
    5.23 +    slouken@libsdl.org
    5.24 +*/
    5.25 +#include "../../include/SDL_scancode.h"
    5.26 +
    5.27 +/* Linux virtual key code to SDLKey mapping table
    5.28 +   Sources:
    5.29 +   - Linux kernel source input.h
    5.30 +*/
    5.31 +/* *INDENT-OFF* */
    5.32 +static SDL_scancode linux_scancode_table[] = {
    5.33 +    /*  0 */    SDL_SCANCODE_UNKNOWN,
    5.34 +    /*  1 */    SDL_SCANCODE_ESCAPE,
    5.35 +    /*  2 */    SDL_SCANCODE_1,
    5.36 +    /*  3 */    SDL_SCANCODE_2,
    5.37 +    /*  4 */    SDL_SCANCODE_3,
    5.38 +    /*  5 */    SDL_SCANCODE_4,
    5.39 +    /*  6 */    SDL_SCANCODE_5,
    5.40 +    /*  7 */    SDL_SCANCODE_6,
    5.41 +    /*  8 */    SDL_SCANCODE_7,
    5.42 +    /*  9 */    SDL_SCANCODE_8,
    5.43 +    /*  10 */    SDL_SCANCODE_9,
    5.44 +    /*  11 */    SDL_SCANCODE_0,
    5.45 +    /*  12 */    SDL_SCANCODE_MINUS,
    5.46 +    /*  13 */    SDL_SCANCODE_EQUALS,
    5.47 +    /*  14 */    SDL_SCANCODE_BACKSPACE,
    5.48 +    /*  15 */    SDL_SCANCODE_TAB,
    5.49 +    /*  16 */    SDL_SCANCODE_Q,
    5.50 +    /*  17 */    SDL_SCANCODE_W,
    5.51 +    /*  18 */    SDL_SCANCODE_E,
    5.52 +    /*  19 */    SDL_SCANCODE_R,
    5.53 +    /*  20 */    SDL_SCANCODE_T,
    5.54 +    /*  21 */    SDL_SCANCODE_Y,
    5.55 +    /*  22 */    SDL_SCANCODE_U,
    5.56 +    /*  23 */    SDL_SCANCODE_I,
    5.57 +    /*  24 */    SDL_SCANCODE_O,
    5.58 +    /*  25 */    SDL_SCANCODE_P,
    5.59 +    /*  26 */    SDL_SCANCODE_LEFTBRACKET,
    5.60 +    /*  27 */    SDL_SCANCODE_RIGHTBRACKET,
    5.61 +    /*  28 */    SDL_SCANCODE_RETURN,
    5.62 +    /*  29 */    SDL_SCANCODE_LCTRL,
    5.63 +    /*  30 */    SDL_SCANCODE_A,
    5.64 +    /*  31 */    SDL_SCANCODE_S,
    5.65 +    /*  32 */    SDL_SCANCODE_D,
    5.66 +    /*  33 */    SDL_SCANCODE_F,
    5.67 +    /*  34 */    SDL_SCANCODE_G,
    5.68 +    /*  35 */    SDL_SCANCODE_H,
    5.69 +    /*  36 */    SDL_SCANCODE_J,
    5.70 +    /*  37 */    SDL_SCANCODE_K,
    5.71 +    /*  38 */    SDL_SCANCODE_L,
    5.72 +    /*  39 */    SDL_SCANCODE_SEMICOLON,
    5.73 +    /*  40 */    SDL_SCANCODE_APOSTROPHE,
    5.74 +    /*  41 */    SDL_SCANCODE_GRAVE,
    5.75 +    /*  42 */    SDL_SCANCODE_LSHIFT,
    5.76 +    /*  43 */    SDL_SCANCODE_BACKSLASH,
    5.77 +    /*  44 */    SDL_SCANCODE_Z,
    5.78 +    /*  45 */    SDL_SCANCODE_X,
    5.79 +    /*  46 */    SDL_SCANCODE_C,
    5.80 +    /*  47 */    SDL_SCANCODE_V,
    5.81 +    /*  48 */    SDL_SCANCODE_B,
    5.82 +    /*  49 */    SDL_SCANCODE_N,
    5.83 +    /*  50 */    SDL_SCANCODE_M,
    5.84 +    /*  51 */    SDL_SCANCODE_COMMA,
    5.85 +    /*  52 */    SDL_SCANCODE_PERIOD,
    5.86 +    /*  53 */    SDL_SCANCODE_SLASH,
    5.87 +    /*  54 */    SDL_SCANCODE_RSHIFT,
    5.88 +    /*  55 */    SDL_SCANCODE_KP_MULTIPLY,
    5.89 +    /*  56 */    SDL_SCANCODE_LALT,
    5.90 +    /*  57 */    SDL_SCANCODE_SPACE,
    5.91 +    /*  58 */    SDL_SCANCODE_CAPSLOCK,
    5.92 +    /*  59 */    SDL_SCANCODE_F1,
    5.93 +    /*  60 */    SDL_SCANCODE_F2,
    5.94 +    /*  61 */    SDL_SCANCODE_F3,
    5.95 +    /*  62 */    SDL_SCANCODE_F4,
    5.96 +    /*  63 */    SDL_SCANCODE_F5,
    5.97 +    /*  64 */    SDL_SCANCODE_F6,
    5.98 +    /*  65 */    SDL_SCANCODE_F7,
    5.99 +    /*  66 */    SDL_SCANCODE_F8,
   5.100 +    /*  67 */    SDL_SCANCODE_F9,
   5.101 +    /*  68 */    SDL_SCANCODE_F10,
   5.102 +    /*  69 */    SDL_SCANCODE_NUMLOCKCLEAR,
   5.103 +    /*  70 */    SDL_SCANCODE_SCROLLLOCK,
   5.104 +    /*  71 */    SDL_SCANCODE_KP_7,
   5.105 +    /*  72 */    SDL_SCANCODE_KP_8,
   5.106 +    /*  73 */    SDL_SCANCODE_KP_9,
   5.107 +    /*  74 */    SDL_SCANCODE_KP_MINUS,
   5.108 +    /*  75 */    SDL_SCANCODE_KP_4,
   5.109 +    /*  76 */    SDL_SCANCODE_KP_5,
   5.110 +    /*  77 */    SDL_SCANCODE_KP_6,
   5.111 +    /*  78 */    SDL_SCANCODE_KP_PLUS,
   5.112 +    /*  79 */    SDL_SCANCODE_KP_1,
   5.113 +    /*  80 */    SDL_SCANCODE_KP_2,
   5.114 +    /*  81 */    SDL_SCANCODE_KP_3,
   5.115 +    /*  82 */    SDL_SCANCODE_KP_0,
   5.116 +    /*  83 */    SDL_SCANCODE_KP_PERIOD,
   5.117 +    0,
   5.118 +    /*  85 */    SDL_SCANCODE_UNKNOWN, /* KEY_ZENKAKUHANKAKU */
   5.119 +    /*  86 */    SDL_SCANCODE_NONUSBACKSLASH, /* KEY_102ND */
   5.120 +    /*  87 */    SDL_SCANCODE_F11,
   5.121 +    /*  88 */    SDL_SCANCODE_F12,
   5.122 +    /*  89 */    SDL_SCANCODE_INTERNATIONAL1, /* KEY_RO */
   5.123 +    /*  90 */    SDL_SCANCODE_LANG3, /* KEY_KATAKANA */
   5.124 +    /*  91 */    SDL_SCANCODE_LANG4, /* KEY_HIRAGANA */
   5.125 +    /*  92 */    SDL_SCANCODE_INTERNATIONAL4, /* KEY_HENKAN */
   5.126 +    /*  93 */    SDL_SCANCODE_INTERNATIONAL2, /* KEY_KATAKANAHIRAGANA */
   5.127 +    /*  94 */    SDL_SCANCODE_INTERNATIONAL5, /* KEY_MUHENKAN */
   5.128 +    /*  95 */    SDL_SCANCODE_INTERNATIONAL5, /* KEY_KPJPCOMMA */
   5.129 +    /*  96 */    SDL_SCANCODE_KP_ENTER,
   5.130 +    /*  97 */    SDL_SCANCODE_RCTRL,
   5.131 +    /*  98 */    SDL_SCANCODE_KP_DIVIDE,
   5.132 +    /*  99 */    SDL_SCANCODE_SYSREQ,
   5.133 +    /*  100 */    SDL_SCANCODE_RALT,
   5.134 +    /*  101 */    SDL_SCANCODE_UNKNOWN, /* KEY_LINEFEED */
   5.135 +    /*  102 */    SDL_SCANCODE_HOME,
   5.136 +    /*  103 */    SDL_SCANCODE_UP,
   5.137 +    /*  104 */    SDL_SCANCODE_PAGEUP,
   5.138 +    /*  105 */    SDL_SCANCODE_LEFT,
   5.139 +    /*  106 */    SDL_SCANCODE_RIGHT,
   5.140 +    /*  107 */    SDL_SCANCODE_END,
   5.141 +    /*  108 */    SDL_SCANCODE_DOWN,
   5.142 +    /*  109 */    SDL_SCANCODE_PAGEDOWN,
   5.143 +    /*  110 */    SDL_SCANCODE_INSERT,
   5.144 +    /*  111 */    SDL_SCANCODE_DELETE,
   5.145 +    /*  112 */    SDL_SCANCODE_UNKNOWN, /* KEY_MACRO */
   5.146 +    /*  113 */    SDL_SCANCODE_MUTE,
   5.147 +    /*  114 */    SDL_SCANCODE_VOLUMEDOWN,
   5.148 +    /*  115 */    SDL_SCANCODE_VOLUMEUP,
   5.149 +    /*  116 */    SDL_SCANCODE_POWER,
   5.150 +    /*  117 */    SDL_SCANCODE_KP_EQUALS,
   5.151 +    /*  118 */    SDL_SCANCODE_KP_PLUSMINUS,
   5.152 +    /*  119 */    SDL_SCANCODE_PAUSE,
   5.153 +    0,
   5.154 +    /*  121 */    SDL_SCANCODE_KP_COMMA,
   5.155 +    /*  122 */    SDL_SCANCODE_LANG1, /* KEY_HANGUEL */
   5.156 +    /*  123 */    SDL_SCANCODE_LANG2, /* KEY_HANJA */
   5.157 +    /*  124 */    SDL_SCANCODE_INTERNATIONAL3, /* KEY_YEN */
   5.158 +    /*  125 */    SDL_SCANCODE_LGUI,
   5.159 +    /*  126 */    SDL_SCANCODE_RGUI,
   5.160 +    /*  127 */    SDL_SCANCODE_UNKNOWN, /* KEY_COMPOSE */
   5.161 +    /*  128 */    SDL_SCANCODE_STOP,
   5.162 +    /*  129 */    SDL_SCANCODE_AGAIN,
   5.163 +    /*  130 */    SDL_SCANCODE_UNKNOWN, /* KEY_PROPS */
   5.164 +    /*  131 */    SDL_SCANCODE_UNDO,
   5.165 +    /*  132 */    SDL_SCANCODE_UNKNOWN, /* KEY_FRONT */
   5.166 +    /*  133 */    SDL_SCANCODE_COPY,
   5.167 +    /*  134 */    SDL_SCANCODE_UNKNOWN, /* KEY_OPEN */
   5.168 +    /*  135 */    SDL_SCANCODE_PASTE,
   5.169 +    /*  136 */    SDL_SCANCODE_FIND,
   5.170 +    /*  137 */    SDL_SCANCODE_CUT,
   5.171 +    /*  138 */    SDL_SCANCODE_HELP,
   5.172 +    /*  139 */    SDL_SCANCODE_MENU,
   5.173 +    /*  140 */    SDL_SCANCODE_CALCULATOR,
   5.174 +    /*  141 */    SDL_SCANCODE_UNKNOWN, /* KEY_SETUP */
   5.175 +    /*  142 */    SDL_SCANCODE_SLEEP,
   5.176 +    /*  143 */    SDL_SCANCODE_UNKNOWN, /* KEY_WAKEUP */
   5.177 +    /*  144 */    SDL_SCANCODE_UNKNOWN, /* KEY_FILE */
   5.178 +    /*  145 */    SDL_SCANCODE_UNKNOWN, /* KEY_SENDFILE */
   5.179 +    /*  146 */    SDL_SCANCODE_UNKNOWN, /* KEY_DELETEFILE */
   5.180 +    /*  147 */    SDL_SCANCODE_UNKNOWN, /* KEY_XFER */
   5.181 +    /*  148 */    SDL_SCANCODE_UNKNOWN, /* KEY_PROG1 */
   5.182 +    /*  149 */    SDL_SCANCODE_UNKNOWN, /* KEY_PROG2 */
   5.183 +    /*  150 */    SDL_SCANCODE_UNKNOWN, /* KEY_WWW */
   5.184 +    /*  151 */    SDL_SCANCODE_UNKNOWN, /* KEY_MSDOS */
   5.185 +    /*  152 */    SDL_SCANCODE_UNKNOWN, /* KEY_COFFEE */
   5.186 +    /*  153 */    SDL_SCANCODE_UNKNOWN, /* KEY_DIRECTION */
   5.187 +    /*  154 */    SDL_SCANCODE_UNKNOWN, /* KEY_CYCLEWINDOWS */
   5.188 +    /*  155 */    SDL_SCANCODE_MAIL,
   5.189 +    /*  156 */    SDL_SCANCODE_AC_BOOKMARKS,
   5.190 +    /*  157 */    SDL_SCANCODE_COMPUTER,
   5.191 +    /*  158 */    SDL_SCANCODE_AC_BACK,
   5.192 +    /*  159 */    SDL_SCANCODE_AC_FORWARD,
   5.193 +    /*  160 */    SDL_SCANCODE_UNKNOWN, /* KEY_CLOSECD */
   5.194 +    /*  161 */    SDL_SCANCODE_EJECT, /* KEY_EJECTCD */
   5.195 +    /*  162 */    SDL_SCANCODE_UNKNOWN, /* KEY_EJECTCLOSECD */
   5.196 +    /*  163 */    SDL_SCANCODE_AUDIONEXT, /* KEY_NEXTSONG */
   5.197 +    /*  164 */    SDL_SCANCODE_AUDIOPLAY, /* KEY_PLAYPAUSE */
   5.198 +    /*  165 */    SDL_SCANCODE_AUDIOPREV, /* KEY_PREVIOUSSONG */
   5.199 +    /*  166 */    SDL_SCANCODE_UNKNOWN, /* KEY_STOPCD */
   5.200 +    /*  167 */    SDL_SCANCODE_UNKNOWN, /* KEY_RECORD */
   5.201 +    /*  168 */    SDL_SCANCODE_UNKNOWN, /* KEY_REWIND */
   5.202 +    /*  169 */    SDL_SCANCODE_UNKNOWN, /* KEY_PHONE */
   5.203 +    /*  170 */    SDL_SCANCODE_UNKNOWN, /* KEY_ISO */
   5.204 +    /*  171 */    SDL_SCANCODE_UNKNOWN, /* KEY_CONFIG */
   5.205 +    /*  172 */    SDL_SCANCODE_AC_HOME,
   5.206 +    /*  173 */    SDL_SCANCODE_AC_REFRESH,
   5.207 +    /*  174 */    SDL_SCANCODE_UNKNOWN, /* KEY_EXIT */
   5.208 +    /*  175 */    SDL_SCANCODE_UNKNOWN, /* KEY_MOVE */
   5.209 +    /*  176 */    SDL_SCANCODE_UNKNOWN, /* KEY_EDIT */
   5.210 +    /*  177 */    SDL_SCANCODE_UNKNOWN, /* KEY_SCROLLUP */
   5.211 +    /*  178 */    SDL_SCANCODE_UNKNOWN, /* KEY_SCROLLDOWN */
   5.212 +    /*  179 */    SDL_SCANCODE_KP_LEFTPAREN,
   5.213 +    /*  180 */    SDL_SCANCODE_KP_RIGHTPAREN,
   5.214 +    /*  181 */    SDL_SCANCODE_UNKNOWN, /* KEY_NEW */
   5.215 +    /*  182 */    SDL_SCANCODE_UNKNOWN, /* KEY_REDO */
   5.216 +    /*  183 */    SDL_SCANCODE_F13,
   5.217 +    /*  184 */    SDL_SCANCODE_F14,
   5.218 +    /*  185 */    SDL_SCANCODE_F15,
   5.219 +    /*  186 */    SDL_SCANCODE_F16,
   5.220 +    /*  187 */    SDL_SCANCODE_F17,
   5.221 +    /*  188 */    SDL_SCANCODE_F18,
   5.222 +    /*  189 */    SDL_SCANCODE_F19,
   5.223 +    /*  190 */    SDL_SCANCODE_F20,
   5.224 +    /*  191 */    SDL_SCANCODE_F21,
   5.225 +    /*  192 */    SDL_SCANCODE_F22,
   5.226 +    /*  193 */    SDL_SCANCODE_F23,
   5.227 +    /*  194 */    SDL_SCANCODE_F24,
   5.228 +    0, 0, 0, 0,
   5.229 +    /*  200 */    SDL_SCANCODE_UNKNOWN, /* KEY_PLAYCD */
   5.230 +    /*  201 */    SDL_SCANCODE_UNKNOWN, /* KEY_PAUSECD */
   5.231 +    /*  202 */    SDL_SCANCODE_UNKNOWN, /* KEY_PROG3 */
   5.232 +    /*  203 */    SDL_SCANCODE_UNKNOWN, /* KEY_PROG4 */
   5.233 +    0,
   5.234 +    /*  205 */    SDL_SCANCODE_UNKNOWN, /* KEY_SUSPEND */
   5.235 +    /*  206 */    SDL_SCANCODE_UNKNOWN, /* KEY_CLOSE */
   5.236 +    /*  207 */    SDL_SCANCODE_UNKNOWN, /* KEY_PLAY */
   5.237 +    /*  208 */    SDL_SCANCODE_UNKNOWN, /* KEY_FASTFORWARD */
   5.238 +    /*  209 */    SDL_SCANCODE_UNKNOWN, /* KEY_BASSBOOST */
   5.239 +    /*  210 */    SDL_SCANCODE_UNKNOWN, /* KEY_PRINT */
   5.240 +    /*  211 */    SDL_SCANCODE_UNKNOWN, /* KEY_HP */
   5.241 +    /*  212 */    SDL_SCANCODE_UNKNOWN, /* KEY_CAMERA */
   5.242 +    /*  213 */    SDL_SCANCODE_UNKNOWN, /* KEY_SOUND */
   5.243 +    /*  214 */    SDL_SCANCODE_UNKNOWN, /* KEY_QUESTION */
   5.244 +    /*  215 */    SDL_SCANCODE_UNKNOWN, /* KEY_EMAIL */
   5.245 +    /*  216 */    SDL_SCANCODE_UNKNOWN, /* KEY_CHAT */
   5.246 +    /*  217 */    SDL_SCANCODE_AC_SEARCH,
   5.247 +    /*  218 */    SDL_SCANCODE_UNKNOWN, /* KEY_CONNECT */
   5.248 +    /*  219 */    SDL_SCANCODE_UNKNOWN, /* KEY_FINANCE */
   5.249 +    /*  220 */    SDL_SCANCODE_UNKNOWN, /* KEY_SPORT */
   5.250 +    /*  221 */    SDL_SCANCODE_UNKNOWN, /* KEY_SHOP */
   5.251 +    /*  222 */    SDL_SCANCODE_ALTERASE,
   5.252 +    /*  223 */    SDL_SCANCODE_CANCEL,
   5.253 +    /*  224 */    SDL_SCANCODE_BRIGHTNESSDOWN,
   5.254 +    /*  225 */    SDL_SCANCODE_BRIGHTNESSUP,
   5.255 +    /*  226 */    SDL_SCANCODE_UNKNOWN, /* KEY_MEDIA */
   5.256 +    /*  227 */    SDL_SCANCODE_DISPLAYSWITCH, /* KEY_SWITCHVIDEOMODE */
   5.257 +    /*  228 */    SDL_SCANCODE_KBDILLUMTOGGLE,
   5.258 +    /*  229 */    SDL_SCANCODE_KBDILLUMDOWN,
   5.259 +    /*  230 */    SDL_SCANCODE_KBDILLUMUP,
   5.260 +    /*  231 */    SDL_SCANCODE_UNKNOWN, /* KEY_SEND */
   5.261 +    /*  232 */    SDL_SCANCODE_UNKNOWN, /* KEY_REPLY */
   5.262 +    /*  233 */    SDL_SCANCODE_UNKNOWN, /* KEY_FORWARDMAIL */
   5.263 +    /*  234 */    SDL_SCANCODE_UNKNOWN, /* KEY_SAVE */
   5.264 +    /*  235 */    SDL_SCANCODE_UNKNOWN, /* KEY_DOCUMENTS */
   5.265 +    /*  236 */    SDL_SCANCODE_UNKNOWN, /* KEY_BATTERY */
   5.266 +};
   5.267 +/* *INDENT-ON* */
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/src/events/scancodes_xfree86.h	Thu Feb 07 15:31:09 2008 +0000
     6.3 @@ -0,0 +1,178 @@
     6.4 +/*
     6.5 +    SDL - Simple DirectMedia Layer
     6.6 +    Copyright (C) 1997-2006 Sam Lantinga
     6.7 +
     6.8 +    This library is free software; you can redistribute it and/or
     6.9 +    modify it under the terms of the GNU Lesser General Public
    6.10 +    License as published by the Free Software Foundation; either
    6.11 +    version 2.1 of the License, or (at your option) any later version.
    6.12 +
    6.13 +    This library is distributed in the hope that it will be useful,
    6.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    6.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    6.16 +    Lesser General Public License for more details.
    6.17 +
    6.18 +    You should have received a copy of the GNU Lesser General Public
    6.19 +    License along with this library; if not, write to the Free Software
    6.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    6.21 +
    6.22 +    Sam Lantinga
    6.23 +    slouken@libsdl.org
    6.24 +*/
    6.25 +#include "../../include/SDL_scancode.h"
    6.26 +
    6.27 +/* XFree86 key code to SDL scancode mapping table
    6.28 +   Sources:
    6.29 +   - atKeyNames.h from XFree86 source code
    6.30 +*/
    6.31 +/* *INDENT-OFF* */
    6.32 +static SDL_scancode xfree86_scancode_table[] = {
    6.33 +    /*  0 */    SDL_SCANCODE_UNKNOWN,
    6.34 +    /*  1 */    SDL_SCANCODE_ESCAPE,
    6.35 +    /*  2 */    SDL_SCANCODE_1,
    6.36 +    /*  3 */    SDL_SCANCODE_2,
    6.37 +    /*  4 */    SDL_SCANCODE_3,
    6.38 +    /*  5 */    SDL_SCANCODE_4,
    6.39 +    /*  6 */    SDL_SCANCODE_5,
    6.40 +    /*  7 */    SDL_SCANCODE_6,
    6.41 +    /*  8 */    SDL_SCANCODE_7,
    6.42 +    /*  9 */    SDL_SCANCODE_8,
    6.43 +    /*  10 */   SDL_SCANCODE_9,
    6.44 +    /*  11 */   SDL_SCANCODE_0,
    6.45 +    /*  12 */   SDL_SCANCODE_MINUS,
    6.46 +    /*  13 */   SDL_SCANCODE_EQUALS,
    6.47 +    /*  14 */   SDL_SCANCODE_BACKSPACE,
    6.48 +    /*  15 */   SDL_SCANCODE_TAB,
    6.49 +    /*  16 */   SDL_SCANCODE_Q,
    6.50 +    /*  17 */   SDL_SCANCODE_W,
    6.51 +    /*  18 */   SDL_SCANCODE_E,
    6.52 +    /*  19 */   SDL_SCANCODE_R,
    6.53 +    /*  20 */   SDL_SCANCODE_T,
    6.54 +    /*  21 */   SDL_SCANCODE_Y,
    6.55 +    /*  22 */   SDL_SCANCODE_U,
    6.56 +    /*  23 */   SDL_SCANCODE_I,
    6.57 +    /*  24 */   SDL_SCANCODE_O,
    6.58 +    /*  25 */   SDL_SCANCODE_P,
    6.59 +    /*  26 */   SDL_SCANCODE_LEFTBRACKET,
    6.60 +    /*  27 */   SDL_SCANCODE_RIGHTBRACKET,
    6.61 +    /*  28 */   SDL_SCANCODE_RETURN,
    6.62 +    /*  29 */   SDL_SCANCODE_LCTRL,
    6.63 +    /*  30 */   SDL_SCANCODE_A,
    6.64 +    /*  31 */   SDL_SCANCODE_S,
    6.65 +    /*  32 */   SDL_SCANCODE_D,
    6.66 +    /*  33 */   SDL_SCANCODE_F,
    6.67 +    /*  34 */   SDL_SCANCODE_G,
    6.68 +    /*  35 */   SDL_SCANCODE_H,
    6.69 +    /*  36 */   SDL_SCANCODE_J,
    6.70 +    /*  37 */   SDL_SCANCODE_K,
    6.71 +    /*  38 */   SDL_SCANCODE_L,
    6.72 +    /*  39 */   SDL_SCANCODE_SEMICOLON,
    6.73 +    /*  40 */   SDL_SCANCODE_APOSTROPHE,
    6.74 +    /*  41 */   SDL_SCANCODE_GRAVE,
    6.75 +    /*  42 */   SDL_SCANCODE_LSHIFT,
    6.76 +    /*  43 */   SDL_SCANCODE_BACKSLASH,
    6.77 +    /*  44 */   SDL_SCANCODE_Z,
    6.78 +    /*  45 */   SDL_SCANCODE_X,
    6.79 +    /*  46 */   SDL_SCANCODE_C,
    6.80 +    /*  47 */   SDL_SCANCODE_V,
    6.81 +    /*  48 */   SDL_SCANCODE_B,
    6.82 +    /*  49 */   SDL_SCANCODE_N,
    6.83 +    /*  50 */   SDL_SCANCODE_M,
    6.84 +    /*  51 */   SDL_SCANCODE_COMMA,
    6.85 +    /*  52 */   SDL_SCANCODE_PERIOD,
    6.86 +    /*  53 */   SDL_SCANCODE_SLASH,
    6.87 +    /*  54 */   SDL_SCANCODE_RSHIFT,
    6.88 +    /*  55 */   SDL_SCANCODE_KP_MULTIPLY,
    6.89 +    /*  56 */   SDL_SCANCODE_LALT,
    6.90 +    /*  57 */   SDL_SCANCODE_SPACE,
    6.91 +    /*  58 */   SDL_SCANCODE_CAPSLOCK,
    6.92 +    /*  59 */   SDL_SCANCODE_F1,
    6.93 +    /*  60 */   SDL_SCANCODE_F2,
    6.94 +    /*  61 */   SDL_SCANCODE_F3,
    6.95 +    /*  62 */   SDL_SCANCODE_F4,
    6.96 +    /*  63 */   SDL_SCANCODE_F5,
    6.97 +    /*  64 */   SDL_SCANCODE_F6,
    6.98 +    /*  65 */   SDL_SCANCODE_F7,
    6.99 +    /*  66 */   SDL_SCANCODE_F8,
   6.100 +    /*  67 */   SDL_SCANCODE_F9,
   6.101 +    /*  68 */   SDL_SCANCODE_F10,
   6.102 +    /*  69 */   SDL_SCANCODE_NUMLOCKCLEAR,
   6.103 +    /*  70 */   SDL_SCANCODE_SCROLLLOCK,
   6.104 +    /*  71 */   SDL_SCANCODE_KP_7,
   6.105 +    /*  72 */   SDL_SCANCODE_KP_8,
   6.106 +    /*  73 */   SDL_SCANCODE_KP_9,
   6.107 +    /*  74 */   SDL_SCANCODE_KP_MINUS,
   6.108 +    /*  75 */   SDL_SCANCODE_KP_4,
   6.109 +    /*  76 */   SDL_SCANCODE_KP_5,
   6.110 +    /*  77 */   SDL_SCANCODE_KP_6,
   6.111 +    /*  78 */   SDL_SCANCODE_KP_PLUS,
   6.112 +    /*  79 */   SDL_SCANCODE_KP_1,
   6.113 +    /*  80 */   SDL_SCANCODE_KP_2,
   6.114 +    /*  81 */   SDL_SCANCODE_KP_3,
   6.115 +    /*  82 */   SDL_SCANCODE_KP_0,
   6.116 +    /*  83 */   SDL_SCANCODE_KP_PERIOD,
   6.117 +    /*  84 */   SDL_SCANCODE_SYSREQ,
   6.118 +    /*  85 */   SDL_SCANCODE_MODE,
   6.119 +    /*  86 */   SDL_SCANCODE_NONUSBACKSLASH,
   6.120 +    /*  87 */   SDL_SCANCODE_F11,
   6.121 +    /*  88 */   SDL_SCANCODE_F12,
   6.122 +    /*  89 */   SDL_SCANCODE_HOME,
   6.123 +    /*  90 */   SDL_SCANCODE_UP,
   6.124 +    /*  91 */   SDL_SCANCODE_PAGEUP,
   6.125 +    /*  92 */   SDL_SCANCODE_LEFT,
   6.126 +    /*  93 */   SDL_SCANCODE_BRIGHTNESSDOWN, /* on PowerBook G4 / KEY_Begin */
   6.127 +    /*  94 */   SDL_SCANCODE_RIGHT,
   6.128 +    /*  95 */   SDL_SCANCODE_END,
   6.129 +    /*  96 */   SDL_SCANCODE_DOWN,
   6.130 +    /*  97 */   SDL_SCANCODE_PAGEDOWN,
   6.131 +    /*  98 */   SDL_SCANCODE_INSERT,
   6.132 +    /*  99 */   SDL_SCANCODE_DELETE,
   6.133 +    /*  100 */  SDL_SCANCODE_KP_ENTER,
   6.134 +    /*  101 */  SDL_SCANCODE_RCTRL,
   6.135 +    /*  102 */  SDL_SCANCODE_PAUSE,
   6.136 +    /*  103 */  SDL_SCANCODE_PRINTSCREEN,
   6.137 +    /*  104 */  SDL_SCANCODE_KP_DIVIDE,
   6.138 +    /*  105 */  SDL_SCANCODE_RALT,
   6.139 +    /*  106 */  SDL_SCANCODE_UNKNOWN, /* BREAK */
   6.140 +    /*  107 */  SDL_SCANCODE_LGUI,
   6.141 +    /*  108 */  SDL_SCANCODE_RGUI,
   6.142 +    /*  109 */  SDL_SCANCODE_APPLICATION,
   6.143 +    /*  110 */  SDL_SCANCODE_F13,
   6.144 +    /*  111 */  SDL_SCANCODE_F14,
   6.145 +    /*  112 */  SDL_SCANCODE_F15,
   6.146 +    /*  113 */  SDL_SCANCODE_F16,
   6.147 +    /*  114 */  SDL_SCANCODE_F17,
   6.148 +    /*  115 */	SDL_SCANCODE_UNKNOWN,
   6.149 +    /*	116 */  SDL_SCANCODE_UNKNOWN, /* is translated to XK_ISO_Level3_Shift by my X server, but I have no keyboard that generates this code, so I don't know what the correct SDL_SCANCODE_* for it is */
   6.150 +    /*  117 */  SDL_SCANCODE_UNKNOWN,
   6.151 +    /*  118 */  SDL_SCANCODE_KP_EQUALS,
   6.152 +    /*  119 */  SDL_SCANCODE_UNKNOWN,
   6.153 +    /*  120 */  SDL_SCANCODE_UNKNOWN,
   6.154 +    /*  121 */  SDL_SCANCODE_UNKNOWN,
   6.155 +    /*  122 */  SDL_SCANCODE_UNKNOWN,
   6.156 +    /*  123 */  SDL_SCANCODE_UNKNOWN,
   6.157 +    /*  124 */  SDL_SCANCODE_UNKNOWN,
   6.158 +    /*  125 */  SDL_SCANCODE_INTERNATIONAL3, /* Yen */
   6.159 +    /*  126 */  SDL_SCANCODE_UNKNOWN,
   6.160 +    /*  127 */  SDL_SCANCODE_UNKNOWN,
   6.161 +    /*  128 */  SDL_SCANCODE_UNKNOWN,
   6.162 +    /*  129 */  SDL_SCANCODE_UNKNOWN,
   6.163 +    /*  130 */  SDL_SCANCODE_UNKNOWN,
   6.164 +    /*  131 */  SDL_SCANCODE_UNKNOWN,
   6.165 +    /*  132 */  SDL_SCANCODE_POWER,
   6.166 +    /*  133 */  SDL_SCANCODE_MUTE,
   6.167 +    /*  134 */  SDL_SCANCODE_VOLUMEDOWN,
   6.168 +    /*  135 */  SDL_SCANCODE_VOLUMEUP,
   6.169 +    /*  136 */  SDL_SCANCODE_HELP,
   6.170 +    /*  137 */  SDL_SCANCODE_STOP,
   6.171 +    /*  138 */  SDL_SCANCODE_AGAIN,
   6.172 +    /*  139 */  SDL_SCANCODE_UNKNOWN, /* PROPS */
   6.173 +    /*  140 */  SDL_SCANCODE_UNDO,
   6.174 +    /*  141 */  SDL_SCANCODE_UNKNOWN, /* FRONT */
   6.175 +    /*  142 */  SDL_SCANCODE_COPY,
   6.176 +    /*  143 */  SDL_SCANCODE_UNKNOWN, /* OPEN */
   6.177 +    /*  144 */  SDL_SCANCODE_PASTE,
   6.178 +    /*  145 */  SDL_SCANCODE_FIND,
   6.179 +    /*  146 */  SDL_SCANCODE_CUT,
   6.180 +};
   6.181 +/* *INDENT-ON* */
     7.1 --- a/src/video/cocoa/SDL_cocoakeyboard.m	Tue Feb 05 07:30:50 2008 +0000
     7.2 +++ b/src/video/cocoa/SDL_cocoakeyboard.m	Thu Feb 07 15:31:09 2008 +0000
     7.3 @@ -22,9 +22,9 @@
     7.4  #include "SDL_config.h"
     7.5  
     7.6  #include "SDL_cocoavideo.h"
     7.7 -#include "SDL_cocoakeys.h"
     7.8  
     7.9  #include "../../events/SDL_keyboard_c.h"
    7.10 +#include "../../events/scancodes_darwin.h"
    7.11  
    7.12  #include <Carbon/Carbon.h>
    7.13  
    7.14 @@ -372,13 +372,13 @@
    7.15          UInt32 keyboard_type = LMGetKbdType();
    7.16          OSStatus err;
    7.17  
    7.18 -        for (i = 0; i < SDL_arraysize(scancode_table); i++) {
    7.19 +        for (i = 0; i < SDL_arraysize(darwin_scancode_table); i++) {
    7.20              UniChar s[8];
    7.21              UniCharCount len;
    7.22              UInt32 dead_key_state;
    7.23  
    7.24              /* Make sure this scancode is a valid character scancode */
    7.25 -            scancode = scancode_table[i];
    7.26 +            scancode = darwin_scancode_table[i];
    7.27              if (scancode == SDL_SCANCODE_UNKNOWN ||
    7.28                  (keymap[scancode] & SDLK_SCANCODE_MASK)) {
    7.29                  continue;
    7.30 @@ -407,7 +407,7 @@
    7.31              UInt32 c, state = 0;
    7.32  
    7.33              /* Make sure this scancode is a valid character scancode */
    7.34 -            scancode = scancode_table[i];
    7.35 +            scancode = darwin_scancode_table[i];
    7.36              if (scancode == SDL_SCANCODE_UNKNOWN ||
    7.37                  (keymap[scancode] & SDLK_SCANCODE_MASK)) {
    7.38                  continue;
    7.39 @@ -487,8 +487,8 @@
    7.40          /* see comments in SDL_cocoakeys.h */
    7.41          scancode = 60 - scancode;
    7.42      }
    7.43 -    if (scancode < SDL_arraysize(scancode_table)) {
    7.44 -        code = scancode_table[scancode];
    7.45 +    if (scancode < SDL_arraysize(darwin_scancode_table)) {
    7.46 +        code = darwin_scancode_table[scancode];
    7.47      }
    7.48      else {
    7.49          /* Hmm, does this ever happen?  If so, need to extend the keymap... */
     8.1 --- a/src/video/cocoa/SDL_cocoakeys.h	Tue Feb 05 07:30:50 2008 +0000
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,160 +0,0 @@
     8.4 -/*
     8.5 -    SDL - Simple DirectMedia Layer
     8.6 -    Copyright (C) 1997-2006 Sam Lantinga
     8.7 -
     8.8 -    This library is free software; you can redistribute it and/or
     8.9 -    modify it under the terms of the GNU Lesser General Public
    8.10 -    License as published by the Free Software Foundation; either
    8.11 -    version 2.1 of the License, or (at your option) any later version.
    8.12 -
    8.13 -    This library is distributed in the hope that it will be useful,
    8.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    8.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    8.16 -    Lesser General Public License for more details.
    8.17 -
    8.18 -    You should have received a copy of the GNU Lesser General Public
    8.19 -    License along with this library; if not, write to the Free Software
    8.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    8.21 -
    8.22 -    Sam Lantinga
    8.23 -    slouken@libsdl.org
    8.24 -*/
    8.25 -
    8.26 -/* Mac virtual key code to SDLKey mapping table
    8.27 -   Sources:
    8.28 -   - Inside Macintosh: Text <http://developer.apple.com/documentation/mac/Text/Text-571.html>
    8.29 -   - Apple USB keyboard driver source <http://darwinsource.opendarwin.org/10.4.6.ppc/IOHIDFamily-172.8/IOHIDFamily/Cosmo_USB2ADB.c>
    8.30 -   - experimentation on various ADB and USB ISO keyboards and one ADB ANSI keyboard
    8.31 -*/
    8.32 -/* *INDENT-OFF* */
    8.33 -static SDL_scancode scancode_table[128] = {
    8.34 -    /*   0 */   SDL_SCANCODE_A,
    8.35 -    /*   1 */   SDL_SCANCODE_S,
    8.36 -    /*   2 */   SDL_SCANCODE_D,
    8.37 -    /*   3 */   SDL_SCANCODE_F,
    8.38 -    /*   4 */   SDL_SCANCODE_H,
    8.39 -    /*   5 */   SDL_SCANCODE_G,
    8.40 -    /*   6 */   SDL_SCANCODE_Z,
    8.41 -    /*   7 */   SDL_SCANCODE_X,
    8.42 -    /*   8 */   SDL_SCANCODE_C,
    8.43 -    /*   9 */   SDL_SCANCODE_V,
    8.44 -    /*  10 */   SDL_SCANCODE_NONUSBACKSLASH, /* SDL_SCANCODE_NONUSBACKSLASH on ANSI and JIS keyboards (if this key would exist there), SDL_SCANCODE_GRAVE on ISO. (The USB keyboard driver actually translates these usage codes to different virtual key codes depending on whether the keyboard is ISO/ANSI/JIS. That's why you have to help it identify the keyboard type when you plug in a PC USB keyboard. It's a historical thing - ADB keyboards are wired this way.) */
    8.45 -    /*  11 */   SDL_SCANCODE_B,
    8.46 -    /*  12 */   SDL_SCANCODE_Q,
    8.47 -    /*  13 */   SDL_SCANCODE_W,
    8.48 -    /*  14 */   SDL_SCANCODE_E,
    8.49 -    /*  15 */   SDL_SCANCODE_R,
    8.50 -    /*  16 */   SDL_SCANCODE_Y,
    8.51 -    /*  17 */   SDL_SCANCODE_T,
    8.52 -    /*  18 */   SDL_SCANCODE_1,
    8.53 -    /*  19 */   SDL_SCANCODE_2,
    8.54 -    /*  20 */   SDL_SCANCODE_3,
    8.55 -    /*  21 */   SDL_SCANCODE_4,
    8.56 -    /*  22 */   SDL_SCANCODE_6,
    8.57 -    /*  23 */   SDL_SCANCODE_5,
    8.58 -    /*  24 */   SDL_SCANCODE_EQUALS,
    8.59 -    /*  25 */   SDL_SCANCODE_9,
    8.60 -    /*  26 */   SDL_SCANCODE_7,
    8.61 -    /*  27 */   SDL_SCANCODE_HYPHENMINUS,
    8.62 -    /*  28 */   SDL_SCANCODE_8,
    8.63 -    /*  29 */   SDL_SCANCODE_0,
    8.64 -    /*  30 */   SDL_SCANCODE_RIGHTBRACKET,
    8.65 -    /*  31 */   SDL_SCANCODE_O,
    8.66 -    /*  32 */   SDL_SCANCODE_U,
    8.67 -    /*  33 */   SDL_SCANCODE_LEFTBRACKET,
    8.68 -    /*  34 */   SDL_SCANCODE_I,
    8.69 -    /*  35 */   SDL_SCANCODE_P,
    8.70 -    /*  36 */   SDL_SCANCODE_RETURN,
    8.71 -    /*  37 */   SDL_SCANCODE_L,
    8.72 -    /*  38 */   SDL_SCANCODE_J,
    8.73 -    /*  39 */   SDL_SCANCODE_APOSTROPHE,
    8.74 -    /*  40 */   SDL_SCANCODE_K,
    8.75 -    /*  41 */   SDL_SCANCODE_SEMICOLON,
    8.76 -    /*  42 */   SDL_SCANCODE_BACKSLASH,
    8.77 -    /*  43 */   SDL_SCANCODE_COMMA,
    8.78 -    /*  44 */   SDL_SCANCODE_SLASH,
    8.79 -    /*  45 */   SDL_SCANCODE_N,
    8.80 -    /*  46 */   SDL_SCANCODE_M,
    8.81 -    /*  47 */   SDL_SCANCODE_PERIOD,
    8.82 -    /*  48 */   SDL_SCANCODE_TAB,
    8.83 -    /*  49 */   SDL_SCANCODE_SPACE,
    8.84 -    /*  50 */   SDL_SCANCODE_GRAVE, /* SDL_SCANCODE_GRAVE on ANSI and JIS keyboards, SDL_SCANCODE_NONUSBACKSLASH on ISO (see comment about virtual key code 10 above) */
    8.85 -    /*  51 */   SDL_SCANCODE_BACKSPACE,
    8.86 -    /*  52 */   SDL_SCANCODE_KP_ENTER, /* keyboard enter on portables */
    8.87 -    /*  53 */   SDL_SCANCODE_ESCAPE,
    8.88 -    /*  54 */   SDL_SCANCODE_RGUI,
    8.89 -    /*  55 */   SDL_SCANCODE_LGUI,
    8.90 -    /*  56 */   SDL_SCANCODE_LSHIFT,
    8.91 -    /*  57 */   SDL_SCANCODE_CAPSLOCK,
    8.92 -    /*  58 */   SDL_SCANCODE_LALT,
    8.93 -    /*  59 */   SDL_SCANCODE_LCTRL,
    8.94 -    /*  60 */   SDL_SCANCODE_RSHIFT,
    8.95 -    /*  61 */   SDL_SCANCODE_RALT,
    8.96 -    /*  62 */   SDL_SCANCODE_RCTRL,
    8.97 -    /*  63 */   SDL_SCANCODE_UNKNOWN, /* fn on portables, acts as a hardware-level modifier already, so we don't generate events for it */
    8.98 -    /*  64 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
    8.99 -    /*  65 */   SDL_SCANCODE_KP_PERIOD,
   8.100 -    /*  66 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
   8.101 -    /*  67 */   SDL_SCANCODE_KP_MULTIPLY,
   8.102 -    /*  68 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
   8.103 -    /*  69 */   SDL_SCANCODE_KP_PLUS,
   8.104 -    /*  70 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
   8.105 -    /*  71 */   SDL_SCANCODE_NUMLOCKCLEAR,
   8.106 -    /*  72 */   SDL_SCANCODE_VOLUMEUP,
   8.107 -    /*  73 */   SDL_SCANCODE_VOLUMEDOWN,
   8.108 -    /*  74 */   SDL_SCANCODE_MUTE,
   8.109 -    /*  75 */   SDL_SCANCODE_KP_DIVIDE,
   8.110 -    /*  76 */   SDL_SCANCODE_KP_ENTER, /* keypad enter on external keyboards, fn-return on portables */
   8.111 -    /*  77 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
   8.112 -    /*  78 */   SDL_SCANCODE_KP_MINUS,
   8.113 -    /*  79 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
   8.114 -    /*  80 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
   8.115 -    /*  81 */   SDL_SCANCODE_KP_EQUALS,
   8.116 -    /*  82 */   SDL_SCANCODE_KP_0,
   8.117 -    /*  83 */   SDL_SCANCODE_KP_1,
   8.118 -    /*  84 */   SDL_SCANCODE_KP_2,
   8.119 -    /*  85 */   SDL_SCANCODE_KP_3,
   8.120 -    /*  86 */   SDL_SCANCODE_KP_4,
   8.121 -    /*  87 */   SDL_SCANCODE_KP_5,
   8.122 -    /*  88 */   SDL_SCANCODE_KP_6,
   8.123 -    /*  89 */   SDL_SCANCODE_KP_7,
   8.124 -    /*  90 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
   8.125 -    /*  91 */   SDL_SCANCODE_KP_8,
   8.126 -    /*  92 */   SDL_SCANCODE_KP_9,
   8.127 -    /*  93 */   SDL_SCANCODE_INTERNATIONAL3, /* Cosmo_USB2ADB.c says "Yen (JIS)" */
   8.128 -    /*  94 */   SDL_SCANCODE_INTERNATIONAL1, /* Cosmo_USB2ADB.c says "Ro (JIS)" */
   8.129 -    /*  95 */   SDL_SCANCODE_KP_COMMA, /* Cosmo_USB2ADB.c says ", JIS only" */
   8.130 -    /*  96 */   SDL_SCANCODE_F5,
   8.131 -    /*  97 */   SDL_SCANCODE_F6,
   8.132 -    /*  98 */   SDL_SCANCODE_F7,
   8.133 -    /*  99 */   SDL_SCANCODE_F3,
   8.134 -    /* 100 */   SDL_SCANCODE_F8,
   8.135 -    /* 101 */   SDL_SCANCODE_F9,
   8.136 -    /* 102 */   SDL_SCANCODE_LANG2, /* Cosmo_USB2ADB.c says "Eisu" */
   8.137 -    /* 103 */   SDL_SCANCODE_F11,
   8.138 -    /* 104 */   SDL_SCANCODE_LANG1, /* Cosmo_USB2ADB.c says "Kana" */
   8.139 -    /* 105 */   SDL_SCANCODE_PRINTSCREEN, /* On ADB keyboards, this key is labeled "F13/print screen". Problem: USB has different usage codes for these two functions. On Apple USB keyboards, the key is labeled "F13" and sends the F13 usage code (SDL_SCANCODE_F13). I decided to use SDL_SCANCODE_PRINTSCREEN here nevertheless since SDL applications are more likely to assume the presence of a print screen key than an F13 key. */
   8.140 -    /* 106 */   SDL_SCANCODE_F16,
   8.141 -    /* 107 */   SDL_SCANCODE_SCROLLLOCK, /* F14/scroll lock, see comment about F13/print screen above */
   8.142 -    /* 108 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
   8.143 -    /* 109 */   SDL_SCANCODE_F10,
   8.144 -    /* 110 */   SDL_SCANCODE_APPLICATION, /* windows contextual menu key, fn-enter on portables */
   8.145 -    /* 111 */   SDL_SCANCODE_F12,
   8.146 -    /* 112 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
   8.147 -    /* 113 */   SDL_SCANCODE_PAUSE, /* F15/pause, see comment about F13/print screen above */
   8.148 -    /* 114 */   SDL_SCANCODE_INSERT, /* the key is actually labeled "help" on Apple keyboards, and works as such in Mac OS, but it sends the "insert" usage code even on Apple USB keyboards */
   8.149 -    /* 115 */   SDL_SCANCODE_HOME,
   8.150 -    /* 116 */   SDL_SCANCODE_PAGEUP,
   8.151 -    /* 117 */   SDL_SCANCODE_DELETE,
   8.152 -    /* 118 */   SDL_SCANCODE_F4,
   8.153 -    /* 119 */   SDL_SCANCODE_END,
   8.154 -    /* 120 */   SDL_SCANCODE_F2,
   8.155 -    /* 121 */   SDL_SCANCODE_PAGEDOWN,
   8.156 -    /* 122 */   SDL_SCANCODE_F1,
   8.157 -    /* 123 */   SDL_SCANCODE_LEFT,
   8.158 -    /* 124 */   SDL_SCANCODE_RIGHT,
   8.159 -    /* 125 */   SDL_SCANCODE_DOWN,
   8.160 -    /* 126 */   SDL_SCANCODE_UP,
   8.161 -    /* 127 */   SDL_SCANCODE_POWER
   8.162 -};
   8.163 -/* *INDENT-ON* */
     9.1 --- a/src/video/x11/SDL_x11events.c	Tue Feb 05 07:30:50 2008 +0000
     9.2 +++ b/src/video/x11/SDL_x11events.c	Thu Feb 07 15:31:09 2008 +0000
     9.3 @@ -140,6 +140,15 @@
     9.4          }
     9.5          break;
     9.6  
     9.7 +        /* Has the keyboard layout changed? */
     9.8 +    case MappingNotify:{
     9.9 +#ifdef DEBUG_XEVENTS
    9.10 +            printf("MappingNotify!\n");
    9.11 +#endif
    9.12 +            X11_UpdateKeymap(this);
    9.13 +        }
    9.14 +        break;
    9.15 +
    9.16          /* Mouse motion? */
    9.17      case MotionNotify:{
    9.18  #ifdef DEBUG_MOTION
    9.19 @@ -174,23 +183,25 @@
    9.20  #ifdef DEBUG_XEVENTS
    9.21              printf("KeyPress (X11 keycode = 0x%X)\n", xevent.xkey.keycode);
    9.22  #endif
    9.23 -            SDLKey physicalKey = videodata->keyCodeToSDLKTable[keycode];
    9.24              SDL_SendKeyboardKey(videodata->keyboard, SDL_PRESSED,
    9.25 -                                (Uint8) keycode, physicalKey);
    9.26 +                                videodata->key_layout[keycode]);
    9.27  #if 1
    9.28 -            if (physicalKey == SDLK_UNKNOWN) {
    9.29 +            if (videodata->key_layout[keycode] == SDLK_UNKNOWN) {
    9.30 +                int min_keycode, max_keycode;
    9.31 +                XDisplayKeycodes(videodata->display, &min_keycode,
    9.32 +                                 &max_keycode);
    9.33 +                keysym = XKeycodeToKeysym(videodata->display, keycode, 0);
    9.34                  fprintf(stderr,
    9.35 -                        "The key you just pressed is not recognized by SDL. To help get this fixed, report this to the SDL mailing list <sdl@libsdl.org> or to Christian Walther <cwalther@gmx.ch>. X11 KeyCode is %d, X11 KeySym 0x%X.\n",
    9.36 -                        (int) keycode,
    9.37 -                        (unsigned int) XKeycodeToKeysym(videodata->display,
    9.38 -                                                        keycode, 0));
    9.39 +                        "The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL mailing list <sdl@libsdl.org> X11 KeyCode %d (%d), X11 KeySym 0x%X (%s).\n",
    9.40 +                        keycode, keycode - min_keycode, keysym,
    9.41 +                        XKeysymToString(keysym));
    9.42              }
    9.43  #endif
    9.44 -            /* works for Latin-1 */
    9.45 -            SDL_memset(&text[0], 0, SDL_TEXTINPUTEVENT_TEXT_SIZE);
    9.46 -            /* Xutf8LookupString() */
    9.47 +            /* Xutf8LookupString(), works for Latin-1 */
    9.48 +            SDL_zero(text);
    9.49              XLookupString(&xevent, text, sizeof(text), &keysym, NULL);
    9.50 -            if (0 != SDL_strlen(text)) {
    9.51 +            if (*text) {
    9.52 +                printf("Sending text event %s\n", text);
    9.53                  SDL_SendKeyboardText(videodata->keyboard, text);
    9.54              }
    9.55          }
    9.56 @@ -204,8 +215,7 @@
    9.57              printf("KeyRelease (X11 keycode = 0x%X)\n", xevent.xkey.keycode);
    9.58  #endif
    9.59              SDL_SendKeyboardKey(videodata->keyboard, SDL_RELEASED,
    9.60 -                                (Uint8) keycode,
    9.61 -                                videodata->keyCodeToSDLKTable[keycode]);
    9.62 +                                videodata->key_layout[keycode]);
    9.63          }
    9.64          break;
    9.65  
    10.1 --- a/src/video/x11/SDL_x11keyboard.c	Tue Feb 05 07:30:50 2008 +0000
    10.2 +++ b/src/video/x11/SDL_x11keyboard.c	Thu Feb 07 15:31:09 2008 +0000
    10.3 @@ -24,1007 +24,376 @@
    10.4  #include "SDL_x11video.h"
    10.5  
    10.6  #include "../../events/SDL_keyboard_c.h"
    10.7 +#include "../../events/scancodes_darwin.h"
    10.8 +#include "../../events/scancodes_xfree86.h"
    10.9  
   10.10  #include <X11/keysym.h>
   10.11  
   10.12  #include "imKStoUCS.h"
   10.13  
   10.14 -/* 
   10.15 -   KeyCode-to-SDLKey translation tables for various X servers. Which
   10.16 -   one to use is decided in X11_InitKeyboard().
   10.17 -*/
   10.18 -
   10.19 -static SDLKey macKeyCodeToSDLK[];
   10.20 -static SDLKey xorgLinuxKeyCodeToSDLK[];
   10.21 -
   10.22 -static SDLKey *keyCodeToSDLKeyTables[] = {
   10.23 -    xorgLinuxKeyCodeToSDLK,
   10.24 -    macKeyCodeToSDLK,
   10.25 -    NULL
   10.26 +static KeySym XKeySymTable[SDL_NUM_SCANCODES] = {
   10.27 +    0, 0, 0, 0,
   10.28 +    XK_a,
   10.29 +    XK_b,
   10.30 +    XK_c,
   10.31 +    XK_d,
   10.32 +    XK_e,
   10.33 +    XK_f,
   10.34 +    XK_g,
   10.35 +    XK_h,
   10.36 +    XK_i,
   10.37 +    XK_j,
   10.38 +    XK_k,
   10.39 +    XK_l,
   10.40 +    XK_m,
   10.41 +    XK_n,
   10.42 +    XK_o,
   10.43 +    XK_p,
   10.44 +    XK_q,
   10.45 +    XK_r,
   10.46 +    XK_s,
   10.47 +    XK_t,
   10.48 +    XK_u,
   10.49 +    XK_v,
   10.50 +    XK_w,
   10.51 +    XK_x,
   10.52 +    XK_y,
   10.53 +    XK_z,
   10.54 +    XK_1,
   10.55 +    XK_2,
   10.56 +    XK_3,
   10.57 +    XK_4,
   10.58 +    XK_5,
   10.59 +    XK_6,
   10.60 +    XK_7,
   10.61 +    XK_8,
   10.62 +    XK_9,
   10.63 +    XK_0,
   10.64 +    XK_Return,
   10.65 +    XK_Escape,
   10.66 +    XK_BackSpace,
   10.67 +    XK_Tab,
   10.68 +    XK_space,
   10.69 +    XK_minus,
   10.70 +    XK_equal,
   10.71 +    XK_bracketleft,
   10.72 +    XK_bracketright,
   10.73 +    XK_backslash,
   10.74 +    0,                          /* SDL_SCANCODE_NONUSHASH ? */
   10.75 +    XK_semicolon,
   10.76 +    XK_apostrophe,
   10.77 +    XK_grave,
   10.78 +    XK_comma,
   10.79 +    XK_period,
   10.80 +    XK_slash,
   10.81 +    XK_Caps_Lock,
   10.82 +    XK_F1,
   10.83 +    XK_F2,
   10.84 +    XK_F3,
   10.85 +    XK_F4,
   10.86 +    XK_F5,
   10.87 +    XK_F6,
   10.88 +    XK_F7,
   10.89 +    XK_F8,
   10.90 +    XK_F9,
   10.91 +    XK_F10,
   10.92 +    XK_F11,
   10.93 +    XK_F12,
   10.94 +    XK_Print,
   10.95 +    XK_Scroll_Lock,
   10.96 +    XK_Pause,
   10.97 +    XK_Insert,
   10.98 +    XK_Home,
   10.99 +    XK_Prior,
  10.100 +    XK_Delete,
  10.101 +    XK_End,
  10.102 +    XK_Next,
  10.103 +    XK_Right,
  10.104 +    XK_Left,
  10.105 +    XK_Down,
  10.106 +    XK_Up,
  10.107 +    XK_Num_Lock,
  10.108 +    XK_KP_Divide,
  10.109 +    XK_KP_Multiply,
  10.110 +    XK_KP_Subtract,
  10.111 +    XK_KP_Add,
  10.112 +    XK_KP_Enter,
  10.113 +    XK_KP_1,
  10.114 +    XK_KP_2,
  10.115 +    XK_KP_3,
  10.116 +    XK_KP_4,
  10.117 +    XK_KP_5,
  10.118 +    XK_KP_6,
  10.119 +    XK_KP_7,
  10.120 +    XK_KP_8,
  10.121 +    XK_KP_9,
  10.122 +    XK_KP_0,
  10.123 +    XK_KP_Decimal,
  10.124 +    0,                          /* SDL_SCANCODE_NONUSBACKSLASH ? */
  10.125 +    XK_Hyper_R,
  10.126 +    0,                          /* SDL_SCANCODE_POWER ? */
  10.127 +    XK_KP_Equal,
  10.128 +    XK_F13,
  10.129 +    XK_F14,
  10.130 +    XK_F15,
  10.131 +    XK_F16,
  10.132 +    XK_F17,
  10.133 +    XK_F18,
  10.134 +    XK_F19,
  10.135 +    XK_F20,
  10.136 +    XK_F21,
  10.137 +    XK_F22,
  10.138 +    XK_F23,
  10.139 +    XK_F24,
  10.140 +    XK_Execute,
  10.141 +    XK_Help,
  10.142 +    XK_Menu,
  10.143 +    XK_Select,
  10.144 +    XK_Cancel,
  10.145 +    XK_Redo,
  10.146 +    XK_Undo,
  10.147 +    0,                          /* SDL_SCANCODE_CUT ? */
  10.148 +    0,                          /* SDL_SCANCODE_COPY ? */
  10.149 +    0,                          /* SDL_SCANCODE_PASTE ? */
  10.150 +    XK_Find,
  10.151 +    0,                          /* SDL_SCANCODE_MUTE ? */
  10.152 +    0,                          /* SDL_SCANCODE_VOLUMEUP ? */
  10.153 +    0,                          /* SDL_SCANCODE_VOLUMEDOWN ? */
  10.154 +    0, 0, 0,
  10.155 +    XK_KP_Separator,
  10.156 +    0,                          /* SDL_SCANCODE_KP_EQUALSAS400 ? */
  10.157 +    0,                          /* SDL_SCANCODE_INTERNATIONAL1 ? */
  10.158 +    0,                          /* SDL_SCANCODE_INTERNATIONAL2 ? */
  10.159 +    0,                          /* SDL_SCANCODE_INTERNATIONAL3 ? */
  10.160 +    0,                          /* SDL_SCANCODE_INTERNATIONAL4 ? */
  10.161 +    0,                          /* SDL_SCANCODE_INTERNATIONAL5 ? */
  10.162 +    0,                          /* SDL_SCANCODE_INTERNATIONAL6 ? */
  10.163 +    0,                          /* SDL_SCANCODE_INTERNATIONAL7 ? */
  10.164 +    0,                          /* SDL_SCANCODE_INTERNATIONAL8 ? */
  10.165 +    0,                          /* SDL_SCANCODE_INTERNATIONAL9 ? */
  10.166 +    0,                          /* SDL_SCANCODE_LANG1 ? */
  10.167 +    0,                          /* SDL_SCANCODE_LANG2 ? */
  10.168 +    0,                          /* SDL_SCANCODE_LANG3 ? */
  10.169 +    0,                          /* SDL_SCANCODE_LANG4 ? */
  10.170 +    0,                          /* SDL_SCANCODE_LANG5 ? */
  10.171 +    0,                          /* SDL_SCANCODE_LANG6 ? */
  10.172 +    0,                          /* SDL_SCANCODE_LANG7 ? */
  10.173 +    0,                          /* SDL_SCANCODE_LANG8 ? */
  10.174 +    0,                          /* SDL_SCANCODE_LANG9 ? */
  10.175 +    0,                          /* SDL_SCANCODE_ALTERASE ? */
  10.176 +    XK_Sys_Req,
  10.177 +    0,                          /* SDL_SCANCODE_CANCEL ? - XK_Cancel was used above... */
  10.178 +    0,                          /* SDL_SCANCODE_CLEAR ? */
  10.179 +    0,                          /* SDL_SCANCODE_PRIOR ? - XK_Prior was used above... */
  10.180 +    0,                          /* SDL_SCANCODE_RETURN2 ? */
  10.181 +    0,                          /* SDL_SCANCODE_SEPARATOR ? */
  10.182 +    0,                          /* SDL_SCANCODE_OUT ? */
  10.183 +    0,                          /* SDL_SCANCODE_OPER ? */
  10.184 +    0,                          /* SDL_SCANCODE_CLEARAGAIN ? */
  10.185 +    0,                          /* SDL_SCANCODE_CRSEL ? */
  10.186 +    0,                          /* SDL_SCANCODE_EXSEL ? */
  10.187 +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  10.188 +    0,                          /* SDL_SCANCODE_KP_00 ? */
  10.189 +    0,                          /* SDL_SCANCODE_KP_000 ? */
  10.190 +    0,                          /* SDL_SCANCODE_THOUSANDSSEPARATOR ? */
  10.191 +    0,                          /* SDL_SCANCODE_DECIMALSEPARATOR ? */
  10.192 +    0,                          /* SDL_SCANCODE_CURRENCYUNIT ? */
  10.193 +    0,                          /* SDL_SCANCODE_CURRENCYSUBUNIT ? */
  10.194 +    0,                          /* SDL_SCANCODE_KP_LEFTPAREN ? */
  10.195 +    0,                          /* SDL_SCANCODE_KP_RIGHTPAREN ? */
  10.196 +    0,                          /* SDL_SCANCODE_KP_LEFTBRACE ? */
  10.197 +    0,                          /* SDL_SCANCODE_KP_RIGHTBRACE ? */
  10.198 +    0,                          /* SDL_SCANCODE_KP_TAB ? */
  10.199 +    0,                          /* SDL_SCANCODE_KP_BACKSPACE ? */
  10.200 +    0,                          /* SDL_SCANCODE_KP_A ? */
  10.201 +    0,                          /* SDL_SCANCODE_KP_B ? */
  10.202 +    0,                          /* SDL_SCANCODE_KP_C ? */
  10.203 +    0,                          /* SDL_SCANCODE_KP_D ? */
  10.204 +    0,                          /* SDL_SCANCODE_KP_E ? */
  10.205 +    0,                          /* SDL_SCANCODE_KP_F ? */
  10.206 +    0,                          /* SDL_SCANCODE_KP_XOR ? */
  10.207 +    0,                          /* SDL_SCANCODE_KP_POWER ? */
  10.208 +    0,                          /* SDL_SCANCODE_KP_PERCENT ? */
  10.209 +    0,                          /* SDL_SCANCODE_KP_LESS ? */
  10.210 +    0,                          /* SDL_SCANCODE_KP_GREATER ? */
  10.211 +    0,                          /* SDL_SCANCODE_KP_AMPERSAND ? */
  10.212 +    0,                          /* SDL_SCANCODE_KP_DBLAMPERSAND ? */
  10.213 +    0,                          /* SDL_SCANCODE_KP_VERTICALBAR ? */
  10.214 +    0,                          /* SDL_SCANCODE_KP_DBLVERTICALBAR ? */
  10.215 +    0,                          /* SDL_SCANCODE_KP_COLON ? */
  10.216 +    0,                          /* SDL_SCANCODE_KP_HASH ? */
  10.217 +    0,                          /* SDL_SCANCODE_KP_SPACE ? */
  10.218 +    0,                          /* SDL_SCANCODE_KP_AT ? */
  10.219 +    0,                          /* SDL_SCANCODE_KP_EXCLAM ? */
  10.220 +    0,                          /* SDL_SCANCODE_KP_MEMSTORE ? */
  10.221 +    0,                          /* SDL_SCANCODE_KP_MEMRECALL ? */
  10.222 +    0,                          /* SDL_SCANCODE_KP_MEMCLEAR ? */
  10.223 +    0,                          /* SDL_SCANCODE_KP_MEMADD ? */
  10.224 +    0,                          /* SDL_SCANCODE_KP_MEMSUBTRACT ? */
  10.225 +    0,                          /* SDL_SCANCODE_KP_MEMMULTIPLY ? */
  10.226 +    0,                          /* SDL_SCANCODE_KP_MEMDIVIDE ? */
  10.227 +    0,                          /* SDL_SCANCODE_KP_PLUSMINUS ? */
  10.228 +    0,                          /* SDL_SCANCODE_KP_CLEAR ? */
  10.229 +    0,                          /* SDL_SCANCODE_KP_CLEARENTRY ? */
  10.230 +    0,                          /* SDL_SCANCODE_KP_BINARY ? */
  10.231 +    0,                          /* SDL_SCANCODE_KP_OCTAL ? */
  10.232 +    0,                          /* SDL_SCANCODE_KP_DECIMAL ? */
  10.233 +    0,                          /* SDL_SCANCODE_KP_HEXADECIMAL ? */
  10.234 +    0, 0,
  10.235 +    XK_Control_L,
  10.236 +    XK_Shift_L,
  10.237 +    XK_Alt_L,
  10.238 +    XK_Meta_L,
  10.239 +    XK_Control_R,
  10.240 +    XK_Shift_R,
  10.241 +    XK_Alt_R,
  10.242 +    XK_Meta_R,
  10.243 +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  10.244 +    XK_Mode_switch /*XK_ISO_Level3_Shift */ ,
  10.245 +    0,                          /* SDL_SCANCODE_AUDIONEXT ? */
  10.246 +    0,                          /* SDL_SCANCODE_AUDIOPREV ? */
  10.247 +    0,                          /* SDL_SCANCODE_AUDIOSTOP ? */
  10.248 +    0,                          /* SDL_SCANCODE_AUDIOPLAY ? */
  10.249 +    0,                          /* SDL_SCANCODE_AUDIOMUTE ? */
  10.250 +    0,                          /* SDL_SCANCODE_MEDIASELECT ? */
  10.251 +    0,                          /* SDL_SCANCODE_WWW ? */
  10.252 +    0,                          /* SDL_SCANCODE_MAIL ? */
  10.253 +    0,                          /* SDL_SCANCODE_CALCULATOR ? */
  10.254 +    0,                          /* SDL_SCANCODE_COMPUTER ? */
  10.255 +    0,                          /* SDL_SCANCODE_AC_SEARCH ? */
  10.256 +    0,                          /* SDL_SCANCODE_AC_HOME ? */
  10.257 +    0,                          /* SDL_SCANCODE_AC_BACK ? */
  10.258 +    0,                          /* SDL_SCANCODE_AC_FORWARD ? */
  10.259 +    0,                          /* SDL_SCANCODE_AC_STOP ? */
  10.260 +    0,                          /* SDL_SCANCODE_AC_REFRESH ? */
  10.261 +    0,                          /* SDL_SCANCODE_AC_BOOKMARKS ? */
  10.262 +    0,                          /* SDL_SCANCODE_BRIGHTNESSDOWN ? */
  10.263 +    0,                          /* SDL_SCANCODE_BRIGHTNESSUP ? */
  10.264 +    0,                          /* SDL_SCANCODE_DISPLAYSWITCH ? */
  10.265 +    0,                          /* SDL_SCANCODE_KBDILLUMTOGGLE ? */
  10.266 +    0,                          /* SDL_SCANCODE_KBDILLUMDOWN ? */
  10.267 +    0,                          /* SDL_SCANCODE_KBDILLUMUP ? */
  10.268 +    0,                          /* SDL_SCANCODE_EJECT ? */
  10.269 +    0,                          /* SDL_SCANCODE_SLEEP ? */
  10.270  };
  10.271  
  10.272 -/* *INDENT-OFF* */
  10.273 -
  10.274 -/* These are just Mac virtual key codes + 8 (see SDL/src/video/cocoa/
  10.275 -   SDL_cocoakeys.h for more info). Observed to work with Apple X11 on
  10.276 -   Mac OS X 10.4. May also work on older Linux distributions on Mac
  10.277 -   hardware.
  10.278 -*/
  10.279 -
  10.280 -#define KeyCodeTableSize (256)
  10.281 -static SDLKey macKeyCodeToSDLK[KeyCodeTableSize] = 
  10.282 -{
  10.283 -    /*   0 */   SDLK_UNKNOWN,
  10.284 -    /*   1 */   SDLK_UNKNOWN,
  10.285 -    /*   2 */   SDLK_UNKNOWN,
  10.286 -    /*   3 */   SDLK_UNKNOWN,
  10.287 -    /*   4 */   SDLK_UNKNOWN,
  10.288 -    /*   5 */   SDLK_UNKNOWN,
  10.289 -    /*   6 */   SDLK_UNKNOWN,
  10.290 -    /*   7 */   SDLK_UNKNOWN,
  10.291 -    /*   8 */   SDLK_A,
  10.292 -    /*   9 */   SDLK_S,
  10.293 -    /*  10 */   SDLK_D,
  10.294 -    /*  11 */   SDLK_F,
  10.295 -    /*  12 */   SDLK_H,
  10.296 -    /*  13 */   SDLK_G,
  10.297 -    /*  14 */   SDLK_Z,
  10.298 -    /*  15 */   SDLK_X,
  10.299 -    /*  16 */   SDLK_C,
  10.300 -    /*  17 */   SDLK_V,
  10.301 -    /*  18 */   SDLK_GRAVE,
  10.302 -    /*  19 */   SDLK_B,
  10.303 -    /*  20 */   SDLK_Q,
  10.304 -    /*  21 */   SDLK_W,
  10.305 -    /*  22 */   SDLK_E,
  10.306 -    /*  23 */   SDLK_R,
  10.307 -    /*  24 */   SDLK_Y,
  10.308 -    /*  25 */   SDLK_T,
  10.309 -    /*  26 */   SDLK_1,
  10.310 -    /*  27 */   SDLK_2,
  10.311 -    /*  28 */   SDLK_3,
  10.312 -    /*  29 */   SDLK_4,
  10.313 -    /*  30 */   SDLK_6,
  10.314 -    /*  31 */   SDLK_5,
  10.315 -    /*  32 */   SDLK_EQUALS,
  10.316 -    /*  33 */   SDLK_9,
  10.317 -    /*  34 */   SDLK_7,
  10.318 -    /*  35 */   SDLK_HYPHENMINUS,
  10.319 -    /*  36 */   SDLK_8,
  10.320 -    /*  37 */   SDLK_0,
  10.321 -    /*  38 */   SDLK_RIGHTBRACKET,
  10.322 -    /*  39 */   SDLK_O,
  10.323 -    /*  40 */   SDLK_U,
  10.324 -    /*  41 */   SDLK_LEFTBRACKET,
  10.325 -    /*  42 */   SDLK_I,
  10.326 -    /*  43 */   SDLK_P,
  10.327 -    /*  44 */   SDLK_RETURN,
  10.328 -    /*  45 */   SDLK_L,
  10.329 -    /*  46 */   SDLK_J,
  10.330 -    /*  47 */   SDLK_APOSTROPHE,
  10.331 -    /*  48 */   SDLK_K,
  10.332 -    /*  49 */   SDLK_SEMICOLON,
  10.333 -    /*  50 */   SDLK_BACKSLASH,
  10.334 -    /*  51 */   SDLK_COMMA,
  10.335 -    /*  52 */   SDLK_SLASH,
  10.336 -    /*  53 */   SDLK_N,
  10.337 -    /*  54 */   SDLK_M,
  10.338 -    /*  55 */   SDLK_PERIOD,
  10.339 -    /*  56 */   SDLK_TAB,
  10.340 -    /*  57 */   SDLK_SPACE,
  10.341 -    /*  58 */   SDLK_NONUSBACKSLASH,
  10.342 -    /*  59 */   SDLK_BACKSPACE,
  10.343 -    /*  60 */   SDLK_KP_ENTER,
  10.344 -    /*  61 */   SDLK_ESCAPE,
  10.345 -    /*  62 */   SDLK_RMETA,
  10.346 -    /*  63 */   SDLK_LMETA,
  10.347 -    /*  64 */   SDLK_LSHIFT,
  10.348 -    /*  65 */   SDLK_CAPSLOCK,
  10.349 -    /*  66 */   SDLK_LALT,
  10.350 -    /*  67 */   SDLK_LCTRL,
  10.351 -    /*  68 */   SDLK_RSHIFT,
  10.352 -    /*  69 */   SDLK_RALT,
  10.353 -    /*  70 */   SDLK_RCTRL,
  10.354 -    /*  71 */   SDLK_NONE,
  10.355 -    /*  72 */   SDLK_UNKNOWN,
  10.356 -    /*  73 */   SDLK_KP_PERIOD,
  10.357 -    /*  74 */   SDLK_UNKNOWN,
  10.358 -    /*  75 */   SDLK_KP_MULTIPLY,
  10.359 -    /*  76 */   SDLK_UNKNOWN,
  10.360 -    /*  77 */   SDLK_KP_PLUS,
  10.361 -    /*  78 */   SDLK_UNKNOWN,
  10.362 -    /*  79 */   SDLK_KP_NUMLOCKCLEAR,
  10.363 -    /*  80 */   SDLK_VOLUMEUP,
  10.364 -    /*  81 */   SDLK_VOLUMEDOWN,
  10.365 -    /*  82 */   SDLK_MUTE,
  10.366 -    /*  83 */   SDLK_KP_DIVIDE,
  10.367 -    /*  84 */   SDLK_KP_ENTER,
  10.368 -    /*  85 */   SDLK_UNKNOWN,
  10.369 -    /*  86 */   SDLK_KP_MINUS,
  10.370 -    /*  87 */   SDLK_UNKNOWN,
  10.371 -    /*  88 */   SDLK_UNKNOWN,
  10.372 -    /*  89 */   SDLK_KP_EQUALS,
  10.373 -    /*  90 */   SDLK_KP_0,
  10.374 -    /*  91 */   SDLK_KP_1,
  10.375 -    /*  92 */   SDLK_KP_2,
  10.376 -    /*  93 */   SDLK_KP_3,
  10.377 -    /*  94 */   SDLK_KP_4,
  10.378 -    /*  95 */   SDLK_KP_5,
  10.379 -    /*  96 */   SDLK_KP_6,
  10.380 -    /*  97 */   SDLK_KP_7,
  10.381 -    /*  98 */   SDLK_UNKNOWN,
  10.382 -    /*  99 */   SDLK_KP_8,
  10.383 -    /* 100 */   SDLK_KP_9,
  10.384 -    /* 101 */   SDLK_INTERNATIONAL3,
  10.385 -    /* 102 */   SDLK_INTERNATIONAL1,
  10.386 -    /* 103 */   SDLK_KP_COMMA,
  10.387 -    /* 104 */   SDLK_F5,
  10.388 -    /* 105 */   SDLK_F6,
  10.389 -    /* 106 */   SDLK_F7,
  10.390 -    /* 107 */   SDLK_F3,
  10.391 -    /* 108 */   SDLK_F8,
  10.392 -    /* 109 */   SDLK_F9,
  10.393 -    /* 110 */   SDLK_LANG2,
  10.394 -    /* 111 */   SDLK_F11,
  10.395 -    /* 112 */   SDLK_LANG1,
  10.396 -    /* 113 */   SDLK_PRINTSCREEN,
  10.397 -    /* 114 */   SDLK_F16,
  10.398 -    /* 115 */   SDLK_SCROLLLOCK,
  10.399 -    /* 116 */   SDLK_UNKNOWN,
  10.400 -    /* 117 */   SDLK_F10,
  10.401 -    /* 118 */   SDLK_APPLICATION,
  10.402 -    /* 119 */   SDLK_F12,
  10.403 -    /* 120 */   SDLK_UNKNOWN,
  10.404 -    /* 121 */   SDLK_PAUSE,
  10.405 -    /* 122 */   SDLK_INSERT,
  10.406 -    /* 123 */   SDLK_HOME,
  10.407 -    /* 124 */   SDLK_PAGEUP,
  10.408 -    /* 125 */   SDLK_DELETE,
  10.409 -    /* 126 */   SDLK_F4,
  10.410 -    /* 127 */   SDLK_END,
  10.411 -    /* 128 */   SDLK_F2,
  10.412 -    /* 129 */   SDLK_PAGEDOWN,
  10.413 -    /* 130 */   SDLK_F1,
  10.414 -    /* 131 */   SDLK_LEFT,
  10.415 -    /* 132 */   SDLK_RIGHT,
  10.416 -    /* 133 */   SDLK_DOWN,
  10.417 -    /* 134 */   SDLK_UP,
  10.418 -    /* 135 */   SDLK_POWER,
  10.419 -    /* 136 */   SDLK_UNKNOWN, /* codes higher than 135 shouldn't occur as Mac virtual keycodes only go to 127 */
  10.420 -    /* 137 */   SDLK_UNKNOWN,
  10.421 -    /* 138 */   SDLK_UNKNOWN,
  10.422 -    /* 139 */   SDLK_UNKNOWN,
  10.423 -    /* 140 */   SDLK_UNKNOWN,
  10.424 -    /* 141 */   SDLK_UNKNOWN,
  10.425 -    /* 142 */   SDLK_UNKNOWN,
  10.426 -    /* 143 */   SDLK_UNKNOWN,
  10.427 -    /* 144 */   SDLK_UNKNOWN,
  10.428 -    /* 145 */   SDLK_UNKNOWN,
  10.429 -    /* 146 */   SDLK_UNKNOWN,
  10.430 -    /* 147 */   SDLK_UNKNOWN,
  10.431 -    /* 148 */   SDLK_UNKNOWN,
  10.432 -    /* 149 */   SDLK_UNKNOWN,
  10.433 -    /* 150 */   SDLK_UNKNOWN,
  10.434 -    /* 151 */   SDLK_UNKNOWN,
  10.435 -    /* 152 */   SDLK_UNKNOWN,
  10.436 -    /* 153 */   SDLK_UNKNOWN,
  10.437 -    /* 154 */   SDLK_UNKNOWN,
  10.438 -    /* 155 */   SDLK_UNKNOWN,
  10.439 -    /* 156 */   SDLK_UNKNOWN,
  10.440 -    /* 157 */   SDLK_UNKNOWN,
  10.441 -    /* 158 */   SDLK_UNKNOWN,
  10.442 -    /* 159 */   SDLK_UNKNOWN,
  10.443 -    /* 160 */   SDLK_UNKNOWN,
  10.444 -    /* 161 */   SDLK_UNKNOWN,
  10.445 -    /* 162 */   SDLK_UNKNOWN,
  10.446 -    /* 163 */   SDLK_UNKNOWN,
  10.447 -    /* 164 */   SDLK_UNKNOWN,
  10.448 -    /* 165 */   SDLK_UNKNOWN,
  10.449 -    /* 166 */   SDLK_UNKNOWN,
  10.450 -    /* 167 */   SDLK_UNKNOWN,
  10.451 -    /* 168 */   SDLK_UNKNOWN,
  10.452 -    /* 169 */   SDLK_UNKNOWN,
  10.453 -    /* 170 */   SDLK_UNKNOWN,
  10.454 -    /* 171 */   SDLK_UNKNOWN,
  10.455 -    /* 172 */   SDLK_UNKNOWN,
  10.456 -    /* 173 */   SDLK_UNKNOWN,
  10.457 -    /* 174 */   SDLK_UNKNOWN,
  10.458 -    /* 175 */   SDLK_UNKNOWN,
  10.459 -    /* 176 */   SDLK_UNKNOWN,
  10.460 -    /* 177 */   SDLK_UNKNOWN,
  10.461 -    /* 178 */   SDLK_UNKNOWN,
  10.462 -    /* 179 */   SDLK_UNKNOWN,
  10.463 -    /* 180 */   SDLK_UNKNOWN,
  10.464 -    /* 181 */   SDLK_UNKNOWN,
  10.465 -    /* 182 */   SDLK_UNKNOWN,
  10.466 -    /* 183 */   SDLK_UNKNOWN,
  10.467 -    /* 184 */   SDLK_UNKNOWN,
  10.468 -    /* 185 */   SDLK_UNKNOWN,
  10.469 -    /* 186 */   SDLK_UNKNOWN,
  10.470 -    /* 187 */   SDLK_UNKNOWN,
  10.471 -    /* 188 */   SDLK_UNKNOWN,
  10.472 -    /* 189 */   SDLK_UNKNOWN,
  10.473 -    /* 190 */   SDLK_UNKNOWN,
  10.474 -    /* 191 */   SDLK_UNKNOWN,
  10.475 -    /* 192 */   SDLK_UNKNOWN,
  10.476 -    /* 193 */   SDLK_UNKNOWN,
  10.477 -    /* 194 */   SDLK_UNKNOWN,
  10.478 -    /* 195 */   SDLK_UNKNOWN,
  10.479 -    /* 196 */   SDLK_UNKNOWN,
  10.480 -    /* 197 */   SDLK_UNKNOWN,
  10.481 -    /* 198 */   SDLK_UNKNOWN,
  10.482 -    /* 199 */   SDLK_UNKNOWN,
  10.483 -    /* 200 */   SDLK_UNKNOWN,
  10.484 -    /* 201 */   SDLK_UNKNOWN,
  10.485 -    /* 202 */   SDLK_UNKNOWN,
  10.486 -    /* 203 */   SDLK_UNKNOWN,
  10.487 -    /* 204 */   SDLK_UNKNOWN,
  10.488 -    /* 205 */   SDLK_UNKNOWN,
  10.489 -    /* 206 */   SDLK_UNKNOWN,
  10.490 -    /* 207 */   SDLK_UNKNOWN,
  10.491 -    /* 208 */   SDLK_UNKNOWN,
  10.492 -    /* 209 */   SDLK_UNKNOWN,
  10.493 -    /* 210 */   SDLK_UNKNOWN,
  10.494 -    /* 211 */   SDLK_UNKNOWN,
  10.495 -    /* 212 */   SDLK_UNKNOWN,
  10.496 -    /* 213 */   SDLK_UNKNOWN,
  10.497 -    /* 214 */   SDLK_UNKNOWN,
  10.498 -    /* 215 */   SDLK_UNKNOWN,
  10.499 -    /* 216 */   SDLK_UNKNOWN,
  10.500 -    /* 217 */   SDLK_UNKNOWN,
  10.501 -    /* 218 */   SDLK_UNKNOWN,
  10.502 -    /* 219 */   SDLK_UNKNOWN,
  10.503 -    /* 220 */   SDLK_UNKNOWN,
  10.504 -    /* 221 */   SDLK_UNKNOWN,
  10.505 -    /* 222 */   SDLK_UNKNOWN,
  10.506 -    /* 223 */   SDLK_UNKNOWN,
  10.507 -    /* 224 */   SDLK_UNKNOWN,
  10.508 -    /* 225 */   SDLK_UNKNOWN,
  10.509 -    /* 226 */   SDLK_UNKNOWN,
  10.510 -    /* 227 */   SDLK_UNKNOWN,
  10.511 -    /* 228 */   SDLK_UNKNOWN,
  10.512 -    /* 229 */   SDLK_UNKNOWN,
  10.513 -    /* 230 */   SDLK_UNKNOWN,
  10.514 -    /* 231 */   SDLK_UNKNOWN,
  10.515 -    /* 232 */   SDLK_UNKNOWN,
  10.516 -    /* 233 */   SDLK_UNKNOWN,
  10.517 -    /* 234 */   SDLK_UNKNOWN,
  10.518 -    /* 235 */   SDLK_UNKNOWN,
  10.519 -    /* 236 */   SDLK_UNKNOWN,
  10.520 -    /* 237 */   SDLK_UNKNOWN,
  10.521 -    /* 238 */   SDLK_UNKNOWN,
  10.522 -    /* 239 */   SDLK_UNKNOWN,
  10.523 -    /* 240 */   SDLK_UNKNOWN,
  10.524 -    /* 241 */   SDLK_UNKNOWN,
  10.525 -    /* 242 */   SDLK_UNKNOWN,
  10.526 -    /* 243 */   SDLK_UNKNOWN,
  10.527 -    /* 244 */   SDLK_UNKNOWN,
  10.528 -    /* 245 */   SDLK_UNKNOWN,
  10.529 -    /* 246 */   SDLK_UNKNOWN,
  10.530 -    /* 247 */   SDLK_UNKNOWN,
  10.531 -    /* 248 */   SDLK_UNKNOWN,
  10.532 -    /* 249 */   SDLK_UNKNOWN,
  10.533 -    /* 250 */   SDLK_UNKNOWN,
  10.534 -    /* 251 */   SDLK_UNKNOWN,
  10.535 -    /* 252 */   SDLK_UNKNOWN,
  10.536 -    /* 253 */   SDLK_UNKNOWN,
  10.537 -    /* 254 */   SDLK_UNKNOWN,
  10.538 -    /* 255 */   SDLK_UNKNOWN
  10.539 -};
  10.540 -
  10.541 -/* Found mostly by experimentation with X.org on Linux (Fedora Core 4 and
  10.542 -   Ubuntu Dapper) on PC and PPC Mac hardware, some parts (especially about
  10.543 -   the "multimedia"/"internet" keys) from various sources on the web.
  10.544 -*/
  10.545 -static SDLKey xorgLinuxKeyCodeToSDLK[KeyCodeTableSize] = 
  10.546 -{
  10.547 -    /*   0 */   SDLK_UNKNOWN,
  10.548 -    /*   1 */   SDLK_UNKNOWN,
  10.549 -    /*   2 */   SDLK_UNKNOWN,
  10.550 -    /*   3 */   SDLK_UNKNOWN,
  10.551 -    /*   4 */   SDLK_UNKNOWN,
  10.552 -    /*   5 */   SDLK_UNKNOWN,
  10.553 -    /*   6 */   SDLK_UNKNOWN,
  10.554 -    /*   7 */   SDLK_UNKNOWN,
  10.555 -    /*   8 */   SDLK_UNKNOWN,
  10.556 -    /*   9 */   SDLK_ESCAPE,
  10.557 -    /*  10 */   SDLK_1,
  10.558 -    /*  11 */   SDLK_2,
  10.559 -    /*  12 */   SDLK_3,
  10.560 -    /*  13 */   SDLK_4,
  10.561 -    /*  14 */   SDLK_5,
  10.562 -    /*  15 */   SDLK_6,
  10.563 -    /*  16 */   SDLK_7,
  10.564 -    /*  17 */   SDLK_8,
  10.565 -    /*  18 */   SDLK_9,
  10.566 -    /*  19 */   SDLK_0,
  10.567 -    /*  20 */   SDLK_HYPHENMINUS,
  10.568 -    /*  21 */   SDLK_EQUALS,
  10.569 -    /*  22 */   SDLK_BACKSPACE,
  10.570 -    /*  23 */   SDLK_TAB,
  10.571 -    /*  24 */   SDLK_Q,
  10.572 -    /*  25 */   SDLK_W,
  10.573 -    /*  26 */   SDLK_E,
  10.574 -    /*  27 */   SDLK_R,
  10.575 -    /*  28 */   SDLK_T,
  10.576 -    /*  29 */   SDLK_Y,
  10.577 -    /*  30 */   SDLK_U,
  10.578 -    /*  31 */   SDLK_I,
  10.579 -    /*  32 */   SDLK_O,
  10.580 -    /*  33 */   SDLK_P,
  10.581 -    /*  34 */   SDLK_LEFTBRACKET,
  10.582 -    /*  35 */   SDLK_RIGHTBRACKET,
  10.583 -    /*  36 */   SDLK_RETURN,
  10.584 -    /*  37 */   SDLK_LCTRL,
  10.585 -    /*  38 */   SDLK_A,
  10.586 -    /*  39 */   SDLK_S,
  10.587 -    /*  40 */   SDLK_D,
  10.588 -    /*  41 */   SDLK_F,
  10.589 -    /*  42 */   SDLK_G,
  10.590 -    /*  43 */   SDLK_H,
  10.591 -    /*  44 */   SDLK_J,
  10.592 -    /*  45 */   SDLK_K,
  10.593 -    /*  46 */   SDLK_L,
  10.594 -    /*  47 */   SDLK_SEMICOLON,
  10.595 -    /*  48 */   SDLK_APOSTROPHE,
  10.596 -    /*  49 */   SDLK_GRAVE,
  10.597 -    /*  50 */   SDLK_LSHIFT,
  10.598 -    /*  51 */   SDLK_BACKSLASH,
  10.599 -    /*  52 */   SDLK_Z,
  10.600 -    /*  53 */   SDLK_X,
  10.601 -    /*  54 */   SDLK_C,
  10.602 -    /*  55 */   SDLK_V,
  10.603 -    /*  56 */   SDLK_B,
  10.604 -    /*  57 */   SDLK_N,
  10.605 -    /*  58 */   SDLK_M,
  10.606 -    /*  59 */   SDLK_COMMA,
  10.607 -    /*  60 */   SDLK_PERIOD,
  10.608 -    /*  61 */   SDLK_SLASH,
  10.609 -    /*  62 */   SDLK_RSHIFT,
  10.610 -    /*  63 */   SDLK_KP_MULTIPLY,
  10.611 -    /*  64 */   SDLK_LALT,
  10.612 -    /*  65 */   SDLK_SPACE,
  10.613 -    /*  66 */   SDLK_CAPSLOCK,
  10.614 -    /*  67 */   SDLK_F1,
  10.615 -    /*  68 */   SDLK_F2,
  10.616 -    /*  69 */   SDLK_F3,
  10.617 -    /*  70 */   SDLK_F4,
  10.618 -    /*  71 */   SDLK_F5,
  10.619 -    /*  72 */   SDLK_F6,
  10.620 -    /*  73 */   SDLK_F7,
  10.621 -    /*  74 */   SDLK_F8,
  10.622 -    /*  75 */   SDLK_F9,
  10.623 -    /*  76 */   SDLK_F10,
  10.624 -    /*  77 */   SDLK_KP_NUMLOCKCLEAR,
  10.625 -    /*  78 */   SDLK_SCROLLLOCK,
  10.626 -    /*  79 */   SDLK_KP_7,
  10.627 -    /*  80 */   SDLK_KP_8,
  10.628 -    /*  81 */   SDLK_KP_9,
  10.629 -    /*  82 */   SDLK_KP_MINUS,
  10.630 -    /*  83 */   SDLK_KP_4,
  10.631 -    /*  84 */   SDLK_KP_5,
  10.632 -    /*  85 */   SDLK_KP_6,
  10.633 -    /*  86 */   SDLK_KP_PLUS,
  10.634 -    /*  87 */   SDLK_KP_1,
  10.635 -    /*  88 */   SDLK_KP_2,
  10.636 -    /*  89 */   SDLK_KP_3,
  10.637 -    /*  90 */   SDLK_KP_0,
  10.638 -    /*  91 */   SDLK_KP_PERIOD,
  10.639 -    /*  92 */   SDLK_SYSREQ,
  10.640 -    /*  93 */   SDLK_MODE, /* is translated to XK_Mode_switch by my X server, but I have no keyboard that generates this code, so I'm not sure if this is correct */
  10.641 -    /*  94 */   SDLK_NONUSBACKSLASH,
  10.642 -    /*  95 */   SDLK_F11,
  10.643 -    /*  96 */   SDLK_F12,
  10.644 -    /*  97 */   SDLK_HOME,
  10.645 -    /*  98 */   SDLK_UP,
  10.646 -    /*  99 */   SDLK_PAGEUP,
  10.647 -    /* 100 */   SDLK_LEFT,
  10.648 -    /* 101 */   SDLK_BRIGHTNESSDOWN, /* on PowerBook G4 */
  10.649 -    /* 102 */   SDLK_RIGHT,
  10.650 -    /* 103 */   SDLK_END,
  10.651 -    /* 104 */   SDLK_DOWN,
  10.652 -    /* 105 */   SDLK_PAGEDOWN,
  10.653 -    /* 106 */   SDLK_INSERT,
  10.654 -    /* 107 */   SDLK_DELETE,
  10.655 -    /* 108 */   SDLK_KP_ENTER,
  10.656 -    /* 109 */   SDLK_RCTRL,
  10.657 -    /* 110 */   SDLK_PAUSE,
  10.658 -    /* 111 */   SDLK_PRINTSCREEN,
  10.659 -    /* 112 */   SDLK_KP_DIVIDE,
  10.660 -    /* 113 */   SDLK_RALT,
  10.661 -    /* 114 */   SDLK_UNKNOWN,
  10.662 -    /* 115 */   SDLK_LMETA,
  10.663 -    /* 116 */   SDLK_RMETA,
  10.664 -    /* 117 */   SDLK_APPLICATION,
  10.665 -    /* 118 */   SDLK_F13,
  10.666 -    /* 119 */   SDLK_F14,
  10.667 -    /* 120 */   SDLK_F15,
  10.668 -    /* 121 */   SDLK_F16,
  10.669 -    /* 122 */   SDLK_F17,
  10.670 -    /* 123 */   SDLK_UNKNOWN,
  10.671 -    /* 124 */   SDLK_UNKNOWN, /* is translated to XK_ISO_Level3_Shift by my X server, but I have no keyboard that generates this code, so I don't know what the correct SDLK_* for it is */
  10.672 -    /* 125 */   SDLK_UNKNOWN,
  10.673 -    /* 126 */   SDLK_KP_EQUALS,
  10.674 -    /* 127 */   SDLK_UNKNOWN,
  10.675 -    /* 128 */   SDLK_UNKNOWN,
  10.676 -    /* 129 */   SDLK_UNKNOWN,
  10.677 -    /* 130 */   SDLK_UNKNOWN,
  10.678 -    /* 131 */   SDLK_UNKNOWN,
  10.679 -    /* 132 */   SDLK_UNKNOWN,
  10.680 -    /* 133 */   SDLK_INTERNATIONAL3, /* Yen */
  10.681 -    /* 134 */   SDLK_UNKNOWN,
  10.682 -    /* 135 */   SDLK_AGAIN,
  10.683 -    /* 136 */   SDLK_UNDO,
  10.684 -    /* 137 */   SDLK_UNKNOWN,
  10.685 -    /* 138 */   SDLK_UNKNOWN,
  10.686 -    /* 139 */   SDLK_UNKNOWN,
  10.687 -    /* 140 */   SDLK_UNKNOWN,
  10.688 -    /* 141 */   SDLK_UNKNOWN,
  10.689 -    /* 142 */   SDLK_UNKNOWN,
  10.690 -    /* 143 */   SDLK_UNKNOWN,
  10.691 -    /* 144 */   SDLK_AUDIOPREV,
  10.692 -    /* 145 */   SDLK_UNKNOWN,
  10.693 -    /* 146 */   SDLK_UNKNOWN,
  10.694 -    /* 147 */   SDLK_UNKNOWN,
  10.695 -    /* 148 */   SDLK_UNKNOWN,
  10.696 -    /* 149 */   SDLK_UNKNOWN,
  10.697 -    /* 150 */   SDLK_UNKNOWN,
  10.698 -    /* 151 */   SDLK_UNKNOWN,
  10.699 -    /* 152 */   SDLK_UNKNOWN,
  10.700 -    /* 153 */   SDLK_AUDIONEXT,
  10.701 -    /* 154 */   SDLK_UNKNOWN,
  10.702 -    /* 155 */   SDLK_UNKNOWN,
  10.703 -    /* 156 */   SDLK_UNKNOWN,
  10.704 -    /* 157 */   SDLK_KP_EQUALS, /* on PowerBook G4 */
  10.705 -    /* 158 */   SDLK_UNKNOWN,
  10.706 -    /* 159 */   SDLK_UNKNOWN,
  10.707 -    /* 160 */   SDLK_MUTE,
  10.708 -    /* 161 */   SDLK_CALC,
  10.709 -    /* 162 */   SDLK_AUDIOPLAY,
  10.710 -    /* 163 */   SDLK_UNKNOWN,
  10.711 -    /* 164 */   SDLK_AUDIOSTOP,
  10.712 -    /* 165 */   SDLK_UNKNOWN,
  10.713 -    /* 166 */   SDLK_UNKNOWN,
  10.714 -    /* 167 */   SDLK_UNKNOWN,
  10.715 -    /* 168 */   SDLK_UNKNOWN,
  10.716 -    /* 169 */   SDLK_UNKNOWN,
  10.717 -    /* 170 */   SDLK_UNKNOWN,
  10.718 -    /* 171 */   SDLK_UNKNOWN,
  10.719 -    /* 172 */   SDLK_UNKNOWN,
  10.720 -    /* 173 */   SDLK_UNKNOWN,
  10.721 -    /* 174 */   SDLK_VOLUMEDOWN,
  10.722 -    /* 175 */   SDLK_UNKNOWN,
  10.723 -    /* 176 */   SDLK_VOLUMEUP,
  10.724 -    /* 177 */   SDLK_UNKNOWN,
  10.725 -    /* 178 */   SDLK_WWW,
  10.726 -    /* 179 */   SDLK_UNKNOWN,
  10.727 -    /* 180 */   SDLK_UNKNOWN,
  10.728 -    /* 181 */   SDLK_UNKNOWN,
  10.729 -    /* 182 */   SDLK_UNKNOWN,
  10.730 -    /* 183 */   SDLK_UNKNOWN,
  10.731 -    /* 184 */   SDLK_UNKNOWN,
  10.732 -    /* 185 */   SDLK_UNKNOWN,
  10.733 -    /* 186 */   SDLK_UNKNOWN,
  10.734 -    /* 187 */   SDLK_HELP,
  10.735 -    /* 188 */   SDLK_UNKNOWN,
  10.736 -    /* 189 */   SDLK_UNKNOWN,
  10.737 -    /* 190 */   SDLK_UNKNOWN,
  10.738 -    /* 191 */   SDLK_UNKNOWN,
  10.739 -    /* 192 */   SDLK_UNKNOWN,
  10.740 -    /* 193 */   SDLK_UNKNOWN,
  10.741 -    /* 194 */   SDLK_UNKNOWN,
  10.742 -    /* 195 */   SDLK_UNKNOWN,
  10.743 -    /* 196 */   SDLK_UNKNOWN,
  10.744 -    /* 197 */   SDLK_UNKNOWN,
  10.745 -    /* 198 */   SDLK_UNKNOWN,
  10.746 -    /* 199 */   SDLK_UNKNOWN,
  10.747 -    /* 200 */   SDLK_UNKNOWN,
  10.748 -    /* 201 */   SDLK_UNKNOWN,
  10.749 -    /* 202 */   SDLK_UNKNOWN,
  10.750 -    /* 203 */   SDLK_UNKNOWN,
  10.751 -    /* 204 */   SDLK_EJECT, /* on PowerBook G4 */
  10.752 -    /* 205 */   SDLK_UNKNOWN,
  10.753 -    /* 206 */   SDLK_UNKNOWN,
  10.754 -    /* 207 */   SDLK_UNKNOWN,
  10.755 -    /* 208 */   SDLK_UNKNOWN,
  10.756 -    /* 209 */   SDLK_UNKNOWN,
  10.757 -    /* 210 */   SDLK_UNKNOWN,
  10.758 -    /* 211 */   SDLK_UNKNOWN,
  10.759 -    /* 212 */   SDLK_BRIGHTNESSUP, /* on PowerBook G4 */
  10.760 -    /* 213 */   SDLK_UNKNOWN,
  10.761 -    /* 214 */   SDLK_DISPLAYSWITCH, /* on PowerBook G4 */
  10.762 -    /* 215 */   SDLK_KBDILLUMTOGGLE,
  10.763 -    /* 216 */   SDLK_KBDILLUMDOWN,
  10.764 -    /* 217 */   SDLK_KBDILLUMUP,
  10.765 -    /* 218 */   SDLK_UNKNOWN,
  10.766 -    /* 219 */   SDLK_UNKNOWN,
  10.767 -    /* 220 */   SDLK_UNKNOWN,
  10.768 -    /* 221 */   SDLK_UNKNOWN,
  10.769 -    /* 222 */   SDLK_POWER,
  10.770 -    /* 223 */   SDLK_SLEEP,
  10.771 -    /* 224 */   SDLK_UNKNOWN,
  10.772 -    /* 225 */   SDLK_UNKNOWN,
  10.773 -    /* 226 */   SDLK_UNKNOWN,
  10.774 -    /* 227 */   SDLK_UNKNOWN,
  10.775 -    /* 228 */   SDLK_UNKNOWN,
  10.776 -    /* 229 */   SDLK_SEARCH,
  10.777 -    /* 230 */   SDLK_BOOKMARKS,
  10.778 -    /* 231 */   SDLK_BROWSERRELOAD,
  10.779 -    /* 232 */   SDLK_BROWSERSTOP,
  10.780 -    /* 233 */   SDLK_BROWSERFORWARD,
  10.781 -    /* 234 */   SDLK_BROWSERBACK,
  10.782 -    /* 235 */   SDLK_COMPUTER,
  10.783 -    /* 236 */   SDLK_EMAIL,
  10.784 -    /* 237 */   SDLK_MEDIA,
  10.785 -    /* 238 */   SDLK_UNKNOWN,
  10.786 -    /* 239 */   SDLK_UNKNOWN,
  10.787 -    /* 240 */   SDLK_UNKNOWN,
  10.788 -    /* 241 */   SDLK_UNKNOWN,
  10.789 -    /* 242 */   SDLK_UNKNOWN,
  10.790 -    /* 243 */   SDLK_UNKNOWN,
  10.791 -    /* 244 */   SDLK_UNKNOWN,
  10.792 -    /* 245 */   SDLK_UNKNOWN,
  10.793 -    /* 246 */   SDLK_UNKNOWN,
  10.794 -    /* 247 */   SDLK_UNKNOWN,
  10.795 -    /* 248 */   SDLK_UNKNOWN,
  10.796 -    /* 249 */   SDLK_UNKNOWN,
  10.797 -    /* 250 */   SDLK_UNKNOWN,
  10.798 -    /* 251 */   SDLK_UNKNOWN,
  10.799 -    /* 252 */   SDLK_UNKNOWN,
  10.800 -    /* 253 */   SDLK_UNKNOWN,
  10.801 -    /* 254 */   SDLK_UNKNOWN,
  10.802 -    /* 255 */   SDLK_UNKNOWN
  10.803 -};
  10.804 -
  10.805 -/*---------------------------------------------------------------------------*/
  10.806 -
  10.807 -/* Used by X11_KeySymToSDLKey(). This is a hybrid of a KeySym-to-layout-key
  10.808 -    mapping (needed in X11_GetLayoutKey()) and a fallback KeySym-to-physical-key
  10.809 -    mapping under the assumption of a US keyboard layout (needed in
  10.810 -    X11_InitKeyboard()). If for a given KeySym...
  10.811 -    - the layout and physical codes are the same (must be an SDLK_ constant):
  10.812 -      there is one entry,
  10.813 -    - the layout and physical codes differ: there are two entries, with the
  10.814 -      layout one first,
  10.815 -    - there is only a physical code in the table (must be an SDLK_ constant):
  10.816 -      it's marked by X11_KEY_PHYSICAL_ONLY_BIT (this is the case when the layout
  10.817 -      key code is handled by KeySymToUcs4()),
  10.818 -    - there is only a layout code in the table (can't be an SDLK_ constant):
  10.819 -      recognizable by the absence of SDL_KEY_CAN_BE_PHYSICAL_BIT.
  10.820 -    This list is sorted by KeySym to allow a binary search.
  10.821 -*/
  10.822 -#define X11_KEY_PHYSICAL_ONLY_BIT SDL_KEY_LAYOUT_SPECIAL_BIT
  10.823 -/* SDL_KEY_LAYOUT_SPECIAL_BIT cannot possibly occur in an SDLK_ constant, so we may repurpose that bit for our own use. */
  10.824  static struct
  10.825  {
  10.826 -    KeySym sym;
  10.827 -    SDLKey key;
  10.828 -} keySymToSDLKey[KeyCodeTableSize] = 
  10.829 -{
  10.830 -    /* 0x00xx */
  10.831 -    {XK_space, SDLK_SPACE},
  10.832 -    {XK_apostrophe, SDLK_APOSTROPHE | X11_KEY_PHYSICAL_ONLY_BIT},
  10.833 -    {XK_comma, SDLK_COMMA | X11_KEY_PHYSICAL_ONLY_BIT},
  10.834 -    {XK_minus, SDLK_HYPHENMINUS | X11_KEY_PHYSICAL_ONLY_BIT},
  10.835 -    {XK_period, SDLK_PERIOD | X11_KEY_PHYSICAL_ONLY_BIT},
  10.836 -    {XK_slash, SDLK_SLASH | X11_KEY_PHYSICAL_ONLY_BIT},
  10.837 -    {XK_0, SDLK_0 | X11_KEY_PHYSICAL_ONLY_BIT},
  10.838 -    {XK_1, SDLK_1 | X11_KEY_PHYSICAL_ONLY_BIT},
  10.839 -    {XK_2, SDLK_2 | X11_KEY_PHYSICAL_ONLY_BIT},
  10.840 -    {XK_3, SDLK_3 | X11_KEY_PHYSICAL_ONLY_BIT},
  10.841 -    {XK_4, SDLK_4 | X11_KEY_PHYSICAL_ONLY_BIT},
  10.842 -    {XK_5, SDLK_5 | X11_KEY_PHYSICAL_ONLY_BIT},
  10.843 -    {XK_6, SDLK_6 | X11_KEY_PHYSICAL_ONLY_BIT},
  10.844 -    {XK_7, SDLK_7 | X11_KEY_PHYSICAL_ONLY_BIT},
  10.845 -    {XK_8, SDLK_8 | X11_KEY_PHYSICAL_ONLY_BIT},
  10.846 -    {XK_9, SDLK_9 | X11_KEY_PHYSICAL_ONLY_BIT},
  10.847 -    {XK_semicolon, SDLK_SEMICOLON | X11_KEY_PHYSICAL_ONLY_BIT},
  10.848 -    {XK_less, SDLK_NONUSBACKSLASH | X11_KEY_PHYSICAL_ONLY_BIT},
  10.849 -    {XK_equal, SDLK_EQUALS | X11_KEY_PHYSICAL_ONLY_BIT},
  10.850 -    {XK_bracketleft, SDLK_LEFTBRACKET | X11_KEY_PHYSICAL_ONLY_BIT},
  10.851 -    {XK_backslash, SDLK_BACKSLASH | X11_KEY_PHYSICAL_ONLY_BIT},
  10.852 -    {XK_bracketright, SDLK_RIGHTBRACKET | X11_KEY_PHYSICAL_ONLY_BIT},
  10.853 -    {XK_grave, SDLK_GRAVE | X11_KEY_PHYSICAL_ONLY_BIT},
  10.854 -    {XK_a, SDLK_A | X11_KEY_PHYSICAL_ONLY_BIT},
  10.855 -    {XK_b, SDLK_B | X11_KEY_PHYSICAL_ONLY_BIT},
  10.856 -    {XK_c, SDLK_C | X11_KEY_PHYSICAL_ONLY_BIT},
  10.857 -    {XK_d, SDLK_D | X11_KEY_PHYSICAL_ONLY_BIT},
  10.858 -    {XK_e, SDLK_E | X11_KEY_PHYSICAL_ONLY_BIT},
  10.859 -    {XK_f, SDLK_F | X11_KEY_PHYSICAL_ONLY_BIT},
  10.860 -    {XK_g, SDLK_G | X11_KEY_PHYSICAL_ONLY_BIT},
  10.861 -    {XK_h, SDLK_H | X11_KEY_PHYSICAL_ONLY_BIT},
  10.862 -    {XK_i, SDLK_I | X11_KEY_PHYSICAL_ONLY_BIT},
  10.863 -    {XK_j, SDLK_J | X11_KEY_PHYSICAL_ONLY_BIT},
  10.864 -    {XK_k, SDLK_K | X11_KEY_PHYSICAL_ONLY_BIT},
  10.865 -    {XK_l, SDLK_L | X11_KEY_PHYSICAL_ONLY_BIT},
  10.866 -    {XK_m, SDLK_M | X11_KEY_PHYSICAL_ONLY_BIT},
  10.867 -    {XK_n, SDLK_N | X11_KEY_PHYSICAL_ONLY_BIT},
  10.868 -    {XK_o, SDLK_O | X11_KEY_PHYSICAL_ONLY_BIT},
  10.869 -    {XK_p, SDLK_P | X11_KEY_PHYSICAL_ONLY_BIT},
  10.870 -    {XK_q, SDLK_Q | X11_KEY_PHYSICAL_ONLY_BIT},
  10.871 -    {XK_r, SDLK_R | X11_KEY_PHYSICAL_ONLY_BIT},
  10.872 -    {XK_s, SDLK_S | X11_KEY_PHYSICAL_ONLY_BIT},
  10.873 -    {XK_t, SDLK_T | X11_KEY_PHYSICAL_ONLY_BIT},
  10.874 -    {XK_u, SDLK_U | X11_KEY_PHYSICAL_ONLY_BIT},
  10.875 -    {XK_v, SDLK_V | X11_KEY_PHYSICAL_ONLY_BIT},
  10.876 -    {XK_w, SDLK_W | X11_KEY_PHYSICAL_ONLY_BIT},
  10.877 -    {XK_x, SDLK_X | X11_KEY_PHYSICAL_ONLY_BIT},
  10.878 -    {XK_y, SDLK_Y | X11_KEY_PHYSICAL_ONLY_BIT},
  10.879 -    {XK_z, SDLK_Z | X11_KEY_PHYSICAL_ONLY_BIT},
  10.880 -    {XK_section, SDLK_NONUSBACKSLASH | X11_KEY_PHYSICAL_ONLY_BIT},
  10.881 -        /* 0xFExx */
  10.882 -    {XK_ISO_Level3_Shift, SDLK_RALT},
  10.883 -    {XK_dead_grave, '`'},
  10.884 -    {XK_dead_acute, 0xB4},
  10.885 -    {XK_dead_circumflex, '^'},
  10.886 -    {XK_dead_tilde, '~'},
  10.887 -    {XK_dead_macron, 0xAF},
  10.888 -    {XK_dead_breve, 0x2D8},
  10.889 -    {XK_dead_abovedot, 0x2D9},
  10.890 -    {XK_dead_diaeresis, 0xA8},
  10.891 -    {XK_dead_abovering, 0x2DA},
  10.892 -    {XK_dead_doubleacute, 0x2DD},
  10.893 -    {XK_dead_caron, 0x2C7},
  10.894 -    {XK_dead_cedilla, 0xB8},
  10.895 -    {XK_dead_ogonek, 0x2DB},
  10.896 -    {XK_dead_iota, 0x3B9},
  10.897 -    {XK_dead_voiced_sound, 0x309B},
  10.898 -    {XK_dead_semivoiced_sound, 0x309C},
  10.899 -    {XK_dead_belowdot, 0xB7},        /* that's actually MIDDLE DOT,
  10.900 -                                        but I haven't found a
  10.901 -                                        non-combining DOT BELOW
  10.902 -                                        XK_dead_hook, XK_dead_horn: I
  10.903 -                                        haven't found non-combining
  10.904 -                                        HOOK and HORN characters */
  10.905 -    /* 0xFFxx */
  10.906 -    {XK_BackSpace, SDLK_BACKSPACE},
  10.907 -    {XK_Tab, SDLK_TAB},
  10.908 -    {XK_Return, SDLK_RETURN},
  10.909 -    {XK_Pause, SDLK_PAUSE},
  10.910 -    {XK_Scroll_Lock, SDLK_SCROLLLOCK},
  10.911 -    {XK_Escape, SDLK_ESCAPE},
  10.912 -    {XK_Home, SDLK_HOME},
  10.913 -    {XK_Left, SDLK_LEFT},
  10.914 -    {XK_Up, SDLK_UP},
  10.915 -    {XK_Right, SDLK_RIGHT},
  10.916 -    {XK_Down, SDLK_DOWN},
  10.917 -    {XK_Page_Up, SDLK_PAGEUP},
  10.918 -    {XK_Page_Down, SDLK_PAGEDOWN},
  10.919 -    {XK_End, SDLK_END},
  10.920 -    {XK_Print, SDLK_PRINTSCREEN},
  10.921 -    {XK_Insert, SDLK_INSERT},
  10.922 -    {XK_Menu, SDLK_APPLICATION},
  10.923 -    {XK_Break, SDLK_PAUSE},
  10.924 -    {XK_Mode_switch, SDLK_MODE},
  10.925 -    {XK_Num_Lock, SDLK_KP_NUMLOCKCLEAR},
  10.926 -    {XK_KP_Enter, SDLK_KP_ENTER},
  10.927 -    {XK_KP_Home, SDLK_KP_7 | X11_KEY_PHYSICAL_ONLY_BIT},
  10.928 -    {XK_KP_Left, SDLK_KP_4 | X11_KEY_PHYSICAL_ONLY_BIT},
  10.929 -    {XK_KP_Up, SDLK_KP_8 | X11_KEY_PHYSICAL_ONLY_BIT},
  10.930 -    {XK_KP_Right, SDLK_KP_6 | X11_KEY_PHYSICAL_ONLY_BIT},
  10.931 -    {XK_KP_Down, SDLK_KP_2 | X11_KEY_PHYSICAL_ONLY_BIT},
  10.932 -    {XK_KP_Page_Up, SDLK_KP_9 | X11_KEY_PHYSICAL_ONLY_BIT},
  10.933 -    {XK_KP_Page_Down, SDLK_KP_3 | X11_KEY_PHYSICAL_ONLY_BIT},
  10.934 -    {XK_KP_End, SDLK_KP_1 | X11_KEY_PHYSICAL_ONLY_BIT},
  10.935 -    {XK_KP_Begin, SDLK_KP_5 | X11_KEY_PHYSICAL_ONLY_BIT},
  10.936 -    {XK_KP_Insert, SDLK_KP_0 | X11_KEY_PHYSICAL_ONLY_BIT},
  10.937 -    {XK_KP_Delete, SDLK_KP_PERIOD | X11_KEY_PHYSICAL_ONLY_BIT},
  10.938 -    {XK_KP_Multiply, '*'},
  10.939 -    {XK_KP_Multiply, SDLK_KP_MULTIPLY},
  10.940 -    {XK_KP_Add, '+'},
  10.941 -    {XK_KP_Add, SDLK_KP_PLUS},
  10.942 -    {XK_KP_Separator, '.'},
  10.943 -    {XK_KP_Separator, SDLK_KP_PERIOD},
  10.944 -    {XK_KP_Subtract, '-'},
  10.945 -    {XK_KP_Subtract, SDLK_KP_MINUS},
  10.946 -    {XK_KP_Decimal, '.'},
  10.947 -    {XK_KP_Decimal, SDLK_KP_PERIOD},
  10.948 -    {XK_KP_Divide, '/'},
  10.949 -    {XK_KP_Divide, SDLK_KP_DIVIDE},
  10.950 -    {XK_KP_0, '0'},
  10.951 -    {XK_KP_0, SDLK_KP_0},
  10.952 -    {XK_KP_1, '1'},
  10.953 -    {XK_KP_1, SDLK_KP_1},
  10.954 -    {XK_KP_2, '2'},
  10.955 -    {XK_KP_2, SDLK_KP_2},
  10.956 -    {XK_KP_3, '3'},
  10.957 -    {XK_KP_3, SDLK_KP_3},
  10.958 -    {XK_KP_4, '4'},
  10.959 -    {XK_KP_4, SDLK_KP_4},
  10.960 -    {XK_KP_5, '5'},
  10.961 -    {XK_KP_5, SDLK_KP_5},
  10.962 -    {XK_KP_6, '6'},
  10.963 -    {XK_KP_6, SDLK_KP_6},
  10.964 -    {XK_KP_7, '7'},
  10.965 -    {XK_KP_7, SDLK_KP_7},
  10.966 -    {XK_KP_8, '8'},
  10.967 -    {XK_KP_8, SDLK_KP_8},
  10.968 -    {XK_KP_9, '9'},
  10.969 -    {XK_KP_9, SDLK_KP_9},
  10.970 -    {XK_KP_Equal, '='},
  10.971 -    {XK_KP_Equal, SDLK_KP_EQUALS},
  10.972 -    {XK_F1, SDLK_F1},
  10.973 -    {XK_F2, SDLK_F2},
  10.974 -    {XK_F3, SDLK_F3},
  10.975 -    {XK_F4, SDLK_F4},
  10.976 -    {XK_F5, SDLK_F5},
  10.977 -    {XK_F6, SDLK_F6},
  10.978 -    {XK_F7, SDLK_F7},
  10.979 -    {XK_F8, SDLK_F8},
  10.980 -    {XK_F9, SDLK_F9},
  10.981 -    {XK_F10, SDLK_F10},
  10.982 -    {XK_F11, SDLK_F11},
  10.983 -    {XK_F12, SDLK_F12},
  10.984 -    {XK_F13, SDLK_F13},
  10.985 -    {XK_F14, SDLK_F14},
  10.986 -    {XK_F15, SDLK_F15},
  10.987 -    {XK_F16, SDLK_F16},
  10.988 -    {XK_F17, SDLK_F17},
  10.989 -    {XK_F18, SDLK_F18},
  10.990 -    {XK_F19, SDLK_F19},
  10.991 -    {XK_F20, SDLK_F20},
  10.992 -    {XK_F21, SDLK_F21},
  10.993 -    {XK_F22, SDLK_F22},
  10.994 -    {XK_F23, SDLK_F23},
  10.995 -    {XK_F24, SDLK_F24},
  10.996 -    {XK_Shift_L, SDLK_LSHIFT},
  10.997 -    {XK_Shift_R, SDLK_RSHIFT},
  10.998 -    {XK_Control_L, SDLK_LCTRL},
  10.999 -    {XK_Control_R, SDLK_RCTRL},
 10.1000 -    {XK_Caps_Lock, SDLK_CAPSLOCK},
 10.1001 -    {XK_Shift_Lock, SDLK_CAPSLOCK},
 10.1002 -    {XK_Meta_L, SDLK_LMETA},
 10.1003 -    {XK_Meta_R, SDLK_RMETA},
 10.1004 -    {XK_Alt_L, SDLK_LALT},
 10.1005 -    {XK_Alt_R, SDLK_RALT},
 10.1006 -    {XK_Super_L, SDLK_LMETA},
 10.1007 -    {XK_Super_R, SDLK_RMETA},
 10.1008 -    {XK_Hyper_L, SDLK_LMETA},
 10.1009 -    {XK_Hyper_R, SDLK_RMETA},
 10.1010 -    {XK_Delete, SDLK_DELETE},
 10.1011 -    {0x1000003, SDLK_KP_ENTER}   /* keyboard enter on Mac OS X */
 10.1012 -};
 10.1013 -
 10.1014 -/* *INDENT-ON* */
 10.1015 -
 10.1016 -/* 
 10.1017 -   Used for two purposes: - by X11_GetLayoutKey(), with physical =
 10.1018 -   false, to convert a KeySym to the corresponding layout key code
 10.1019 -   (SDLK_ ones and some character ones - most character KeySyms are
 10.1020 -   handled by X11_KeySymToUcs4() after this function returns
 10.1021 -   SDLK_UNKNOWN for them).  - by X11_InitKeyboard(), with physical =
 10.1022 -   true, to build a makeshift translation table based on the KeySyms
 10.1023 -   when none of the predefined KeyCode- to-SDLKey tables fits. This
 10.1024 -   is *not* correct anywhere but on a US layout, since the
 10.1025 -   translation table deals with physical key codes, while the X11
 10.1026 -   KeySym corresponds to our concept of a layout key code, but it's
 10.1027 -   better than nothing.
 10.1028 -*/
 10.1029 -
 10.1030 -static SDLKey
 10.1031 -X11_KeySymToSDLKey(KeySym sym, SDL_bool physical)
 10.1032 -{
 10.1033 -    /* Do a binary search for sym in the keySymToSDLKey table */
 10.1034 -    SDLKey key = SDLK_UNKNOWN;
 10.1035 -    int start = -1;
 10.1036 -    int end = SDL_arraysize(keySymToSDLKey);
 10.1037 -    int i;
 10.1038 -    /* Invariant: keySymToSDLKey[start].sym < sym <
 10.1039 -       keySymToSDLKey[end].sym (imagine ...[-1] = -inf and
 10.1040 -       ...[arraysize] = inf, these entries needn't be there in reality
 10.1041 -       because they're never accessed) */
 10.1042 -    while (end > start + 1) {
 10.1043 -        i = (start + end) / 2;
 10.1044 -        if (keySymToSDLKey[i].sym == sym) {
 10.1045 -            /* found an entry, if it's the second of two back up to the first */
 10.1046 -            if (keySymToSDLKey[i - 1].sym == sym)
 10.1047 -                i--;
 10.1048 -            /* if there are two, the physical one is the second */
 10.1049 -            if (physical && keySymToSDLKey[i + 1].sym == sym)
 10.1050 -                i++;
 10.1051 -            key = keySymToSDLKey[i].key;
 10.1052 -            break;
 10.1053 -        } else if (keySymToSDLKey[i].sym < sym)
 10.1054 -            start = i;
 10.1055 -        else
 10.1056 -            end = i;
 10.1057 -    }
 10.1058 -
 10.1059 -    /* if we're being asked for a layout key code, but the table only
 10.1060 -       has a physical one, or vice versa, return SDLK_UNKNOWN) */
 10.1061 -
 10.1062 -    if (!physical && ((key & X11_KEY_PHYSICAL_ONLY_BIT) != 0)
 10.1063 -        || physical && ((key & SDL_KEY_CAN_BE_PHYSICAL_BIT) == 0))
 10.1064 -        key = SDLK_UNKNOWN;
 10.1065 -    key &= ~X11_KEY_PHYSICAL_ONLY_BIT;
 10.1066 -    return key;
 10.1067 -}
 10.1068 +    SDL_scancode *table;
 10.1069 +    int table_size;
 10.1070 +} scancode_set[] = {
 10.1071 +    {
 10.1072 +    darwin_scancode_table, SDL_arraysize(darwin_scancode_table)}, {
 10.1073 +xfree86_scancode_table, SDL_arraysize(xfree86_scancode_table)},};
 10.1074  
 10.1075  int
 10.1076  X11_InitKeyboard(_THIS)
 10.1077  {
 10.1078      SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
 10.1079      SDL_Keyboard keyboard;
 10.1080 -    SDLKey **table;
 10.1081 -    SDLKey *foundTable;
 10.1082 -    int i;
 10.1083 -    int code;
 10.1084 -    SDLKey sdlkey;
 10.1085 +    int i, j;
 10.1086 +    int min_keycode, max_keycode;
 10.1087 +    SDL_scancode fingerprint_scancodes[] = {
 10.1088 +        SDL_SCANCODE_HOME,
 10.1089 +        SDL_SCANCODE_PAGEUP,
 10.1090 +        SDL_SCANCODE_PAGEDOWN
 10.1091 +    };
 10.1092 +    int fingerprint[3];
 10.1093 +    SDL_bool fingerprint_detected;
 10.1094  
 10.1095      XAutoRepeatOn(data->display);
 10.1096  
 10.1097 -    /* A random collection of KeySym/SDLKey pairs that should be valid
 10.1098 -       in any keyboard layout (if this isn't the case on yours,
 10.1099 -       please adjust). Using XKeysymToKeycode on these KeySyms
 10.1100 -       creates a "fingerprint" of the X server's key-to-KeyCode
 10.1101 -       mapping which is then matched against all our predefined
 10.1102 -       KeyCodeToSDLK tables to find the right one (if any).
 10.1103 -     */
 10.1104 +    /* Try to determine which scancodes are being used based on fingerprint */
 10.1105 +    fingerprint_detected = SDL_FALSE;
 10.1106 +    XDisplayKeycodes(data->display, &min_keycode, &max_keycode);
 10.1107 +    for (i = 0; i < SDL_arraysize(fingerprint_scancodes); ++i) {
 10.1108 +        fingerprint[i] =
 10.1109 +            XKeysymToKeycode(data->display,
 10.1110 +                             XKeySymTable[fingerprint_scancodes[i]]) -
 10.1111 +            min_keycode;
 10.1112 +    }
 10.1113 +    for (i = 0; i < SDL_arraysize(scancode_set); ++i) {
 10.1114 +        /* Make sure the scancode set isn't too big */
 10.1115 +        if ((max_keycode - min_keycode + 1) <= scancode_set[i].table_size) {
 10.1116 +            continue;
 10.1117 +        }
 10.1118 +        for (j = 0; j < SDL_arraysize(fingerprint); ++j) {
 10.1119 +            if (fingerprint[j] < 0
 10.1120 +                || fingerprint[j] >= scancode_set[i].table_size) {
 10.1121 +                break;
 10.1122 +            }
 10.1123 +            if (scancode_set[i].table[fingerprint[j]] !=
 10.1124 +                fingerprint_scancodes[j]) {
 10.1125 +                break;
 10.1126 +            }
 10.1127 +        }
 10.1128 +        if (j == SDL_arraysize(fingerprint)) {
 10.1129 +            printf("Using scancode set %d\n", i);
 10.1130 +            SDL_memcpy(&data->key_layout[min_keycode], scancode_set[i].table,
 10.1131 +                       sizeof(SDL_scancode) * scancode_set[i].table_size);
 10.1132 +            fingerprint_detected = SDL_TRUE;
 10.1133 +            break;
 10.1134 +        }
 10.1135 +    }
 10.1136  
 10.1137 -/* *INDENT-OFF* */
 10.1138 -    struct
 10.1139 -    {
 10.1140 -        KeySym sym;
 10.1141 -        SDLKey key;
 10.1142 -    } fingerprint[] = 
 10.1143 -      {
 10.1144 -        {XK_Tab, SDLK_TAB}, 
 10.1145 -        {XK_Return, SDLK_RETURN}, 
 10.1146 -        {XK_Escape, SDLK_ESCAPE}, 
 10.1147 -        {XK_space, SDLK_SPACE}
 10.1148 -    };
 10.1149 -/* *INDENT-ON* */
 10.1150 +    if (!fingerprint_detected) {
 10.1151 +        printf
 10.1152 +            ("Keyboard layout unknown, please send the following to the SDL mailing list (sdl@libsdl.org):\n");
 10.1153 +
 10.1154 +        /* Determine key_layout - only works on US QWERTY layout */
 10.1155 +        for (i = min_keycode; i <= max_keycode; ++i) {
 10.1156 +            KeySym sym;
 10.1157 +            sym = XKeycodeToKeysym(data->display, i, 0);
 10.1158 +            if (sym) {
 10.1159 +                printf("code = %d, sym = 0x%X (%s) ", i - min_keycode, sym,
 10.1160 +                       XKeysymToString(sym));
 10.1161 +                for (j = 0; j < SDL_arraysize(XKeySymTable); ++j) {
 10.1162 +                    if (XKeySymTable[j] == sym) {
 10.1163 +                        data->key_layout[i] = (SDL_scancode) j;
 10.1164 +                        break;
 10.1165 +                    }
 10.1166 +                }
 10.1167 +                if (j == SDL_arraysize(XKeySymTable)) {
 10.1168 +                    printf("scancode not found\n");
 10.1169 +                } else {
 10.1170 +                    printf("scancode = %d (%s)\n", j, SDL_GetScancodeName(j));
 10.1171 +                }
 10.1172 +            }
 10.1173 +        }
 10.1174 +    }
 10.1175  
 10.1176      SDL_zero(keyboard);
 10.1177      data->keyboard = SDL_AddKeyboard(&keyboard, -1);
 10.1178 +    X11_UpdateKeymap(this);
 10.1179  
 10.1180 -    /* Determine which X11 KeyCode to SDL physical key code table to use */
 10.1181 -
 10.1182 -    foundTable = NULL;
 10.1183 -    table = keyCodeToSDLKeyTables;
 10.1184 -    while ((NULL == foundTable) && (NULL != (*table))) {
 10.1185 -        foundTable = *table;
 10.1186 -        for (i = 0; i < SDL_arraysize(fingerprint); i++) {
 10.1187 -            code = XKeysymToKeycode(data->display, fingerprint[i].sym);
 10.1188 -            if ((code != 0) && ((*table)[code] != fingerprint[i].key)) {
 10.1189 -                foundTable = NULL;
 10.1190 -                break;
 10.1191 -            }
 10.1192 -        }
 10.1193 -        table++;
 10.1194 -    }
 10.1195 -
 10.1196 -    if (NULL != foundTable) {
 10.1197 -        /* Found a suitable one among the predefined tables */
 10.1198 -        data->keyCodeToSDLKTable = foundTable;
 10.1199 -    } else {
 10.1200 -        /* No suitable table found - build a makeshift table based on
 10.1201 -           the KeySyms, assuming a US keyboard layout */
 10.1202 -
 10.1203 -#if 1
 10.1204 -        fprintf(stderr,
 10.1205 -                "The key codes of your X server are unknown to SDL. Keys may not be recognized properly. To help get this fixed, report this to the SDL mailing list <sdl@libsdl.org> or to Christian Walther <cwalther@gmx.ch>.\n");
 10.1206 -#endif
 10.1207 -        data->keyCodeToSDLKTable =
 10.1208 -            SDL_malloc(KeyCodeTableSize * sizeof(SDLKey));
 10.1209 -        if (data->keyCodeToSDLKTable == NULL) {
 10.1210 -            SDL_OutOfMemory();
 10.1211 -            return -1;
 10.1212 -        }
 10.1213 -        for (code = KeyCodeTableSize; code >= 0; code--) {
 10.1214 -            data->keyCodeToSDLKTable[code] =
 10.1215 -                X11_KeySymToSDLKey(XKeycodeToKeysym(data->display, code, 0),
 10.1216 -                                   SDL_TRUE);
 10.1217 -        }
 10.1218 -    }
 10.1219 -
 10.1220 -    /* Set some non-default key names */
 10.1221 -
 10.1222 -    for (code = 0; code < KeyCodeTableSize; code++) {
 10.1223 -        sdlkey = data->keyCodeToSDLKTable[code];
 10.1224 -        switch (sdlkey) {
 10.1225 -            /* The SDLK_*META keys are used as XK_Meta_* by some X
 10.1226 -               servers, as XK_Super_* by others */
 10.1227 -        case SDLK_LMETA:
 10.1228 -        case SDLK_RMETA:
 10.1229 -            switch (XKeycodeToKeysym(data->display, code, 0)) {
 10.1230 -                /* nothing to do for XK_Meta_* because that's already the default name */
 10.1231 -            case XK_Super_L:
 10.1232 -                SDL_SetKeyName(sdlkey, "left super");
 10.1233 -                break;
 10.1234 -            case XK_Super_R:
 10.1235 -                SDL_SetKeyName(sdlkey, "right super");
 10.1236 -                break;
 10.1237 -            }
 10.1238 -            break;
 10.1239 -        }
 10.1240 -    }
 10.1241 -    SDL_SetKeyName(SDLK_APPLICATION, "menu");
 10.1242 +    SDL_SetScancodeName(SDL_SCANCODE_APPLICATION, "Menu");
 10.1243  
 10.1244      return 0;
 10.1245  }
 10.1246  
 10.1247 -SDLKey
 10.1248 -X11_GetLayoutKey(_THIS, SDLKey physicalKey)
 10.1249 +void
 10.1250 +X11_UpdateKeymap(_THIS)
 10.1251  {
 10.1252      SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
 10.1253 -    int code = 0;
 10.1254 -    KeySym sym;
 10.1255 -    SDLKey layoutKey;
 10.1256 +    int i;
 10.1257 +    SDL_scancode scancode;
 10.1258 +    SDLKey keymap[SDL_NUM_SCANCODES];
 10.1259  
 10.1260 -    switch (physicalKey) {
 10.1261 -    case SDLK_UNKNOWN:
 10.1262 -        return physicalKey;
 10.1263 +    SDL_GetDefaultKeymap(keymap);
 10.1264  
 10.1265 -        /* Shortcut handling of keypad numbers because on my PC their
 10.1266 -           primary KeySyms are not the numbers that I want but
 10.1267 -           XK_KP_Home, XK_KP_Up etc. The downside is that this gets us
 10.1268 -           latin numerals even on e.g. an Arabic layout. */
 10.1269 -    case SDLK_KP_1:
 10.1270 -        return '1';
 10.1271 -    case SDLK_KP_2:
 10.1272 -        return '2';
 10.1273 -    case SDLK_KP_3:
 10.1274 -        return '3';
 10.1275 -    case SDLK_KP_4:
 10.1276 -        return '4';
 10.1277 -    case SDLK_KP_5:
 10.1278 -        return '5';
 10.1279 -    case SDLK_KP_6:
 10.1280 -        return '6';
 10.1281 -    case SDLK_KP_7:
 10.1282 -        return '7';
 10.1283 -    case SDLK_KP_8:
 10.1284 -        return '8';
 10.1285 -    case SDLK_KP_9:
 10.1286 -        return '9';
 10.1287 -    case SDLK_KP_0:
 10.1288 -        return '0';
 10.1289 -    case SDLK_KP_PERIOD:
 10.1290 -        return '.';
 10.1291 -    default:
 10.1292 -        break;                  /* just to avoid a compiler warning */
 10.1293 +    for (i = 0; i < SDL_arraysize(data->key_layout); i++) {
 10.1294 +
 10.1295 +        /* Make sure this scancode is a valid character scancode */
 10.1296 +        scancode = data->key_layout[i];
 10.1297 +        if (scancode == SDL_SCANCODE_UNKNOWN ||
 10.1298 +            (keymap[scancode] & SDLK_SCANCODE_MASK)) {
 10.1299 +            continue;
 10.1300 +        }
 10.1301 +
 10.1302 +        keymap[scancode] =
 10.1303 +            (SDLKey) X11_KeySymToUcs4(XKeycodeToKeysym(data->display, i, 0));
 10.1304      }
 10.1305 -
 10.1306 -    /* Look up physicalKey to get an X11 KeyCode - linear search isn't
 10.1307 -       terribly efficient, this might have to be optimized. */
 10.1308 -    while ((code < KeyCodeTableSize) &&
 10.1309 -           (physicalKey != data->keyCodeToSDLKTable[code])) {
 10.1310 -        code++;
 10.1311 -    }
 10.1312 -
 10.1313 -    if (code == KeyCodeTableSize) {
 10.1314 -        return physicalKey;
 10.1315 -    }
 10.1316 -    /* Get the corresponding KeySym - this is where the keyboard
 10.1317 -       layout comes into play */
 10.1318 -    sym = XKeycodeToKeysym(data->display, code, 0);
 10.1319 -
 10.1320 -    /* Try our own KeySym-to-layout-key-code table: it handles all
 10.1321 -       keys whose layout code is an SDLK_ one, including a few where
 10.1322 -       X11_KeySymToUcs4() would yield a character, but not a suitable
 10.1323 -       one as a key name (e.g. space), and some that are character
 10.1324 -       keys for our purposes, but aren't handled by X11_KeySymToUcs4()
 10.1325 -       (dead keys, keypad operations). */
 10.1326 -
 10.1327 -    layoutKey = X11_KeySymToSDLKey(sym, SDL_FALSE);
 10.1328 -
 10.1329 -    /* If it wasn't handled by X11_KeySymToSDLKey(), it's most
 10.1330 -       probably a plain character KeySym that X11_KeySymToUcs4()
 10.1331 -       (ripped from X.org) knows. */
 10.1332 -
 10.1333 -    if (layoutKey == SDLK_UNKNOWN) {
 10.1334 -        unsigned int ucs = X11_KeySymToUcs4(sym);
 10.1335 -        if (ucs != 0)
 10.1336 -            layoutKey = (SDLKey) ucs;
 10.1337 -    }
 10.1338 -
 10.1339 -    /* Still no success? Give up. */
 10.1340 -    if (layoutKey == SDLK_UNKNOWN) {
 10.1341 -        return physicalKey;
 10.1342 -    }
 10.1343 -
 10.1344 -    return layoutKey;
 10.1345 +    SDL_SetKeymap(data->keyboard, 0, keymap, SDL_NUM_SCANCODES);
 10.1346  }
 10.1347  
 10.1348  void
 10.1349 @@ -1032,18 +401,6 @@
 10.1350  {
 10.1351      SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
 10.1352  
 10.1353 -    if (data->keyCodeToSDLKTable != NULL) {
 10.1354 -        /* If it's not one of the predefined tables, it was malloced
 10.1355 -           and must be freed */
 10.1356 -        SDLKey **table = keyCodeToSDLKeyTables;
 10.1357 -        while (*table != NULL && *table != data->keyCodeToSDLKTable) {
 10.1358 -            table++;
 10.1359 -        }
 10.1360 -        if (*table == NULL)
 10.1361 -            SDL_free(data->keyCodeToSDLKTable);
 10.1362 -        data->keyCodeToSDLKTable = NULL;
 10.1363 -    }
 10.1364 -
 10.1365      SDL_DelKeyboard(data->keyboard);
 10.1366  }
 10.1367  
    11.1 --- a/src/video/x11/SDL_x11keyboard.h	Tue Feb 05 07:30:50 2008 +0000
    11.2 +++ b/src/video/x11/SDL_x11keyboard.h	Thu Feb 07 15:31:09 2008 +0000
    11.3 @@ -25,7 +25,7 @@
    11.4  #define _SDL_x11keyboard_h
    11.5  
    11.6  extern int X11_InitKeyboard(_THIS);
    11.7 -extern SDLKey X11_GetLayoutKey(_THIS, SDLKey physicalKey);
    11.8 +extern void X11_UpdateKeymap(_THIS);
    11.9  extern void X11_QuitKeyboard(_THIS);
   11.10  
   11.11  #endif /* _SDL_x11keyboard_h */
    12.1 --- a/src/video/x11/SDL_x11sym.h	Tue Feb 05 07:30:50 2008 +0000
    12.2 +++ b/src/video/x11/SDL_x11sym.h	Thu Feb 07 15:31:09 2008 +0000
    12.3 @@ -48,6 +48,7 @@
    12.4  SDL_X11_SYM(int,XDefineCursor,(Display* a,Window b,Cursor c),(a,b,c),return)
    12.5  SDL_X11_SYM(int,XDeleteProperty,(Display* a,Window b,Atom c),(a,b,c),return)
    12.6  SDL_X11_SYM(int,XDestroyWindow,(Display* a,Window b),(a,b),return)
    12.7 +SDL_X11_SYM(int,XDisplayKeycodes,(Display* a,int* b,int* c),(a,b,c),return)
    12.8  SDL_X11_SYM(char*,XDisplayName,(_Xconst char* a),(a),return)
    12.9  SDL_X11_SYM(int,XEventsQueued,(Display* a,int b),(a,b),return)
   12.10  SDL_X11_SYM(Bool,XFilterEvent,(XEvent *event,Window w),(event,w),return)
   12.11 @@ -73,6 +74,7 @@
   12.12  SDL_X11_SYM(Status,XIconifyWindow,(Display* a,Window b,int c),(a,b,c),return)
   12.13  SDL_X11_SYM(int,XInstallColormap,(Display* a,Colormap b),(a,b),return)
   12.14  SDL_X11_SYM(KeyCode,XKeysymToKeycode,(Display* a,KeySym b),(a,b),return)
   12.15 +SDL_X11_SYM(char*,XKeysymToString,(KeySym a),(a),return)
   12.16  SDL_X11_SYM(int,XKillClient,(Display* a,XID b),(a,b),return)
   12.17  SDL_X11_SYM(Atom,XInternAtom,(Display* a,_Xconst char* b,Bool c),(a,b,c),return)
   12.18  SDL_X11_SYM(XPixmapFormatValues*,XListPixmapFormats,(Display* a,int* b),(a,b),return)
    13.1 --- a/src/video/x11/SDL_x11video.c	Tue Feb 05 07:30:50 2008 +0000
    13.2 +++ b/src/video/x11/SDL_x11video.c	Thu Feb 07 15:31:09 2008 +0000
    13.3 @@ -171,7 +171,6 @@
    13.4      device->SetDisplayGammaRamp = X11_SetDisplayGammaRamp;
    13.5      device->GetDisplayGammaRamp = X11_GetDisplayGammaRamp;
    13.6      device->PumpEvents = X11_PumpEvents;
    13.7 -    device->GetLayoutKey = X11_GetLayoutKey;
    13.8  
    13.9      device->CreateWindow = X11_CreateWindow;
   13.10      device->CreateWindowFrom = X11_CreateWindowFrom;
    14.1 --- a/src/video/x11/SDL_x11video.h	Tue Feb 05 07:30:50 2008 +0000
    14.2 +++ b/src/video/x11/SDL_x11video.h	Thu Feb 07 15:31:09 2008 +0000
    14.3 @@ -70,7 +70,7 @@
    14.4      int mouse;
    14.5      int keyboard;
    14.6      Atom WM_DELETE_WINDOW;
    14.7 -    SDLKey *keyCodeToSDLKTable;
    14.8 +    SDL_scancode key_layout[256];
    14.9  } SDL_VideoData;
   14.10  
   14.11  #endif /* _SDL_x11video_h */
    15.1 --- a/test/checkkeys.c	Tue Feb 05 07:30:50 2008 +0000
    15.2 +++ b/test/checkkeys.c	Thu Feb 07 15:31:09 2008 +0000
    15.3 @@ -91,6 +91,7 @@
    15.4  static void
    15.5  PrintText(char *text)
    15.6  {
    15.7 +    printf("Text: %s\n", text);
    15.8  }
    15.9  
   15.10  int
   15.11 @@ -124,13 +125,6 @@
   15.12          quit(2);
   15.13      }
   15.14  
   15.15 -    /* Enable UNICODE translation for keyboard input */
   15.16 -    SDL_EnableUNICODE(1);
   15.17 -
   15.18 -    /* Enable auto repeat for keyboard input */
   15.19 -    SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,
   15.20 -                        SDL_DEFAULT_REPEAT_INTERVAL);
   15.21 -
   15.22      /* Watch keystrokes */
   15.23      done = 0;
   15.24      while (!done) {