First pass implementation of new SDL scancode concept, as discussed with
authorSam Lantinga <slouken@libsdl.org>
Tue, 05 Feb 2008 07:19:23 +0000
changeset 2303d87417504c75
parent 2302 7ae1c419b626
child 2304 50f58ce12497
First pass implementation of new SDL scancode concept, as discussed with
Christian Walther. Currently only implemented on Mac OS X for sanity
checking purposes.
Makefile.in
include/SDL_compat.h
include/SDL_keyboard.h
include/SDL_keysym.h
include/SDL_scancode.h
src/SDL_compat.c
src/events/SDL_keyboard.c
src/events/SDL_keyboard_c.h
src/events/SDL_keynames.h
src/video/SDL_sysvideo.h
src/video/cocoa/SDL_cocoakeyboard.h
src/video/cocoa/SDL_cocoakeyboard.m
src/video/cocoa/SDL_cocoakeys.h
src/video/cocoa/SDL_cocoavideo.h
src/video/cocoa/SDL_cocoavideo.m
test/checkkeys.c
     1.1 --- a/Makefile.in	Mon Feb 04 17:25:33 2008 +0000
     1.2 +++ b/Makefile.in	Tue Feb 05 07:19:23 2008 +0000
     1.3 @@ -42,7 +42,7 @@
     1.4  
     1.5  DIST = acinclude.m4 autogen.sh Borland.html Borland.zip BUGS build-scripts configure configure.in COPYING CREDITS docs docs.html include INSTALL Makefile.dc Makefile.minimal Makefile.in README* sdl-config.in sdl.m4 sdl.pc.in SDL.qpg.in SDL.spec SDL.spec.in src test TODO VisualC.html VisualC VisualCE Watcom-OS2.zip Watcom-Win32.zip WhatsNew Xcode
     1.6  
     1.7 -HDRS = SDL.h SDL_audio.h SDL_cdrom.h SDL_compat.h SDL_cpuinfo.h SDL_endian.h SDL_error.h SDL_events.h SDL_joystick.h SDL_keyboard.h SDL_keysym.h SDL_loadso.h SDL_main.h SDL_mouse.h SDL_mutex.h SDL_name.h SDL_opengl.h SDL_pixels.h SDL_platform.h SDL_quit.h SDL_rect.h SDL_rwops.h SDL_stdinc.h SDL_surface.h SDL_syswm.h SDL_thread.h SDL_timer.h SDL_types.h SDL_version.h SDL_video.h begin_code.h close_code.h
     1.8 +HDRS = SDL.h SDL_audio.h SDL_cdrom.h SDL_compat.h SDL_cpuinfo.h SDL_endian.h SDL_error.h SDL_events.h SDL_joystick.h SDL_keyboard.h SDL_keysym.h SDL_loadso.h SDL_main.h SDL_mouse.h SDL_mutex.h SDL_name.h SDL_opengl.h SDL_pixels.h SDL_platform.h SDL_quit.h SDL_rect.h SDL_rwops.h SDL_scancode.h SDL_stdinc.h SDL_surface.h SDL_syswm.h SDL_thread.h SDL_timer.h SDL_types.h SDL_version.h SDL_video.h begin_code.h close_code.h
     1.9  
    1.10  LT_AGE      = @LT_AGE@
    1.11  LT_CURRENT  = @LT_CURRENT@
     2.1 --- a/include/SDL_compat.h	Mon Feb 04 17:25:33 2008 +0000
     2.2 +++ b/include/SDL_compat.h	Tue Feb 05 07:19:23 2008 +0000
     2.3 @@ -130,47 +130,54 @@
     2.4  
     2.5  struct SDL_SysWMinfo;
     2.6  
     2.7 -/* Key codes
     2.8 -   Note that the correspondences defined here are approximate at best because
     2.9 -   the meaning of the event structure field that carries these values has
    2.10 -   changed: in SDL 1.2, it referred to the key's label in the current keyboard
    2.11 -   layout, whereas now it refers to a specific physical key on the keyboard,
    2.12 -   regardless of the keyboard layout setting.
    2.13 -   To get comparable behavior to SDL 1.2, code that uses any of the codes below
    2.14 -   in ways like "if (somekey == SDLK_EXCLAIM)" should be changed to the
    2.15 -   equivalent of "if (SDL_GetLayoutKey(somekey) == '!')".
    2.16 - */
    2.17 +/* Obsolete or renamed key codes */
    2.18  
    2.19 -/* These key constants were renamed for clarity or consistence. */
    2.20 -#define SDLK_QUOTE SDLK_APOSTROPHE
    2.21 -#define SDLK_MINUS SDLK_HYPHENMINUS
    2.22 -#define SDLK_BACKQUOTE SDLK_GRAVE
    2.23 -#define SDLK_a SDLK_A
    2.24 -#define SDLK_b SDLK_B
    2.25 -#define SDLK_c SDLK_C
    2.26 -#define SDLK_d SDLK_D
    2.27 -#define SDLK_e SDLK_E
    2.28 -#define SDLK_f SDLK_F
    2.29 -#define SDLK_g SDLK_G
    2.30 -#define SDLK_h SDLK_H
    2.31 -#define SDLK_i SDLK_I
    2.32 -#define SDLK_j SDLK_J
    2.33 -#define SDLK_k SDLK_K
    2.34 -#define SDLK_l SDLK_L
    2.35 -#define SDLK_m SDLK_M
    2.36 -#define SDLK_n SDLK_N
    2.37 -#define SDLK_o SDLK_O
    2.38 -#define SDLK_p SDLK_P
    2.39 -#define SDLK_q SDLK_Q
    2.40 -#define SDLK_r SDLK_R
    2.41 -#define SDLK_s SDLK_S
    2.42 -#define SDLK_t SDLK_T
    2.43 -#define SDLK_u SDLK_U
    2.44 -#define SDLK_v SDLK_V
    2.45 -#define SDLK_w SDLK_W
    2.46 -#define SDLK_x SDLK_X
    2.47 -#define SDLK_y SDLK_Y
    2.48 -#define SDLK_z SDLK_Z
    2.49 +/* These key constants were renamed for clarity or consistency. */
    2.50 +#define SDLK_a  'a'
    2.51 +#define SDLK_b  'b'
    2.52 +#define SDLK_c  'c'
    2.53 +#define SDLK_d  'd'
    2.54 +#define SDLK_e  'e'
    2.55 +#define SDLK_f  'f'
    2.56 +#define SDLK_g  'g'
    2.57 +#define SDLK_h  'h'
    2.58 +#define SDLK_i  'i'
    2.59 +#define SDLK_j  'j'
    2.60 +#define SDLK_k  'k'
    2.61 +#define SDLK_l  'l'
    2.62 +#define SDLK_m  'm'
    2.63 +#define SDLK_n  'n'
    2.64 +#define SDLK_o  'o'
    2.65 +#define SDLK_p  'p'
    2.66 +#define SDLK_q  'q'
    2.67 +#define SDLK_r  'r'
    2.68 +#define SDLK_s  's'
    2.69 +#define SDLK_t  't'
    2.70 +#define SDLK_u  'u'
    2.71 +#define SDLK_v  'v'
    2.72 +#define SDLK_w  'w'
    2.73 +#define SDLK_x  'x'
    2.74 +#define SDLK_y  'y'
    2.75 +#define SDLK_z  'z'
    2.76 +#define SDLK_QUOTE      '\''
    2.77 +#define SDLK_MINUS      '-'
    2.78 +#define SDLK_BACKQUOTE  '`'
    2.79 +#define SDLK_EXCLAIM    '!'
    2.80 +#define SDLK_QUOTEDBL   '"'
    2.81 +#define SDLK_HASH       '#'
    2.82 +#define SDLK_DOLLAR     '$'
    2.83 +#define SDLK_AMPERSAND  '&'
    2.84 +#define SDLK_LEFTPAREN  '('
    2.85 +#define SDLK_RIGHTPAREN ')'
    2.86 +#define SDLK_ASTERISK   '*'
    2.87 +#define SDLK_PLUS       '+'
    2.88 +#define SDLK_COLON      ':'
    2.89 +#define SDLK_LESS       '<'
    2.90 +#define SDLK_GREATER    '>'
    2.91 +#define SDLK_QUESTION   '?'
    2.92 +#define SDLK_AT         '@'
    2.93 +#define SDLK_CARET      '^'
    2.94 +#define SDLK_UNDERSCORE '_'
    2.95  #define SDLK_KP0 SDLK_KP_0
    2.96  #define SDLK_KP1 SDLK_KP_1
    2.97  #define SDLK_KP2 SDLK_KP_2
    2.98 @@ -181,30 +188,14 @@
    2.99  #define SDLK_KP7 SDLK_KP_7
   2.100  #define SDLK_KP8 SDLK_KP_8
   2.101  #define SDLK_KP9 SDLK_KP_9
   2.102 -#define SDLK_NUMLOCK SDLK_KP_NUMLOCKCLEAR
   2.103 +#define SDLK_NUMLOCK SDLK_NUMLOCKCLEAR
   2.104  #define SDLK_SCROLLOCK SDLK_SCROLLLOCK
   2.105  #define SDLK_PRINT SDLK_PRINTSCREEN
   2.106  
   2.107 -/* These key constants are obsoleted by the new keyboard handling,
   2.108 -   their definitions here correspond to how they appear on a US
   2.109 -   keyboard. */
   2.110 -
   2.111 -#define SDLK_EXCLAIM SDLK_1
   2.112 -#define SDLK_QUOTEDBL SDLK_APOSTROPHE
   2.113 -#define SDLK_HASH SDLK_3
   2.114 -#define SDLK_DOLLAR SDLK_4
   2.115 -#define SDLK_AMPERSAND SDLK_7
   2.116 -#define SDLK_LEFTPAREN SDLK_9
   2.117 -#define SDLK_RIGHTPAREN SDLK_0
   2.118 -#define SDLK_ASTERISK SDLK_8
   2.119 -#define SDLK_PLUS SDLK_EQUALS
   2.120 -#define SDLK_COLON SDLK_SEMICOLON
   2.121 -#define SDLK_LESS SDLK_COMMA
   2.122 -#define SDLK_GREATER SDLK_PERIOD
   2.123 -#define SDLK_QUESTION SDLK_SLASH
   2.124 -#define SDLK_AT SDLK_2
   2.125 -#define SDLK_CARET SDLK_6
   2.126 -#define SDLK_UNDERSCORE SDLK_HYPHENMINUS
   2.127 +/* The META modifier is equivalent to the GUI modifier from the USB standard */
   2.128 +#define KMOD_LMETA KMOD_LGUI
   2.129 +#define KMOD_RMETA KMOD_RGUI
   2.130 +#define KMOD_META KMOD_GUI
   2.131  
   2.132  /* These keys don't appear in the USB specification (or at least not under those names). I'm unsure if the following assignments make sense or if these codes should be defined as actual additional SDLK_ constants. */
   2.133  #define SDLK_LSUPER SDLK_LMETA
   2.134 @@ -268,6 +259,7 @@
   2.135  extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers(void);
   2.136  extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval);
   2.137  extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval);
   2.138 +extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable);
   2.139  
   2.140  /* Ends C function definitions when using C++ */
   2.141  #ifdef __cplusplus
     3.1 --- a/include/SDL_keyboard.h	Mon Feb 04 17:25:33 2008 +0000
     3.2 +++ b/include/SDL_keyboard.h	Tue Feb 05 07:19:23 2008 +0000
     3.3 @@ -48,8 +48,7 @@
     3.4   */
     3.5  typedef struct SDL_keysym
     3.6  {
     3.7 -    Uint8 scancode;             /**< keyboard specific scancode */
     3.8 -    Uint8 padding[3];           /**< alignment padding */
     3.9 +    SDL_scancode scancode;      /**< SDL physical key code - see ::SDL_scancode for details */
    3.10      SDLKey sym;                 /**< SDL virtual key code - see ::SDLKey for details */
    3.11      Uint16 mod;                 /**< current key modifiers */
    3.12      Uint32 unicode;             /**< OBSOLETE, use SDL_TextInputEvent instead */
    3.13 @@ -80,32 +79,19 @@
    3.14  extern DECLSPEC int SDLCALL SDL_SelectKeyboard(int index);
    3.15  
    3.16  /**
    3.17 - * \fn int SDL_EnableUNICODE(int enable)
    3.18 - *
    3.19 - * \brief Enable/Disable UNICODE translation of keyboard input.
    3.20 - *
    3.21 - * \param enable 1 to enable translation, 0 to disable translation, -1 to query translation
    3.22 - *
    3.23 - * \return The previous state of keyboard translation
    3.24 - *
    3.25 - * \note This translation has some overhead, so translation defaults off.
    3.26 - */
    3.27 -extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable);
    3.28 -
    3.29 -/**
    3.30 - * \fn Uint8 *SDL_GetKeyState(int *numkeys)
    3.31 + * \fn Uint8 *SDL_GetKeyboardState(int *numkeys)
    3.32   *
    3.33   * \brief Get a snapshot of the current state of the selected keyboard.
    3.34   *
    3.35   * \param numkeys if non-NULL, receives the length of the returned array.
    3.36   *
    3.37 - * \return An array of key states. Indexes into this array are obtained by using the SDLK_INDEX() macro on the \link ::SDLPhysicalKey SDLK_* \endlink syms.
    3.38 + * \return An array of key states. Indexes into this array are obtained by using ::SDL_scancode values.
    3.39   *
    3.40   * Example:
    3.41 - * 	Uint8 *keystate = SDL_GetKeyState(NULL);
    3.42 - *	if ( keystate[SDLK_INDEX(SDLK_RETURN)] ) ... <RETURN> is pressed.
    3.43 + * 	Uint8 *state = SDL_GetKeyboardState(NULL);
    3.44 + *	if ( state[SDL_SCANCODE_RETURN)] ) ... <RETURN> is pressed.
    3.45   */
    3.46 -extern DECLSPEC Uint8 *SDLCALL SDL_GetKeyState(int *numkeys);
    3.47 +extern DECLSPEC Uint8 *SDLCALL SDL_GetKeyboardState(int *numkeys);
    3.48  
    3.49  /**
    3.50   * \fn SDLMod SDL_GetModState(void)
    3.51 @@ -124,32 +110,49 @@
    3.52  extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate);
    3.53  
    3.54  /**
    3.55 - * \fn SDLKey SDL_GetLayoutKey(SDLKey physicalKey)
    3.56 + * \fn SDLKey SDL_GetKeyFromScancode(SDL_scancode scancode)
    3.57   * 
    3.58 - * \brief Get the layout key code corresponding to the given physical key code according to the current keyboard layout.
    3.59 + * \brief Get the key code corresponding to the given scancode according to the current keyboard layout.
    3.60   *
    3.61   * See ::SDLKey for details.
    3.62   *
    3.63 - * If \a physicalKey is not a physical key code, it is returned unchanged.
    3.64 - *
    3.65   * \sa SDL_GetKeyName()
    3.66   */
    3.67 -extern DECLSPEC SDLKey SDLCALL SDL_GetLayoutKey(SDLKey physicalKey);
    3.68 +extern DECLSPEC SDLKey SDLCALL SDL_GetKeyFromScancode(SDL_scancode scancode);
    3.69  
    3.70  /**
    3.71 - * \fn const char *SDL_GetKeyName(SDLKey layoutKey)
    3.72 + * \fn SDL_scancode SDL_GetScancodeFromKey(SDLKey key)
    3.73 + * 
    3.74 + * \brief Get the scancode corresponding to the given key code according to the current keyboard layout.
    3.75 + *
    3.76 + * See ::SDL_scancode for details.
    3.77 + *
    3.78 + * \sa SDL_GetScancodeName()
    3.79 + */
    3.80 +extern DECLSPEC SDL_scancode SDLCALL SDL_GetScancodeFromKey(SDLKey key);
    3.81 +
    3.82 +/**
    3.83 + * \fn const char *SDL_GetScancodeName(SDL_scancode scancode)
    3.84 + * 
    3.85 + * \brief Get a human-readable name for a scancode.
    3.86 + *
    3.87 + * \return A pointer to a UTF-8 string that stays valid at least until the next call to this function. If you need it around any longer, you must copy it.  If the scancode doesn't have a name, this function returns "".
    3.88 + *
    3.89 + * \sa SDL_scancode
    3.90 + */
    3.91 +extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_scancode
    3.92 +                                                        scancode);
    3.93 +
    3.94 +/**
    3.95 + * \fn const char *SDL_GetKeyName(SDLKey key)
    3.96   * 
    3.97   * \brief Get a human-readable name for a key.
    3.98   *
    3.99 - * \param layoutKey An SDL layout key code.
   3.100 - *
   3.101 - * If what you have is a physical key code, e.g. from the \link SDL_keysym::sym key.keysym.sym \endlink field of the SDL_Event structure, convert it to a layout key code using SDL_GetLayoutKey() first. Doing this ensures that the returned name matches what users see on their keyboards. Calling this function directly on a physical key code (that is not also a layout key code) is possible, but is not recommended except for debugging purposes. The name returned in that case is the name of the \link ::SDLPhysicalKey SDLK_* \endlink constant and is not suitable for display to users.
   3.102 - *
   3.103 - * \return A pointer to a UTF-8 string that stays valid at least until the next call to this function. If you need it around any longer, you must copy it. Always non-NULL.
   3.104 + * \return A pointer to a UTF-8 string that stays valid at least until the next call to this function. If you need it around any longer, you must copy it.  If the key doesn't have a name, this function returns "".
   3.105   *
   3.106   * \sa SDLKey
   3.107   */
   3.108 -extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDLKey layoutKey);
   3.109 +extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDLKey key);
   3.110  
   3.111  
   3.112  /* Ends C function definitions when using C++ */
     4.1 --- a/include/SDL_keysym.h	Mon Feb 04 17:25:33 2008 +0000
     4.2 +++ b/include/SDL_keysym.h	Tue Feb 05 07:19:23 2008 +0000
     4.3 @@ -28,413 +28,222 @@
     4.4  #define _SDL_keysym_h
     4.5  
     4.6  #include "SDL_stdinc.h"
     4.7 +#include "SDL_scancode.h"
     4.8  
     4.9  /**
    4.10   * \typedef SDLKey
    4.11   *
    4.12   * \brief The SDL virtual key representation.
    4.13   *
    4.14 - * Values of this type are used to represent keyboard keys, among other places
    4.15 - * in the \link SDL_keysym::sym key.keysym.sym \endlink field of the SDL_Event
    4.16 - * structure.
    4.17 - *
    4.18 - * There are two fundamental ways of referring to a key: First, a certain code
    4.19 - * can stand for a key at a specific physical location on the keyboard,
    4.20 - * independent of its label or what character it generates. These are the \e
    4.21 - * physical key codes, comparable to the raw hardware scancodes that a keyboard
    4.22 - * generates. Second, a code can refer to a key with a specific label,
    4.23 - * generating a specific character or performing a specific function, which may
    4.24 - * be located at different places on the keyboard, or not exist at all,
    4.25 - * depending on what keyboard layout is used. These are \e layout key codes.
    4.26 - *
    4.27 - * There is a certain overlap between the sets of physical key codes and layout
    4.28 - * key codes: \e return, \e tab, \e ctrl etc. are typically independent of the
    4.29 - * keyboard layout and can be thought of as either a physical or a layout key.
    4.30 - * Therefore, rather than having separate types with separate sets of constants
    4.31 - * for physical keys and layout keys, a single type ::SDLKey is used for both
    4.32 - * sets. The physical key codes (forming a well-known set of a few hundred
    4.33 - * elements) are enumerated in enum ::SDLPhysicalKey. The set of layout key
    4.34 - * codes is more diverse: For keys that don't generate characters, the layout
    4.35 - * key code is equal to the physical key code, i.e. the same SDLK_* constants
    4.36 - * from enum ::SDLPhysicalKey are used. For character keys, the layout key code
    4.37 - * is equal to the Unicode code point of the character that is generated when
    4.38 - * the key is pressed without shift or any other modifiers (for ASCII
    4.39 - * characters, this can be directly written as a character literal like
    4.40 - * <tt>'x'</tt>).
    4.41 - *
    4.42 - * The \link SDL_keysym::sym key.keysym.sym \endlink field of the SDL_Event
    4.43 - * structure is always a physical key code. To get the layout key code for the
    4.44 - * event, run that physical key code through SDL_GetLayoutKey(), which converts
    4.45 - * it to a layout key code according to the current keyboard layout settings of
    4.46 - * the OS. In particular, this is what should be done when displaying the name
    4.47 - * of a key to the user: use
    4.48 - * <tt>SDL_GetKeyName(SDL_GetLayoutKey(myPhysicalKeyCode))</tt>. Do not use
    4.49 - * SDL_GetKeyName() directly on a physical key code (except for debugging
    4.50 - * purposes), as the name returned by that will not correspond to how the key
    4.51 - * is labeled on the user's keyboard.
    4.52 - *
    4.53 - * \par Example:
    4.54 - * To implement WASD directional keys, it makes sense to use physical key
    4.55 - * codes, so that the "forward" key will be above the "backward" key even
    4.56 - * though, for example, it's labeled "Z", not "W", on a French keyboard:
    4.57 - * \code
    4.58 - * print("To go forward, press the %s key.", SDL_GetKeyName(SDL_GetLayoutKey(SDLK_W)));
    4.59 - * ...
    4.60 - * switch (event.key.keysym.sym) {
    4.61 - *     case SDLK_W:
    4.62 - *         forward();
    4.63 - *         break;
    4.64 - *     case SDLK_A:
    4.65 - *         left();
    4.66 - *         break;
    4.67 - *     ...
    4.68 - * }
    4.69 - * \endcode
    4.70 - * For keys based on mnemonics like "I for inventory" or "Z for zoom", use
    4.71 - * layout key codes, so that the key labeled "Z" will zoom, whether it's at the
    4.72 - * bottom left of the keyboard like on a US layout, or in the upper center like
    4.73 - * on a German layout (but keep in mind that this forces your users to use a
    4.74 - * keyboard layout where there \e is an I or Z key):
    4.75 - * \code
    4.76 - * print("To open the inventory, press the %s key.", SDL_GetKeyName('i'));
    4.77 - * ...
    4.78 - * switch (SDL_GetLayoutKey(event.key.keysym.sym)) {
    4.79 - *     case 'i':
    4.80 - *         inventory();
    4.81 - *         break;
    4.82 - *     case 'z':
    4.83 - *         zoom();
    4.84 - *         break;
    4.85 - *     ...
    4.86 - * }
    4.87 - * \endcode
    4.88 - * Of course, in a real application, you should not hardcode your key
    4.89 - * assignments like this, but make them user-configurable.
    4.90 + * Values of this type are used to represent keyboard keys using the current
    4.91 + * layout of the keyboard.  These values include Unicode values representing
    4.92 + * the unmodified character that would be generated by pressing the key, or
    4.93 + * an SDLK_* constant for those keys that do not generate characters.
    4.94   */
    4.95 -typedef Uint32 SDLKey;
    4.96 +typedef Sint32 SDLKey;
    4.97  
    4.98 -#define SDL_KEY_CAN_BE_PHYSICAL_BIT (1<<24)     /* marks SDLKeys from the "physical" set (some of these are also in the "layout" set) */
    4.99 -#define SDL_KEY_KEYPAD_BIT (1<<25)      /* marks keypad keys that need [] around their name to distinguish them from the corresponding keyboard keys */
   4.100 -#define SDL_KEY_LAYOUT_SPECIAL_BIT (1<<26)      /* marks non-physical layout keys that cannot be described by a single character */
   4.101 +#define SDLK_SCANCODE_MASK (1<<30)
   4.102 +#define SDL_SCANCODE_TO_KEYCODE(X)	(X | SDLK_SCANCODE_MASK)
   4.103  
   4.104 -/** Converts an \link ::SDLPhysicalKey SDLK_* \endlink constant to an index into the array obtained from SDL_GetKeyState(). */
   4.105 -#define SDLK_INDEX(k) ((k) & 0x00FFFFFF)
   4.106 +enum
   4.107 +{
   4.108 +    SDLK_UNKNOWN = 0,
   4.109  
   4.110 -#define SDL_PHYSICAL_KEY(n) ((n) | SDL_KEY_CAN_BE_PHYSICAL_BIT)
   4.111 +    SDLK_RETURN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RETURN),
   4.112 +    SDLK_ESCAPE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_ESCAPE),
   4.113 +    SDLK_BACKSPACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_BACKSPACE),
   4.114 +    SDLK_TAB = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_TAB),
   4.115 +    SDLK_SPACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SPACE),
   4.116  
   4.117 -/**
   4.118 - * \brief SDL physical key codes.
   4.119 - *
   4.120 - * This is the set of physical key codes, i.e. the values of SDL_keysym::sym.
   4.121 - * Some of them (those for non-character keys) also appear as layout key codes.
   4.122 - * The constants are typically named after how the key would be labeled on a US
   4.123 - * keyboard, e.g. SDLK_A or SDLK_LEFTBRACKET refer to the keys used as A and [
   4.124 - * on a US layout, but used as Q and ^ on a French layout.
   4.125 - *
   4.126 - * <em>enum SDLPhysicalKey</em> is not a useful type in its own right - the
   4.127 - * constants defined here are intended as values of the ::SDLKey type. The only
   4.128 - * reason for the enum to have a name at all is that otherwise it would be
   4.129 - * impossible to refer to it in the documentation.
   4.130 - *
   4.131 - * \sa SDLKey
   4.132 - *
   4.133 - * \par Notes for driver implementors:
   4.134 - * These constants and their numerical values are based on the USB HID usage
   4.135 - * tables, version 1.12
   4.136 - * <http://www.usb.org/developers/devclass_docs/Hut1_12.pdf>, section "10
   4.137 - * Keyboard/Keypad Page (0x07)". When deciding what code to generate for what
   4.138 - * key, the following rules can be used as guidelines:
   4.139 - * - A given key on a given keyboard should produce the same SDLK_* code, no
   4.140 - * matter what computer it is connected to, what OS runs on that computer, and
   4.141 - * what the keyboard layout settings in the OS are. For USB keyboards, that
   4.142 - * should be the code numerically corresponding to the key's USB usage code
   4.143 - * (with exceptions, see comments for specific constants).
   4.144 - * - Two keys on two different keyboards are considered "the same key" and
   4.145 - * should generate the same SDLK_* code if, when connected to the same
   4.146 - * computer, they are treated equally by the OS. For USB keyboards, that's
   4.147 - * generally the case when they generate the same USB usage code. Non-USB
   4.148 - * keyboards can probably be treated like USB keyboards of the same layout, if
   4.149 - * such exist. If not, and there's no possibility to determine the equivalence
   4.150 - * relation by transitivity from the above - in particular, on devices like
   4.151 - * phones or game consoles that don't have PC-style alphabetic keyboards -
   4.152 - * apply common sense. If none of the predefined codes fit, insert new ones at
   4.153 - * the end.
   4.154 - */
   4.155 -enum SDLPhysicalKey
   4.156 -{
   4.157 -    SDLK_FIRST_PHYSICAL = 0, /**< (not a key, just marks the lowest used value in this enum) */
   4.158 -    SDLK_NONE = SDL_PHYSICAL_KEY(0),
   4.159 -    SDLK_UNKNOWN = SDL_PHYSICAL_KEY(1), /* Not from the USB spec, but this is a convenient place for it */
   4.160 +    SDLK_CAPSLOCK = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CAPSLOCK),
   4.161  
   4.162 -    SDLK_A = SDL_PHYSICAL_KEY(4),
   4.163 -    SDLK_B = SDL_PHYSICAL_KEY(5),
   4.164 -    SDLK_C = SDL_PHYSICAL_KEY(6),
   4.165 -    SDLK_D = SDL_PHYSICAL_KEY(7),
   4.166 -    SDLK_E = SDL_PHYSICAL_KEY(8),
   4.167 -    SDLK_F = SDL_PHYSICAL_KEY(9),
   4.168 -    SDLK_G = SDL_PHYSICAL_KEY(10),
   4.169 -    SDLK_H = SDL_PHYSICAL_KEY(11),
   4.170 -    SDLK_I = SDL_PHYSICAL_KEY(12),
   4.171 -    SDLK_J = SDL_PHYSICAL_KEY(13),
   4.172 -    SDLK_K = SDL_PHYSICAL_KEY(14),
   4.173 -    SDLK_L = SDL_PHYSICAL_KEY(15),
   4.174 -    SDLK_M = SDL_PHYSICAL_KEY(16),
   4.175 -    SDLK_N = SDL_PHYSICAL_KEY(17),
   4.176 -    SDLK_O = SDL_PHYSICAL_KEY(18),
   4.177 -    SDLK_P = SDL_PHYSICAL_KEY(19),
   4.178 -    SDLK_Q = SDL_PHYSICAL_KEY(20),
   4.179 -    SDLK_R = SDL_PHYSICAL_KEY(21),
   4.180 -    SDLK_S = SDL_PHYSICAL_KEY(22),
   4.181 -    SDLK_T = SDL_PHYSICAL_KEY(23),
   4.182 -    SDLK_U = SDL_PHYSICAL_KEY(24),
   4.183 -    SDLK_V = SDL_PHYSICAL_KEY(25),
   4.184 -    SDLK_W = SDL_PHYSICAL_KEY(26),
   4.185 -    SDLK_X = SDL_PHYSICAL_KEY(27),
   4.186 -    SDLK_Y = SDL_PHYSICAL_KEY(28),
   4.187 -    SDLK_Z = SDL_PHYSICAL_KEY(29),
   4.188 +    SDLK_F1 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F1),
   4.189 +    SDLK_F2 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F2),
   4.190 +    SDLK_F3 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F3),
   4.191 +    SDLK_F4 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F4),
   4.192 +    SDLK_F5 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F5),
   4.193 +    SDLK_F6 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F6),
   4.194 +    SDLK_F7 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F7),
   4.195 +    SDLK_F8 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F8),
   4.196 +    SDLK_F9 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F9),
   4.197 +    SDLK_F10 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F10),
   4.198 +    SDLK_F11 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F11),
   4.199 +    SDLK_F12 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F12),
   4.200  
   4.201 -    SDLK_1 = SDL_PHYSICAL_KEY(30),
   4.202 -    SDLK_2 = SDL_PHYSICAL_KEY(31),
   4.203 -    SDLK_3 = SDL_PHYSICAL_KEY(32),
   4.204 -    SDLK_4 = SDL_PHYSICAL_KEY(33),
   4.205 -    SDLK_5 = SDL_PHYSICAL_KEY(34),
   4.206 -    SDLK_6 = SDL_PHYSICAL_KEY(35),
   4.207 -    SDLK_7 = SDL_PHYSICAL_KEY(36),
   4.208 -    SDLK_8 = SDL_PHYSICAL_KEY(37),
   4.209 -    SDLK_9 = SDL_PHYSICAL_KEY(38),
   4.210 -    SDLK_0 = SDL_PHYSICAL_KEY(39),
   4.211 +    SDLK_PRINTSCREEN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PRINTSCREEN),
   4.212 +    SDLK_SCROLLLOCK = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SCROLLLOCK),
   4.213 +    SDLK_PAUSE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAUSE),
   4.214 +    SDLK_INSERT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_INSERT),
   4.215 +    SDLK_HOME = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_HOME),
   4.216 +    SDLK_PAGEUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAGEUP),
   4.217 +    SDLK_DELETE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_DELETE),
   4.218 +    SDLK_END = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_END),
   4.219 +    SDLK_PAGEDOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAGEDOWN),
   4.220 +    SDLK_RIGHT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RIGHT),
   4.221 +    SDLK_LEFT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LEFT),
   4.222 +    SDLK_DOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_DOWN),
   4.223 +    SDLK_UP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_UP),
   4.224  
   4.225 -    SDLK_RETURN = SDL_PHYSICAL_KEY(40),
   4.226 -    SDLK_ESCAPE = SDL_PHYSICAL_KEY(41),
   4.227 -    SDLK_BACKSPACE = SDL_PHYSICAL_KEY(42),
   4.228 -    SDLK_TAB = SDL_PHYSICAL_KEY(43),
   4.229 -    SDLK_SPACE = SDL_PHYSICAL_KEY(44),
   4.230 +    SDLK_NUMLOCKCLEAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_NUMLOCKCLEAR),
   4.231 +    SDLK_KP_DIVIDE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DIVIDE),
   4.232 +    SDLK_KP_MULTIPLY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MULTIPLY),
   4.233 +    SDLK_KP_MINUS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MINUS),
   4.234 +    SDLK_KP_PLUS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PLUS),
   4.235 +    SDLK_KP_ENTER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_ENTER),
   4.236 +    SDLK_KP_1 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_1),
   4.237 +    SDLK_KP_2 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_2),
   4.238 +    SDLK_KP_3 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_3),
   4.239 +    SDLK_KP_4 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_4),
   4.240 +    SDLK_KP_5 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_5),
   4.241 +    SDLK_KP_6 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_6),
   4.242 +    SDLK_KP_7 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_7),
   4.243 +    SDLK_KP_8 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_8),
   4.244 +    SDLK_KP_9 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_9),
   4.245 +    SDLK_KP_0 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_0),
   4.246 +    SDLK_KP_PERIOD = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PERIOD),
   4.247  
   4.248 -    SDLK_HYPHENMINUS = SDL_PHYSICAL_KEY(45),
   4.249 -    SDLK_EQUALS = SDL_PHYSICAL_KEY(46),
   4.250 -    SDLK_LEFTBRACKET = SDL_PHYSICAL_KEY(47),
   4.251 -    SDLK_RIGHTBRACKET = SDL_PHYSICAL_KEY(48),
   4.252 -    SDLK_BACKSLASH = SDL_PHYSICAL_KEY(49), /**< Located at the lower left of the return key on ISO keyboards and at the right end of the QWERTY row on ANSI keyboards. Produces REVERSE SOLIDUS (backslash) and VERTICAL LINE in a US layout, REVERSE SOLIDUS and VERTICAL LINE in a UK Mac layout, NUMBER SIGN and TILDE in a UK Windows layout, DOLLAR SIGN and POUND SIGN in a Swiss German layout, NUMBER SIGN and APOSTROPHE in a German layout, GRAVE ACCENT and POUND SIGN in a French Mac layout, and ASTERISK and MICRO SIGN in a French Windows layout. */
   4.253 -    SDLK_NONUSHASH = SDL_PHYSICAL_KEY(50), /**< ISO USB keyboards actually use this code instead of 49 for the same key, but all OSes I've seen treat the two codes identically. So, as an implementor, unless your keyboard generates both of those codes and your OS treats them differently, you should generate SDLK_BACKSLASH instead of this code. As a user, you should not rely on this code because SDL will never generate it with most (all?) keyboards. */
   4.254 -    SDLK_SEMICOLON = SDL_PHYSICAL_KEY(51),
   4.255 -    SDLK_APOSTROPHE = SDL_PHYSICAL_KEY(52),
   4.256 -    SDLK_GRAVE = SDL_PHYSICAL_KEY(53), /**< Located in the top left corner (on both ANSI and ISO keyboards). Produces GRAVE ACCENT and TILDE in a US Windows layout and in US and UK Mac layouts on ANSI keyboards, GRAVE ACCENT and NOT SIGN in a UK Windows layout, SECTION SIGN and PLUS-MINUS SIGN in US and UK Mac layouts on ISO keyboards, SECTION SIGN and DEGREE SIGN in a Swiss German layout (Mac: only on ISO keyboards), CIRCUMFLEX ACCENT and DEGREE SIGN in a German layout (Mac: only on ISO keyboards), SUPERSCRIPT TWO and TILDE in a French Windows layout, COMMERCIAL AT and NUMBER SIGN in a French Mac layout on ISO keyboards, and LESS-THAN SIGN and GREATER-THAN SIGN in a Swiss German, German, or French Mac layout on ANSI keyboards. */
   4.257 -    SDLK_COMMA = SDL_PHYSICAL_KEY(54),
   4.258 -    SDLK_PERIOD = SDL_PHYSICAL_KEY(55),
   4.259 -    SDLK_SLASH = SDL_PHYSICAL_KEY(56),
   4.260 +    SDLK_APPLICATION = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_APPLICATION),
   4.261 +    SDLK_POWER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_POWER),
   4.262 +    SDLK_KP_EQUALS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_EQUALS),
   4.263 +    SDLK_F13 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F13),
   4.264 +    SDLK_F14 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F14),
   4.265 +    SDLK_F15 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F15),
   4.266 +    SDLK_F16 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F16),
   4.267 +    SDLK_F17 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F17),
   4.268 +    SDLK_F18 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F18),
   4.269 +    SDLK_F19 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F19),
   4.270 +    SDLK_F20 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F20),
   4.271 +    SDLK_F21 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F21),
   4.272 +    SDLK_F22 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F22),
   4.273 +    SDLK_F23 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F23),
   4.274 +    SDLK_F24 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F24),
   4.275 +    SDLK_EXECUTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_EXECUTE),
   4.276 +    SDLK_HELP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_HELP),
   4.277 +    SDLK_MENU = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MENU),
   4.278 +    SDLK_SELECT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SELECT),
   4.279 +    SDLK_STOP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_STOP),
   4.280 +    SDLK_AGAIN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AGAIN),
   4.281 +    SDLK_UNDO = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_UNDO),
   4.282 +    SDLK_CUT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CUT),
   4.283 +    SDLK_COPY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_COPY),
   4.284 +    SDLK_PASTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PASTE),
   4.285 +    SDLK_FIND = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_FIND),
   4.286 +    SDLK_MUTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MUTE),
   4.287 +    SDLK_VOLUMEUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_VOLUMEUP),
   4.288 +    SDLK_VOLUMEDOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_VOLUMEDOWN),
   4.289 +    SDLK_KP_COMMA = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_COMMA),
   4.290 +    SDLK_KP_EQUALSAS400 =
   4.291 +        SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_EQUALSAS400),
   4.292  
   4.293 -    SDLK_CAPSLOCK = SDL_PHYSICAL_KEY(57),
   4.294 +    SDLK_ALTERASE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_ALTERASE),
   4.295 +    SDLK_SYSREQ = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SYSREQ),
   4.296 +    SDLK_CANCEL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CANCEL),
   4.297 +    SDLK_CLEAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CLEAR),
   4.298 +    SDLK_PRIOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PRIOR),
   4.299 +    SDLK_RETURN2 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RETURN2),
   4.300 +    SDLK_SEPARATOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SEPARATOR),
   4.301 +    SDLK_OUT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_OUT),
   4.302 +    SDLK_OPER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_OPER),
   4.303 +    SDLK_CLEARAGAIN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CLEARAGAIN),
   4.304 +    SDLK_CRSEL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CRSEL),
   4.305 +    SDLK_EXSEL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_EXSEL),
   4.306  
   4.307 -    SDLK_F1 = SDL_PHYSICAL_KEY(58),
   4.308 -    SDLK_F2 = SDL_PHYSICAL_KEY(59),
   4.309 -    SDLK_F3 = SDL_PHYSICAL_KEY(60),
   4.310 -    SDLK_F4 = SDL_PHYSICAL_KEY(61),
   4.311 -    SDLK_F5 = SDL_PHYSICAL_KEY(62),
   4.312 -    SDLK_F6 = SDL_PHYSICAL_KEY(63),
   4.313 -    SDLK_F7 = SDL_PHYSICAL_KEY(64),
   4.314 -    SDLK_F8 = SDL_PHYSICAL_KEY(65),
   4.315 -    SDLK_F9 = SDL_PHYSICAL_KEY(66),
   4.316 -    SDLK_F10 = SDL_PHYSICAL_KEY(67),
   4.317 -    SDLK_F11 = SDL_PHYSICAL_KEY(68),
   4.318 -    SDLK_F12 = SDL_PHYSICAL_KEY(69),
   4.319 +    SDLK_KP_00 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_00),
   4.320 +    SDLK_KP_000 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_000),
   4.321 +    SDLK_THOUSANDSSEPARATOR =
   4.322 +        SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_THOUSANDSSEPARATOR),
   4.323 +    SDLK_DECIMALSEPARATOR =
   4.324 +        SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_DECIMALSEPARATOR),
   4.325 +    SDLK_CURRENCYUNIT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CURRENCYUNIT),
   4.326 +    SDLK_CURRENCYSUBUNIT =
   4.327 +        SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CURRENCYSUBUNIT),
   4.328 +    SDLK_KP_LEFTPAREN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_LEFTPAREN),
   4.329 +    SDLK_KP_RIGHTPAREN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_RIGHTPAREN),
   4.330 +    SDLK_KP_LEFTBRACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_LEFTBRACE),
   4.331 +    SDLK_KP_RIGHTBRACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_RIGHTBRACE),
   4.332 +    SDLK_KP_TAB = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_TAB),
   4.333 +    SDLK_KP_BACKSPACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_BACKSPACE),
   4.334 +    SDLK_KP_A = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_A),
   4.335 +    SDLK_KP_B = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_B),
   4.336 +    SDLK_KP_C = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_C),
   4.337 +    SDLK_KP_D = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_D),
   4.338 +    SDLK_KP_E = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_E),
   4.339 +    SDLK_KP_F = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_F),
   4.340 +    SDLK_KP_XOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_XOR),
   4.341 +    SDLK_KP_POWER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_POWER),
   4.342 +    SDLK_KP_PERCENT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PERCENT),
   4.343 +    SDLK_KP_LESS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_LESS),
   4.344 +    SDLK_KP_GREATER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_GREATER),
   4.345 +    SDLK_KP_AMPERSAND = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_AMPERSAND),
   4.346 +    SDLK_KP_DBLAMPERSAND =
   4.347 +        SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DBLAMPERSAND),
   4.348 +    SDLK_KP_VERTICALBAR =
   4.349 +        SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_VERTICALBAR),
   4.350 +    SDLK_KP_DBLVERTICALBAR =
   4.351 +        SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DBLVERTICALBAR),
   4.352 +    SDLK_KP_COLON = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_COLON),
   4.353 +    SDLK_KP_HASH = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_HASH),
   4.354 +    SDLK_KP_SPACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_SPACE),
   4.355 +    SDLK_KP_AT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_AT),
   4.356 +    SDLK_KP_EXCLAM = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_EXCLAM),
   4.357 +    SDLK_KP_MEMSTORE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMSTORE),
   4.358 +    SDLK_KP_MEMRECALL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMRECALL),
   4.359 +    SDLK_KP_MEMCLEAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMCLEAR),
   4.360 +    SDLK_KP_MEMADD = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMADD),
   4.361 +    SDLK_KP_MEMSUBTRACT =
   4.362 +        SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMSUBTRACT),
   4.363 +    SDLK_KP_MEMMULTIPLY =
   4.364 +        SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMMULTIPLY),
   4.365 +    SDLK_KP_MEMDIVIDE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMDIVIDE),
   4.366 +    SDLK_KP_PLUSMINUS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PLUSMINUS),
   4.367 +    SDLK_KP_CLEAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_CLEAR),
   4.368 +    SDLK_KP_CLEARENTRY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_CLEARENTRY),
   4.369 +    SDLK_KP_BINARY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_BINARY),
   4.370 +    SDLK_KP_OCTAL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_OCTAL),
   4.371 +    SDLK_KP_DECIMAL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DECIMAL),
   4.372 +    SDLK_KP_HEXADECIMAL =
   4.373 +        SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_HEXADECIMAL),
   4.374  
   4.375 -    SDLK_PRINTSCREEN = SDL_PHYSICAL_KEY(70),
   4.376 -    SDLK_SCROLLLOCK = SDL_PHYSICAL_KEY(71),
   4.377 -    SDLK_PAUSE = SDL_PHYSICAL_KEY(72),
   4.378 -    SDLK_INSERT = SDL_PHYSICAL_KEY(73), /**< insert on PC, help on some Mac keyboards (but does send code 73, not 117) */
   4.379 -    SDLK_HOME = SDL_PHYSICAL_KEY(74),
   4.380 -    SDLK_PAGEUP = SDL_PHYSICAL_KEY(75),
   4.381 -    SDLK_DELETE = SDL_PHYSICAL_KEY(76),
   4.382 -    SDLK_END = SDL_PHYSICAL_KEY(77),
   4.383 -    SDLK_PAGEDOWN = SDL_PHYSICAL_KEY(78),
   4.384 -    SDLK_RIGHT = SDL_PHYSICAL_KEY(79),
   4.385 -    SDLK_LEFT = SDL_PHYSICAL_KEY(80),
   4.386 -    SDLK_DOWN = SDL_PHYSICAL_KEY(81),
   4.387 -    SDLK_UP = SDL_PHYSICAL_KEY(82),
   4.388 +    SDLK_LCTRL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LCTRL),
   4.389 +    SDLK_LSHIFT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LSHIFT),
   4.390 +    SDLK_LALT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LALT),
   4.391 +    SDLK_LGUI = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LGUI),
   4.392 +    SDLK_RCTRL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RCTRL),
   4.393 +    SDLK_RSHIFT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RSHIFT),
   4.394 +    SDLK_RALT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RALT),
   4.395 +    SDLK_RGUI = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RGUI),
   4.396  
   4.397 -    SDLK_KP_NUMLOCKCLEAR = SDL_PHYSICAL_KEY(83), /**< num lock on PC, clear on Mac keyboards */
   4.398 -    SDLK_KP_DIVIDE = SDL_PHYSICAL_KEY(84) | SDL_KEY_KEYPAD_BIT,
   4.399 -    SDLK_KP_MULTIPLY = SDL_PHYSICAL_KEY(85) | SDL_KEY_KEYPAD_BIT,
   4.400 -    SDLK_KP_MINUS = SDL_PHYSICAL_KEY(86) | SDL_KEY_KEYPAD_BIT,
   4.401 -    SDLK_KP_PLUS = SDL_PHYSICAL_KEY(87) | SDL_KEY_KEYPAD_BIT,
   4.402 -    SDLK_KP_ENTER = SDL_PHYSICAL_KEY(88),
   4.403 -    SDLK_KP_1 = SDL_PHYSICAL_KEY(89) | SDL_KEY_KEYPAD_BIT,
   4.404 -    SDLK_KP_2 = SDL_PHYSICAL_KEY(90) | SDL_KEY_KEYPAD_BIT,
   4.405 -    SDLK_KP_3 = SDL_PHYSICAL_KEY(91) | SDL_KEY_KEYPAD_BIT,
   4.406 -    SDLK_KP_4 = SDL_PHYSICAL_KEY(92) | SDL_KEY_KEYPAD_BIT,
   4.407 -    SDLK_KP_5 = SDL_PHYSICAL_KEY(93) | SDL_KEY_KEYPAD_BIT,
   4.408 -    SDLK_KP_6 = SDL_PHYSICAL_KEY(94) | SDL_KEY_KEYPAD_BIT,
   4.409 -    SDLK_KP_7 = SDL_PHYSICAL_KEY(95) | SDL_KEY_KEYPAD_BIT,
   4.410 -    SDLK_KP_8 = SDL_PHYSICAL_KEY(96) | SDL_KEY_KEYPAD_BIT,
   4.411 -    SDLK_KP_9 = SDL_PHYSICAL_KEY(97) | SDL_KEY_KEYPAD_BIT,
   4.412 -    SDLK_KP_0 = SDL_PHYSICAL_KEY(98) | SDL_KEY_KEYPAD_BIT,
   4.413 -    SDLK_KP_PERIOD = SDL_PHYSICAL_KEY(99) | SDL_KEY_KEYPAD_BIT,
   4.414 +    SDLK_MODE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MODE),
   4.415  
   4.416 -    SDLK_NONUSBACKSLASH = SDL_PHYSICAL_KEY(100), /**< This is the additional key that ISO keyboards have over ANSI ones, located between left shift and Y. Produces GRAVE ACCENT and TILDE in a US or UK Mac layout, REVERSE SOLIDUS (backslash) and VERTICAL LINE in a US or UK Windows layout, and LESS-THAN SIGN and GREATER-THAN SIGN in a Swiss German, German, or French layout. */
   4.417 -    SDLK_APPLICATION = SDL_PHYSICAL_KEY(101), /**< windows contextual menu, compose */
   4.418 -    SDLK_POWER = SDL_PHYSICAL_KEY(102), /**< The USB document says this is a status flag, not a physical key - but some Mac keyboards do have a power key. */
   4.419 -    SDLK_KP_EQUALS = SDL_PHYSICAL_KEY(103) | SDL_KEY_KEYPAD_BIT,
   4.420 -    SDLK_F13 = SDL_PHYSICAL_KEY(104),
   4.421 -    SDLK_F14 = SDL_PHYSICAL_KEY(105),
   4.422 -    SDLK_F15 = SDL_PHYSICAL_KEY(106),
   4.423 -    SDLK_F16 = SDL_PHYSICAL_KEY(107),
   4.424 -    SDLK_F17 = SDL_PHYSICAL_KEY(108),
   4.425 -    SDLK_F18 = SDL_PHYSICAL_KEY(109),
   4.426 -    SDLK_F19 = SDL_PHYSICAL_KEY(110),
   4.427 -    SDLK_F20 = SDL_PHYSICAL_KEY(111),
   4.428 -    SDLK_F21 = SDL_PHYSICAL_KEY(112),
   4.429 -    SDLK_F22 = SDL_PHYSICAL_KEY(113),
   4.430 -    SDLK_F23 = SDL_PHYSICAL_KEY(114),
   4.431 -    SDLK_F24 = SDL_PHYSICAL_KEY(115),
   4.432 -    SDLK_EXECUTE = SDL_PHYSICAL_KEY(116),
   4.433 -    SDLK_HELP = SDL_PHYSICAL_KEY(117),
   4.434 -    SDLK_MENU = SDL_PHYSICAL_KEY(118),
   4.435 -    SDLK_SELECT = SDL_PHYSICAL_KEY(119),
   4.436 -    SDLK_STOP = SDL_PHYSICAL_KEY(120),
   4.437 -    SDLK_AGAIN = SDL_PHYSICAL_KEY(121), /*!< redo */
   4.438 -    SDLK_UNDO = SDL_PHYSICAL_KEY(122),
   4.439 -    SDLK_CUT = SDL_PHYSICAL_KEY(123),
   4.440 -    SDLK_COPY = SDL_PHYSICAL_KEY(124),
   4.441 -    SDLK_PASTE = SDL_PHYSICAL_KEY(125),
   4.442 -    SDLK_FIND = SDL_PHYSICAL_KEY(126),
   4.443 -    SDLK_MUTE = SDL_PHYSICAL_KEY(127),
   4.444 -    SDLK_VOLUMEUP = SDL_PHYSICAL_KEY(128),
   4.445 -    SDLK_VOLUMEDOWN = SDL_PHYSICAL_KEY(129),
   4.446 -/* not sure whether there's a reason to enable these */
   4.447 -/*     SDLK_LOCKINGCAPSLOCK = SDL_PHYSICAL_KEY(130),  */
   4.448 -/*     SDLK_LOCKINGNUMLOCK = SDL_PHYSICAL_KEY(131), */
   4.449 -/*     SDLK_LOCKINGSCROLLLOCK = SDL_PHYSICAL_KEY(132), */
   4.450 -    SDLK_KP_COMMA = SDL_PHYSICAL_KEY(133) | SDL_KEY_KEYPAD_BIT,
   4.451 -    SDLK_KP_EQUALSAS400 = SDL_PHYSICAL_KEY(134) | SDL_KEY_KEYPAD_BIT,
   4.452 +    SDLK_AUDIONEXT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIONEXT),
   4.453 +    SDLK_AUDIOPREV = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOPREV),
   4.454 +    SDLK_AUDIOSTOP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOSTOP),
   4.455 +    SDLK_AUDIOPLAY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOPLAY),
   4.456 +    SDLK_AUDIOMUTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOMUTE),
   4.457 +    SDLK_MEDIASELECT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIASELECT),
   4.458 +    SDLK_MAIL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MAIL),
   4.459 +    SDLK_CALCULATOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CALCULATOR),
   4.460 +    SDLK_COMPUTER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_COMPUTER),
   4.461 +    SDLK_AC_SEARCH = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_SEARCH),
   4.462 +    SDLK_AC_HOME = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_HOME),
   4.463 +    SDLK_AC_BACK = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_BACK),
   4.464 +    SDLK_AC_FORWARD = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_FORWARD),
   4.465 +    SDLK_AC_STOP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_STOP),
   4.466 +    SDLK_AC_REFRESH = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_REFRESH),
   4.467 +    SDLK_AC_BOOKMARKS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_BOOKMARKS),
   4.468  
   4.469 -    SDLK_INTERNATIONAL1 = SDL_PHYSICAL_KEY(135), /**< used on Asian keyboards, see footnotes in USB doc */
   4.470 -    SDLK_INTERNATIONAL2 = SDL_PHYSICAL_KEY(136),
   4.471 -    SDLK_INTERNATIONAL3 = SDL_PHYSICAL_KEY(137), /**< Yen */
   4.472 -    SDLK_INTERNATIONAL4 = SDL_PHYSICAL_KEY(138),
   4.473 -    SDLK_INTERNATIONAL5 = SDL_PHYSICAL_KEY(139),
   4.474 -    SDLK_INTERNATIONAL6 = SDL_PHYSICAL_KEY(140),
   4.475 -    SDLK_INTERNATIONAL7 = SDL_PHYSICAL_KEY(141),
   4.476 -    SDLK_INTERNATIONAL8 = SDL_PHYSICAL_KEY(142),
   4.477 -    SDLK_INTERNATIONAL9 = SDL_PHYSICAL_KEY(143),
   4.478 -    SDLK_LANG1 = SDL_PHYSICAL_KEY(144), /**< Hangul/English toggle */
   4.479 -    SDLK_LANG2 = SDL_PHYSICAL_KEY(145), /**< Hanja conversion */
   4.480 -    SDLK_LANG3 = SDL_PHYSICAL_KEY(146), /**< Katakana */
   4.481 -    SDLK_LANG4 = SDL_PHYSICAL_KEY(147), /**< Hiragana */
   4.482 -    SDLK_LANG5 = SDL_PHYSICAL_KEY(148), /**< Zenkaku/Hankaku */
   4.483 -    SDLK_LANG6 = SDL_PHYSICAL_KEY(149), /**< reserved */
   4.484 -    SDLK_LANG7 = SDL_PHYSICAL_KEY(150), /**< reserved */
   4.485 -    SDLK_LANG8 = SDL_PHYSICAL_KEY(151), /**< reserved */
   4.486 -    SDLK_LANG9 = SDL_PHYSICAL_KEY(152), /**< reserved */
   4.487 -
   4.488 -    SDLK_ALTERASE = SDL_PHYSICAL_KEY(153), /**< Erase-Eaze */
   4.489 -    SDLK_SYSREQ = SDL_PHYSICAL_KEY(154),
   4.490 -    SDLK_CANCEL = SDL_PHYSICAL_KEY(155),
   4.491 -    SDLK_CLEAR = SDL_PHYSICAL_KEY(156),
   4.492 -    SDLK_PRIOR = SDL_PHYSICAL_KEY(157),
   4.493 -    SDLK_RETURN2 = SDL_PHYSICAL_KEY(158),
   4.494 -    SDLK_SEPARATOR = SDL_PHYSICAL_KEY(159),
   4.495 -    SDLK_OUT = SDL_PHYSICAL_KEY(160),
   4.496 -    SDLK_OPER = SDL_PHYSICAL_KEY(161),
   4.497 -    SDLK_CLEARAGAIN = SDL_PHYSICAL_KEY(162),
   4.498 -    SDLK_CRSELPROPS = SDL_PHYSICAL_KEY(163),
   4.499 -    SDLK_EXSEL = SDL_PHYSICAL_KEY(164),
   4.500 -
   4.501 -    SDLK_KP_00 = SDL_PHYSICAL_KEY(176) | SDL_KEY_KEYPAD_BIT,
   4.502 -    SDLK_KP_000 = SDL_PHYSICAL_KEY(177) | SDL_KEY_KEYPAD_BIT,
   4.503 -    SDLK_THOUSANDSSEPARATOR = SDL_PHYSICAL_KEY(178),
   4.504 -    SDLK_DECIMALSEPARATOR = SDL_PHYSICAL_KEY(179),
   4.505 -    SDLK_CURRENCYUNIT = SDL_PHYSICAL_KEY(180),
   4.506 -    SDLK_CURRENCYSUBUNIT = SDL_PHYSICAL_KEY(181),
   4.507 -    SDLK_KP_LEFTPAREN = SDL_PHYSICAL_KEY(182) | SDL_KEY_KEYPAD_BIT,
   4.508 -    SDLK_KP_RIGHTPAREN = SDL_PHYSICAL_KEY(183) | SDL_KEY_KEYPAD_BIT,
   4.509 -    SDLK_KP_LEFTBRACE = SDL_PHYSICAL_KEY(184) | SDL_KEY_KEYPAD_BIT,
   4.510 -    SDLK_KP_RIGHTBRACE = SDL_PHYSICAL_KEY(185) | SDL_KEY_KEYPAD_BIT,
   4.511 -    SDLK_KP_TAB = SDL_PHYSICAL_KEY(186) | SDL_KEY_KEYPAD_BIT,
   4.512 -    SDLK_KP_BACKSPACE = SDL_PHYSICAL_KEY(187) | SDL_KEY_KEYPAD_BIT,
   4.513 -    SDLK_KP_A = SDL_PHYSICAL_KEY(188) | SDL_KEY_KEYPAD_BIT,
   4.514 -    SDLK_KP_B = SDL_PHYSICAL_KEY(189) | SDL_KEY_KEYPAD_BIT,
   4.515 -    SDLK_KP_C = SDL_PHYSICAL_KEY(190) | SDL_KEY_KEYPAD_BIT,
   4.516 -    SDLK_KP_D = SDL_PHYSICAL_KEY(191) | SDL_KEY_KEYPAD_BIT,
   4.517 -    SDLK_KP_E = SDL_PHYSICAL_KEY(192) | SDL_KEY_KEYPAD_BIT,
   4.518 -    SDLK_KP_F = SDL_PHYSICAL_KEY(193) | SDL_KEY_KEYPAD_BIT,
   4.519 -    SDLK_KP_XOR = SDL_PHYSICAL_KEY(194) | SDL_KEY_KEYPAD_BIT,
   4.520 -    SDLK_KP_POWER = SDL_PHYSICAL_KEY(195) | SDL_KEY_KEYPAD_BIT,
   4.521 -    SDLK_KP_PERCENT = SDL_PHYSICAL_KEY(196) | SDL_KEY_KEYPAD_BIT,
   4.522 -    SDLK_KP_LESS = SDL_PHYSICAL_KEY(197) | SDL_KEY_KEYPAD_BIT,
   4.523 -    SDLK_KP_GREATER = SDL_PHYSICAL_KEY(198) | SDL_KEY_KEYPAD_BIT,
   4.524 -    SDLK_KP_AMPERSAND = SDL_PHYSICAL_KEY(199) | SDL_KEY_KEYPAD_BIT,
   4.525 -    SDLK_KP_DBLAMPERSAND = SDL_PHYSICAL_KEY(200) | SDL_KEY_KEYPAD_BIT,
   4.526 -    SDLK_KP_VERTICALBAR = SDL_PHYSICAL_KEY(201) | SDL_KEY_KEYPAD_BIT,
   4.527 -    SDLK_KP_DBLVERTICALBAR = SDL_PHYSICAL_KEY(202) | SDL_KEY_KEYPAD_BIT,
   4.528 -    SDLK_KP_COLON = SDL_PHYSICAL_KEY(203) | SDL_KEY_KEYPAD_BIT,
   4.529 -    SDLK_KP_HASH = SDL_PHYSICAL_KEY(204) | SDL_KEY_KEYPAD_BIT,
   4.530 -    SDLK_KP_SPACE = SDL_PHYSICAL_KEY(205) | SDL_KEY_KEYPAD_BIT,
   4.531 -    SDLK_KP_AT = SDL_PHYSICAL_KEY(206) | SDL_KEY_KEYPAD_BIT,
   4.532 -    SDLK_KP_EXCLAM = SDL_PHYSICAL_KEY(207) | SDL_KEY_KEYPAD_BIT,
   4.533 -    SDLK_KP_MEMSTORE = SDL_PHYSICAL_KEY(208) | SDL_KEY_KEYPAD_BIT,
   4.534 -    SDLK_KP_MEMRECALL = SDL_PHYSICAL_KEY(209) | SDL_KEY_KEYPAD_BIT,
   4.535 -    SDLK_KP_MEMCLEAR = SDL_PHYSICAL_KEY(210) | SDL_KEY_KEYPAD_BIT,
   4.536 -    SDLK_KP_MEMADD = SDL_PHYSICAL_KEY(211) | SDL_KEY_KEYPAD_BIT,
   4.537 -    SDLK_KP_MEMSUBTRACT = SDL_PHYSICAL_KEY(212) | SDL_KEY_KEYPAD_BIT,
   4.538 -    SDLK_KP_MEMMULTIPLY = SDL_PHYSICAL_KEY(213) | SDL_KEY_KEYPAD_BIT,
   4.539 -    SDLK_KP_MEMDIVIDE = SDL_PHYSICAL_KEY(214) | SDL_KEY_KEYPAD_BIT,
   4.540 -    SDLK_KP_PLUSMINUS = SDL_PHYSICAL_KEY(215) | SDL_KEY_KEYPAD_BIT,
   4.541 -    SDLK_KP_CLEAR = SDL_PHYSICAL_KEY(216) | SDL_KEY_KEYPAD_BIT,
   4.542 -    SDLK_KP_CLEARENTRY = SDL_PHYSICAL_KEY(217) | SDL_KEY_KEYPAD_BIT,
   4.543 -    SDLK_KP_BINARY = SDL_PHYSICAL_KEY(218) | SDL_KEY_KEYPAD_BIT,
   4.544 -    SDLK_KP_OCTAL = SDL_PHYSICAL_KEY(219) | SDL_KEY_KEYPAD_BIT,
   4.545 -    SDLK_KP_DECIMAL = SDL_PHYSICAL_KEY(220) | SDL_KEY_KEYPAD_BIT,
   4.546 -    SDLK_KP_HEXADECIMAL = SDL_PHYSICAL_KEY(221) | SDL_KEY_KEYPAD_BIT,
   4.547 -
   4.548 -    SDLK_LCTRL = SDL_PHYSICAL_KEY(224),
   4.549 -    SDLK_LSHIFT = SDL_PHYSICAL_KEY(225),
   4.550 -    SDLK_LALT = SDL_PHYSICAL_KEY(226), /**< alt, option */
   4.551 -    SDLK_LMETA = SDL_PHYSICAL_KEY(227), /**< windows, command (apple), meta */
   4.552 -    SDLK_RCTRL = SDL_PHYSICAL_KEY(228),
   4.553 -    SDLK_RSHIFT = SDL_PHYSICAL_KEY(229),
   4.554 -    SDLK_RALT = SDL_PHYSICAL_KEY(230), /**< alt gr, option */
   4.555 -    SDLK_RMETA = SDL_PHYSICAL_KEY(231), /**< windows, command (apple), meta */
   4.556 -
   4.557 -    /* Everything below here is not from the USB spec */
   4.558 -
   4.559 -    SDLK_MODE = SDL_PHYSICAL_KEY(232),  /* I'm not sure if this is really not covered by any of the above, but since there's a special KMOD_MODE for it I'm adding it here */
   4.560 -
   4.561 -    SDLK_BRIGHTNESSDOWN = SDL_PHYSICAL_KEY(236),
   4.562 -    SDLK_BRIGHTNESSUP = SDL_PHYSICAL_KEY(237),
   4.563 -    SDLK_DISPLAYSWITCH = SDL_PHYSICAL_KEY(238), /**< display mirroring/dual display switch, video mode switch */
   4.564 -    SDLK_KBDILLUMTOGGLE = SDL_PHYSICAL_KEY(239),
   4.565 -    SDLK_KBDILLUMDOWN = SDL_PHYSICAL_KEY(240),
   4.566 -    SDLK_KBDILLUMUP = SDL_PHYSICAL_KEY(241),
   4.567 -    SDLK_EJECT = SDL_PHYSICAL_KEY(242),
   4.568 -    SDLK_SLEEP = SDL_PHYSICAL_KEY(243),
   4.569 -
   4.570 -    /* Some of the more common and more standardized "multimedia"/"internet" keyboard keys */
   4.571 -    SDLK_AUDIOPLAY = SDL_PHYSICAL_KEY(244),
   4.572 -    SDLK_AUDIOSTOP = SDL_PHYSICAL_KEY(245),
   4.573 -    SDLK_AUDIOPREV = SDL_PHYSICAL_KEY(246),
   4.574 -    SDLK_AUDIONEXT = SDL_PHYSICAL_KEY(247),
   4.575 -    SDLK_CALC = SDL_PHYSICAL_KEY(248),
   4.576 -    SDLK_WWW = SDL_PHYSICAL_KEY(249),
   4.577 -    SDLK_EMAIL = SDL_PHYSICAL_KEY(250),
   4.578 -    SDLK_MEDIA = SDL_PHYSICAL_KEY(251),
   4.579 -    SDLK_COMPUTER = SDL_PHYSICAL_KEY(252),
   4.580 -    SDLK_SEARCH = SDL_PHYSICAL_KEY(253),
   4.581 -    SDLK_BOOKMARKS = SDL_PHYSICAL_KEY(254),
   4.582 -    SDLK_BROWSERBACK = SDL_PHYSICAL_KEY(255),
   4.583 -    SDLK_BROWSERFORWARD = SDL_PHYSICAL_KEY(256),
   4.584 -    SDLK_BROWSERRELOAD = SDL_PHYSICAL_KEY(257),
   4.585 -    SDLK_BROWSERSTOP = SDL_PHYSICAL_KEY(258),
   4.586 -
   4.587 -    /* Add any other keys here */
   4.588 -
   4.589 -    SDLK_LAST_PHYSICAL /**< (not a key, just marks the highest used value in this enum) */
   4.590 +    SDLK_BRIGHTNESSDOWN =
   4.591 +        SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_BRIGHTNESSDOWN),
   4.592 +    SDLK_BRIGHTNESSUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_BRIGHTNESSUP),
   4.593 +    SDLK_DISPLAYSWITCH = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_DISPLAYSWITCH),
   4.594 +    SDLK_KBDILLUMTOGGLE =
   4.595 +        SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KBDILLUMTOGGLE),
   4.596 +    SDLK_KBDILLUMDOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KBDILLUMDOWN),
   4.597 +    SDLK_KBDILLUMUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KBDILLUMUP),
   4.598 +    SDLK_EJECT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_EJECT),
   4.599 +    SDLK_SLEEP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SLEEP),
   4.600  };
   4.601  
   4.602 -#define SDLK_FIRST SDLK_INDEX(SDLK_FIRST_PHYSICAL)
   4.603 -#define SDLK_LAST SDLK_INDEX(SDLK_LAST_PHYSICAL)
   4.604 -
   4.605 -
   4.606 -
   4.607  /**
   4.608   * \enum SDLMod
   4.609   *
   4.610 @@ -449,8 +258,8 @@
   4.611      KMOD_RCTRL = 0x0080,
   4.612      KMOD_LALT = 0x0100,
   4.613      KMOD_RALT = 0x0200,
   4.614 -    KMOD_LMETA = 0x0400,
   4.615 -    KMOD_RMETA = 0x0800,
   4.616 +    KMOD_LGUI = 0x0400,
   4.617 +    KMOD_RGUI = 0x0800,
   4.618      KMOD_NUM = 0x1000,
   4.619      KMOD_CAPS = 0x2000,
   4.620      KMOD_MODE = 0x4000,
   4.621 @@ -460,6 +269,8 @@
   4.622  #define KMOD_CTRL	(KMOD_LCTRL|KMOD_RCTRL)
   4.623  #define KMOD_SHIFT	(KMOD_LSHIFT|KMOD_RSHIFT)
   4.624  #define KMOD_ALT	(KMOD_LALT|KMOD_RALT)
   4.625 -#define KMOD_META	(KMOD_LMETA|KMOD_RMETA)
   4.626 +#define KMOD_GUI	(KMOD_LGUI|KMOD_RGUI)
   4.627  
   4.628  #endif /* _SDL_keysym_h */
   4.629 +
   4.630 +/* vi: set ts=4 sw=4 expandtab: */
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/include/SDL_scancode.h	Tue Feb 05 07:19:23 2008 +0000
     5.3 @@ -0,0 +1,318 @@
     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 +
    5.26 +/**
    5.27 + * \file SDL_scancode.h
    5.28 + */
    5.29 +
    5.30 +#ifndef _SDL_scancode_h
    5.31 +#define _SDL_scancode_h
    5.32 +
    5.33 +#include "SDL_stdinc.h"
    5.34 +
    5.35 +/**
    5.36 + * \enum SDL_scancode
    5.37 + *
    5.38 + * \brief The SDL keyboard scancode representation.
    5.39 + *
    5.40 + * Values of this type are used to represent keyboard keys, among other places
    5.41 + * in the \link SDL_keysym::scancode key.keysym.scancode \endlink field of the
    5.42 + * SDL_Event structure.
    5.43 + *
    5.44 + * The values in this enumeration are based on the USB usage page standard:
    5.45 + * http://www.usb.org/developers/devclass_docs/Hut1_12.pdf
    5.46 + */
    5.47 +typedef enum
    5.48 +{
    5.49 +    SDL_SCANCODE_UNKNOWN = 0,
    5.50 +
    5.51 +    /* These values are from usage page 0x07 (USB keyboard page) */
    5.52 +
    5.53 +    SDL_SCANCODE_A = 4,
    5.54 +    SDL_SCANCODE_B = 5,
    5.55 +    SDL_SCANCODE_C = 6,
    5.56 +    SDL_SCANCODE_D = 7,
    5.57 +    SDL_SCANCODE_E = 8,
    5.58 +    SDL_SCANCODE_F = 9,
    5.59 +    SDL_SCANCODE_G = 10,
    5.60 +    SDL_SCANCODE_H = 11,
    5.61 +    SDL_SCANCODE_I = 12,
    5.62 +    SDL_SCANCODE_J = 13,
    5.63 +    SDL_SCANCODE_K = 14,
    5.64 +    SDL_SCANCODE_L = 15,
    5.65 +    SDL_SCANCODE_M = 16,
    5.66 +    SDL_SCANCODE_N = 17,
    5.67 +    SDL_SCANCODE_O = 18,
    5.68 +    SDL_SCANCODE_P = 19,
    5.69 +    SDL_SCANCODE_Q = 20,
    5.70 +    SDL_SCANCODE_R = 21,
    5.71 +    SDL_SCANCODE_S = 22,
    5.72 +    SDL_SCANCODE_T = 23,
    5.73 +    SDL_SCANCODE_U = 24,
    5.74 +    SDL_SCANCODE_V = 25,
    5.75 +    SDL_SCANCODE_W = 26,
    5.76 +    SDL_SCANCODE_X = 27,
    5.77 +    SDL_SCANCODE_Y = 28,
    5.78 +    SDL_SCANCODE_Z = 29,
    5.79 +
    5.80 +    SDL_SCANCODE_1 = 30,
    5.81 +    SDL_SCANCODE_2 = 31,
    5.82 +    SDL_SCANCODE_3 = 32,
    5.83 +    SDL_SCANCODE_4 = 33,
    5.84 +    SDL_SCANCODE_5 = 34,
    5.85 +    SDL_SCANCODE_6 = 35,
    5.86 +    SDL_SCANCODE_7 = 36,
    5.87 +    SDL_SCANCODE_8 = 37,
    5.88 +    SDL_SCANCODE_9 = 38,
    5.89 +    SDL_SCANCODE_0 = 39,
    5.90 +
    5.91 +    SDL_SCANCODE_RETURN = 40,
    5.92 +    SDL_SCANCODE_ESCAPE = 41,
    5.93 +    SDL_SCANCODE_BACKSPACE = 42,
    5.94 +    SDL_SCANCODE_TAB = 43,
    5.95 +    SDL_SCANCODE_SPACE = 44,
    5.96 +
    5.97 +    SDL_SCANCODE_HYPHENMINUS = 45,
    5.98 +    SDL_SCANCODE_EQUALS = 46,
    5.99 +    SDL_SCANCODE_LEFTBRACKET = 47,
   5.100 +    SDL_SCANCODE_RIGHTBRACKET = 48,
   5.101 +    SDL_SCANCODE_BACKSLASH = 49, /**< Located at the lower left of the return key on ISO keyboards and at the right end of the QWERTY row on ANSI keyboards. Produces REVERSE SOLIDUS (backslash) and VERTICAL LINE in a US layout, REVERSE SOLIDUS and VERTICAL LINE in a UK Mac layout, NUMBER SIGN and TILDE in a UK Windows layout, DOLLAR SIGN and POUND SIGN in a Swiss German layout, NUMBER SIGN and APOSTROPHE in a German layout, GRAVE ACCENT and POUND SIGN in a French Mac layout, and ASTERISK and MICRO SIGN in a French Windows layout. */
   5.102 +    SDL_SCANCODE_NONUSHASH = 50, /**< ISO USB keyboards actually use this code instead of 49 for the same key, but all OSes I've seen treat the two codes identically. So, as an implementor, unless your keyboard generates both of those codes and your OS treats them differently, you should generate SDL_SCANCODE_BACKSLASH instead of this code. As a user, you should not rely on this code because SDL will never generate it with most (all?) keyboards. */
   5.103 +    SDL_SCANCODE_SEMICOLON = 51,
   5.104 +    SDL_SCANCODE_APOSTROPHE = 52,
   5.105 +    SDL_SCANCODE_GRAVE = 53, /**< Located in the top left corner (on both ANSI and ISO keyboards). Produces GRAVE ACCENT and TILDE in a US Windows layout and in US and UK Mac layouts on ANSI keyboards, GRAVE ACCENT and NOT SIGN in a UK Windows layout, SECTION SIGN and PLUS-MINUS SIGN in US and UK Mac layouts on ISO keyboards, SECTION SIGN and DEGREE SIGN in a Swiss German layout (Mac: only on ISO keyboards), CIRCUMFLEX ACCENT and DEGREE SIGN in a German layout (Mac: only on ISO keyboards), SUPERSCRIPT TWO and TILDE in a French Windows layout, COMMERCIAL AT and NUMBER SIGN in a French Mac layout on ISO keyboards, and LESS-THAN SIGN and GREATER-THAN SIGN in a Swiss German, German, or French Mac layout on ANSI keyboards. */
   5.106 +    SDL_SCANCODE_COMMA = 54,
   5.107 +    SDL_SCANCODE_PERIOD = 55,
   5.108 +    SDL_SCANCODE_SLASH = 56,
   5.109 +
   5.110 +    SDL_SCANCODE_CAPSLOCK = 57,
   5.111 +
   5.112 +    SDL_SCANCODE_F1 = 58,
   5.113 +    SDL_SCANCODE_F2 = 59,
   5.114 +    SDL_SCANCODE_F3 = 60,
   5.115 +    SDL_SCANCODE_F4 = 61,
   5.116 +    SDL_SCANCODE_F5 = 62,
   5.117 +    SDL_SCANCODE_F6 = 63,
   5.118 +    SDL_SCANCODE_F7 = 64,
   5.119 +    SDL_SCANCODE_F8 = 65,
   5.120 +    SDL_SCANCODE_F9 = 66,
   5.121 +    SDL_SCANCODE_F10 = 67,
   5.122 +    SDL_SCANCODE_F11 = 68,
   5.123 +    SDL_SCANCODE_F12 = 69,
   5.124 +
   5.125 +    SDL_SCANCODE_PRINTSCREEN = 70,
   5.126 +    SDL_SCANCODE_SCROLLLOCK = 71,
   5.127 +    SDL_SCANCODE_PAUSE = 72,
   5.128 +    SDL_SCANCODE_INSERT = 73, /**< insert on PC, help on some Mac keyboards (but does send code 73, not 117) */
   5.129 +    SDL_SCANCODE_HOME = 74,
   5.130 +    SDL_SCANCODE_PAGEUP = 75,
   5.131 +    SDL_SCANCODE_DELETE = 76,
   5.132 +    SDL_SCANCODE_END = 77,
   5.133 +    SDL_SCANCODE_PAGEDOWN = 78,
   5.134 +    SDL_SCANCODE_RIGHT = 79,
   5.135 +    SDL_SCANCODE_LEFT = 80,
   5.136 +    SDL_SCANCODE_DOWN = 81,
   5.137 +    SDL_SCANCODE_UP = 82,
   5.138 +
   5.139 +    SDL_SCANCODE_NUMLOCKCLEAR = 83, /**< num lock on PC, clear on Mac keyboards */
   5.140 +    SDL_SCANCODE_KP_DIVIDE = 84,
   5.141 +    SDL_SCANCODE_KP_MULTIPLY = 85,
   5.142 +    SDL_SCANCODE_KP_MINUS = 86,
   5.143 +    SDL_SCANCODE_KP_PLUS = 87,
   5.144 +    SDL_SCANCODE_KP_ENTER = 88,
   5.145 +    SDL_SCANCODE_KP_1 = 89,
   5.146 +    SDL_SCANCODE_KP_2 = 90,
   5.147 +    SDL_SCANCODE_KP_3 = 91,
   5.148 +    SDL_SCANCODE_KP_4 = 92,
   5.149 +    SDL_SCANCODE_KP_5 = 93,
   5.150 +    SDL_SCANCODE_KP_6 = 94,
   5.151 +    SDL_SCANCODE_KP_7 = 95,
   5.152 +    SDL_SCANCODE_KP_8 = 96,
   5.153 +    SDL_SCANCODE_KP_9 = 97,
   5.154 +    SDL_SCANCODE_KP_0 = 98,
   5.155 +    SDL_SCANCODE_KP_PERIOD = 99,
   5.156 +
   5.157 +    SDL_SCANCODE_NONUSBACKSLASH = 100, /**< This is the additional key that ISO keyboards have over ANSI ones, located between left shift and Y. Produces GRAVE ACCENT and TILDE in a US or UK Mac layout, REVERSE SOLIDUS (backslash) and VERTICAL LINE in a US or UK Windows layout, and LESS-THAN SIGN and GREATER-THAN SIGN in a Swiss German, German, or French layout. */
   5.158 +    SDL_SCANCODE_APPLICATION = 101, /**< windows contextual menu, compose */
   5.159 +    SDL_SCANCODE_POWER = 102, /**< The USB document says this is a status flag, not a physical key - but some Mac keyboards do have a power key. */
   5.160 +    SDL_SCANCODE_KP_EQUALS = 103,
   5.161 +    SDL_SCANCODE_F13 = 104,
   5.162 +    SDL_SCANCODE_F14 = 105,
   5.163 +    SDL_SCANCODE_F15 = 106,
   5.164 +    SDL_SCANCODE_F16 = 107,
   5.165 +    SDL_SCANCODE_F17 = 108,
   5.166 +    SDL_SCANCODE_F18 = 109,
   5.167 +    SDL_SCANCODE_F19 = 110,
   5.168 +    SDL_SCANCODE_F20 = 111,
   5.169 +    SDL_SCANCODE_F21 = 112,
   5.170 +    SDL_SCANCODE_F22 = 113,
   5.171 +    SDL_SCANCODE_F23 = 114,
   5.172 +    SDL_SCANCODE_F24 = 115,
   5.173 +    SDL_SCANCODE_EXECUTE = 116,
   5.174 +    SDL_SCANCODE_HELP = 117,
   5.175 +    SDL_SCANCODE_MENU = 118,
   5.176 +    SDL_SCANCODE_SELECT = 119,
   5.177 +    SDL_SCANCODE_STOP = 120,
   5.178 +    SDL_SCANCODE_AGAIN = 121,   /*!< redo */
   5.179 +    SDL_SCANCODE_UNDO = 122,
   5.180 +    SDL_SCANCODE_CUT = 123,
   5.181 +    SDL_SCANCODE_COPY = 124,
   5.182 +    SDL_SCANCODE_PASTE = 125,
   5.183 +    SDL_SCANCODE_FIND = 126,
   5.184 +    SDL_SCANCODE_MUTE = 127,
   5.185 +    SDL_SCANCODE_VOLUMEUP = 128,
   5.186 +    SDL_SCANCODE_VOLUMEDOWN = 129,
   5.187 +/* not sure whether there's a reason to enable these */
   5.188 +/*     SDL_SCANCODE_LOCKINGCAPSLOCK = 130,  */
   5.189 +/*     SDL_SCANCODE_LOCKINGNUMLOCK = 131, */
   5.190 +/*     SDL_SCANCODE_LOCKINGSCROLLLOCK = 132, */
   5.191 +    SDL_SCANCODE_KP_COMMA = 133,
   5.192 +    SDL_SCANCODE_KP_EQUALSAS400 = 134,
   5.193 +
   5.194 +    SDL_SCANCODE_INTERNATIONAL1 = 135, /**< used on Asian keyboards, see footnotes in USB doc */
   5.195 +    SDL_SCANCODE_INTERNATIONAL2 = 136,
   5.196 +    SDL_SCANCODE_INTERNATIONAL3 = 137, /**< Yen */
   5.197 +    SDL_SCANCODE_INTERNATIONAL4 = 138,
   5.198 +    SDL_SCANCODE_INTERNATIONAL5 = 139,
   5.199 +    SDL_SCANCODE_INTERNATIONAL6 = 140,
   5.200 +    SDL_SCANCODE_INTERNATIONAL7 = 141,
   5.201 +    SDL_SCANCODE_INTERNATIONAL8 = 142,
   5.202 +    SDL_SCANCODE_INTERNATIONAL9 = 143,
   5.203 +    SDL_SCANCODE_LANG1 = 144, /**< Hangul/English toggle */
   5.204 +    SDL_SCANCODE_LANG2 = 145, /**< Hanja conversion */
   5.205 +    SDL_SCANCODE_LANG3 = 146, /**< Katakana */
   5.206 +    SDL_SCANCODE_LANG4 = 147, /**< Hiragana */
   5.207 +    SDL_SCANCODE_LANG5 = 148, /**< Zenkaku/Hankaku */
   5.208 +    SDL_SCANCODE_LANG6 = 149, /**< reserved */
   5.209 +    SDL_SCANCODE_LANG7 = 150, /**< reserved */
   5.210 +    SDL_SCANCODE_LANG8 = 151, /**< reserved */
   5.211 +    SDL_SCANCODE_LANG9 = 152, /**< reserved */
   5.212 +
   5.213 +    SDL_SCANCODE_ALTERASE = 153, /**< Erase-Eaze */
   5.214 +    SDL_SCANCODE_SYSREQ = 154,
   5.215 +    SDL_SCANCODE_CANCEL = 155,
   5.216 +    SDL_SCANCODE_CLEAR = 156,
   5.217 +    SDL_SCANCODE_PRIOR = 157,
   5.218 +    SDL_SCANCODE_RETURN2 = 158,
   5.219 +    SDL_SCANCODE_SEPARATOR = 159,
   5.220 +    SDL_SCANCODE_OUT = 160,
   5.221 +    SDL_SCANCODE_OPER = 161,
   5.222 +    SDL_SCANCODE_CLEARAGAIN = 162,
   5.223 +    SDL_SCANCODE_CRSEL = 163,
   5.224 +    SDL_SCANCODE_EXSEL = 164,
   5.225 +
   5.226 +    SDL_SCANCODE_KP_00 = 176,
   5.227 +    SDL_SCANCODE_KP_000 = 177,
   5.228 +    SDL_SCANCODE_THOUSANDSSEPARATOR = 178,
   5.229 +    SDL_SCANCODE_DECIMALSEPARATOR = 179,
   5.230 +    SDL_SCANCODE_CURRENCYUNIT = 180,
   5.231 +    SDL_SCANCODE_CURRENCYSUBUNIT = 181,
   5.232 +    SDL_SCANCODE_KP_LEFTPAREN = 182,
   5.233 +    SDL_SCANCODE_KP_RIGHTPAREN = 183,
   5.234 +    SDL_SCANCODE_KP_LEFTBRACE = 184,
   5.235 +    SDL_SCANCODE_KP_RIGHTBRACE = 185,
   5.236 +    SDL_SCANCODE_KP_TAB = 186,
   5.237 +    SDL_SCANCODE_KP_BACKSPACE = 187,
   5.238 +    SDL_SCANCODE_KP_A = 188,
   5.239 +    SDL_SCANCODE_KP_B = 189,
   5.240 +    SDL_SCANCODE_KP_C = 190,
   5.241 +    SDL_SCANCODE_KP_D = 191,
   5.242 +    SDL_SCANCODE_KP_E = 192,
   5.243 +    SDL_SCANCODE_KP_F = 193,
   5.244 +    SDL_SCANCODE_KP_XOR = 194,
   5.245 +    SDL_SCANCODE_KP_POWER = 195,
   5.246 +    SDL_SCANCODE_KP_PERCENT = 196,
   5.247 +    SDL_SCANCODE_KP_LESS = 197,
   5.248 +    SDL_SCANCODE_KP_GREATER = 198,
   5.249 +    SDL_SCANCODE_KP_AMPERSAND = 199,
   5.250 +    SDL_SCANCODE_KP_DBLAMPERSAND = 200,
   5.251 +    SDL_SCANCODE_KP_VERTICALBAR = 201,
   5.252 +    SDL_SCANCODE_KP_DBLVERTICALBAR = 202,
   5.253 +    SDL_SCANCODE_KP_COLON = 203,
   5.254 +    SDL_SCANCODE_KP_HASH = 204,
   5.255 +    SDL_SCANCODE_KP_SPACE = 205,
   5.256 +    SDL_SCANCODE_KP_AT = 206,
   5.257 +    SDL_SCANCODE_KP_EXCLAM = 207,
   5.258 +    SDL_SCANCODE_KP_MEMSTORE = 208,
   5.259 +    SDL_SCANCODE_KP_MEMRECALL = 209,
   5.260 +    SDL_SCANCODE_KP_MEMCLEAR = 210,
   5.261 +    SDL_SCANCODE_KP_MEMADD = 211,
   5.262 +    SDL_SCANCODE_KP_MEMSUBTRACT = 212,
   5.263 +    SDL_SCANCODE_KP_MEMMULTIPLY = 213,
   5.264 +    SDL_SCANCODE_KP_MEMDIVIDE = 214,
   5.265 +    SDL_SCANCODE_KP_PLUSMINUS = 215,
   5.266 +    SDL_SCANCODE_KP_CLEAR = 216,
   5.267 +    SDL_SCANCODE_KP_CLEARENTRY = 217,
   5.268 +    SDL_SCANCODE_KP_BINARY = 218,
   5.269 +    SDL_SCANCODE_KP_OCTAL = 219,
   5.270 +    SDL_SCANCODE_KP_DECIMAL = 220,
   5.271 +    SDL_SCANCODE_KP_HEXADECIMAL = 221,
   5.272 +
   5.273 +    SDL_SCANCODE_LCTRL = 224,
   5.274 +    SDL_SCANCODE_LSHIFT = 225,
   5.275 +    SDL_SCANCODE_LALT = 226, /**< alt, option */
   5.276 +    SDL_SCANCODE_LGUI = 227, /**< windows, command (apple), meta */
   5.277 +    SDL_SCANCODE_RCTRL = 228,
   5.278 +    SDL_SCANCODE_RSHIFT = 229,
   5.279 +    SDL_SCANCODE_RALT = 230, /**< alt gr, option */
   5.280 +    SDL_SCANCODE_RGUI = 231, /**< windows, command (apple), meta */
   5.281 +
   5.282 +    SDL_SCANCODE_MODE = 257,    /* I'm not sure if this is really not covered by any of the above, but since there's a special KMOD_MODE for it I'm adding it here */
   5.283 +
   5.284 +    /* These values are mapped from usage page 0x0C (USB consumer page) */
   5.285 +
   5.286 +    SDL_SCANCODE_AUDIONEXT = 258,
   5.287 +    SDL_SCANCODE_AUDIOPREV = 259,
   5.288 +    SDL_SCANCODE_AUDIOSTOP = 260,
   5.289 +    SDL_SCANCODE_AUDIOPLAY = 261,
   5.290 +    SDL_SCANCODE_AUDIOMUTE = 262,
   5.291 +    SDL_SCANCODE_MEDIASELECT = 263,
   5.292 +    SDL_SCANCODE_MAIL = 264,
   5.293 +    SDL_SCANCODE_CALCULATOR = 265,
   5.294 +    SDL_SCANCODE_COMPUTER = 266,
   5.295 +    SDL_SCANCODE_AC_SEARCH = 267,
   5.296 +    SDL_SCANCODE_AC_HOME = 268,
   5.297 +    SDL_SCANCODE_AC_BACK = 269,
   5.298 +    SDL_SCANCODE_AC_FORWARD = 270,
   5.299 +    SDL_SCANCODE_AC_STOP = 271,
   5.300 +    SDL_SCANCODE_AC_REFRESH = 272,
   5.301 +    SDL_SCANCODE_AC_BOOKMARKS = 273,
   5.302 +
   5.303 +    /* These are values that Christian Walther added (for mac keyboard?) */
   5.304 +
   5.305 +    SDL_SCANCODE_BRIGHTNESSDOWN = 274,
   5.306 +    SDL_SCANCODE_BRIGHTNESSUP = 275,
   5.307 +    SDL_SCANCODE_DISPLAYSWITCH = 276, /**< display mirroring/dual display switch, video mode switch */
   5.308 +    SDL_SCANCODE_KBDILLUMTOGGLE = 277,
   5.309 +    SDL_SCANCODE_KBDILLUMDOWN = 278,
   5.310 +    SDL_SCANCODE_KBDILLUMUP = 279,
   5.311 +    SDL_SCANCODE_EJECT = 280,
   5.312 +    SDL_SCANCODE_SLEEP = 281,
   5.313 +
   5.314 +    /* Add any other keys here */
   5.315 +
   5.316 +    SDL_NUM_SCANCODES = 512 /**< (not a key, just marks the number of scancodes for array bounds) */
   5.317 +} SDL_scancode;
   5.318 +
   5.319 +#endif /* _SDL_scancode_h */
   5.320 +
   5.321 +/* vi: set ts=4 sw=4 expandtab: */
     6.1 --- a/src/SDL_compat.c	Mon Feb 04 17:25:33 2008 +0000
     6.2 +++ b/src/SDL_compat.c	Tue Feb 05 07:19:23 2008 +0000
     6.3 @@ -1531,4 +1531,10 @@
     6.4      }
     6.5  }
     6.6  
     6.7 +int
     6.8 +SDL_EnableUNICODE(int enable)
     6.9 +{
    6.10 +    return SDL_EventState(SDL_TEXTINPUT, enable);
    6.11 +}
    6.12 +
    6.13  /* vi: set ts=4 sw=4 expandtab: */
     7.1 --- a/src/events/SDL_keyboard.c	Mon Feb 04 17:25:33 2008 +0000
     7.2 +++ b/src/events/SDL_keyboard.c	Tue Feb 05 07:19:23 2008 +0000
     7.3 @@ -27,18 +27,475 @@
     7.4  #include "SDL_events.h"
     7.5  #include "SDL_events_c.h"
     7.6  #include "SDL_sysevents.h"
     7.7 -#include "SDL_keynames.h"
     7.8  
     7.9  
    7.10  /* Global keyboard information */
    7.11 -int SDL_TranslateUNICODE = 0;
    7.12  static int SDL_num_keyboards;
    7.13  static int SDL_current_keyboard;
    7.14  static SDL_Keyboard **SDL_keyboards;
    7.15  
    7.16 +static SDLKey SDL_default_keymap[SDL_NUM_SCANCODES] = {
    7.17 +    0, 0, 0, 0,
    7.18 +    'a',
    7.19 +    'b',
    7.20 +    'c',
    7.21 +    'd',
    7.22 +    'e',
    7.23 +    'f',
    7.24 +    'g',
    7.25 +    'h',
    7.26 +    'i',
    7.27 +    'j',
    7.28 +    'k',
    7.29 +    'l',
    7.30 +    'm',
    7.31 +    'n',
    7.32 +    'o',
    7.33 +    'p',
    7.34 +    'q',
    7.35 +    'r',
    7.36 +    's',
    7.37 +    't',
    7.38 +    'u',
    7.39 +    'v',
    7.40 +    'w',
    7.41 +    'x',
    7.42 +    'y',
    7.43 +    'z',
    7.44 +    '1',
    7.45 +    '2',
    7.46 +    '3',
    7.47 +    '4',
    7.48 +    '5',
    7.49 +    '6',
    7.50 +    '7',
    7.51 +    '8',
    7.52 +    '9',
    7.53 +    '0',
    7.54 +    SDLK_RETURN,
    7.55 +    SDLK_ESCAPE,
    7.56 +    SDLK_BACKSPACE,
    7.57 +    SDLK_TAB,
    7.58 +    SDLK_SPACE,
    7.59 +    '-',
    7.60 +    '=',
    7.61 +    '[',
    7.62 +    ']',
    7.63 +    '\\',
    7.64 +    '#',
    7.65 +    ';',
    7.66 +    '\'',
    7.67 +    '`',
    7.68 +    ',',
    7.69 +    '.',
    7.70 +    '/',
    7.71 +    SDLK_CAPSLOCK,
    7.72 +    SDLK_F1,
    7.73 +    SDLK_F2,
    7.74 +    SDLK_F3,
    7.75 +    SDLK_F4,
    7.76 +    SDLK_F5,
    7.77 +    SDLK_F6,
    7.78 +    SDLK_F7,
    7.79 +    SDLK_F8,
    7.80 +    SDLK_F9,
    7.81 +    SDLK_F10,
    7.82 +    SDLK_F11,
    7.83 +    SDLK_F12,
    7.84 +    SDLK_PRINTSCREEN,
    7.85 +    SDLK_SCROLLLOCK,
    7.86 +    SDLK_PAUSE,
    7.87 +    SDLK_INSERT,
    7.88 +    SDLK_HOME,
    7.89 +    SDLK_PAGEUP,
    7.90 +    SDLK_DELETE,
    7.91 +    SDLK_END,
    7.92 +    SDLK_PAGEDOWN,
    7.93 +    SDLK_RIGHT,
    7.94 +    SDLK_LEFT,
    7.95 +    SDLK_DOWN,
    7.96 +    SDLK_UP,
    7.97 +    SDLK_NUMLOCKCLEAR,
    7.98 +    SDLK_KP_DIVIDE,
    7.99 +    SDLK_KP_MULTIPLY,
   7.100 +    SDLK_KP_MINUS,
   7.101 +    SDLK_KP_PLUS,
   7.102 +    SDLK_KP_ENTER,
   7.103 +    SDLK_KP_1,
   7.104 +    SDLK_KP_2,
   7.105 +    SDLK_KP_3,
   7.106 +    SDLK_KP_4,
   7.107 +    SDLK_KP_5,
   7.108 +    SDLK_KP_6,
   7.109 +    SDLK_KP_7,
   7.110 +    SDLK_KP_8,
   7.111 +    SDLK_KP_9,
   7.112 +    SDLK_KP_0,
   7.113 +    SDLK_KP_PERIOD,
   7.114 +    0,
   7.115 +    SDLK_APPLICATION,
   7.116 +    SDLK_POWER,
   7.117 +    SDLK_KP_EQUALS,
   7.118 +    SDLK_F13,
   7.119 +    SDLK_F14,
   7.120 +    SDLK_F15,
   7.121 +    SDLK_F16,
   7.122 +    SDLK_F17,
   7.123 +    SDLK_F18,
   7.124 +    SDLK_F19,
   7.125 +    SDLK_F20,
   7.126 +    SDLK_F21,
   7.127 +    SDLK_F22,
   7.128 +    SDLK_F23,
   7.129 +    SDLK_F24,
   7.130 +    SDLK_EXECUTE,
   7.131 +    SDLK_HELP,
   7.132 +    SDLK_MENU,
   7.133 +    SDLK_SELECT,
   7.134 +    SDLK_STOP,
   7.135 +    SDLK_AGAIN,
   7.136 +    SDLK_UNDO,
   7.137 +    SDLK_CUT,
   7.138 +    SDLK_COPY,
   7.139 +    SDLK_PASTE,
   7.140 +    SDLK_FIND,
   7.141 +    SDLK_MUTE,
   7.142 +    SDLK_VOLUMEUP,
   7.143 +    SDLK_VOLUMEDOWN,
   7.144 +    0, 0, 0,
   7.145 +    SDLK_KP_COMMA,
   7.146 +    SDLK_KP_EQUALSAS400,
   7.147 +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   7.148 +    SDLK_ALTERASE,
   7.149 +    SDLK_SYSREQ,
   7.150 +    SDLK_CANCEL,
   7.151 +    SDLK_CLEAR,
   7.152 +    SDLK_PRIOR,
   7.153 +    SDLK_RETURN2,
   7.154 +    SDLK_SEPARATOR,
   7.155 +    SDLK_OUT,
   7.156 +    SDLK_OPER,
   7.157 +    SDLK_CLEARAGAIN,
   7.158 +    SDLK_CRSEL,
   7.159 +    SDLK_EXSEL,
   7.160 +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   7.161 +    SDLK_KP_00,
   7.162 +    SDLK_KP_000,
   7.163 +    SDLK_THOUSANDSSEPARATOR,
   7.164 +    SDLK_DECIMALSEPARATOR,
   7.165 +    SDLK_CURRENCYUNIT,
   7.166 +    SDLK_CURRENCYSUBUNIT,
   7.167 +    SDLK_KP_LEFTPAREN,
   7.168 +    SDLK_KP_RIGHTPAREN,
   7.169 +    SDLK_KP_LEFTBRACE,
   7.170 +    SDLK_KP_RIGHTBRACE,
   7.171 +    SDLK_KP_TAB,
   7.172 +    SDLK_KP_BACKSPACE,
   7.173 +    SDLK_KP_A,
   7.174 +    SDLK_KP_B,
   7.175 +    SDLK_KP_C,
   7.176 +    SDLK_KP_D,
   7.177 +    SDLK_KP_E,
   7.178 +    SDLK_KP_F,
   7.179 +    SDLK_KP_XOR,
   7.180 +    SDLK_KP_POWER,
   7.181 +    SDLK_KP_PERCENT,
   7.182 +    SDLK_KP_LESS,
   7.183 +    SDLK_KP_GREATER,
   7.184 +    SDLK_KP_AMPERSAND,
   7.185 +    SDLK_KP_DBLAMPERSAND,
   7.186 +    SDLK_KP_VERTICALBAR,
   7.187 +    SDLK_KP_DBLVERTICALBAR,
   7.188 +    SDLK_KP_COLON,
   7.189 +    SDLK_KP_HASH,
   7.190 +    SDLK_KP_SPACE,
   7.191 +    SDLK_KP_AT,
   7.192 +    SDLK_KP_EXCLAM,
   7.193 +    SDLK_KP_MEMSTORE,
   7.194 +    SDLK_KP_MEMRECALL,
   7.195 +    SDLK_KP_MEMCLEAR,
   7.196 +    SDLK_KP_MEMADD,
   7.197 +    SDLK_KP_MEMSUBTRACT,
   7.198 +    SDLK_KP_MEMMULTIPLY,
   7.199 +    SDLK_KP_MEMDIVIDE,
   7.200 +    SDLK_KP_PLUSMINUS,
   7.201 +    SDLK_KP_CLEAR,
   7.202 +    SDLK_KP_CLEARENTRY,
   7.203 +    SDLK_KP_BINARY,
   7.204 +    SDLK_KP_OCTAL,
   7.205 +    SDLK_KP_DECIMAL,
   7.206 +    SDLK_KP_HEXADECIMAL,
   7.207 +    0, 0,
   7.208 +    SDLK_LCTRL,
   7.209 +    SDLK_LSHIFT,
   7.210 +    SDLK_LALT,
   7.211 +    SDLK_LGUI,
   7.212 +    SDLK_RCTRL,
   7.213 +    SDLK_RSHIFT,
   7.214 +    SDLK_RALT,
   7.215 +    SDLK_RGUI,
   7.216 +    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,
   7.217 +    SDLK_MODE,
   7.218 +    SDLK_AUDIONEXT,
   7.219 +    SDLK_AUDIOPREV,
   7.220 +    SDLK_AUDIOSTOP,
   7.221 +    SDLK_AUDIOPLAY,
   7.222 +    SDLK_AUDIOMUTE,
   7.223 +    SDLK_MEDIASELECT,
   7.224 +    SDLK_MAIL,
   7.225 +    SDLK_CALCULATOR,
   7.226 +    SDLK_COMPUTER,
   7.227 +    SDLK_AC_SEARCH,
   7.228 +    SDLK_AC_HOME,
   7.229 +    SDLK_AC_BACK,
   7.230 +    SDLK_AC_FORWARD,
   7.231 +    SDLK_AC_STOP,
   7.232 +    SDLK_AC_REFRESH,
   7.233 +    SDLK_AC_BOOKMARKS,
   7.234 +    SDLK_BRIGHTNESSDOWN,
   7.235 +    SDLK_BRIGHTNESSUP,
   7.236 +    SDLK_DISPLAYSWITCH,
   7.237 +    SDLK_KBDILLUMTOGGLE,
   7.238 +    SDLK_KBDILLUMDOWN,
   7.239 +    SDLK_KBDILLUMUP,
   7.240 +    SDLK_EJECT,
   7.241 +    SDLK_SLEEP,
   7.242 +};
   7.243 +
   7.244 +static const char *SDL_scancode_names[SDL_NUM_SCANCODES] = {
   7.245 +    NULL, NULL, NULL, NULL,
   7.246 +    "A",
   7.247 +    "B",
   7.248 +    "C",
   7.249 +    "D",
   7.250 +    "E",
   7.251 +    "F",
   7.252 +    "G",
   7.253 +    "H",
   7.254 +    "I",
   7.255 +    "J",
   7.256 +    "K",
   7.257 +    "L",
   7.258 +    "M",
   7.259 +    "N",
   7.260 +    "O",
   7.261 +    "P",
   7.262 +    "Q",
   7.263 +    "R",
   7.264 +    "S",
   7.265 +    "T",
   7.266 +    "U",
   7.267 +    "V",
   7.268 +    "W",
   7.269 +    "X",
   7.270 +    "Y",
   7.271 +    "Z",
   7.272 +    "1",
   7.273 +    "2",
   7.274 +    "3",
   7.275 +    "4",
   7.276 +    "5",
   7.277 +    "6",
   7.278 +    "7",
   7.279 +    "8",
   7.280 +    "9",
   7.281 +    "0",
   7.282 +    "Return",
   7.283 +    "Escape",
   7.284 +    "Backspace",
   7.285 +    "Tab",
   7.286 +    "Space",
   7.287 +    "-",
   7.288 +    "=",
   7.289 +    "[",
   7.290 +    "]",
   7.291 +    "\\",
   7.292 +    "#",
   7.293 +    ";",
   7.294 +    "'",
   7.295 +    "`",
   7.296 +    ",",
   7.297 +    ".",
   7.298 +    "/",
   7.299 +    "CapsLock",
   7.300 +    "F1",
   7.301 +    "F2",
   7.302 +    "F3",
   7.303 +    "F4",
   7.304 +    "F5",
   7.305 +    "F6",
   7.306 +    "F7",
   7.307 +    "F8",
   7.308 +    "F9",
   7.309 +    "F10",
   7.310 +    "F11",
   7.311 +    "F12",
   7.312 +    "PrintScreen",
   7.313 +    "ScrollLock",
   7.314 +    "Pause",
   7.315 +    "Insert",
   7.316 +    "Home",
   7.317 +    "PageUp",
   7.318 +    "Delete",
   7.319 +    "End",
   7.320 +    "PageDown",
   7.321 +    "Right",
   7.322 +    "Left",
   7.323 +    "Down",
   7.324 +    "Up",
   7.325 +    "Numlock",
   7.326 +    "Keypad /",
   7.327 +    "Keypad *",
   7.328 +    "Keypad -",
   7.329 +    "Keypad +",
   7.330 +    "Keypad Enter",
   7.331 +    "Keypad 1",
   7.332 +    "Keypad 2",
   7.333 +    "Keypad 3",
   7.334 +    "Keypad 4",
   7.335 +    "Keypad 5",
   7.336 +    "Keypad 6",
   7.337 +    "Keypad 7",
   7.338 +    "Keypad 8",
   7.339 +    "Keypad 9",
   7.340 +    "Keypad 0",
   7.341 +    "Keypad .",
   7.342 +    NULL,
   7.343 +    "Application",
   7.344 +    "Power",
   7.345 +    "Keypad =",
   7.346 +    "F13",
   7.347 +    "F14",
   7.348 +    "F15",
   7.349 +    "F16",
   7.350 +    "F17",
   7.351 +    "F18",
   7.352 +    "F19",
   7.353 +    "F20",
   7.354 +    "F21",
   7.355 +    "F22",
   7.356 +    "F23",
   7.357 +    "F24",
   7.358 +    "Execute",
   7.359 +    "Help",
   7.360 +    "Menu",
   7.361 +    "Select",
   7.362 +    "Stop",
   7.363 +    "Again",
   7.364 +    "Undo",
   7.365 +    "Cut",
   7.366 +    "Copy",
   7.367 +    "Paste",
   7.368 +    "Find",
   7.369 +    "Mute",
   7.370 +    "VolumeUp",
   7.371 +    "VolumeDown",
   7.372 +    NULL, NULL, NULL,
   7.373 +    "Keypad ,",
   7.374 +    "Keypad = (AS400)",
   7.375 +    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   7.376 +    NULL, NULL, NULL, NULL, NULL, NULL,
   7.377 +    "AltErase",
   7.378 +    "SysReq",
   7.379 +    "Cancel",
   7.380 +    "Clear",
   7.381 +    "Prior",
   7.382 +    "Return",
   7.383 +    "Separator",
   7.384 +    "Out",
   7.385 +    "Oper",
   7.386 +    "Clear / Again",
   7.387 +    "CrSel",
   7.388 +    "ExSel",
   7.389 +    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   7.390 +    "Keypad 00",
   7.391 +    "Keypad 000",
   7.392 +    "ThousandsSeparator",
   7.393 +    "DecimalSeparator",
   7.394 +    "CurrencyUnit",
   7.395 +    "CurrencySubUnit",
   7.396 +    "Keypad (",
   7.397 +    "Keypad )",
   7.398 +    "Keypad {",
   7.399 +    "Keypad }",
   7.400 +    "Keypad Tab",
   7.401 +    "Keypad Backspace",
   7.402 +    "Keypad A",
   7.403 +    "Keypad B",
   7.404 +    "Keypad C",
   7.405 +    "Keypad D",
   7.406 +    "Keypad E",
   7.407 +    "Keypad F",
   7.408 +    "Keypad XOR",
   7.409 +    "Keypad ^",
   7.410 +    "Keypad %",
   7.411 +    "Keypad <",
   7.412 +    "Keypad >",
   7.413 +    "Keypad &",
   7.414 +    "Keypad &&",
   7.415 +    "Keypad |",
   7.416 +    "Keypad ||",
   7.417 +    "Keypad :",
   7.418 +    "Keypad #",
   7.419 +    "Keypad Space",
   7.420 +    "Keypad @",
   7.421 +    "Keypad !",
   7.422 +    "Keypad MemStore",
   7.423 +    "Keypad MemRecall",
   7.424 +    "Keypad MemClear",
   7.425 +    "Keypad MemAdd",
   7.426 +    "Keypad MemSubtract",
   7.427 +    "Keypad MemMultiply",
   7.428 +    "Keypad MemDivide",
   7.429 +    "Keypad +/-",
   7.430 +    "Keypad Clear",
   7.431 +    "Keypad ClearEntry",
   7.432 +    "Keypad Binary",
   7.433 +    "Keypad Octal",
   7.434 +    "Keypad Decimal",
   7.435 +    "Keypad Hexadecimal",
   7.436 +    NULL, NULL,
   7.437 +    "Left Ctrl",
   7.438 +    "Left Shift",
   7.439 +    "Left Alt",
   7.440 +    "Left GUI",
   7.441 +    "Right Ctrl",
   7.442 +    "Right Shift",
   7.443 +    "Right Alt",
   7.444 +    "Right GUI",
   7.445 +    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   7.446 +    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   7.447 +    NULL,
   7.448 +    "ModeSwitch",
   7.449 +    "AudioNext",
   7.450 +    "AudioPrev",
   7.451 +    "AudioStop",
   7.452 +    "AudioPlay",
   7.453 +    "AudioMute",
   7.454 +    "MediaSelect",
   7.455 +    "Mail",
   7.456 +    "Calculator",
   7.457 +    "Computer",
   7.458 +    "AC Search",
   7.459 +    "AC Home",
   7.460 +    "AC Back",
   7.461 +    "AC Forward",
   7.462 +    "AC Stop",
   7.463 +    "AC Refresh",
   7.464 +    "AC Bookmarks",
   7.465 +    "BrightnessDown",
   7.466 +    "BrightnessUp",
   7.467 +    "DisplaySwitch",
   7.468 +    "KBDIllumToggle",
   7.469 +    "KBDIllumDown",
   7.470 +    "KBDIllumUp",
   7.471 +    "Eject",
   7.472 +    "Sleep",
   7.473 +};
   7.474 +
   7.475  /* Taken from SDL_iconv() */
   7.476 -char *
   7.477 -SDL_Ucs4ToUtf8(Uint32 ch, char *dst)
   7.478 +static char *
   7.479 +SDL_UCS4ToUTF8(Uint32 ch, char *dst)
   7.480  {
   7.481      Uint8 *p = (Uint8 *) dst;
   7.482      if (ch <= 0x7F) {
   7.483 @@ -82,9 +539,6 @@
   7.484  int
   7.485  SDL_KeyboardInit(void)
   7.486  {
   7.487 -    /* Set default mode of UNICODE translation */
   7.488 -    SDL_EnableUNICODE(DEFAULT_UNICODE_TRANSLATION);
   7.489 -
   7.490      return (0);
   7.491  }
   7.492  
   7.493 @@ -148,170 +602,45 @@
   7.494  SDL_ResetKeyboard(int index)
   7.495  {
   7.496      SDL_Keyboard *keyboard = SDL_GetKeyboard(index);
   7.497 -    int key;
   7.498 +    SDL_scancode scancode;
   7.499  
   7.500      if (!keyboard) {
   7.501          return;
   7.502      }
   7.503  
   7.504 -    for (key = SDLK_FIRST; key < SDLK_LAST; ++key) {
   7.505 -        if (keyboard->keystate[key] == SDL_PRESSED) {
   7.506 -            SDL_SendKeyboardKey(index, SDL_RELEASED, 0,
   7.507 -                                key | SDL_KEY_CAN_BE_PHYSICAL_BIT);
   7.508 +    for (scancode = 0; scancode < SDL_NUM_SCANCODES; ++scancode) {
   7.509 +        if (keyboard->keystate[scancode] == SDL_PRESSED) {
   7.510 +            SDL_SendKeyboardKey(index, SDL_RELEASED, scancode);
   7.511          }
   7.512      }
   7.513  }
   7.514  
   7.515  void
   7.516 -SDL_KeyboardQuit(void)
   7.517 +SDL_GetDefaultKeymap(SDLKey * keymap)
   7.518  {
   7.519 -    int i;
   7.520 -
   7.521 -    for (i = 0; i < SDL_num_keyboards; ++i) {
   7.522 -        SDL_DelKeyboard(i);
   7.523 -    }
   7.524 -    SDL_num_keyboards = 0;
   7.525 -    SDL_current_keyboard = 0;
   7.526 -
   7.527 -    if (SDL_keyboards) {
   7.528 -        SDL_free(SDL_keyboards);
   7.529 -        SDL_keyboards = NULL;
   7.530 -    }
   7.531 -}
   7.532 -
   7.533 -int
   7.534 -SDL_GetNumKeyboards(void)
   7.535 -{
   7.536 -    return SDL_num_keyboards;
   7.537 -}
   7.538 -
   7.539 -int
   7.540 -SDL_SelectKeyboard(int index)
   7.541 -{
   7.542 -    if (index >= 0 && index < SDL_num_keyboards) {
   7.543 -        SDL_current_keyboard = index;
   7.544 -    }
   7.545 -    return SDL_current_keyboard;
   7.546 -}
   7.547 -
   7.548 -int
   7.549 -SDL_EnableUNICODE(int enable)
   7.550 -{
   7.551 -    int old_mode;
   7.552 -
   7.553 -    old_mode = SDL_TranslateUNICODE;
   7.554 -    if (enable >= 0) {
   7.555 -        SDL_TranslateUNICODE = enable;
   7.556 -    }
   7.557 -    return (old_mode);
   7.558 -}
   7.559 -
   7.560 -Uint8 *
   7.561 -SDL_GetKeyState(int *numkeys)
   7.562 -{
   7.563 -    SDL_Keyboard *keyboard = SDL_GetKeyboard(SDL_current_keyboard);
   7.564 -
   7.565 -    if (numkeys != (int *) 0) {
   7.566 -        *numkeys = SDLK_LAST;
   7.567 -    }
   7.568 -
   7.569 -    if (!keyboard) {
   7.570 -        return NULL;
   7.571 -    }
   7.572 -    return keyboard->keystate;
   7.573 -}
   7.574 -
   7.575 -SDLMod
   7.576 -SDL_GetModState(void)
   7.577 -{
   7.578 -    SDL_Keyboard *keyboard = SDL_GetKeyboard(SDL_current_keyboard);
   7.579 -
   7.580 -    if (!keyboard) {
   7.581 -        return KMOD_NONE;
   7.582 -    }
   7.583 -    return keyboard->modstate;
   7.584 +    SDL_memcpy(keymap, SDL_default_keymap, sizeof(SDL_default_keymap));
   7.585  }
   7.586  
   7.587  void
   7.588 -SDL_SetModState(SDLMod modstate)
   7.589 +SDL_SetKeymap(int index, int start, SDLKey * keys, int length)
   7.590  {
   7.591 -    SDL_Keyboard *keyboard = SDL_GetKeyboard(SDL_current_keyboard);
   7.592 +    SDL_Keyboard *keyboard = SDL_GetKeyboard(index);
   7.593  
   7.594      if (!keyboard) {
   7.595          return;
   7.596      }
   7.597 -    keyboard->modstate = modstate;
   7.598 -}
   7.599  
   7.600 -SDLKey
   7.601 -SDL_GetLayoutKey(SDLKey physicalKey)
   7.602 -{
   7.603 -    SDL_VideoDevice *_this = SDL_GetVideoDevice();
   7.604 -    if (_this && _this->GetLayoutKey) {
   7.605 -        return _this->GetLayoutKey(_this, physicalKey)
   7.606 -            | (physicalKey & SDL_KEY_KEYPAD_BIT);
   7.607 -    } else {
   7.608 -        return physicalKey;
   7.609 -    }
   7.610 -}
   7.611 -
   7.612 -const char *
   7.613 -SDL_GetKeyName(SDLKey layoutKey)
   7.614 -{
   7.615 -    const char *keyname = NULL;
   7.616 -
   7.617 -    if ((layoutKey & SDL_KEY_LAYOUT_SPECIAL_BIT) != 0) {
   7.618 -        SDL_VideoDevice *_this = SDL_GetVideoDevice();
   7.619 -        if (_this && _this->GetSpecialKeyName) {
   7.620 -            keyname = _this->GetSpecialKeyName(_this, layoutKey);
   7.621 -        }
   7.622 -    } else if ((layoutKey & SDL_KEY_CAN_BE_PHYSICAL_BIT) == 0) {
   7.623 -        /* SDLK_INDEX(layoutKey) is the unicode code point of the
   7.624 -           character generated by the key */
   7.625 -        static char buffer[9];  /* 6 (maximal UTF-8 char length) + 2 ([] for keypad) + 1 (null teminator) */
   7.626 -        char *bufferPtr = &buffer[1];
   7.627 -        Uint32 codepoint = SDLK_INDEX(layoutKey);
   7.628 -
   7.629 -        /* Unaccented letter keys on latin keyboards are normally
   7.630 -           labeled in upper case (and probably on others like Greek or
   7.631 -           Cyrillic too, so if you happen to know for sure, please
   7.632 -           adapt this). */
   7.633 -        if (codepoint >= 'a' && codepoint <= 'z') {
   7.634 -            codepoint -= 32;
   7.635 -        }
   7.636 -
   7.637 -        bufferPtr = SDL_Ucs4ToUtf8(codepoint, bufferPtr);
   7.638 -        *bufferPtr = '\0';
   7.639 -
   7.640 -        if ((layoutKey & SDL_KEY_KEYPAD_BIT) != 0) {
   7.641 -            buffer[0] = '[';
   7.642 -            *bufferPtr++ = ']';
   7.643 -            *bufferPtr = '\0';
   7.644 -            keyname = buffer;
   7.645 -        } else {
   7.646 -            keyname = &buffer[1];
   7.647 -        }
   7.648 -    } else {
   7.649 -        /* SDLK_INDEX(layoutKey) is a physical key number */
   7.650 -        if (SDLK_INDEX(layoutKey) < SDL_arraysize(SDL_keynames)) {
   7.651 -            keyname = SDL_keynames[SDLK_INDEX(layoutKey)];
   7.652 -        }
   7.653 +    if (start < 0 || start + length > SDL_NUM_SCANCODES) {
   7.654 +        return;
   7.655      }
   7.656  
   7.657 -    if (keyname == NULL) {
   7.658 -        keyname = SDL_keynames[SDLK_INDEX(SDLK_UNKNOWN)];
   7.659 -    }
   7.660 -
   7.661 -    return keyname;
   7.662 +    SDL_memcpy(&keyboard->keymap[start], keys, sizeof(*keys) * length);
   7.663  }
   7.664  
   7.665  void
   7.666 -SDL_SetKeyName(SDLKey physicalKey, const char *name)
   7.667 +SDL_SetScancodeName(SDL_scancode scancode, const char *name)
   7.668  {
   7.669 -    physicalKey = SDLK_INDEX(physicalKey);
   7.670 -    if (physicalKey < SDL_arraysize(SDL_keynames)) {
   7.671 -        SDL_keynames[physicalKey] = name;
   7.672 -    }
   7.673 +    SDL_scancode_names[scancode] = name;
   7.674  }
   7.675  
   7.676  void
   7.677 @@ -366,94 +695,89 @@
   7.678  }
   7.679  
   7.680  int
   7.681 -SDL_SendKeyboardKey(int index, Uint8 state, Uint8 scancode,
   7.682 -                    SDLKey physicalKey)
   7.683 +SDL_SendKeyboardKey(int index, Uint8 state, SDL_scancode scancode)
   7.684  {
   7.685      SDL_Keyboard *keyboard = SDL_GetKeyboard(index);
   7.686      int posted;
   7.687      Uint16 modstate;
   7.688      Uint8 type;
   7.689  
   7.690 -    if (!keyboard || physicalKey == SDLK_NONE) {
   7.691 +    if (!keyboard || !scancode) {
   7.692          return 0;
   7.693      }
   7.694  #if 0
   7.695 -    printf("The '%s' key has been %s\n", SDL_GetKeyName(physicalKey),
   7.696 +    printf("The '%s' key has been %s\n", SDL_GetScancodeName(scancode),
   7.697             state == SDL_PRESSED ? "pressed" : "released");
   7.698  #endif
   7.699      if (state == SDL_PRESSED) {
   7.700          modstate = keyboard->modstate;
   7.701 -        switch (physicalKey) {
   7.702 -        case SDLK_UNKNOWN:
   7.703 -            break;
   7.704 -        case SDLK_KP_NUMLOCKCLEAR:
   7.705 +        switch (scancode) {
   7.706 +        case SDL_SCANCODE_NUMLOCKCLEAR:
   7.707              keyboard->modstate ^= KMOD_NUM;
   7.708              break;
   7.709 -        case SDLK_CAPSLOCK:
   7.710 +        case SDL_SCANCODE_CAPSLOCK:
   7.711              keyboard->modstate ^= KMOD_CAPS;
   7.712              break;
   7.713 -        case SDLK_LCTRL:
   7.714 +        case SDL_SCANCODE_LCTRL:
   7.715              keyboard->modstate |= KMOD_LCTRL;
   7.716              break;
   7.717 -        case SDLK_RCTRL:
   7.718 +        case SDL_SCANCODE_RCTRL:
   7.719              keyboard->modstate |= KMOD_RCTRL;
   7.720              break;
   7.721 -        case SDLK_LSHIFT:
   7.722 +        case SDL_SCANCODE_LSHIFT:
   7.723              keyboard->modstate |= KMOD_LSHIFT;
   7.724              break;
   7.725 -        case SDLK_RSHIFT:
   7.726 +        case SDL_SCANCODE_RSHIFT:
   7.727              keyboard->modstate |= KMOD_RSHIFT;
   7.728              break;
   7.729 -        case SDLK_LALT:
   7.730 +        case SDL_SCANCODE_LALT:
   7.731              keyboard->modstate |= KMOD_LALT;
   7.732              break;
   7.733 -        case SDLK_RALT:
   7.734 +        case SDL_SCANCODE_RALT:
   7.735              keyboard->modstate |= KMOD_RALT;
   7.736              break;
   7.737 -        case SDLK_LMETA:
   7.738 -            keyboard->modstate |= KMOD_LMETA;
   7.739 +        case SDL_SCANCODE_LGUI:
   7.740 +            keyboard->modstate |= KMOD_LGUI;
   7.741              break;
   7.742 -        case SDLK_RMETA:
   7.743 -            keyboard->modstate |= KMOD_RMETA;
   7.744 +        case SDL_SCANCODE_RGUI:
   7.745 +            keyboard->modstate |= KMOD_RGUI;
   7.746              break;
   7.747 -        case SDLK_MODE:
   7.748 +        case SDL_SCANCODE_MODE:
   7.749              keyboard->modstate |= KMOD_MODE;
   7.750              break;
   7.751          default:
   7.752              break;
   7.753          }
   7.754      } else {
   7.755 -        switch (physicalKey) {
   7.756 -        case SDLK_UNKNOWN:
   7.757 +        switch (scancode) {
   7.758 +        case SDL_SCANCODE_NUMLOCKCLEAR:
   7.759 +        case SDL_SCANCODE_CAPSLOCK:
   7.760              break;
   7.761 -        case SDLK_KP_NUMLOCKCLEAR:
   7.762 -        case SDLK_CAPSLOCK:
   7.763 -            break;
   7.764 -        case SDLK_LCTRL:
   7.765 +        case SDL_SCANCODE_LCTRL:
   7.766              keyboard->modstate &= ~KMOD_LCTRL;
   7.767              break;
   7.768 -        case SDLK_RCTRL:
   7.769 +        case SDL_SCANCODE_RCTRL:
   7.770              keyboard->modstate &= ~KMOD_RCTRL;
   7.771              break;
   7.772 -        case SDLK_LSHIFT:
   7.773 +        case SDL_SCANCODE_LSHIFT:
   7.774              keyboard->modstate &= ~KMOD_LSHIFT;
   7.775              break;
   7.776 -        case SDLK_RSHIFT:
   7.777 +        case SDL_SCANCODE_RSHIFT:
   7.778              keyboard->modstate &= ~KMOD_RSHIFT;
   7.779              break;
   7.780 -        case SDLK_LALT:
   7.781 +        case SDL_SCANCODE_LALT:
   7.782              keyboard->modstate &= ~KMOD_LALT;
   7.783              break;
   7.784 -        case SDLK_RALT:
   7.785 +        case SDL_SCANCODE_RALT:
   7.786              keyboard->modstate &= ~KMOD_RALT;
   7.787              break;
   7.788 -        case SDLK_LMETA:
   7.789 -            keyboard->modstate &= ~KMOD_LMETA;
   7.790 +        case SDL_SCANCODE_LGUI:
   7.791 +            keyboard->modstate &= ~KMOD_LGUI;
   7.792              break;
   7.793 -        case SDLK_RMETA:
   7.794 -            keyboard->modstate &= ~KMOD_RMETA;
   7.795 +        case SDL_SCANCODE_RGUI:
   7.796 +            keyboard->modstate &= ~KMOD_RGUI;
   7.797              break;
   7.798 -        case SDLK_MODE:
   7.799 +        case SDL_SCANCODE_MODE:
   7.800              keyboard->modstate &= ~KMOD_MODE;
   7.801              break;
   7.802          default:
   7.803 @@ -475,18 +799,16 @@
   7.804          return 0;
   7.805      }
   7.806  
   7.807 -    if (physicalKey != SDLK_UNKNOWN) {
   7.808 -        /* Drop events that don't change state */
   7.809 -        if (keyboard->keystate[SDLK_INDEX(physicalKey)] == state) {
   7.810 +    /* Drop events that don't change state */
   7.811 +    if (keyboard->keystate[scancode] == state) {
   7.812  #if 0
   7.813 -            printf("Keyboard event didn't change state - dropped!\n");
   7.814 +        printf("Keyboard event didn't change state - dropped!\n");
   7.815  #endif
   7.816 -            return 0;
   7.817 -        }
   7.818 +        return 0;
   7.819 +    }
   7.820  
   7.821 -        /* Update internal keyboard state */
   7.822 -        keyboard->keystate[SDLK_INDEX(physicalKey)] = state;
   7.823 -    }
   7.824 +    /* Update internal keyboard state */
   7.825 +    keyboard->keystate[scancode] = state;
   7.826  
   7.827      /* Post the event, if desired */
   7.828      posted = 0;
   7.829 @@ -496,7 +818,7 @@
   7.830          event.key.which = (Uint8) index;
   7.831          event.key.state = state;
   7.832          event.key.keysym.scancode = scancode;
   7.833 -        event.key.keysym.sym = physicalKey;
   7.834 +        event.key.keysym.sym = keyboard->keymap[scancode];
   7.835          event.key.keysym.mod = modstate;
   7.836          event.key.keysym.unicode = 0;
   7.837          event.key.windowID = keyboard->focus;
   7.838 @@ -528,4 +850,138 @@
   7.839      return (posted);
   7.840  }
   7.841  
   7.842 +void
   7.843 +SDL_KeyboardQuit(void)
   7.844 +{
   7.845 +    int i;
   7.846 +
   7.847 +    for (i = 0; i < SDL_num_keyboards; ++i) {
   7.848 +        SDL_DelKeyboard(i);
   7.849 +    }
   7.850 +    SDL_num_keyboards = 0;
   7.851 +    SDL_current_keyboard = 0;
   7.852 +
   7.853 +    if (SDL_keyboards) {
   7.854 +        SDL_free(SDL_keyboards);
   7.855 +        SDL_keyboards = NULL;
   7.856 +    }
   7.857 +}
   7.858 +
   7.859 +int
   7.860 +SDL_GetNumKeyboards(void)
   7.861 +{
   7.862 +    return SDL_num_keyboards;
   7.863 +}
   7.864 +
   7.865 +int
   7.866 +SDL_SelectKeyboard(int index)
   7.867 +{
   7.868 +    if (index >= 0 && index < SDL_num_keyboards) {
   7.869 +        SDL_current_keyboard = index;
   7.870 +    }
   7.871 +    return SDL_current_keyboard;
   7.872 +}
   7.873 +
   7.874 +Uint8 *
   7.875 +SDL_GetKeyboardState(int *numkeys)
   7.876 +{
   7.877 +    SDL_Keyboard *keyboard = SDL_GetKeyboard(SDL_current_keyboard);
   7.878 +
   7.879 +    if (numkeys != (int *) 0) {
   7.880 +        *numkeys = SDL_NUM_SCANCODES;
   7.881 +    }
   7.882 +
   7.883 +    if (!keyboard) {
   7.884 +        return NULL;
   7.885 +    }
   7.886 +    return keyboard->keystate;
   7.887 +}
   7.888 +
   7.889 +SDLMod
   7.890 +SDL_GetModState(void)
   7.891 +{
   7.892 +    SDL_Keyboard *keyboard = SDL_GetKeyboard(SDL_current_keyboard);
   7.893 +
   7.894 +    if (!keyboard) {
   7.895 +        return KMOD_NONE;
   7.896 +    }
   7.897 +    return keyboard->modstate;
   7.898 +}
   7.899 +
   7.900 +void
   7.901 +SDL_SetModState(SDLMod modstate)
   7.902 +{
   7.903 +    SDL_Keyboard *keyboard = SDL_GetKeyboard(SDL_current_keyboard);
   7.904 +
   7.905 +    if (!keyboard) {
   7.906 +        return;
   7.907 +    }
   7.908 +    keyboard->modstate = modstate;
   7.909 +}
   7.910 +
   7.911 +SDLKey
   7.912 +SDL_GetKeyFromScancode(SDL_scancode scancode)
   7.913 +{
   7.914 +    SDL_Keyboard *keyboard = SDL_GetKeyboard(SDL_current_keyboard);
   7.915 +
   7.916 +    if (!keyboard) {
   7.917 +        return SDLK_UNKNOWN;
   7.918 +    }
   7.919 +    return keyboard->keymap[scancode];
   7.920 +}
   7.921 +
   7.922 +SDL_scancode
   7.923 +SDL_GetScancodeFromKey(SDLKey key)
   7.924 +{
   7.925 +    SDL_Keyboard *keyboard = SDL_GetKeyboard(SDL_current_keyboard);
   7.926 +    SDL_scancode scancode;
   7.927 +
   7.928 +    if (!keyboard) {
   7.929 +        return SDL_SCANCODE_UNKNOWN;
   7.930 +    }
   7.931 +
   7.932 +    for (scancode = SDL_SCANCODE_UNKNOWN; scancode < SDL_NUM_SCANCODES;
   7.933 +         ++scancode) {
   7.934 +        if (keyboard->keymap[scancode] == key) {
   7.935 +            return scancode;
   7.936 +        }
   7.937 +    }
   7.938 +    return SDL_SCANCODE_UNKNOWN;
   7.939 +}
   7.940 +
   7.941 +const char *
   7.942 +SDL_GetScancodeName(SDL_scancode scancode)
   7.943 +{
   7.944 +    const char *name = SDL_scancode_names[scancode];
   7.945 +
   7.946 +    if (name)
   7.947 +        return name;
   7.948 +    else
   7.949 +        return "";
   7.950 +}
   7.951 +
   7.952 +const char *
   7.953 +SDL_GetKeyName(SDLKey key)
   7.954 +{
   7.955 +    static char name[8];
   7.956 +    char *end;
   7.957 +
   7.958 +    if (key & SDLK_SCANCODE_MASK) {
   7.959 +        return
   7.960 +            SDL_GetScancodeName((SDL_scancode) (key & ~SDLK_SCANCODE_MASK));
   7.961 +    }
   7.962 +
   7.963 +    /* Unaccented letter keys on latin keyboards are normally
   7.964 +       labeled in upper case (and probably on others like Greek or
   7.965 +       Cyrillic too, so if you happen to know for sure, please
   7.966 +       adapt this). */
   7.967 +    if (key >= 'a' && key <= 'z') {
   7.968 +        key -= 32;
   7.969 +    }
   7.970 +
   7.971 +    end = SDL_UCS4ToUTF8((Uint32) key, name);
   7.972 +    *end = '\0';
   7.973 +    return name;
   7.974 +}
   7.975 +
   7.976  /* vi: set ts=4 sw=4 expandtab: */
     8.1 --- a/src/events/SDL_keyboard_c.h	Mon Feb 04 17:25:33 2008 +0000
     8.2 +++ b/src/events/SDL_keyboard_c.h	Tue Feb 05 07:19:23 2008 +0000
     8.3 @@ -37,20 +37,12 @@
     8.4      /* Data common to all keyboards */
     8.5      SDL_WindowID focus;
     8.6      Uint16 modstate;
     8.7 -    Uint8 keystate[SDLK_LAST];
     8.8 +    Uint8 keystate[(SDL_NUM_SCANCODES + 7) / 8];
     8.9 +    SDLKey keymap[SDL_NUM_SCANCODES];
    8.10  
    8.11      void *driverdata;
    8.12  };
    8.13  
    8.14 -/* Used by the OS keyboard code to detect whether or not to do UNICODE */
    8.15 -#ifndef DEFAULT_UNICODE_TRANSLATION
    8.16 -#define DEFAULT_UNICODE_TRANSLATION 0   /* Default off because of overhead */
    8.17 -#endif
    8.18 -extern int SDL_TranslateUNICODE;
    8.19 -
    8.20 -/* convert UCS4 to utf8 */
    8.21 -extern char *SDL_Ucs4ToUtf8(Uint32 ch, char *dst);
    8.22 -
    8.23  /* Initialize the keyboard subsystem */
    8.24  extern int SDL_KeyboardInit(void);
    8.25  
    8.26 @@ -68,18 +60,23 @@
    8.27  /* Clear the state of a keyboard at an index */
    8.28  extern void SDL_ResetKeyboard(int index);
    8.29  
    8.30 +/* Get the default keymap */
    8.31 +extern void SDL_GetDefaultKeymap(SDLKey * keymap);
    8.32 +
    8.33 +/* Set the mapping of scancode to key codes for this keyboard */
    8.34 +extern void SDL_SetKeymap(int index, int start, SDLKey * keys, int length);
    8.35 +
    8.36  /* Set a platform-dependent key name, overriding the default platform-agnostic
    8.37     name. Encoded as UTF-8. The string is not copied, thus the pointer given to
    8.38     this function must stay valid forever (or at least until the call to
    8.39     VideoQuit()). */
    8.40 -extern void SDL_SetKeyName(SDLKey physicalKey, const char *name);
    8.41 +extern void SDL_SetScancodeName(SDL_scancode scancode, const char *name);
    8.42  
    8.43  /* Set the keyboard focus window */
    8.44  extern void SDL_SetKeyboardFocus(int index, SDL_WindowID windowID);
    8.45  
    8.46  /* Send a keyboard event for a keyboard at an index */
    8.47 -extern int SDL_SendKeyboardKey(int index, Uint8 state, Uint8 scancode,
    8.48 -                               SDLKey key);
    8.49 +extern int SDL_SendKeyboardKey(int index, Uint8 state, SDL_scancode scancode);
    8.50  
    8.51  /* Send keyboard text input for a keyboard at an index */
    8.52  extern int SDL_SendKeyboardText(int index, const char *text);
     9.1 --- a/src/events/SDL_keynames.h	Mon Feb 04 17:25:33 2008 +0000
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,304 +0,0 @@
     9.4 -/*
     9.5 -    SDL - Simple DirectMedia Layer
     9.6 -    Copyright (C) 1997-2007 Sam Lantinga
     9.7 -
     9.8 -    This library is free software; you can redistribute it and/or
     9.9 -    modify it under the terms of the GNU Lesser General Public
    9.10 -    License as published by the Free Software Foundation; either
    9.11 -    version 2.1 of the License, or (at your option) any later version.
    9.12 -
    9.13 -    This library is distributed in the hope that it will be useful,
    9.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    9.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    9.16 -    Lesser General Public License for more details.
    9.17 -
    9.18 -    You should have received a copy of the GNU Lesser General Public
    9.19 -    License along with this library; if not, write to the Free Software
    9.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    9.21 -
    9.22 -    Christian Walther
    9.23 -    cwalther@gmx.ch
    9.24 -*/
    9.25 -
    9.26 -/* Names for the physical SDLKey constants, returned by SDL_GetKeyName().
    9.27 -   The strings are in UTF-8 encoding.
    9.28 -   This table can (and should) be modified by a video driver in its VideoInit()
    9.29 -   function using SDL_SetKeyName() to account for platform-dependent (but
    9.30 -   layout-independent) key names.
    9.31 -   
    9.32 -   The physical SDLKey codes can be divided into two groups:
    9.33 -   - codes that occur both as physical and as layout keys. These have their
    9.34 -     real, "user-readable" display name here.
    9.35 -   - codes that only occur as physical keys, i.e. are never returned by
    9.36 -     SDL_GetLayoutKey() if the backend implements it properly. These names are
    9.37 -     therefore never returned by SDL_GetKeyName(SDL_GetLayoutKey(
    9.38 -     event.key.keysym.sym)), the proper way of displaying a key name to the
    9.39 -     user, but only by SDL_GetKeyName(event.key.keysym.sym), which is only
    9.40 -     useful for debugging purposes. To emphasize this, these codes are named by
    9.41 -     their "programmer-readable" SDLK_ constants here rather than by a
    9.42 -     "user-readable" display name.
    9.43 - */
    9.44 -
    9.45 -/* *INDENT-OFF* */
    9.46 -static const char *SDL_keynames[SDLK_LAST] = {
    9.47 -    /*   0 */   "", /* SDL_PK_NONE */
    9.48 -    /*   1 */   "unknown key",
    9.49 -    /*   2 */   NULL, /* unused */
    9.50 -    /*   3 */   NULL, /* unused */
    9.51 -    /*   4 */   "SDLK_A",
    9.52 -    /*   5 */   "SDLK_B",
    9.53 -    /*   6 */   "SDLK_C",
    9.54 -    /*   7 */   "SDLK_D",
    9.55 -    /*   8 */   "SDLK_E",
    9.56 -    /*   9 */   "SDLK_F",
    9.57 -    /*  10 */   "SDLK_G",
    9.58 -    /*  11 */   "SDLK_H",
    9.59 -    /*  12 */   "SDLK_I",
    9.60 -    /*  13 */   "SDLK_J",
    9.61 -    /*  14 */   "SDLK_K",
    9.62 -    /*  15 */   "SDLK_L",
    9.63 -    /*  16 */   "SDLK_M",
    9.64 -    /*  17 */   "SDLK_N",
    9.65 -    /*  18 */   "SDLK_O",
    9.66 -    /*  19 */   "SDLK_P",
    9.67 -    /*  20 */   "SDLK_Q",
    9.68 -    /*  21 */   "SDLK_R",
    9.69 -    /*  22 */   "SDLK_S",
    9.70 -    /*  23 */   "SDLK_T",
    9.71 -    /*  24 */   "SDLK_U",
    9.72 -    /*  25 */   "SDLK_V",
    9.73 -    /*  26 */   "SDLK_W",
    9.74 -    /*  27 */   "SDLK_X",
    9.75 -    /*  28 */   "SDLK_Y",
    9.76 -    /*  29 */   "SDLK_Z",
    9.77 -    /*  30 */   "SDLK_1",
    9.78 -    /*  31 */   "SDLK_2",
    9.79 -    /*  32 */   "SDLK_3",
    9.80 -    /*  33 */   "SDLK_4",
    9.81 -    /*  34 */   "SDLK_5",
    9.82 -    /*  35 */   "SDLK_6",
    9.83 -    /*  36 */   "SDLK_7",
    9.84 -    /*  37 */   "SDLK_8",
    9.85 -    /*  38 */   "SDLK_9",
    9.86 -    /*  39 */   "SDLK_0",
    9.87 -    /*  40 */   "return",
    9.88 -    /*  41 */   "escape",
    9.89 -    /*  42 */   "backspace",
    9.90 -    /*  43 */   "tab",
    9.91 -    /*  44 */   "space",
    9.92 -    /*  45 */   "SDLK_HYPHENMINUS",
    9.93 -    /*  46 */   "SDLK_EQUALS",
    9.94 -    /*  47 */   "SDLK_LEFTBRACKET",
    9.95 -    /*  48 */   "SDLK_RIGHTBRACKET",
    9.96 -    /*  49 */   "SDLK_BACKSLASH",
    9.97 -    /*  50 */   "SDLK_NONUSHASH",
    9.98 -    /*  51 */   "SDLK_SEMICOLON",
    9.99 -    /*  52 */   "SDLK_APOSTROPHE",
   9.100 -    /*  53 */   "SDLK_GRAVE",
   9.101 -    /*  54 */   "SDLK_COMMA",
   9.102 -    /*  55 */   "SDLK_PERIOD",
   9.103 -    /*  56 */   "SDLK_SLASH",
   9.104 -    /*  57 */   "caps lock",
   9.105 -    /*  58 */   "F1",
   9.106 -    /*  59 */   "F2",
   9.107 -    /*  60 */   "F3",
   9.108 -    /*  61 */   "F4",
   9.109 -    /*  62 */   "F5",
   9.110 -    /*  63 */   "F6",
   9.111 -    /*  64 */   "F7",
   9.112 -    /*  65 */   "F8",
   9.113 -    /*  66 */   "F9",
   9.114 -    /*  67 */   "F10",
   9.115 -    /*  68 */   "F11",
   9.116 -    /*  69 */   "F12",
   9.117 -    /*  70 */   "print screen",
   9.118 -    /*  71 */   "scroll lock",
   9.119 -    /*  72 */   "pause",
   9.120 -    /*  73 */   "insert",
   9.121 -    /*  74 */   "home",
   9.122 -    /*  75 */   "page up",
   9.123 -    /*  76 */   "delete",
   9.124 -    /*  77 */   "end",
   9.125 -    /*  78 */   "page down",
   9.126 -    /*  79 */   "right",
   9.127 -    /*  80 */   "left",
   9.128 -    /*  81 */   "down",
   9.129 -    /*  82 */   "up",
   9.130 -    /*  83 */   "num lock",
   9.131 -    /*  84 */   "SDLK_KP_DIVIDE",
   9.132 -    /*  85 */   "SDLK_KP_MULTIPLY",
   9.133 -    /*  86 */   "SDLK_KP_MINUS",
   9.134 -    /*  87 */   "SDLK_KP_PLUS",
   9.135 -    /*  88 */   "enter",
   9.136 -    /*  89 */   "SDLK_KP_1",
   9.137 -    /*  90 */   "SDLK_KP_2",
   9.138 -    /*  91 */   "SDLK_KP_3",
   9.139 -    /*  92 */   "SDLK_KP_4",
   9.140 -    /*  93 */   "SDLK_KP_5",
   9.141 -    /*  94 */   "SDLK_KP_6",
   9.142 -    /*  95 */   "SDLK_KP_7",
   9.143 -    /*  96 */   "SDLK_KP_8",
   9.144 -    /*  97 */   "SDLK_KP_9",
   9.145 -    /*  98 */   "SDLK_KP_0",
   9.146 -    /*  99 */   "SDLK_KP_PERIOD",
   9.147 -    /* 100 */   "SDLK_NONUSBACKSLASH",
   9.148 -    /* 101 */   "application",
   9.149 -    /* 102 */   "power",
   9.150 -    /* 103 */   "SDLK_KP_EQUALS",
   9.151 -    /* 104 */   "F13",
   9.152 -    /* 105 */   "F14",
   9.153 -    /* 106 */   "F15",
   9.154 -    /* 107 */   "F16",
   9.155 -    /* 108 */   "F17",
   9.156 -    /* 109 */   "F18",
   9.157 -    /* 110 */   "F19",
   9.158 -    /* 111 */   "F20",
   9.159 -    /* 112 */   "F21",
   9.160 -    /* 113 */   "F22",
   9.161 -    /* 114 */   "F23",
   9.162 -    /* 115 */   "F24",
   9.163 -    /* 116 */   "execute",
   9.164 -    /* 117 */   "help",
   9.165 -    /* 118 */   "menu",
   9.166 -    /* 119 */   "select",
   9.167 -    /* 120 */   "stop",
   9.168 -    /* 121 */   "again",
   9.169 -    /* 122 */   "undo",
   9.170 -    /* 123 */   "cut",
   9.171 -    /* 124 */   "copy",
   9.172 -    /* 125 */   "paste",
   9.173 -    /* 126 */   "find",
   9.174 -    /* 127 */   "mute",
   9.175 -    /* 128 */   "volume up",
   9.176 -    /* 129 */   "volume down",
   9.177 -    /* 130 */   "caps lock", /* unused */
   9.178 -    /* 131 */   "num lock", /* unused */
   9.179 -    /* 132 */   "scroll lock", /* unused */
   9.180 -    /* 133 */   "SDLK_KP_COMMA",
   9.181 -    /* 134 */   "SDLK_KP_EQUALSAS400",
   9.182 -    /* 135 */   "international 1",
   9.183 -    /* 136 */   "international 2",
   9.184 -    /* 137 */   "international 3",
   9.185 -    /* 138 */   "international 4",
   9.186 -    /* 139 */   "international 5",
   9.187 -    /* 140 */   "international 6",
   9.188 -    /* 141 */   "international 7",
   9.189 -    /* 142 */   "international 8",
   9.190 -    /* 143 */   "international 9",
   9.191 -    /* 144 */   "lang 1",
   9.192 -    /* 145 */   "lang 2",
   9.193 -    /* 146 */   "lang 3",
   9.194 -    /* 147 */   "lang 4",
   9.195 -    /* 148 */   "lang 5",
   9.196 -    /* 149 */   "lang 6",
   9.197 -    /* 150 */   "lang 7",
   9.198 -    /* 151 */   "lang 8",
   9.199 -    /* 152 */   "lang 9",
   9.200 -    /* 153 */   "alt erase",
   9.201 -    /* 154 */   "sys req",
   9.202 -    /* 155 */   "cancel",
   9.203 -    /* 156 */   "clear",
   9.204 -    /* 157 */   "prior",
   9.205 -    /* 158 */   "return",
   9.206 -    /* 159 */   "separator",
   9.207 -    /* 160 */   "out",
   9.208 -    /* 161 */   "oper",
   9.209 -    /* 162 */   "clear/again",
   9.210 -    /* 163 */   "crsel/props",
   9.211 -    /* 164 */   "exsel",
   9.212 -    /* 165 */   NULL, /* unused */
   9.213 -    /* 166 */   NULL, /* unused */
   9.214 -    /* 167 */   NULL, /* unused */
   9.215 -    /* 168 */   NULL, /* unused */
   9.216 -    /* 169 */   NULL, /* unused */
   9.217 -    /* 170 */   NULL, /* unused */
   9.218 -    /* 171 */   NULL, /* unused */
   9.219 -    /* 172 */   NULL, /* unused */
   9.220 -    /* 173 */   NULL, /* unused */
   9.221 -    /* 174 */   NULL, /* unused */
   9.222 -    /* 175 */   NULL, /* unused */
   9.223 -    /* 176 */   "[00]",
   9.224 -    /* 177 */   "[000]",
   9.225 -    /* 178 */   "thousands separator",
   9.226 -    /* 179 */   "decimal separator",
   9.227 -    /* 180 */   "currency unit",
   9.228 -    /* 181 */   "currency sub-unit",
   9.229 -    /* 182 */   "[(]",
   9.230 -    /* 183 */   "[)]",
   9.231 -    /* 184 */   "[{]",
   9.232 -    /* 185 */   "[}]",
   9.233 -    /* 186 */   "[tab]",
   9.234 -    /* 187 */   "[backspace]",
   9.235 -    /* 188 */   "[A]",
   9.236 -    /* 189 */   "[B]",
   9.237 -    /* 190 */   "[C]",
   9.238 -    /* 191 */   "[D]",
   9.239 -    /* 192 */   "[E]",
   9.240 -    /* 193 */   "[F]",
   9.241 -    /* 194 */   "[XOR]",
   9.242 -    /* 195 */   "[^]",
   9.243 -    /* 196 */   "[%]",
   9.244 -    /* 197 */   "[<]",
   9.245 -    /* 198 */   "[>]",
   9.246 -    /* 199 */   "[&]",
   9.247 -    /* 200 */   "[&&]",
   9.248 -    /* 201 */   "[|]",
   9.249 -    /* 202 */   "[||]",
   9.250 -    /* 203 */   "[:]",
   9.251 -    /* 204 */   "[#]",
   9.252 -    /* 205 */   "[space]",
   9.253 -    /* 206 */   "[@]",
   9.254 -    /* 207 */   "[!]",
   9.255 -    /* 208 */   "[mem store]",
   9.256 -    /* 209 */   "[mem recall]",
   9.257 -    /* 210 */   "[mem clear]",
   9.258 -    /* 211 */   "[mem +]",
   9.259 -    /* 212 */   "[mem -]",
   9.260 -    /* 213 */   "[mem *]",
   9.261 -    /* 214 */   "[mem /]",
   9.262 -    /* 215 */   "[+/-]",
   9.263 -    /* 216 */   "[clear]",
   9.264 -    /* 217 */   "[clear entry]",
   9.265 -    /* 218 */   "[binary]",
   9.266 -    /* 219 */   "[octal]",
   9.267 -    /* 220 */   "[decimal]",
   9.268 -    /* 221 */   "[hexadecimal]",
   9.269 -    /* 222 */   NULL, /* unused */
   9.270 -    /* 223 */   NULL, /* unused */
   9.271 -    /* 224 */   "left ctrl",
   9.272 -    /* 225 */   "left shift",
   9.273 -    /* 226 */   "left alt",
   9.274 -    /* 227 */   "left meta",
   9.275 -    /* 228 */   "right ctrl",
   9.276 -    /* 229 */   "right shift",
   9.277 -    /* 230 */   "right alt",
   9.278 -    /* 231 */   "right meta",
   9.279 -    /* 232 */   "mode",
   9.280 -    /* 233 */   NULL, /* unused */
   9.281 -    /* 234 */   NULL, /* unused */
   9.282 -    /* 235 */   NULL, /* unused */
   9.283 -    /* 236 */   "brightness down",
   9.284 -    /* 237 */   "brightness up",
   9.285 -    /* 238 */   "display switch",
   9.286 -    /* 239 */   "kbd illum toggle",
   9.287 -    /* 240 */   "kbd illum down",
   9.288 -    /* 241 */   "kbd illum up",
   9.289 -    /* 242 */   "eject",
   9.290 -    /* 243 */   "sleep",
   9.291 -    /* 244 */   "play",
   9.292 -    /* 245 */   "stop",
   9.293 -    /* 246 */   "previous",
   9.294 -    /* 247 */   "next",
   9.295 -    /* 248 */   "calc",
   9.296 -    /* 249 */   "www",
   9.297 -    /* 250 */   "e-mail",
   9.298 -    /* 251 */   "media",
   9.299 -    /* 252 */   "computer",
   9.300 -    /* 253 */   "search",
   9.301 -    /* 254 */   "bookmarks",
   9.302 -    /* 255 */   "back",
   9.303 -    /* 256 */   "forward",
   9.304 -    /* 257 */   "reload",
   9.305 -    /* 258 */   "stop"
   9.306 -};
   9.307 -/* *INDENT-ON* */
    10.1 --- a/src/video/SDL_sysvideo.h	Mon Feb 04 17:25:33 2008 +0000
    10.2 +++ b/src/video/SDL_sysvideo.h	Tue Feb 05 07:19:23 2008 +0000
    10.3 @@ -257,45 +257,6 @@
    10.4       */
    10.5      void (*PumpEvents) (_THIS);
    10.6  
    10.7 -    /* Get the layout key code corresponding to the given physical key code
    10.8 -     * according to the OS' current keyboard layout.
    10.9 -     *
   10.10 -     * - For character keys, this should return the Unicode code point of the
   10.11 -     * character that is generated when the key is pressed without shift or
   10.12 -     * any other modifiers.
   10.13 -     * - For non-character keys, this should return one of the SDLK_* constants
   10.14 -     * (usually the argument itself since these keys are typically layout-
   10.15 -     * independent). Make sure that all of these values returned by this
   10.16 -     * function have a suitable name defined, either the default from
   10.17 -     * SDL_keynames.h, or one set using SDL_SetKeyName() in VideoInit(). In
   10.18 -     * particular, if this function can return any of the codes whose default
   10.19 -     * names start with "SDLK_" (usually, it shouldn't, since these are layout-
   10.20 -     * dependent character keys), these names should be replaced by proper
   10.21 -     * user-readable names.
   10.22 -     * - If there are keys that cannot be adequately described by either a
   10.23 -     * single Unicode character or an SDLK_* constant, this function may return
   10.24 -     * a code with SDL_KEY_LAYOUT_SPECIAL_BIT set in the most significant byte
   10.25 -     * and an arbitrary value in the less significant 3 bytes. The
   10.26 -     * GetSpecialKeyName() function must then be implemented to take this code
   10.27 -     * and return a human-readable key name for it.
   10.28 -     * If the argument is not a physical key code or if translation of the key
   10.29 -     * code by the OS' keyboard layout fails for any reason, the argument must
   10.30 -     * be returned unchanged.
   10.31 -     *
   10.32 -     * On platforms that don't have the notion of a user-configurable keyboard
   10.33 -     * layout, this may be left unimplemented. The default implementation of
   10.34 -     * SDL_GetLayoutKey() then acts as the identity. The note about defining
   10.35 -     * key names above particularly applies in this case.
   10.36 -     */
   10.37 -      SDLKey(*GetLayoutKey) (_THIS, SDLKey physicalKey);
   10.38 -
   10.39 -    /* Get a human-readable name for a special layout key code.
   10.40 -     * This only needs to be implemented if this driver's implementation of
   10.41 -     * GetLayoutKey() generates such codes (with SDL_KEY_LAYOUT_SPECIAL_BIT
   10.42 -     * set) - see above.
   10.43 -     */
   10.44 -    const char *(*GetSpecialKeyName) (_THIS, SDLKey layoutKey);
   10.45 -
   10.46      /* * * */
   10.47      /* Data common to all drivers */
   10.48      int num_displays;
    11.1 --- a/src/video/cocoa/SDL_cocoakeyboard.h	Mon Feb 04 17:25:33 2008 +0000
    11.2 +++ b/src/video/cocoa/SDL_cocoakeyboard.h	Tue Feb 05 07:19:23 2008 +0000
    11.3 @@ -26,7 +26,6 @@
    11.4  
    11.5  extern void Cocoa_InitKeyboard(_THIS);
    11.6  extern void Cocoa_HandleKeyEvent(_THIS, NSEvent * event);
    11.7 -extern SDLKey Cocoa_GetLayoutKey(_THIS, SDLKey physicalKey);
    11.8  extern void Cocoa_QuitKeyboard(_THIS);
    11.9  
   11.10  #endif /* _SDL_cocoakeyboard_h */
    12.1 --- a/src/video/cocoa/SDL_cocoakeyboard.m	Mon Feb 04 17:25:33 2008 +0000
    12.2 +++ b/src/video/cocoa/SDL_cocoakeyboard.m	Tue Feb 05 07:19:23 2008 +0000
    12.3 @@ -71,7 +71,13 @@
    12.4  DoUnsidedModifiers(int keyboard, unsigned short scancode,
    12.5                     unsigned int oldMods, unsigned int newMods)
    12.6  {
    12.7 -    const int mapping[] = { SDLK_CAPSLOCK, SDLK_LSHIFT, SDLK_LCTRL, SDLK_LALT, SDLK_LMETA };
    12.8 +    const int mapping[] = {
    12.9 +        SDL_SCANCODE_CAPSLOCK,
   12.10 +        SDL_SCANCODE_LSHIFT,
   12.11 +        SDL_SCANCODE_LCTRL,
   12.12 +        SDL_SCANCODE_LALT,
   12.13 +        SDL_SCANCODE_LGUI
   12.14 +    };
   12.15      unsigned int i, bit;
   12.16  
   12.17      /* Iterate through the bits, testing each against the current modifiers */
   12.18 @@ -84,14 +90,14 @@
   12.19          if (oldMask && oldMask != newMask) {        /* modifier up event */
   12.20              /* If this was Caps Lock, we need some additional voodoo to make SDL happy */
   12.21              if (bit == NSAlphaShiftKeyMask) {
   12.22 -                SDL_SendKeyboardKey(keyboard, SDL_PRESSED, (Uint8)scancode, mapping[i]);
   12.23 +                SDL_SendKeyboardKey(keyboard, SDL_PRESSED, mapping[i]);
   12.24              }
   12.25 -            SDL_SendKeyboardKey(keyboard, SDL_RELEASED, (Uint8)scancode, mapping[i]);
   12.26 +            SDL_SendKeyboardKey(keyboard, SDL_RELEASED, mapping[i]);
   12.27          } else if (newMask && oldMask != newMask) { /* modifier down event */
   12.28 -            SDL_SendKeyboardKey(keyboard, SDL_PRESSED, (Uint8)scancode, mapping[i]);
   12.29 +            SDL_SendKeyboardKey(keyboard, SDL_PRESSED, mapping[i]);
   12.30              /* If this was Caps Lock, we need some additional voodoo to make SDL happy */
   12.31              if (bit == NSAlphaShiftKeyMask) {
   12.32 -                SDL_SendKeyboardKey(keyboard, SDL_RELEASED, (Uint8)scancode, mapping[i]);
   12.33 +                SDL_SendKeyboardKey(keyboard, SDL_RELEASED, mapping[i]);
   12.34              }
   12.35          }
   12.36      }
   12.37 @@ -102,11 +108,11 @@
   12.38   * sides was made.
   12.39   */
   12.40  static void
   12.41 -HandleNonDeviceModifier(int keyboard, unsigned short scancode,
   12.42 +HandleNonDeviceModifier(int keyboard,
   12.43                          unsigned int device_independent_mask,
   12.44                          unsigned int oldMods,
   12.45                          unsigned int newMods,
   12.46 -                        SDLKey key_sym)
   12.47 +                        SDL_scancode scancode)
   12.48  {
   12.49      unsigned int oldMask, newMask;
   12.50      
   12.51 @@ -117,9 +123,9 @@
   12.52      newMask = newMods & device_independent_mask;
   12.53      
   12.54      if (oldMask && oldMask != newMask) {
   12.55 -        SDL_SendKeyboardKey(keyboard, SDL_RELEASED, (Uint8)scancode, key_sym);
   12.56 +        SDL_SendKeyboardKey(keyboard, SDL_RELEASED, scancode);
   12.57      } else if (newMask && oldMask != newMask) {
   12.58 -        SDL_SendKeyboardKey(keyboard, SDL_PRESSED, (Uint8)scancode, key_sym);
   12.59 +        SDL_SendKeyboardKey(keyboard, SDL_PRESSED, scancode);
   12.60      }
   12.61  }
   12.62  
   12.63 @@ -127,9 +133,9 @@
   12.64   * This function sets the actual SDL_PrivateKeyboard event.
   12.65   */
   12.66  static void
   12.67 -HandleModifierOneSide(int keyboard, unsigned short scancode,
   12.68 +HandleModifierOneSide(int keyboard,
   12.69                        unsigned int oldMods, unsigned int newMods,
   12.70 -                      SDLKey key_sym, 
   12.71 +                      SDL_scancode scancode, 
   12.72                        unsigned int sided_device_dependent_mask)
   12.73  {
   12.74      unsigned int old_dep_mask, new_dep_mask;
   12.75 @@ -145,9 +151,9 @@
   12.76       * find out which it is.
   12.77       */
   12.78      if (new_dep_mask && old_dep_mask != new_dep_mask) {
   12.79 -        SDL_SendKeyboardKey(keyboard, SDL_PRESSED, (Uint8)scancode, key_sym);
   12.80 +        SDL_SendKeyboardKey(keyboard, SDL_PRESSED, scancode);
   12.81      } else {
   12.82 -        SDL_SendKeyboardKey(keyboard, SDL_RELEASED, (Uint8)scancode, key_sym);
   12.83 +        SDL_SendKeyboardKey(keyboard, SDL_RELEASED, scancode);
   12.84      }
   12.85  }
   12.86  
   12.87 @@ -156,11 +162,11 @@
   12.88   * e.g. left-shift vs right-shift. 
   12.89   */
   12.90  static void
   12.91 -HandleModifierSide(int keyboard, unsigned short scancode,
   12.92 +HandleModifierSide(int keyboard,
   12.93                     int device_independent_mask, 
   12.94                     unsigned int oldMods, unsigned int newMods, 
   12.95 -                   SDLKey left_key_sym, 
   12.96 -                   SDLKey right_key_sym,
   12.97 +                   SDL_scancode left_scancode, 
   12.98 +                   SDL_scancode right_scancode,
   12.99                     unsigned int left_device_dependent_mask, 
  12.100                     unsigned int right_device_dependent_mask)
  12.101  {
  12.102 @@ -174,7 +180,7 @@
  12.103       */
  12.104      if ((device_dependent_mask & newMods) == 0) {
  12.105          /* Revert to the old behavior */
  12.106 -        HandleNonDeviceModifier(keyboard, scancode, device_independent_mask, oldMods, newMods, left_key_sym);
  12.107 +        HandleNonDeviceModifier(keyboard, device_independent_mask, oldMods, newMods, left_scancode);
  12.108          return;
  12.109      }
  12.110  
  12.111 @@ -187,10 +193,10 @@
  12.112           * change or if the bits don't both exist.
  12.113           */
  12.114          if (left_device_dependent_mask & diff_mod) {
  12.115 -            HandleModifierOneSide(keyboard, scancode, oldMods, newMods, left_key_sym, left_device_dependent_mask);
  12.116 +            HandleModifierOneSide(keyboard, oldMods, newMods, left_scancode, left_device_dependent_mask);
  12.117          }
  12.118          if (right_device_dependent_mask & diff_mod) {
  12.119 -            HandleModifierOneSide(keyboard, scancode, oldMods, newMods, right_key_sym, right_device_dependent_mask);
  12.120 +            HandleModifierOneSide(keyboard, oldMods, newMods, right_scancode, right_device_dependent_mask);
  12.121          }
  12.122      }
  12.123  }
  12.124 @@ -201,11 +207,11 @@
  12.125   * can't still be down).
  12.126   */
  12.127  static void
  12.128 -ReleaseModifierSide(int keyboard, unsigned short scancode,
  12.129 +ReleaseModifierSide(int keyboard,
  12.130                      unsigned int device_independent_mask, 
  12.131                      unsigned int oldMods, unsigned int newMods,
  12.132 -                    SDLKey left_key_sym, 
  12.133 -                    SDLKey right_key_sym,
  12.134 +                    SDL_scancode left_scancode, 
  12.135 +                    SDL_scancode right_scancode,
  12.136                      unsigned int left_device_dependent_mask, 
  12.137                      unsigned int right_device_dependent_mask)
  12.138  {
  12.139 @@ -220,7 +226,7 @@
  12.140          /* In this case, we can't detect the keyboard, so use the left side 
  12.141           * to represent both, and release it. 
  12.142           */
  12.143 -        SDL_SendKeyboardKey(keyboard, SDL_RELEASED, (Uint8)scancode, left_key_sym);
  12.144 +        SDL_SendKeyboardKey(keyboard, SDL_RELEASED, left_scancode);
  12.145          return;
  12.146      }
  12.147  
  12.148 @@ -231,10 +237,10 @@
  12.149       * so I hope this doesn't cause other problems.
  12.150       */
  12.151      if ( left_device_dependent_mask & oldMods ) {
  12.152 -        SDL_SendKeyboardKey(keyboard, SDL_RELEASED, (Uint8)scancode, left_key_sym);
  12.153 +        SDL_SendKeyboardKey(keyboard, SDL_RELEASED, left_scancode);
  12.154      }
  12.155      if ( right_device_dependent_mask & oldMods ) {
  12.156 -        SDL_SendKeyboardKey(keyboard, SDL_RELEASED, (Uint8)scancode, right_key_sym);
  12.157 +        SDL_SendKeyboardKey(keyboard, SDL_RELEASED, right_scancode);
  12.158      }
  12.159  }
  12.160  
  12.161 @@ -251,16 +257,16 @@
  12.162      newMask = newMods & NSAlphaShiftKeyMask;
  12.163  
  12.164      if (oldMask != newMask) {
  12.165 -        SDL_SendKeyboardKey(keyboard, SDL_PRESSED, (Uint8)scancode, SDLK_CAPSLOCK);
  12.166 -        SDL_SendKeyboardKey(keyboard, SDL_RELEASED, (Uint8)scancode, SDLK_CAPSLOCK);
  12.167 +        SDL_SendKeyboardKey(keyboard, SDL_PRESSED, SDL_SCANCODE_CAPSLOCK);
  12.168 +        SDL_SendKeyboardKey(keyboard, SDL_RELEASED, SDL_SCANCODE_CAPSLOCK);
  12.169      }
  12.170  
  12.171      oldMask = oldMods & NSNumericPadKeyMask;
  12.172      newMask = newMods & NSNumericPadKeyMask;
  12.173  
  12.174      if (oldMask != newMask) {
  12.175 -        SDL_SendKeyboardKey(keyboard, SDL_PRESSED, (Uint8)scancode, SDLK_KP_NUMLOCKCLEAR);
  12.176 -        SDL_SendKeyboardKey(keyboard, SDL_RELEASED, (Uint8)scancode, SDLK_KP_NUMLOCKCLEAR);
  12.177 +        SDL_SendKeyboardKey(keyboard, SDL_PRESSED, SDL_SCANCODE_NUMLOCKCLEAR);
  12.178 +        SDL_SendKeyboardKey(keyboard, SDL_RELEASED, SDL_SCANCODE_NUMLOCKCLEAR);
  12.179      }
  12.180  }
  12.181  
  12.182 @@ -272,8 +278,18 @@
  12.183                   unsigned int oldMods, unsigned int newMods)
  12.184  {
  12.185  	/* Set up arrays for the key syms for the left and right side. */
  12.186 -    const SDLKey left_mapping[]  = { SDLK_LSHIFT, SDLK_LCTRL, SDLK_LALT, SDLK_LMETA };
  12.187 -    const SDLKey right_mapping[] = { SDLK_RSHIFT, SDLK_RCTRL, SDLK_RALT, SDLK_RMETA };
  12.188 +    const SDL_scancode left_mapping[]  = {
  12.189 +        SDL_SCANCODE_LSHIFT,
  12.190 +        SDL_SCANCODE_LCTRL,
  12.191 +        SDL_SCANCODE_LALT,
  12.192 +        SDL_SCANCODE_LGUI
  12.193 +    };
  12.194 +    const SDL_scancode right_mapping[] = {
  12.195 +        SDL_SCANCODE_RSHIFT,
  12.196 +        SDL_SCANCODE_RCTRL,
  12.197 +        SDL_SCANCODE_RALT,
  12.198 +        SDL_SCANCODE_RGUI
  12.199 +    };
  12.200  	/* Set up arrays for the device dependent masks with indices that 
  12.201       * correspond to the _mapping arrays 
  12.202       */
  12.203 @@ -296,7 +312,7 @@
  12.204           * and right side keys may alternate or both may be pressed.
  12.205           */
  12.206          if (newMask) {
  12.207 -            HandleModifierSide(keyboard, scancode, bit, oldMods, newMods,
  12.208 +            HandleModifierSide(keyboard, bit, oldMods, newMods,
  12.209                                 left_mapping[i], right_mapping[i],
  12.210                                 left_device_mapping[i], right_device_mapping[i]);
  12.211          }
  12.212 @@ -304,7 +320,7 @@
  12.213              * the device dependent bits to release the correct keys.
  12.214              */
  12.215          else if (oldMask && oldMask != newMask) {
  12.216 -            ReleaseModifierSide(keyboard, scancode, bit, oldMods, newMods,
  12.217 +            ReleaseModifierSide(keyboard, bit, oldMods, newMods,
  12.218                                left_mapping[i], right_mapping[i],
  12.219                                left_device_mapping[i], right_device_mapping[i]);
  12.220          }
  12.221 @@ -332,6 +348,109 @@
  12.222      data->modifierFlags = modifierFlags;
  12.223  }
  12.224  
  12.225 +static void
  12.226 +UpdateKeymap(SDL_VideoData *data)
  12.227 +{
  12.228 +    KeyboardLayoutRef key_layout;
  12.229 +    const void *chr_data;
  12.230 +    int i;
  12.231 +    SDL_scancode scancode;
  12.232 +    SDLKey keymap[SDL_NUM_SCANCODES];
  12.233 +
  12.234 +    /* See if the keymap needs to be updated */
  12.235 +    KLGetCurrentKeyboardLayout(&key_layout);
  12.236 +    if (key_layout == data->key_layout) {
  12.237 +        return;
  12.238 +    }
  12.239 +    data->key_layout = key_layout;
  12.240 +
  12.241 +    SDL_GetDefaultKeymap(keymap);
  12.242 +
  12.243 +    /* Try Unicode data first (preferred as of Mac OS X 10.5) */
  12.244 +    KLGetKeyboardLayoutProperty(key_layout, kKLuchrData, &chr_data);
  12.245 +    if (chr_data) {
  12.246 +        UInt32 keyboard_type = LMGetKbdType();
  12.247 +        OSStatus err;
  12.248 +
  12.249 +        for (i = 0; i < SDL_arraysize(scancode_table); i++) {
  12.250 +            UniChar s[8];
  12.251 +            UniCharCount len;
  12.252 +            UInt32 dead_key_state;
  12.253 +
  12.254 +            /* Make sure this scancode is a valid character scancode */
  12.255 +            scancode = scancode_table[i];
  12.256 +            if (scancode == SDL_SCANCODE_UNKNOWN ||
  12.257 +                (keymap[scancode] & SDLK_SCANCODE_MASK)) {
  12.258 +                continue;
  12.259 +            }
  12.260 +
  12.261 +            dead_key_state = 0;
  12.262 +            err = UCKeyTranslate (chr_data, i, kUCKeyActionDown,
  12.263 +                                  0, keyboard_type,
  12.264 +                                  kUCKeyTranslateNoDeadKeysMask,
  12.265 +                                  &dead_key_state, 8, &len, s);
  12.266 +            if (err != noErr)
  12.267 +                continue;
  12.268 +
  12.269 +            if (len > 0 && s[0] != 0x10) {
  12.270 +                keymap[scancode] = s[0];
  12.271 +            }
  12.272 +        }
  12.273 +        SDL_SetKeymap(data->keyboard, 0, keymap, SDL_NUM_SCANCODES);
  12.274 +        return;
  12.275 +    }
  12.276 +
  12.277 +    /* Fall back to older style key map data */
  12.278 +    KLGetKeyboardLayoutProperty(key_layout, kKLKCHRData, &chr_data);
  12.279 +    if (chr_data) {
  12.280 +        for (i = 0; i < 128; i++) {
  12.281 +            UInt32 c, state = 0;
  12.282 +
  12.283 +            /* Make sure this scancode is a valid character scancode */
  12.284 +            scancode = scancode_table[i];
  12.285 +            if (scancode == SDL_SCANCODE_UNKNOWN ||
  12.286 +                (keymap[scancode] & SDLK_SCANCODE_MASK)) {
  12.287 +                continue;
  12.288 +            }
  12.289 +
  12.290 +            c = KeyTranslate (chr_data, i, &state);
  12.291 +            if (state) {
  12.292 +                /* Dead key, process key up */
  12.293 +                c = KeyTranslate (chr_data, i | 128, &state);
  12.294 +            }
  12.295 +
  12.296 +            if (c != 0 && c != 0x10 && c < 256) {
  12.297 +                /* MacRoman to Unicode table, taken from X.org sources */
  12.298 +                static const unsigned short macroman_table[128] = {
  12.299 +                    0xc4, 0xc5, 0xc7, 0xc9, 0xd1, 0xd6, 0xdc, 0xe1,
  12.300 +                    0xe0, 0xe2, 0xe4, 0xe3, 0xe5, 0xe7, 0xe9, 0xe8,
  12.301 +                    0xea, 0xeb, 0xed, 0xec, 0xee, 0xef, 0xf1, 0xf3,
  12.302 +                    0xf2, 0xf4, 0xf6, 0xf5, 0xfa, 0xf9, 0xfb, 0xfc,
  12.303 +                    0x2020, 0xb0, 0xa2, 0xa3, 0xa7, 0x2022, 0xb6, 0xdf,
  12.304 +                    0xae, 0xa9, 0x2122, 0xb4, 0xa8, 0x2260, 0xc6, 0xd8,
  12.305 +                    0x221e, 0xb1, 0x2264, 0x2265, 0xa5, 0xb5, 0x2202, 0x2211,
  12.306 +                    0x220f, 0x3c0, 0x222b, 0xaa, 0xba, 0x3a9, 0xe6, 0xf8,
  12.307 +                    0xbf, 0xa1, 0xac, 0x221a, 0x192, 0x2248, 0x2206, 0xab,
  12.308 +                    0xbb, 0x2026, 0xa0, 0xc0, 0xc3, 0xd5, 0x152, 0x153,
  12.309 +                    0x2013, 0x2014, 0x201c, 0x201d, 0x2018, 0x2019, 0xf7, 0x25ca,
  12.310 +                    0xff, 0x178, 0x2044, 0x20ac, 0x2039, 0x203a, 0xfb01, 0xfb02,
  12.311 +                    0x2021, 0xb7, 0x201a, 0x201e, 0x2030, 0xc2, 0xca, 0xc1,
  12.312 +                    0xcb, 0xc8, 0xcd, 0xce, 0xcf, 0xcc, 0xd3, 0xd4,
  12.313 +                    0xf8ff, 0xd2, 0xda, 0xdb, 0xd9, 0x131, 0x2c6, 0x2dc,
  12.314 +                    0xaf, 0x2d8, 0x2d9, 0x2da, 0xb8, 0x2dd, 0x2db, 0x2c7,
  12.315 +                };
  12.316 +
  12.317 +                if (c >= 128) {
  12.318 +                    c = macroman_table[c - 128];
  12.319 +                }
  12.320 +                keymap[scancode] = c;
  12.321 +            }
  12.322 +        }
  12.323 +        SDL_SetKeymap(data->keyboard, 0, keymap, SDL_NUM_SCANCODES);
  12.324 +        return;
  12.325 +    }
  12.326 +}
  12.327 +
  12.328  void
  12.329  Cocoa_InitKeyboard(_THIS)
  12.330  {
  12.331 @@ -345,13 +464,15 @@
  12.332      
  12.333      SDL_zero(keyboard);
  12.334      data->keyboard = SDL_AddKeyboard(&keyboard, -1);
  12.335 +    UpdateKeymap(data);
  12.336      
  12.337      /* Set our own names for the platform-dependent but layout-independent keys */
  12.338 -    SDL_SetKeyName(SDLK_KP_NUMLOCKCLEAR, "clear");
  12.339 -    SDL_SetKeyName(SDLK_LALT, "left option");
  12.340 -    SDL_SetKeyName(SDLK_LMETA, "left command");
  12.341 -    SDL_SetKeyName(SDLK_RALT, "right option");
  12.342 -    SDL_SetKeyName(SDLK_RMETA, "right command");
  12.343 +    /* This key is NumLock on the MacBook keyboard. :) */
  12.344 +    /*SDL_SetScancodeName(SDL_SCANCODE_NUMLOCKCLEAR, "Clear");*/
  12.345 +    SDL_SetScancodeName(SDL_SCANCODE_LALT, "Left Option");
  12.346 +    SDL_SetScancodeName(SDL_SCANCODE_LGUI, "Left Command");
  12.347 +    SDL_SetScancodeName(SDL_SCANCODE_RALT, "Right Option");
  12.348 +    SDL_SetScancodeName(SDL_SCANCODE_RGUI, "Right Command");
  12.349  }
  12.350  
  12.351  void
  12.352 @@ -359,27 +480,30 @@
  12.353  {
  12.354      SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
  12.355      unsigned short scancode = [event keyCode];
  12.356 -    SDLKey physicalKey;
  12.357 +    SDL_scancode code;
  12.358      const char *text;
  12.359  
  12.360      if ((scancode == 10 || scancode == 50) && KBGetLayoutType(LMGetKbdType()) == kKeyboardISO) {
  12.361          /* see comments in SDL_cocoakeys.h */
  12.362          scancode = 60 - scancode;
  12.363      }
  12.364 -    if (scancode < SDL_arraysize(macToSDLKey)) {
  12.365 -        physicalKey = macToSDLKey[scancode];
  12.366 +    if (scancode < SDL_arraysize(scancode_table)) {
  12.367 +        code = scancode_table[scancode];
  12.368      }
  12.369      else {
  12.370          /* Hmm, does this ever happen?  If so, need to extend the keymap... */
  12.371 -        physicalKey = SDLK_UNKNOWN;
  12.372 +        code = SDL_SCANCODE_UNKNOWN;
  12.373      }
  12.374  
  12.375      switch ([event type]) {
  12.376      case NSKeyDown:
  12.377          if (![event isARepeat]) {
  12.378 -            SDL_SendKeyboardKey(data->keyboard, SDL_PRESSED, (Uint8)scancode, physicalKey);
  12.379 +            /* See if we need to rebuild the keyboard layout */
  12.380 +            UpdateKeymap(data);
  12.381 +
  12.382 +            SDL_SendKeyboardKey(data->keyboard, SDL_PRESSED, code);
  12.383  #if 1
  12.384 -            if (physicalKey == SDLK_UNKNOWN) {
  12.385 +            if (code == SDL_SCANCODE_UNKNOWN) {
  12.386                  fprintf(stderr, "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>. Mac virtual key code is %d.\n", scancode);
  12.387              }
  12.388  #endif
  12.389 @@ -395,7 +519,7 @@
  12.390          }
  12.391          break;
  12.392      case NSKeyUp:
  12.393 -        SDL_SendKeyboardKey(data->keyboard, SDL_RELEASED, (Uint8)scancode, physicalKey);
  12.394 +        SDL_SendKeyboardKey(data->keyboard, SDL_RELEASED, code);
  12.395          break;
  12.396      case NSFlagsChanged:
  12.397          /* FIXME CW 2007-08-14: check if this whole mess that takes up half of this file is really necessary */
  12.398 @@ -406,128 +530,6 @@
  12.399      }
  12.400  }
  12.401  
  12.402 -SDLKey
  12.403 -Cocoa_GetLayoutKey(_THIS, SDLKey physicalKey)
  12.404 -{
  12.405 -    switch (physicalKey) {
  12.406 -        /* Many of these keys would generate a character in the translation by keyboard layout, but an inappropriate one, so we catch them before. */
  12.407 -        case SDLK_UNKNOWN:
  12.408 -        case SDLK_RETURN:
  12.409 -        case SDLK_ESCAPE:
  12.410 -        case SDLK_BACKSPACE:
  12.411 -        case SDLK_TAB:
  12.412 -        case SDLK_SPACE:
  12.413 -        case SDLK_CAPSLOCK:
  12.414 -        case SDLK_F1:
  12.415 -        case SDLK_F2:
  12.416 -        case SDLK_F3:
  12.417 -        case SDLK_F4:
  12.418 -        case SDLK_F5:
  12.419 -        case SDLK_F6:
  12.420 -        case SDLK_F7:
  12.421 -        case SDLK_F8:
  12.422 -        case SDLK_F9:
  12.423 -        case SDLK_F10:
  12.424 -        case SDLK_F11:
  12.425 -        case SDLK_F12:
  12.426 -        case SDLK_PRINTSCREEN:
  12.427 -        case SDLK_SCROLLLOCK:
  12.428 -        case SDLK_PAUSE:
  12.429 -        case SDLK_INSERT:
  12.430 -        case SDLK_HOME:
  12.431 -        case SDLK_PAGEUP:
  12.432 -        case SDLK_DELETE:
  12.433 -        case SDLK_END:
  12.434 -        case SDLK_PAGEDOWN:
  12.435 -        case SDLK_RIGHT:
  12.436 -        case SDLK_LEFT:
  12.437 -        case SDLK_DOWN:
  12.438 -        case SDLK_UP:
  12.439 -        case SDLK_KP_NUMLOCKCLEAR:
  12.440 -        case SDLK_KP_ENTER:
  12.441 -        case SDLK_APPLICATION:
  12.442 -        case SDLK_POWER:
  12.443 -        case SDLK_F13:
  12.444 -        case SDLK_F14:
  12.445 -        case SDLK_F15:
  12.446 -        case SDLK_F16:
  12.447 -        case SDLK_LCTRL:
  12.448 -        case SDLK_LSHIFT:
  12.449 -        case SDLK_LALT:
  12.450 -        case SDLK_LMETA:
  12.451 -        case SDLK_RCTRL:
  12.452 -        case SDLK_RSHIFT:
  12.453 -        case SDLK_RALT:
  12.454 -        case SDLK_RMETA:
  12.455 -            return physicalKey;
  12.456 -        
  12.457 -        /* For the rest, we try the translation first. */
  12.458 -        default: {
  12.459 -            UInt16 vkey = 0;
  12.460 -            KeyboardLayoutRef layout;
  12.461 -            KeyboardLayoutKind kind;
  12.462 -            UInt32 keyboardType = LMGetKbdType();
  12.463 -            
  12.464 -            /* Look up pkey to get a Mac virtual key code - linear search isn't terribly efficient, this might have to be optimized. */
  12.465 -            while (vkey < 128 && physicalKey != macToSDLKey[vkey]) vkey++;
  12.466 -            if (vkey == 128) return physicalKey;
  12.467 -            if ((vkey == 10 || vkey == 50) && KBGetLayoutType(keyboardType) == kKeyboardISO) vkey = 60 - vkey; /* see comments in SDL_cocoakeys.h */
  12.468 -            
  12.469 -            if (KLGetCurrentKeyboardLayout(&layout) != noErr) return physicalKey;
  12.470 -            if (KLGetKeyboardLayoutProperty(layout, kKLKind, (const void **)&kind) != noErr) return physicalKey;
  12.471 -            if (kind == kKLKCHRuchrKind || kind == kKLuchrKind) {
  12.472 -                UniChar utf16String[4];
  12.473 -                UInt32 deadKeyState = 0;
  12.474 -                UniCharCount actualStringLength;
  12.475 -                const UCKeyboardLayout *uchrData;
  12.476 -                
  12.477 -                if (KLGetKeyboardLayoutProperty(layout, kKLuchrData, (const void **)&uchrData) != noErr) return physicalKey;
  12.478 -                if (UCKeyTranslate(uchrData, vkey, kUCKeyActionDisplay, 0, keyboardType, 0, &deadKeyState, 4, &actualStringLength, utf16String) != noErr) return physicalKey;
  12.479 -                /* kUCKeyActionDisplay (instead of kUCKeyActionDown) seems to take care of dead keys, so no need to check for that case and simulate a second key press */
  12.480 -                
  12.481 -                if (actualStringLength == 0) return physicalKey;
  12.482 -                
  12.483 -                /* Decode the first character from UTF-16. I'm not sure if this is appropriate for keyboard layouts that generate more than 1 character, or if we would have to use SDL_KEY_LAYOUT_SPECIAL_BIT in that case. */
  12.484 -                if (utf16String[0] < 0xD800 || utf16String[0] > 0xDFFF) {
  12.485 -                    return utf16String[0];
  12.486 -                }
  12.487 -                else if (utf16String[0] > 0xDBFF || utf16String[1] < 0xDC00 || utf16String[1] > 0xDFFF) {
  12.488 -                    /* invalid UTF-16 */
  12.489 -                    return physicalKey;
  12.490 -                }
  12.491 -                else {
  12.492 -                    return (((utf16String[0] & 0x3FF) << 10) | (utf16String[1] & 0x3FF)) + 0x10000;
  12.493 -                }
  12.494 -            }
  12.495 -            else { /* kind == kKLKCHRKind */
  12.496 -                const void *kchrData;
  12.497 -                UInt32 state = 0;
  12.498 -                UInt8 charCode;
  12.499 -                SInt32 scriptCode;
  12.500 -                TextEncoding keyboardEncoding;
  12.501 -                CFStringRef conversionString;
  12.502 -                UniChar codepoint;
  12.503 -                
  12.504 -                if (KLGetKeyboardLayoutProperty(layout, kKLKCHRData, &kchrData) != noErr) return physicalKey;
  12.505 -                charCode = KeyTranslate(kchrData, vkey, &state) & 0xFF; /* Actually returns a UInt32 containing two character codes (and two 'reserved' bytes), but we're only interested in the second (or only) one */
  12.506 -                if (charCode == 0) {
  12.507 -                    /* It's a dead key, so simulate a second key press */
  12.508 -                    charCode = KeyTranslate(kchrData, vkey, &state) & 0xFF;
  12.509 -                    /* Still zero? Give up. */
  12.510 -                    if (charCode == 0) return physicalKey;
  12.511 -                }
  12.512 -                if (KLGetKeyboardLayoutProperty(layout, kKLGroupIdentifier, (const void **)&scriptCode) != noErr) return physicalKey; /* That the group identifier is actually a script code is not documented, but confirmed here: <http://lists.apple.com/archives/carbon-dev/2005/Jan/msg00533.html> */
  12.513 -                if (UpgradeScriptInfoToTextEncoding(scriptCode, kTextLanguageDontCare, kTextRegionDontCare, NULL, &keyboardEncoding) != noErr) return physicalKey;
  12.514 -                
  12.515 -                conversionString = CFStringCreateWithBytes(kCFAllocatorDefault, &charCode, 1, keyboardEncoding, FALSE);
  12.516 -                codepoint = CFStringGetCharacterAtIndex(conversionString, 0);
  12.517 -                CFRelease(conversionString);
  12.518 -                return codepoint;
  12.519 -            }
  12.520 -        }
  12.521 -    }
  12.522 -}
  12.523 -
  12.524  void
  12.525  Cocoa_QuitKeyboard(_THIS)
  12.526  {
    13.1 --- a/src/video/cocoa/SDL_cocoakeys.h	Mon Feb 04 17:25:33 2008 +0000
    13.2 +++ b/src/video/cocoa/SDL_cocoakeys.h	Tue Feb 05 07:19:23 2008 +0000
    13.3 @@ -27,134 +27,134 @@
    13.4     - experimentation on various ADB and USB ISO keyboards and one ADB ANSI keyboard
    13.5  */
    13.6  /* *INDENT-OFF* */
    13.7 -static SDLKey macToSDLKey[128] = {
    13.8 -    /*   0 */   SDLK_A,
    13.9 -    /*   1 */   SDLK_S,
   13.10 -    /*   2 */   SDLK_D,
   13.11 -    /*   3 */   SDLK_F,
   13.12 -    /*   4 */   SDLK_H,
   13.13 -    /*   5 */   SDLK_G,
   13.14 -    /*   6 */   SDLK_Z,
   13.15 -    /*   7 */   SDLK_X,
   13.16 -    /*   8 */   SDLK_C,
   13.17 -    /*   9 */   SDLK_V,
   13.18 -    /*  10 */   SDLK_NONUSBACKSLASH, /* SDLK_NONUSBACKSLASH on ANSI and JIS keyboards (if this key would exist there), SDLK_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.) */
   13.19 -    /*  11 */   SDLK_B,
   13.20 -    /*  12 */   SDLK_Q,
   13.21 -    /*  13 */   SDLK_W,
   13.22 -    /*  14 */   SDLK_E,
   13.23 -    /*  15 */   SDLK_R,
   13.24 -    /*  16 */   SDLK_Y,
   13.25 -    /*  17 */   SDLK_T,
   13.26 -    /*  18 */   SDLK_1,
   13.27 -    /*  19 */   SDLK_2,
   13.28 -    /*  20 */   SDLK_3,
   13.29 -    /*  21 */   SDLK_4,
   13.30 -    /*  22 */   SDLK_6,
   13.31 -    /*  23 */   SDLK_5,
   13.32 -    /*  24 */   SDLK_EQUALS,
   13.33 -    /*  25 */   SDLK_9,
   13.34 -    /*  26 */   SDLK_7,
   13.35 -    /*  27 */   SDLK_HYPHENMINUS,
   13.36 -    /*  28 */   SDLK_8,
   13.37 -    /*  29 */   SDLK_0,
   13.38 -    /*  30 */   SDLK_RIGHTBRACKET,
   13.39 -    /*  31 */   SDLK_O,
   13.40 -    /*  32 */   SDLK_U,
   13.41 -    /*  33 */   SDLK_LEFTBRACKET,
   13.42 -    /*  34 */   SDLK_I,
   13.43 -    /*  35 */   SDLK_P,
   13.44 -    /*  36 */   SDLK_RETURN,
   13.45 -    /*  37 */   SDLK_L,
   13.46 -    /*  38 */   SDLK_J,
   13.47 -    /*  39 */   SDLK_APOSTROPHE,
   13.48 -    /*  40 */   SDLK_K,
   13.49 -    /*  41 */   SDLK_SEMICOLON,
   13.50 -    /*  42 */   SDLK_BACKSLASH,
   13.51 -    /*  43 */   SDLK_COMMA,
   13.52 -    /*  44 */   SDLK_SLASH,
   13.53 -    /*  45 */   SDLK_N,
   13.54 -    /*  46 */   SDLK_M,
   13.55 -    /*  47 */   SDLK_PERIOD,
   13.56 -    /*  48 */   SDLK_TAB,
   13.57 -    /*  49 */   SDLK_SPACE,
   13.58 -    /*  50 */   SDLK_GRAVE, /* SDLK_GRAVE on ANSI and JIS keyboards, SDLK_NONUSBACKSLASH on ISO (see comment about virtual key code 10 above) */
   13.59 -    /*  51 */   SDLK_BACKSPACE,
   13.60 -    /*  52 */   SDLK_KP_ENTER, /* keyboard enter on portables */
   13.61 -    /*  53 */   SDLK_ESCAPE,
   13.62 -    /*  54 */   SDLK_RMETA,
   13.63 -    /*  55 */   SDLK_LMETA,
   13.64 -    /*  56 */   SDLK_LSHIFT,
   13.65 -    /*  57 */   SDLK_CAPSLOCK,
   13.66 -    /*  58 */   SDLK_LALT,
   13.67 -    /*  59 */   SDLK_LCTRL,
   13.68 -    /*  60 */   SDLK_RSHIFT,
   13.69 -    /*  61 */   SDLK_RALT,
   13.70 -    /*  62 */   SDLK_RCTRL,
   13.71 -    /*  63 */   SDLK_NONE, /* fn on portables, acts as a hardware-level modifier already, so we don't generate events for it */
   13.72 -    /*  64 */   SDLK_UNKNOWN, /* unknown (unused?) */
   13.73 -    /*  65 */   SDLK_KP_PERIOD,
   13.74 -    /*  66 */   SDLK_UNKNOWN, /* unknown (unused?) */
   13.75 -    /*  67 */   SDLK_KP_MULTIPLY,
   13.76 -    /*  68 */   SDLK_UNKNOWN, /* unknown (unused?) */
   13.77 -    /*  69 */   SDLK_KP_PLUS,
   13.78 -    /*  70 */   SDLK_UNKNOWN, /* unknown (unused?) */
   13.79 -    /*  71 */   SDLK_KP_NUMLOCKCLEAR,
   13.80 -    /*  72 */   SDLK_VOLUMEUP,
   13.81 -    /*  73 */   SDLK_VOLUMEDOWN,
   13.82 -    /*  74 */   SDLK_MUTE,
   13.83 -    /*  75 */   SDLK_KP_DIVIDE,
   13.84 -    /*  76 */   SDLK_KP_ENTER, /* keypad enter on external keyboards, fn-return on portables */
   13.85 -    /*  77 */   SDLK_UNKNOWN, /* unknown (unused?) */
   13.86 -    /*  78 */   SDLK_KP_MINUS,
   13.87 -    /*  79 */   SDLK_UNKNOWN, /* unknown (unused?) */
   13.88 -    /*  80 */   SDLK_UNKNOWN, /* unknown (unused?) */
   13.89 -    /*  81 */   SDLK_KP_EQUALS,
   13.90 -    /*  82 */   SDLK_KP_0,
   13.91 -    /*  83 */   SDLK_KP_1,
   13.92 -    /*  84 */   SDLK_KP_2,
   13.93 -    /*  85 */   SDLK_KP_3,
   13.94 -    /*  86 */   SDLK_KP_4,
   13.95 -    /*  87 */   SDLK_KP_5,
   13.96 -    /*  88 */   SDLK_KP_6,
   13.97 -    /*  89 */   SDLK_KP_7,
   13.98 -    /*  90 */   SDLK_UNKNOWN, /* unknown (unused?) */
   13.99 -    /*  91 */   SDLK_KP_8,
  13.100 -    /*  92 */   SDLK_KP_9,
  13.101 -    /*  93 */   SDLK_INTERNATIONAL3, /* Cosmo_USB2ADB.c says "Yen (JIS)" */
  13.102 -    /*  94 */   SDLK_INTERNATIONAL1, /* Cosmo_USB2ADB.c says "Ro (JIS)" */
  13.103 -    /*  95 */   SDLK_KP_COMMA, /* Cosmo_USB2ADB.c says ", JIS only" */
  13.104 -    /*  96 */   SDLK_F5,
  13.105 -    /*  97 */   SDLK_F6,
  13.106 -    /*  98 */   SDLK_F7,
  13.107 -    /*  99 */   SDLK_F3,
  13.108 -    /* 100 */   SDLK_F8,
  13.109 -    /* 101 */   SDLK_F9,
  13.110 -    /* 102 */   SDLK_LANG2, /* Cosmo_USB2ADB.c says "Eisu" */
  13.111 -    /* 103 */   SDLK_F11,
  13.112 -    /* 104 */   SDLK_LANG1, /* Cosmo_USB2ADB.c says "Kana" */
  13.113 -    /* 105 */   SDLK_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 (SDLK_F13). I decided to use SDLK_PRINTSCREEN here nevertheless since SDL applications are more likely to assume the presence of a print screen key than an F13 key. */
  13.114 -    /* 106 */   SDLK_F16,
  13.115 -    /* 107 */   SDLK_SCROLLLOCK, /* F14/scroll lock, see comment about F13/print screen above */
  13.116 -    /* 108 */   SDLK_UNKNOWN, /* unknown (unused?) */
  13.117 -    /* 109 */   SDLK_F10,
  13.118 -    /* 110 */   SDLK_APPLICATION, /* windows contextual menu key, fn-enter on portables */
  13.119 -    /* 111 */   SDLK_F12,
  13.120 -    /* 112 */   SDLK_UNKNOWN, /* unknown (unused?) */
  13.121 -    /* 113 */   SDLK_PAUSE, /* F15/pause, see comment about F13/print screen above */
  13.122 -    /* 114 */   SDLK_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 */
  13.123 -    /* 115 */   SDLK_HOME,
  13.124 -    /* 116 */   SDLK_PAGEUP,
  13.125 -    /* 117 */   SDLK_DELETE,
  13.126 -    /* 118 */   SDLK_F4,
  13.127 -    /* 119 */   SDLK_END,
  13.128 -    /* 120 */   SDLK_F2,
  13.129 -    /* 121 */   SDLK_PAGEDOWN,
  13.130 -    /* 122 */   SDLK_F1,
  13.131 -    /* 123 */   SDLK_LEFT,
  13.132 -    /* 124 */   SDLK_RIGHT,
  13.133 -    /* 125 */   SDLK_DOWN,
  13.134 -    /* 126 */   SDLK_UP,
  13.135 -    /* 127 */   SDLK_POWER
  13.136 +static SDL_scancode scancode_table[128] = {
  13.137 +    /*   0 */   SDL_SCANCODE_A,
  13.138 +    /*   1 */   SDL_SCANCODE_S,
  13.139 +    /*   2 */   SDL_SCANCODE_D,
  13.140 +    /*   3 */   SDL_SCANCODE_F,
  13.141 +    /*   4 */   SDL_SCANCODE_H,
  13.142 +    /*   5 */   SDL_SCANCODE_G,
  13.143 +    /*   6 */   SDL_SCANCODE_Z,
  13.144 +    /*   7 */   SDL_SCANCODE_X,
  13.145 +    /*   8 */   SDL_SCANCODE_C,
  13.146 +    /*   9 */   SDL_SCANCODE_V,
  13.147 +    /*  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.) */
  13.148 +    /*  11 */   SDL_SCANCODE_B,
  13.149 +    /*  12 */   SDL_SCANCODE_Q,
  13.150 +    /*  13 */   SDL_SCANCODE_W,
  13.151 +    /*  14 */   SDL_SCANCODE_E,
  13.152 +    /*  15 */   SDL_SCANCODE_R,
  13.153 +    /*  16 */   SDL_SCANCODE_Y,
  13.154 +    /*  17 */   SDL_SCANCODE_T,
  13.155 +    /*  18 */   SDL_SCANCODE_1,
  13.156 +    /*  19 */   SDL_SCANCODE_2,
  13.157 +    /*  20 */   SDL_SCANCODE_3,
  13.158 +    /*  21 */   SDL_SCANCODE_4,
  13.159 +    /*  22 */   SDL_SCANCODE_6,
  13.160 +    /*  23 */   SDL_SCANCODE_5,
  13.161 +    /*  24 */   SDL_SCANCODE_EQUALS,
  13.162 +    /*  25 */   SDL_SCANCODE_9,
  13.163 +    /*  26 */   SDL_SCANCODE_7,
  13.164 +    /*  27 */   SDL_SCANCODE_HYPHENMINUS,
  13.165 +    /*  28 */   SDL_SCANCODE_8,
  13.166 +    /*  29 */   SDL_SCANCODE_0,
  13.167 +    /*  30 */   SDL_SCANCODE_RIGHTBRACKET,
  13.168 +    /*  31 */   SDL_SCANCODE_O,
  13.169 +    /*  32 */   SDL_SCANCODE_U,
  13.170 +    /*  33 */   SDL_SCANCODE_LEFTBRACKET,
  13.171 +    /*  34 */   SDL_SCANCODE_I,
  13.172 +    /*  35 */   SDL_SCANCODE_P,
  13.173 +    /*  36 */   SDL_SCANCODE_RETURN,
  13.174 +    /*  37 */   SDL_SCANCODE_L,
  13.175 +    /*  38 */   SDL_SCANCODE_J,
  13.176 +    /*  39 */   SDL_SCANCODE_APOSTROPHE,
  13.177 +    /*  40 */   SDL_SCANCODE_K,
  13.178 +    /*  41 */   SDL_SCANCODE_SEMICOLON,
  13.179 +    /*  42 */   SDL_SCANCODE_BACKSLASH,
  13.180 +    /*  43 */   SDL_SCANCODE_COMMA,
  13.181 +    /*  44 */   SDL_SCANCODE_SLASH,
  13.182 +    /*  45 */   SDL_SCANCODE_N,
  13.183 +    /*  46 */   SDL_SCANCODE_M,
  13.184 +    /*  47 */   SDL_SCANCODE_PERIOD,
  13.185 +    /*  48 */   SDL_SCANCODE_TAB,
  13.186 +    /*  49 */   SDL_SCANCODE_SPACE,
  13.187 +    /*  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) */
  13.188 +    /*  51 */   SDL_SCANCODE_BACKSPACE,
  13.189 +    /*  52 */   SDL_SCANCODE_KP_ENTER, /* keyboard enter on portables */
  13.190 +    /*  53 */   SDL_SCANCODE_ESCAPE,
  13.191 +    /*  54 */   SDL_SCANCODE_RGUI,
  13.192 +    /*  55 */   SDL_SCANCODE_LGUI,
  13.193 +    /*  56 */   SDL_SCANCODE_LSHIFT,
  13.194 +    /*  57 */   SDL_SCANCODE_CAPSLOCK,
  13.195 +    /*  58 */   SDL_SCANCODE_LALT,
  13.196 +    /*  59 */   SDL_SCANCODE_LCTRL,
  13.197 +    /*  60 */   SDL_SCANCODE_RSHIFT,
  13.198 +    /*  61 */   SDL_SCANCODE_RALT,
  13.199 +    /*  62 */   SDL_SCANCODE_RCTRL,
  13.200 +    /*  63 */   SDL_SCANCODE_UNKNOWN, /* fn on portables, acts as a hardware-level modifier already, so we don't generate events for it */
  13.201 +    /*  64 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
  13.202 +    /*  65 */   SDL_SCANCODE_KP_PERIOD,
  13.203 +    /*  66 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
  13.204 +    /*  67 */   SDL_SCANCODE_KP_MULTIPLY,
  13.205 +    /*  68 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
  13.206 +    /*  69 */   SDL_SCANCODE_KP_PLUS,
  13.207 +    /*  70 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
  13.208 +    /*  71 */   SDL_SCANCODE_NUMLOCKCLEAR,
  13.209 +    /*  72 */   SDL_SCANCODE_VOLUMEUP,
  13.210 +    /*  73 */   SDL_SCANCODE_VOLUMEDOWN,
  13.211 +    /*  74 */   SDL_SCANCODE_MUTE,
  13.212 +    /*  75 */   SDL_SCANCODE_KP_DIVIDE,
  13.213 +    /*  76 */   SDL_SCANCODE_KP_ENTER, /* keypad enter on external keyboards, fn-return on portables */
  13.214 +    /*  77 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
  13.215 +    /*  78 */   SDL_SCANCODE_KP_MINUS,
  13.216 +    /*  79 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
  13.217 +    /*  80 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
  13.218 +    /*  81 */   SDL_SCANCODE_KP_EQUALS,
  13.219 +    /*  82 */   SDL_SCANCODE_KP_0,
  13.220 +    /*  83 */   SDL_SCANCODE_KP_1,
  13.221 +    /*  84 */   SDL_SCANCODE_KP_2,
  13.222 +    /*  85 */   SDL_SCANCODE_KP_3,
  13.223 +    /*  86 */   SDL_SCANCODE_KP_4,
  13.224 +    /*  87 */   SDL_SCANCODE_KP_5,
  13.225 +    /*  88 */   SDL_SCANCODE_KP_6,
  13.226 +    /*  89 */   SDL_SCANCODE_KP_7,
  13.227 +    /*  90 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
  13.228 +    /*  91 */   SDL_SCANCODE_KP_8,
  13.229 +    /*  92 */   SDL_SCANCODE_KP_9,
  13.230 +    /*  93 */   SDL_SCANCODE_INTERNATIONAL3, /* Cosmo_USB2ADB.c says "Yen (JIS)" */
  13.231 +    /*  94 */   SDL_SCANCODE_INTERNATIONAL1, /* Cosmo_USB2ADB.c says "Ro (JIS)" */
  13.232 +    /*  95 */   SDL_SCANCODE_KP_COMMA, /* Cosmo_USB2ADB.c says ", JIS only" */
  13.233 +    /*  96 */   SDL_SCANCODE_F5,
  13.234 +    /*  97 */   SDL_SCANCODE_F6,
  13.235 +    /*  98 */   SDL_SCANCODE_F7,
  13.236 +    /*  99 */   SDL_SCANCODE_F3,
  13.237 +    /* 100 */   SDL_SCANCODE_F8,
  13.238 +    /* 101 */   SDL_SCANCODE_F9,
  13.239 +    /* 102 */   SDL_SCANCODE_LANG2, /* Cosmo_USB2ADB.c says "Eisu" */
  13.240 +    /* 103 */   SDL_SCANCODE_F11,
  13.241 +    /* 104 */   SDL_SCANCODE_LANG1, /* Cosmo_USB2ADB.c says "Kana" */
  13.242 +    /* 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. */
  13.243 +    /* 106 */   SDL_SCANCODE_F16,
  13.244 +    /* 107 */   SDL_SCANCODE_SCROLLLOCK, /* F14/scroll lock, see comment about F13/print screen above */
  13.245 +    /* 108 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
  13.246 +    /* 109 */   SDL_SCANCODE_F10,
  13.247 +    /* 110 */   SDL_SCANCODE_APPLICATION, /* windows contextual menu key, fn-enter on portables */
  13.248 +    /* 111 */   SDL_SCANCODE_F12,
  13.249 +    /* 112 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
  13.250 +    /* 113 */   SDL_SCANCODE_PAUSE, /* F15/pause, see comment about F13/print screen above */
  13.251 +    /* 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 */
  13.252 +    /* 115 */   SDL_SCANCODE_HOME,
  13.253 +    /* 116 */   SDL_SCANCODE_PAGEUP,
  13.254 +    /* 117 */   SDL_SCANCODE_DELETE,
  13.255 +    /* 118 */   SDL_SCANCODE_F4,
  13.256 +    /* 119 */   SDL_SCANCODE_END,
  13.257 +    /* 120 */   SDL_SCANCODE_F2,
  13.258 +    /* 121 */   SDL_SCANCODE_PAGEDOWN,
  13.259 +    /* 122 */   SDL_SCANCODE_F1,
  13.260 +    /* 123 */   SDL_SCANCODE_LEFT,
  13.261 +    /* 124 */   SDL_SCANCODE_RIGHT,
  13.262 +    /* 125 */   SDL_SCANCODE_DOWN,
  13.263 +    /* 126 */   SDL_SCANCODE_UP,
  13.264 +    /* 127 */   SDL_SCANCODE_POWER
  13.265  };
  13.266  /* *INDENT-ON* */
    14.1 --- a/src/video/cocoa/SDL_cocoavideo.h	Mon Feb 04 17:25:33 2008 +0000
    14.2 +++ b/src/video/cocoa/SDL_cocoavideo.h	Tue Feb 05 07:19:23 2008 +0000
    14.3 @@ -45,6 +45,7 @@
    14.4      unsigned int modifierFlags;
    14.5      int mouse;
    14.6      int keyboard;
    14.7 +    void *key_layout;
    14.8      NSText *fieldEdit;
    14.9  } SDL_VideoData;
   14.10  
    15.1 --- a/src/video/cocoa/SDL_cocoavideo.m	Mon Feb 04 17:25:33 2008 +0000
    15.2 +++ b/src/video/cocoa/SDL_cocoavideo.m	Tue Feb 05 07:19:23 2008 +0000
    15.3 @@ -75,7 +75,6 @@
    15.4      device->GetDisplayModes = Cocoa_GetDisplayModes;
    15.5      device->SetDisplayMode = Cocoa_SetDisplayMode;
    15.6      device->PumpEvents = Cocoa_PumpEvents;
    15.7 -    device->GetLayoutKey = Cocoa_GetLayoutKey;
    15.8  
    15.9      device->CreateWindow = Cocoa_CreateWindow;
   15.10      device->CreateWindowFrom = Cocoa_CreateWindowFrom;
    16.1 --- a/test/checkkeys.c	Mon Feb 04 17:25:33 2008 +0000
    16.2 +++ b/test/checkkeys.c	Tue Feb 05 07:19:23 2008 +0000
    16.3 @@ -40,10 +40,10 @@
    16.4          printf(" LALT");
    16.5      if (mod & KMOD_RALT)
    16.6          printf(" RALT");
    16.7 -    if (mod & KMOD_LMETA)
    16.8 -        printf(" LMETA");
    16.9 -    if (mod & KMOD_RMETA)
   16.10 -        printf(" RMETA");
   16.11 +    if (mod & KMOD_LGUI)
   16.12 +        printf(" LGUI");
   16.13 +    if (mod & KMOD_RGUI)
   16.14 +        printf(" RGUI");
   16.15      if (mod & KMOD_NUM)
   16.16          printf(" NUM");
   16.17      if (mod & KMOD_CAPS)
   16.18 @@ -57,14 +57,13 @@
   16.19  {
   16.20      /* Print the keycode, name and state */
   16.21      if (sym->sym) {
   16.22 -        printf("Key %s:  physical 0x%08X = %s, layout 0x%08X = %s ",
   16.23 +        printf("Key %s:  scancode 0x%04X = %s, keycode 0x%08X = %s ",
   16.24                 pressed ? "pressed " : "released",
   16.25 -               sym->sym,
   16.26 -               SDL_GetKeyName(sym->sym),
   16.27 -               SDL_GetLayoutKey(sym->sym),
   16.28 -               SDL_GetKeyName(SDL_GetLayoutKey(sym->sym)));
   16.29 +               sym->scancode,
   16.30 +               SDL_GetScancodeName(sym->scancode),
   16.31 +               sym->sym, SDL_GetKeyName(sym->sym));
   16.32      } else {
   16.33 -        printf("Unknown Key (scancode = 0x%08X) %s ",
   16.34 +        printf("Unknown Key (scancode = 0x%04X) %s ",
   16.35                 sym->scancode, pressed ? "pressed" : "released");
   16.36      }
   16.37