Commit 02f2e328 authored by Sam Lantinga's avatar Sam Lantinga

First pass implementation of new SDL scancode concept, as discussed with

Christian Walther.  Currently only implemented on Mac OS X for sanity
checking purposes.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402715
parent 844280a6
...@@ -42,7 +42,7 @@ SDLMAIN_OBJECTS = @SDLMAIN_OBJECTS@ ...@@ -42,7 +42,7 @@ SDLMAIN_OBJECTS = @SDLMAIN_OBJECTS@
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 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
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 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
LT_AGE = @LT_AGE@ LT_AGE = @LT_AGE@
LT_CURRENT = @LT_CURRENT@ LT_CURRENT = @LT_CURRENT@
......
...@@ -130,47 +130,54 @@ typedef enum ...@@ -130,47 +130,54 @@ typedef enum
struct SDL_SysWMinfo; struct SDL_SysWMinfo;
/* Key codes /* Obsolete or renamed key codes */
Note that the correspondences defined here are approximate at best because
the meaning of the event structure field that carries these values has /* These key constants were renamed for clarity or consistency. */
changed: in SDL 1.2, it referred to the key's label in the current keyboard #define SDLK_a 'a'
layout, whereas now it refers to a specific physical key on the keyboard, #define SDLK_b 'b'
regardless of the keyboard layout setting. #define SDLK_c 'c'
To get comparable behavior to SDL 1.2, code that uses any of the codes below #define SDLK_d 'd'
in ways like "if (somekey == SDLK_EXCLAIM)" should be changed to the #define SDLK_e 'e'
equivalent of "if (SDL_GetLayoutKey(somekey) == '!')". #define SDLK_f 'f'
*/ #define SDLK_g 'g'
#define SDLK_h 'h'
/* These key constants were renamed for clarity or consistence. */ #define SDLK_i 'i'
#define SDLK_QUOTE SDLK_APOSTROPHE #define SDLK_j 'j'
#define SDLK_MINUS SDLK_HYPHENMINUS #define SDLK_k 'k'
#define SDLK_BACKQUOTE SDLK_GRAVE #define SDLK_l 'l'
#define SDLK_a SDLK_A #define SDLK_m 'm'
#define SDLK_b SDLK_B #define SDLK_n 'n'
#define SDLK_c SDLK_C #define SDLK_o 'o'
#define SDLK_d SDLK_D #define SDLK_p 'p'
#define SDLK_e SDLK_E #define SDLK_q 'q'
#define SDLK_f SDLK_F #define SDLK_r 'r'
#define SDLK_g SDLK_G #define SDLK_s 's'
#define SDLK_h SDLK_H #define SDLK_t 't'
#define SDLK_i SDLK_I #define SDLK_u 'u'
#define SDLK_j SDLK_J #define SDLK_v 'v'
#define SDLK_k SDLK_K #define SDLK_w 'w'
#define SDLK_l SDLK_L #define SDLK_x 'x'
#define SDLK_m SDLK_M #define SDLK_y 'y'
#define SDLK_n SDLK_N #define SDLK_z 'z'
#define SDLK_o SDLK_O #define SDLK_QUOTE '\''
#define SDLK_p SDLK_P #define SDLK_MINUS '-'
#define SDLK_q SDLK_Q #define SDLK_BACKQUOTE '`'
#define SDLK_r SDLK_R #define SDLK_EXCLAIM '!'
#define SDLK_s SDLK_S #define SDLK_QUOTEDBL '"'
#define SDLK_t SDLK_T #define SDLK_HASH '#'
#define SDLK_u SDLK_U #define SDLK_DOLLAR '$'
#define SDLK_v SDLK_V #define SDLK_AMPERSAND '&'
#define SDLK_w SDLK_W #define SDLK_LEFTPAREN '('
#define SDLK_x SDLK_X #define SDLK_RIGHTPAREN ')'
#define SDLK_y SDLK_Y #define SDLK_ASTERISK '*'
#define SDLK_z SDLK_Z #define SDLK_PLUS '+'
#define SDLK_COLON ':'
#define SDLK_LESS '<'
#define SDLK_GREATER '>'
#define SDLK_QUESTION '?'
#define SDLK_AT '@'
#define SDLK_CARET '^'
#define SDLK_UNDERSCORE '_'
#define SDLK_KP0 SDLK_KP_0 #define SDLK_KP0 SDLK_KP_0
#define SDLK_KP1 SDLK_KP_1 #define SDLK_KP1 SDLK_KP_1
#define SDLK_KP2 SDLK_KP_2 #define SDLK_KP2 SDLK_KP_2
...@@ -181,30 +188,14 @@ struct SDL_SysWMinfo; ...@@ -181,30 +188,14 @@ struct SDL_SysWMinfo;
#define SDLK_KP7 SDLK_KP_7 #define SDLK_KP7 SDLK_KP_7
#define SDLK_KP8 SDLK_KP_8 #define SDLK_KP8 SDLK_KP_8
#define SDLK_KP9 SDLK_KP_9 #define SDLK_KP9 SDLK_KP_9
#define SDLK_NUMLOCK SDLK_KP_NUMLOCKCLEAR #define SDLK_NUMLOCK SDLK_NUMLOCKCLEAR
#define SDLK_SCROLLOCK SDLK_SCROLLLOCK #define SDLK_SCROLLOCK SDLK_SCROLLLOCK
#define SDLK_PRINT SDLK_PRINTSCREEN #define SDLK_PRINT SDLK_PRINTSCREEN
/* These key constants are obsoleted by the new keyboard handling, /* The META modifier is equivalent to the GUI modifier from the USB standard */
their definitions here correspond to how they appear on a US #define KMOD_LMETA KMOD_LGUI
keyboard. */ #define KMOD_RMETA KMOD_RGUI
#define KMOD_META KMOD_GUI
#define SDLK_EXCLAIM SDLK_1
#define SDLK_QUOTEDBL SDLK_APOSTROPHE
#define SDLK_HASH SDLK_3
#define SDLK_DOLLAR SDLK_4
#define SDLK_AMPERSAND SDLK_7
#define SDLK_LEFTPAREN SDLK_9
#define SDLK_RIGHTPAREN SDLK_0
#define SDLK_ASTERISK SDLK_8
#define SDLK_PLUS SDLK_EQUALS
#define SDLK_COLON SDLK_SEMICOLON
#define SDLK_LESS SDLK_COMMA
#define SDLK_GREATER SDLK_PERIOD
#define SDLK_QUESTION SDLK_SLASH
#define SDLK_AT SDLK_2
#define SDLK_CARET SDLK_6
#define SDLK_UNDERSCORE SDLK_HYPHENMINUS
/* 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. */ /* 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. */
#define SDLK_LSUPER SDLK_LMETA #define SDLK_LSUPER SDLK_LMETA
...@@ -268,6 +259,7 @@ extern DECLSPEC void SDLCALL SDL_FreeYUVOverlay(SDL_Overlay * overlay); ...@@ -268,6 +259,7 @@ extern DECLSPEC void SDLCALL SDL_FreeYUVOverlay(SDL_Overlay * overlay);
extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers(void); extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers(void);
extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval); extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval);
extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval); extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval);
extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable);
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -48,8 +48,7 @@ extern "C" { ...@@ -48,8 +48,7 @@ extern "C" {
*/ */
typedef struct SDL_keysym typedef struct SDL_keysym
{ {
Uint8 scancode; /**< keyboard specific scancode */ SDL_scancode scancode; /**< SDL physical key code - see ::SDL_scancode for details */
Uint8 padding[3]; /**< alignment padding */
SDLKey sym; /**< SDL virtual key code - see ::SDLKey for details */ SDLKey sym; /**< SDL virtual key code - see ::SDLKey for details */
Uint16 mod; /**< current key modifiers */ Uint16 mod; /**< current key modifiers */
Uint32 unicode; /**< OBSOLETE, use SDL_TextInputEvent instead */ Uint32 unicode; /**< OBSOLETE, use SDL_TextInputEvent instead */
...@@ -80,32 +79,19 @@ extern DECLSPEC int SDLCALL SDL_GetNumKeyboards(void); ...@@ -80,32 +79,19 @@ extern DECLSPEC int SDLCALL SDL_GetNumKeyboards(void);
extern DECLSPEC int SDLCALL SDL_SelectKeyboard(int index); extern DECLSPEC int SDLCALL SDL_SelectKeyboard(int index);
/** /**
* \fn int SDL_EnableUNICODE(int enable) * \fn Uint8 *SDL_GetKeyboardState(int *numkeys)
*
* \brief Enable/Disable UNICODE translation of keyboard input.
*
* \param enable 1 to enable translation, 0 to disable translation, -1 to query translation
*
* \return The previous state of keyboard translation
*
* \note This translation has some overhead, so translation defaults off.
*/
extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable);
/**
* \fn Uint8 *SDL_GetKeyState(int *numkeys)
* *
* \brief Get a snapshot of the current state of the selected keyboard. * \brief Get a snapshot of the current state of the selected keyboard.
* *
* \param numkeys if non-NULL, receives the length of the returned array. * \param numkeys if non-NULL, receives the length of the returned array.
* *
* \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. * \return An array of key states. Indexes into this array are obtained by using ::SDL_scancode values.
* *
* Example: * Example:
* Uint8 *keystate = SDL_GetKeyState(NULL); * Uint8 *state = SDL_GetKeyboardState(NULL);
* if ( keystate[SDLK_INDEX(SDLK_RETURN)] ) ... <RETURN> is pressed. * if ( state[SDL_SCANCODE_RETURN)] ) ... <RETURN> is pressed.
*/ */
extern DECLSPEC Uint8 *SDLCALL SDL_GetKeyState(int *numkeys); extern DECLSPEC Uint8 *SDLCALL SDL_GetKeyboardState(int *numkeys);
/** /**
* \fn SDLMod SDL_GetModState(void) * \fn SDLMod SDL_GetModState(void)
...@@ -124,32 +110,49 @@ extern DECLSPEC SDLMod SDLCALL SDL_GetModState(void); ...@@ -124,32 +110,49 @@ extern DECLSPEC SDLMod SDLCALL SDL_GetModState(void);
extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate); extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate);
/** /**
* \fn SDLKey SDL_GetLayoutKey(SDLKey physicalKey) * \fn SDLKey SDL_GetKeyFromScancode(SDL_scancode scancode)
* *
* \brief Get the layout key code corresponding to the given physical key code according to the current keyboard layout. * \brief Get the key code corresponding to the given scancode according to the current keyboard layout.
* *
* See ::SDLKey for details. * See ::SDLKey for details.
* *
* If \a physicalKey is not a physical key code, it is returned unchanged.
*
* \sa SDL_GetKeyName() * \sa SDL_GetKeyName()
*/ */
extern DECLSPEC SDLKey SDLCALL SDL_GetLayoutKey(SDLKey physicalKey); extern DECLSPEC SDLKey SDLCALL SDL_GetKeyFromScancode(SDL_scancode scancode);
/** /**
* \fn const char *SDL_GetKeyName(SDLKey layoutKey) * \fn SDL_scancode SDL_GetScancodeFromKey(SDLKey key)
* *
* \brief Get a human-readable name for a key. * \brief Get the scancode corresponding to the given key code according to the current keyboard layout.
*
* See ::SDL_scancode for details.
* *
* \param layoutKey An SDL layout key code. * \sa SDL_GetScancodeName()
*/
extern DECLSPEC SDL_scancode SDLCALL SDL_GetScancodeFromKey(SDLKey key);
/**
* \fn const char *SDL_GetScancodeName(SDL_scancode scancode)
*
* \brief Get a human-readable name for a scancode.
*
* \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 "".
* *
* 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. * \sa SDL_scancode
*/
extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_scancode
scancode);
/**
* \fn const char *SDL_GetKeyName(SDLKey key)
*
* \brief Get a human-readable name for a key.
* *
* \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. * \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 "".
* *
* \sa SDLKey * \sa SDLKey
*/ */
extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDLKey layoutKey); extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDLKey key);
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
......
This diff is collapsed.
This diff is collapsed.
...@@ -1531,4 +1531,10 @@ SDL_GetKeyRepeat(int *delay, int *interval) ...@@ -1531,4 +1531,10 @@ SDL_GetKeyRepeat(int *delay, int *interval)
} }
} }
int
SDL_EnableUNICODE(int enable)
{
return SDL_EventState(SDL_TEXTINPUT, enable);
}
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */
This diff is collapsed.
...@@ -37,20 +37,12 @@ struct SDL_Keyboard ...@@ -37,20 +37,12 @@ struct SDL_Keyboard
/* Data common to all keyboards */ /* Data common to all keyboards */
SDL_WindowID focus; SDL_WindowID focus;
Uint16 modstate; Uint16 modstate;
Uint8 keystate[SDLK_LAST]; Uint8 keystate[(SDL_NUM_SCANCODES + 7) / 8];
SDLKey keymap[SDL_NUM_SCANCODES];
void *driverdata; void *driverdata;
}; };
/* Used by the OS keyboard code to detect whether or not to do UNICODE */
#ifndef DEFAULT_UNICODE_TRANSLATION
#define DEFAULT_UNICODE_TRANSLATION 0 /* Default off because of overhead */
#endif
extern int SDL_TranslateUNICODE;
/* convert UCS4 to utf8 */
extern char *SDL_Ucs4ToUtf8(Uint32 ch, char *dst);
/* Initialize the keyboard subsystem */ /* Initialize the keyboard subsystem */
extern int SDL_KeyboardInit(void); extern int SDL_KeyboardInit(void);
...@@ -68,18 +60,23 @@ extern void SDL_DelKeyboard(int index); ...@@ -68,18 +60,23 @@ extern void SDL_DelKeyboard(int index);
/* Clear the state of a keyboard at an index */ /* Clear the state of a keyboard at an index */
extern void SDL_ResetKeyboard(int index); extern void SDL_ResetKeyboard(int index);
/* Get the default keymap */
extern void SDL_GetDefaultKeymap(SDLKey * keymap);
/* Set the mapping of scancode to key codes for this keyboard */
extern void SDL_SetKeymap(int index, int start, SDLKey * keys, int length);
/* Set a platform-dependent key name, overriding the default platform-agnostic /* Set a platform-dependent key name, overriding the default platform-agnostic
name. Encoded as UTF-8. The string is not copied, thus the pointer given to name. Encoded as UTF-8. The string is not copied, thus the pointer given to
this function must stay valid forever (or at least until the call to this function must stay valid forever (or at least until the call to
VideoQuit()). */ VideoQuit()). */
extern void SDL_SetKeyName(SDLKey physicalKey, const char *name); extern void SDL_SetScancodeName(SDL_scancode scancode, const char *name);
/* Set the keyboard focus window */ /* Set the keyboard focus window */
extern void SDL_SetKeyboardFocus(int index, SDL_WindowID windowID); extern void SDL_SetKeyboardFocus(int index, SDL_WindowID windowID);
/* Send a keyboard event for a keyboard at an index */ /* Send a keyboard event for a keyboard at an index */
extern int SDL_SendKeyboardKey(int index, Uint8 state, Uint8 scancode, extern int SDL_SendKeyboardKey(int index, Uint8 state, SDL_scancode scancode);
SDLKey key);
/* Send keyboard text input for a keyboard at an index */ /* Send keyboard text input for a keyboard at an index */
extern int SDL_SendKeyboardText(int index, const char *text); extern int SDL_SendKeyboardText(int index, const char *text);
......
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2007 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Christian Walther
cwalther@gmx.ch
*/
/* Names for the physical SDLKey constants, returned by SDL_GetKeyName().
The strings are in UTF-8 encoding.
This table can (and should) be modified by a video driver in its VideoInit()
function using SDL_SetKeyName() to account for platform-dependent (but
layout-independent) key names.
The physical SDLKey codes can be divided into two groups:
- codes that occur both as physical and as layout keys. These have their
real, "user-readable" display name here.
- codes that only occur as physical keys, i.e. are never returned by
SDL_GetLayoutKey() if the backend implements it properly. These names are
therefore never returned by SDL_GetKeyName(SDL_GetLayoutKey(
event.key.keysym.sym)), the proper way of displaying a key name to the
user, but only by SDL_GetKeyName(event.key.keysym.sym), which is only
useful for debugging purposes. To emphasize this, these codes are named by
their "programmer-readable" SDLK_ constants here rather than by a
"user-readable" display name.
*/
/* *INDENT-OFF* */
static const char *SDL_keynames[SDLK_LAST] = {
/* 0 */ "", /* SDL_PK_NONE */
/* 1 */ "unknown key",
/* 2 */ NULL, /* unused */
/* 3 */ NULL, /* unused */
/* 4 */ "SDLK_A",
/* 5 */ "SDLK_B",
/* 6 */ "SDLK_C",
/* 7 */ "SDLK_D",
/* 8 */ "SDLK_E",
/* 9 */ "SDLK_F",
/* 10 */ "SDLK_G",
/* 11 */ "SDLK_H",
/* 12 */ "SDLK_I",
/* 13 */ "SDLK_J",
/* 14 */ "SDLK_K",
/* 15 */ "SDLK_L",
/* 16 */ "SDLK_M",
/* 17 */ "SDLK_N",
/* 18 */ "SDLK_O",
/* 19 */ "SDLK_P",
/* 20 */ "SDLK_Q",
/* 21 */ "SDLK_R",
/* 22 */ "SDLK_S",
/* 23 */ "SDLK_T",
/* 24 */ "SDLK_U",
/* 25 */ "SDLK_V",
/* 26 */ "SDLK_W",
/* 27 */ "SDLK_X",
/* 28 */ "SDLK_Y",
/* 29 */ "SDLK_Z",
/* 30 */ "SDLK_1",
/* 31 */ "SDLK_2",
/* 32 */ "SDLK_3",
/* 33 */ "SDLK_4",
/* 34 */ "SDLK_5",
/* 35 */ "SDLK_6",
/* 36 */ "SDLK_7",
/* 37 */ "SDLK_8",
/* 38 */ "SDLK_9",
/* 39 */ "SDLK_0",
/* 40 */ "return",
/* 41 */ "escape",
/* 42 */ "backspace",
/* 43 */ "tab",
/* 44 */ "space",
/* 45 */ "SDLK_HYPHENMINUS",
/* 46 */ "SDLK_EQUALS",
/* 47 */ "SDLK_LEFTBRACKET",
/* 48 */ "SDLK_RIGHTBRACKET",
/* 49 */ "SDLK_BACKSLASH",
/* 50 */ "SDLK_NONUSHASH",
/* 51 */ "SDLK_SEMICOLON",
/* 52 */ "SDLK_APOSTROPHE",
/* 53 */ "SDLK_GRAVE",
/* 54 */ "SDLK_COMMA",
/* 55 */ "SDLK_PERIOD",
/* 56 */ "SDLK_SLASH",
/* 57 */ "caps lock",
/* 58 */ "F1",
/* 59 */ "F2",
/* 60 */ "F3",
/* 61 */ "F4",
/* 62 */ "F5",
/* 63 */ "F6",
/* 64 */ "F7",
/* 65 */ "F8",
/* 66 */ "F9",
/* 67 */ "F10",
/* 68 */ "F11",
/* 69 */ "F12",
/* 70 */ "print screen",
/* 71 */ "scroll lock",
/* 72 */ "pause",
/* 73 */ "insert",
/* 74 */ "home",
/* 75 */ "page up",
/* 76 */ "delete",
/* 77 */ "end",
/* 78 */ "page down",
/* 79 */ "right",
/* 80 */ "left",
/* 81 */ "down",
/* 82 */ "up",
/* 83 */ "num lock",
/* 84 */ "SDLK_KP_DIVIDE",
/* 85 */ "SDLK_KP_MULTIPLY",
/* 86 */ "SDLK_KP_MINUS",
/* 87 */ "SDLK_KP_PLUS",
/* 88 */ "enter",
/* 89 */ "SDLK_KP_1",
/* 90 */ "SDLK_KP_2",
/* 91 */ "SDLK_KP_3",
/* 92 */ "SDLK_KP_4",
/* 93 */ "SDLK_KP_5",
/* 94 */ "SDLK_KP_6",
/* 95 */ "SDLK_KP_7",
/* 96 */ "SDLK_KP_8",
/* 97 */ "SDLK_KP_9",
/* 98 */ "SDLK_KP_0",
/* 99 */ "SDLK_KP_PERIOD",
/* 100 */ "SDLK_NONUSBACKSLASH",
/* 101 */ "application",
/* 102 */ "power",
/* 103 */ "SDLK_KP_EQUALS",
/* 104 */ "F13",
/* 105 */ "F14",
/* 106 */ "F15",
/* 107 */ "F16",
/* 108 */ "F17",
/* 109 */ "F18",
/* 110 */ "F19",
/* 111 */ "F20",
/* 112 */ "F21",
/* 113 */ "F22",
/* 114 */ "F23",
/* 115 */ "F24",
/* 116 */ "execute",
/* 117 */ "help",
/* 118 */ "menu",
/* 119 */ "select",
/* 120 */ "stop",
/* 121 */ "again",
/* 122 */ "undo",
/* 123 */ "cut",
/* 124 */ "copy",
/* 125 */ "paste",
/* 126 */ "find",
/* 127 */ "mute",
/* 128 */ "volume up",
/* 129 */ "volume down",
/* 130 */ "caps lock", /* unused */
/* 131 */ "num lock", /* unused */
/* 132 */ "scroll lock", /* unused */
/* 133 */ "SDLK_KP_COMMA",
/* 134 */ "SDLK_KP_EQUALSAS400",
/* 135 */ "international 1",
/* 136 */ "international 2",
/* 137 */ "international 3",
/* 138 */ "international 4",
/* 139 */ "international 5",
/* 140 */ "international 6",
/* 141 */ "international 7",
/* 142 */ "international 8",
/* 143 */ "international 9",
/* 144 */ "lang 1",
/* 145 */ "lang 2",
/* 146 */ "lang 3",
/* 147 */ "lang 4",
/* 148 */ "lang 5",
/* 149 */ "lang 6",
/* 150 */ "lang 7",
/* 151 */ "lang 8",
/* 152 */ "lang 9",
/* 153 */ "alt erase",
/* 154 */ "sys req",
/* 155 */ "cancel",
/* 156 */ "clear",
/* 157 */ "prior",
/* 158 */ "return",
/* 159 */ "separator",
/* 160 */ "out",
/* 161 */ "oper",
/* 162 */ "clear/again",
/* 163 */ "crsel/props",
/* 164 */ "exsel",
/* 165 */ NULL, /* unused */
/* 166 */ NULL, /* unused */
/* 167 */ NULL, /* unused */
/* 168 */ NULL, /* unused */
/* 169 */ NULL, /* unused */
/* 170 */ NULL, /* unused */
/* 171 */ NULL, /* unused */
/* 172 */ NULL, /* unused */
/* 173 */ NULL, /* unused */
/* 174 */ NULL, /* unused */
/* 175 */ NULL, /* unused */
/* 176 */ "[00]",
/* 177 */ "[000]",
/* 178 */ "thousands separator",
/* 179 */ "decimal separator",
/* 180 */ "currency unit",
/* 181 */ "currency sub-unit",
/* 182 */ "[(]",
/* 183 */ "[)]",
/* 184 */ "[{]",
/* 185 */ "[}]",
/* 186 */ "[tab]",
/* 187 */ "[backspace]",
/* 188 */ "[A]",
/* 189 */ "[B]",
/* 190 */ "[C]",
/* 191 */ "[D]",
/* 192 */ "[E]",
/* 193 */ "[F]",
/* 194 */ "[XOR]",
/* 195 */ "[^]",
/* 196 */ "[%]",
/* 197 */ "[<]",
/* 198 */ "[>]",
/* 199 */ "[&]",
/* 200 */ "[&&]",
/* 201 */ "[|]",
/* 202 */ "[||]",
/* 203 */ "[:]",
/* 204 */ "[#]",
/* 205 */ "[space]",
/* 206 */ "[@]",
/* 207 */ "[!]",
/* 208 */ "[mem store]",
/* 209 */ "[mem recall]",
/* 210 */ "[mem clear]",
/* 211 */ "[mem +]",
/* 212 */ "[mem -]",
/* 213 */ "[mem *]",
/* 214 */ "[mem /]",
/* 215 */ "[+/-]",
/* 216 */ "[clear]",
/* 217 */ "[clear entry]",
/* 218 */ "[binary]",
/* 219 */ "[octal]",
/* 220 */ "[decimal]",
/* 221 */ "[hexadecimal]",
/* 222 */ NULL, /* unused */
/* 223 */ NULL, /* unused */
/* 224 */ "left ctrl",
/* 225 */ "left shift",
/* 226 */ "left alt",
/* 227 */ "left meta",
/* 228 */ "right ctrl",
/* 229 */ "right shift",
/* 230 */ "right alt",
/* 231 */ "right meta",
/* 232 */ "mode",
/* 233 */ NULL, /* unused */
/* 234 */ NULL, /* unused */
/* 235 */ NULL, /* unused */
/* 236 */ "brightness down",
/* 237 */ "brightness up",
/* 238 */ "display switch",
/* 239 */ "kbd illum toggle",
/* 240 */ "kbd illum down",
/* 241 */ "kbd illum up",
/* 242 */ "eject",
/* 243 */ "sleep",
/* 244 */ "play",
/* 245 */ "stop",
/* 246 */ "previous",
/* 247 */ "next",
/* 248 */ "calc",
/* 249 */ "www",
/* 250 */ "e-mail",
/* 251 */ "media",
/* 252 */ "computer",
/* 253 */ "search",
/* 254 */ "bookmarks",
/* 255 */ "back",
/* 256 */ "forward",
/* 257 */ "reload",
/* 258 */ "stop"
};
/* *INDENT-ON* */
...@@ -257,45 +257,6 @@ struct SDL_VideoDevice ...@@ -257,45 +257,6 @@ struct SDL_VideoDevice
*/ */
void (*PumpEvents) (_THIS); void (*PumpEvents) (_THIS);
/* Get the layout key code corresponding to the given physical key code
* according to the OS' current keyboard layout.
*
* - For character keys, this should return the Unicode code point of the
* character that is generated when the key is pressed without shift or
* any other modifiers.
* - For non-character keys, this should return one of the SDLK_* constants
* (usually the argument itself since these keys are typically layout-
* independent). Make sure that all of these values returned by this
* function have a suitable name defined, either the default from
* SDL_keynames.h, or one set using SDL_SetKeyName() in VideoInit(). In
* particular, if this function can return any of the codes whose default
* names start with "SDLK_" (usually, it shouldn't, since these are layout-
* dependent character keys), these names should be replaced by proper
* user-readable names.
* - If there are keys that cannot be adequately described by either a
* single Unicode character or an SDLK_* constant, this function may return
* a code with SDL_KEY_LAYOUT_SPECIAL_BIT set in the most significant byte
* and an arbitrary value in the less significant 3 bytes. The
* GetSpecialKeyName() function must then be implemented to take this code
* and return a human-readable key name for it.
* If the argument is not a physical key code or if translation of the key
* code by the OS' keyboard layout fails for any reason, the argument must
* be returned unchanged.
*
* On platforms that don't have the notion of a user-configurable keyboard
* layout, this may be left unimplemented. The default implementation of
* SDL_GetLayoutKey() then acts as the identity. The note about defining
* key names above particularly applies in this case.
*/
SDLKey(*GetLayoutKey) (_THIS, SDLKey physicalKey);
/* Get a human-readable name for a special layout key code.
* This only needs to be implemented if this driver's implementation of
* GetLayoutKey() generates such codes (with SDL_KEY_LAYOUT_SPECIAL_BIT
* set) - see above.
*/
const char *(*GetSpecialKeyName) (_THIS, SDLKey layoutKey);
/* * * */ /* * * */
/* Data common to all drivers */ /* Data common to all drivers */
int num_displays; int num_displays;
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
extern void Cocoa_InitKeyboard(_THIS); extern void Cocoa_InitKeyboard(_THIS);
extern void Cocoa_HandleKeyEvent(_THIS, NSEvent * event); extern void Cocoa_HandleKeyEvent(_THIS, NSEvent * event);
extern SDLKey Cocoa_GetLayoutKey(_THIS, SDLKey physicalKey);
extern void Cocoa_QuitKeyboard(_THIS); extern void Cocoa_QuitKeyboard(_THIS);
#endif /* _SDL_cocoakeyboard_h */ #endif /* _SDL_cocoakeyboard_h */
......
This diff is collapsed.
This diff is collapsed.
...@@ -45,6 +45,7 @@ typedef struct SDL_VideoData ...@@ -45,6 +45,7 @@ typedef struct SDL_VideoData
unsigned int modifierFlags; unsigned int modifierFlags;
int mouse; int mouse;
int keyboard; int keyboard;
void *key_layout;
NSText *fieldEdit; NSText *fieldEdit;
} SDL_VideoData; } SDL_VideoData;
......
...@@ -75,7 +75,6 @@ Cocoa_CreateDevice(int devindex) ...@@ -75,7 +75,6 @@ Cocoa_CreateDevice(int devindex)
device->GetDisplayModes = Cocoa_GetDisplayModes; device->GetDisplayModes = Cocoa_GetDisplayModes;
device->SetDisplayMode = Cocoa_SetDisplayMode; device->SetDisplayMode = Cocoa_SetDisplayMode;
device->PumpEvents = Cocoa_PumpEvents; device->PumpEvents = Cocoa_PumpEvents;
device->GetLayoutKey = Cocoa_GetLayoutKey;
device->CreateWindow = Cocoa_CreateWindow; device->CreateWindow = Cocoa_CreateWindow;
device->CreateWindowFrom = Cocoa_CreateWindowFrom; device->CreateWindowFrom = Cocoa_CreateWindowFrom;
......
...@@ -40,10 +40,10 @@ print_modifiers(void) ...@@ -40,10 +40,10 @@ print_modifiers(void)
printf(" LALT"); printf(" LALT");
if (mod & KMOD_RALT) if (mod & KMOD_RALT)
printf(" RALT"); printf(" RALT");
if (mod & KMOD_LMETA) if (mod & KMOD_LGUI)
printf(" LMETA"); printf(" LGUI");
if (mod & KMOD_RMETA) if (mod & KMOD_RGUI)
printf(" RMETA"); printf(" RGUI");
if (mod & KMOD_NUM) if (mod & KMOD_NUM)
printf(" NUM"); printf(" NUM");
if (mod & KMOD_CAPS) if (mod & KMOD_CAPS)
...@@ -57,14 +57,13 @@ PrintKey(SDL_keysym * sym, int pressed) ...@@ -57,14 +57,13 @@ PrintKey(SDL_keysym * sym, int pressed)
{ {
/* Print the keycode, name and state */ /* Print the keycode, name and state */
if (sym->sym) { if (sym->sym) {
printf("Key %s: physical 0x%08X = %s, layout 0x%08X = %s ", printf("Key %s: scancode 0x%04X = %s, keycode 0x%08X = %s ",
pressed ? "pressed " : "released", pressed ? "pressed " : "released",
sym->sym, sym->scancode,
SDL_GetKeyName(sym->sym), SDL_GetScancodeName(sym->scancode),
SDL_GetLayoutKey(sym->sym), sym->sym, SDL_GetKeyName(sym->sym));
SDL_GetKeyName(SDL_GetLayoutKey(sym->sym)));
} else { } else {
printf("Unknown Key (scancode = 0x%08X) %s ", printf("Unknown Key (scancode = 0x%04X) %s ",
sym->scancode, pressed ? "pressed" : "released"); sym->scancode, pressed ? "pressed" : "released");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment