--- a/include/SDL_keyboard.h Fri Jun 09 07:06:12 2006 +0000
+++ b/include/SDL_keyboard.h Sat Jun 10 09:11:59 2006 +0000
@@ -41,82 +41,116 @@
/* *INDENT-ON* */
#endif
-/* Keysym structure
- - The scancode is hardware dependent, and should not be used by general
- applications. If no hardware scancode is available, it will be 0.
-
- - The 'unicode' translated character is only available when character
- translation is enabled by the SDL_EnableUNICODE() API. If non-zero,
- this is a UNICODE character corresponding to the keypress. If the
- high 9 bits of the character are 0, then this maps to the equivalent
- ASCII character:
- char ch;
- if ( (keysym.unicode & 0xFF80) == 0 ) {
- ch = keysym.unicode & 0x7F;
- } else {
- An international character..
- }
+/**
+ * \struct SDL_keysym
+ *
+ * \brief The SDL keysym structure, used in key events.
*/
typedef struct SDL_keysym
{
- Uint8 scancode; /* hardware specific scancode */
- SDLKey sym; /* SDL virtual keysym */
- SDLMod mod; /* current key modifiers */
- Uint16 unicode; /* translated character */
+ Uint8 scancode; /**< keyboard specific scancode */
+ SDLKey sym; /**< SDL virtual keysym */
+ SDLMod mod; /**< current key modifiers */
} SDL_keysym;
-/* This is the mask which refers to all hotkey bindings */
-#define SDL_ALL_HOTKEYS 0xFFFFFFFF
+/* Function prototypes */
+
+/**
+ * \fn int SDL_GetNumKeyboards(void)
+ *
+ * \brief Get the number of keyboard input devices available.
+ *
+ * \sa SDL_SelectKeyboard()
+ */
+extern DECLSPEC int SDLCALL SDL_GetNumKeyboards(void);
-/* Function prototypes */
-/*
- * Enable/Disable UNICODE translation of keyboard input.
- * This translation has some overhead, so translation defaults off.
- * If 'enable' is 1, translation is enabled.
- * If 'enable' is 0, translation is disabled.
- * If 'enable' is -1, the translation state is not changed.
- * It returns the previous state of keyboard translation.
+/**
+ * \fn int SDL_SelectKeyboard(int index)
+ *
+ * \brief Set the index of the currently selected keyboard.
+ *
+ * \return The index of the previously selected keyboard.
+ *
+ * \note You can query the currently selected keyboard by passing an index of -1.
+ *
+ * \sa SDL_GetNumKeyboards()
+ */
+extern DECLSPEC int SDLCALL SDL_SelectKeyboard(int index);
+
+/**
+ * \fn int SDL_EnableUNICODE(int enable)
+ *
+ * \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);
-/*
- * Enable/Disable keyboard repeat. Keyboard repeat defaults to off.
- * 'delay' is the initial delay in ms between the time when a key is
- * pressed, and keyboard repeat begins.
- * 'interval' is the time in ms between keyboard repeat events.
+/**
+ * \fn int SDL_EnableKeyRepeat(int delay, int interval)
+ *
+ * \brief Enable keyboard repeat for the selected keyboard.
+ *
+ * \param delay The initial delay in milliseconds between the time when a
+ * key is pressed and keyboard repeat begins. Setting a delay
+ * of 0 will disable keyboard repeat.
+ * \param interval The time in milliseconds between keyboard repeat events.
+ *
+ * \return 0 on success, or -1 if there was an error.
+ *
+ * \note Keyboard repeat defaults to off.
*/
#define SDL_DEFAULT_REPEAT_DELAY 500
#define SDL_DEFAULT_REPEAT_INTERVAL 30
-/*
- * If 'delay' is set to 0, keyboard repeat is disabled.
+ /**/
+ extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval);
+
+/**
+ * \fn void SDL_GetKeyRepeat(int *delay, int *interval)
+ *
+ * \brief Get the current keyboard repeat setting for the selected keyboard.
*/
-extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval);
extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval);
-/*
- * Get a snapshot of the current state of the keyboard.
- * Returns an array of keystates, indexed by the SDLK_* syms.
- * Used:
+/**
+ * \fn Uint8 *SDL_GetKeyState(int *numkeys)
+ *
+ * \brief Get a snapshot of the current state of the selected keyboard.
+ *
+ * \return An array of keystates, indexed by the SDLK_* syms.
+ *
+ * Example:
* Uint8 *keystate = SDL_GetKeyState(NULL);
* if ( keystate[SDLK_RETURN] ) ... <RETURN> is pressed.
*/
extern DECLSPEC Uint8 *SDLCALL SDL_GetKeyState(int *numkeys);
-/*
- * Get the current key modifier state
+/**
+ * \fn SDLMod SDL_GetModState(void)
+ *
+ * \brief Get the current key modifier state for the selected keyboard.
*/
extern DECLSPEC SDLMod SDLCALL SDL_GetModState(void);
-/*
- * Set the current key modifier state
- * This does not change the keyboard state, only the key modifier flags.
+/**
+ * \fn void SDL_SetModState(SDLMod modstate)
+ *
+ * \brief Set the current key modifier state for the selected keyboard.
+ *
+ * \note This does not change the keyboard state, only the key modifier flags.
*/
extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate);
-/*
- * Get the name of an SDL virtual keysym
+/**
+ * \fn const char *SDL_GetKeyName(SDLKey key)
+ *
+ * \brief Get the name of an SDL virtual keysym
*/
-extern DECLSPEC char *SDLCALL SDL_GetKeyName(SDLKey key);
+extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDLKey key);
/* Ends C function definitions when using C++ */
--- a/include/SDL_keysym.h Fri Jun 09 07:06:12 2006 +0000
+++ b/include/SDL_keysym.h Sat Jun 10 09:11:59 2006 +0000
@@ -27,12 +27,16 @@
#ifndef _SDL_keysym_h
#define _SDL_keysym_h
-/* What we really want is a mapping of every raw key on the keyboard.
- To support international keyboards, we use the range 0xA1 - 0xFF
- as international virtual keycodes. We'll follow in the footsteps of X11...
- The names of the keys
+/**
+ * \enum SDLKey
+ *
+ * \brief The SDL virtual key representation
+ *
+ * The SDLKey represents the unmodified character printed on the key
+ * for the current keyboard layout. The first 255 characters are used
+ * unchanged from Latin-1, e.g. a key with 'a' on it will have the value "a".
+ * The rest of the keys are named below, and fall into the range above 255.
*/
-
typedef enum
{
/* The keyboard syms have been cleverly chosen to map to ASCII */
@@ -114,104 +118,6 @@
SDLK_DELETE = 127,
/* End of ASCII mapped keysyms */
- /* International keyboard syms */
- SDLK_WORLD_0 = 160, /* 0xA0 */
- SDLK_WORLD_1 = 161,
- SDLK_WORLD_2 = 162,
- SDLK_WORLD_3 = 163,
- SDLK_WORLD_4 = 164,
- SDLK_WORLD_5 = 165,
- SDLK_WORLD_6 = 166,
- SDLK_WORLD_7 = 167,
- SDLK_WORLD_8 = 168,
- SDLK_WORLD_9 = 169,
- SDLK_WORLD_10 = 170,
- SDLK_WORLD_11 = 171,
- SDLK_WORLD_12 = 172,
- SDLK_WORLD_13 = 173,
- SDLK_WORLD_14 = 174,
- SDLK_WORLD_15 = 175,
- SDLK_WORLD_16 = 176,
- SDLK_WORLD_17 = 177,
- SDLK_WORLD_18 = 178,
- SDLK_WORLD_19 = 179,
- SDLK_WORLD_20 = 180,
- SDLK_WORLD_21 = 181,
- SDLK_WORLD_22 = 182,
- SDLK_WORLD_23 = 183,
- SDLK_WORLD_24 = 184,
- SDLK_WORLD_25 = 185,
- SDLK_WORLD_26 = 186,
- SDLK_WORLD_27 = 187,
- SDLK_WORLD_28 = 188,
- SDLK_WORLD_29 = 189,
- SDLK_WORLD_30 = 190,
- SDLK_WORLD_31 = 191,
- SDLK_WORLD_32 = 192,
- SDLK_WORLD_33 = 193,
- SDLK_WORLD_34 = 194,
- SDLK_WORLD_35 = 195,
- SDLK_WORLD_36 = 196,
- SDLK_WORLD_37 = 197,
- SDLK_WORLD_38 = 198,
- SDLK_WORLD_39 = 199,
- SDLK_WORLD_40 = 200,
- SDLK_WORLD_41 = 201,
- SDLK_WORLD_42 = 202,
- SDLK_WORLD_43 = 203,
- SDLK_WORLD_44 = 204,
- SDLK_WORLD_45 = 205,
- SDLK_WORLD_46 = 206,
- SDLK_WORLD_47 = 207,
- SDLK_WORLD_48 = 208,
- SDLK_WORLD_49 = 209,
- SDLK_WORLD_50 = 210,
- SDLK_WORLD_51 = 211,
- SDLK_WORLD_52 = 212,
- SDLK_WORLD_53 = 213,
- SDLK_WORLD_54 = 214,
- SDLK_WORLD_55 = 215,
- SDLK_WORLD_56 = 216,
- SDLK_WORLD_57 = 217,
- SDLK_WORLD_58 = 218,
- SDLK_WORLD_59 = 219,
- SDLK_WORLD_60 = 220,
- SDLK_WORLD_61 = 221,
- SDLK_WORLD_62 = 222,
- SDLK_WORLD_63 = 223,
- SDLK_WORLD_64 = 224,
- SDLK_WORLD_65 = 225,
- SDLK_WORLD_66 = 226,
- SDLK_WORLD_67 = 227,
- SDLK_WORLD_68 = 228,
- SDLK_WORLD_69 = 229,
- SDLK_WORLD_70 = 230,
- SDLK_WORLD_71 = 231,
- SDLK_WORLD_72 = 232,
- SDLK_WORLD_73 = 233,
- SDLK_WORLD_74 = 234,
- SDLK_WORLD_75 = 235,
- SDLK_WORLD_76 = 236,
- SDLK_WORLD_77 = 237,
- SDLK_WORLD_78 = 238,
- SDLK_WORLD_79 = 239,
- SDLK_WORLD_80 = 240,
- SDLK_WORLD_81 = 241,
- SDLK_WORLD_82 = 242,
- SDLK_WORLD_83 = 243,
- SDLK_WORLD_84 = 244,
- SDLK_WORLD_85 = 245,
- SDLK_WORLD_86 = 246,
- SDLK_WORLD_87 = 247,
- SDLK_WORLD_88 = 248,
- SDLK_WORLD_89 = 249,
- SDLK_WORLD_90 = 250,
- SDLK_WORLD_91 = 251,
- SDLK_WORLD_92 = 252,
- SDLK_WORLD_93 = 253,
- SDLK_WORLD_94 = 254,
- SDLK_WORLD_95 = 255, /* 0xFF */
-
/* Numeric keypad */
SDLK_KP0 = 256,
SDLK_KP1 = 257,
@@ -271,10 +177,10 @@
SDLK_LALT = 308,
SDLK_RMETA = 309,
SDLK_LMETA = 310,
- SDLK_LSUPER = 311, /* Left "Windows" key */
- SDLK_RSUPER = 312, /* Right "Windows" key */
- SDLK_MODE = 313, /* "Alt Gr" key */
- SDLK_COMPOSE = 314, /* Multi-key compose key */
+ SDLK_LSUPER = 311, /**< Left "Windows" key */
+ SDLK_RSUPER = 312, /**< Right "Windows" key */
+ SDLK_MODE = 313, /**< "Alt Gr" key */
+ SDLK_COMPOSE = 314, /**< Multi-key compose key */
/* Miscellaneous function keys */
SDLK_HELP = 315,
@@ -282,16 +188,20 @@
SDLK_SYSREQ = 317,
SDLK_BREAK = 318,
SDLK_MENU = 319,
- SDLK_POWER = 320, /* Power Macintosh power key */
- SDLK_EURO = 321, /* Some european keyboards */
- SDLK_UNDO = 322, /* Atari keyboard has Undo */
+ SDLK_POWER = 320, /**< Power Macintosh power key */
+ SDLK_EURO = 321, /**< Some european keyboards */
+ SDLK_UNDO = 322, /**< Atari keyboard has Undo */
/* Add any other keys here */
SDLK_LAST
} SDLKey;
-/* Enumeration of valid key mods (possibly OR'd together) */
+/**
+ * \enum SDLMod
+ *
+ * \brief Enumeration of valid key mods (possibly OR'd together)
+ */
typedef enum
{
KMOD_NONE = 0x0000,
--- a/include/SDL_mouse.h Fri Jun 09 07:06:12 2006 +0000
+++ b/include/SDL_mouse.h Sat Jun 10 09:11:59 2006 +0000
@@ -45,7 +45,8 @@
/* Function prototypes */
-/* \fn int SDL_GetNumMice(void)
+/**
+ * \fn int SDL_GetNumMice(void)
*
* \brief Get the number of mouse input devices available.
*
@@ -53,7 +54,8 @@
*/
extern DECLSPEC int SDLCALL SDL_GetNumMice(void);
-/* \fn int SDL_SelectMouse(int index)
+/**
+ * \fn int SDL_SelectMouse(int index)
*
* \brief Set the index of the currently selected mouse.
*
@@ -65,13 +67,14 @@
*/
extern DECLSPEC int SDLCALL SDL_SelectMouse(int index);
-/* \fn SDL_WindowID SDL_GetMouseFocusWindow(void)
+/**
+ * \fn SDL_WindowID SDL_GetMouseFocusWindow(void)
*
* \brief Get the window which currently has focus for the currently selected mouse.
*/
extern DECLSPEC SDL_WindowID SDLCALL SDL_GetMouseFocusWindow(void);
-/*
+/**
* \fn Uint8 SDL_GetMouseState(int *x, int *y)
*
* \brief Retrieve the current state of the mouse.
@@ -83,7 +86,7 @@
*/
extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState(int *x, int *y);
-/*
+/**
* \fn Uint8 SDL_GetRelativeMouseState(int *x, int *y)
*
* \brief Retrieve the current state of the mouse.
@@ -94,7 +97,7 @@
*/
extern DECLSPEC Uint8 SDLCALL SDL_GetRelativeMouseState(int *x, int *y);
-/*
+/**
* \fn void SDL_WarpMouseInWindow(SDL_WindowID windowID, int x, int y)
*
* \brief Moves the currently selected mouse to the given position within the window.
@@ -108,7 +111,7 @@
extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_WindowID windowID,
int x, int y);
-/*
+/**
* \fn SDL_Cursor *SDL_CreateCursor (const Uint8 * data, const Uint8 * mask, int w, int h, int hot_x, int hot_y)
*
* \brief Create a cursor for the currently selected mouse, using the
@@ -130,7 +133,7 @@
int w, int h, int hot_x,
int hot_y);
-/*
+/**
* \fn void SDL_SetCursor(SDL_Cursor * cursor)
*
* \brief Set the active cursor for the currently selected mouse.
@@ -139,14 +142,14 @@
*/
extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor * cursor);
-/*
+/**
* \fn SDL_Cursor *SDL_GetCursor(void)
*
* \brief Return the active cursor for the currently selected mouse.
*/
extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor(void);
-/*
+/**
* \fn void SDL_FreeCursor(SDL_Cursor * cursor)
*
* \brief Frees a cursor created with SDL_CreateCursor().
@@ -155,7 +158,7 @@
*/
extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor * cursor);
-/*
+/**
* \fn int SDL_ShowCursor(int toggle)
*
* \brief Toggle whether or not the cursor is shown for the currently selected mouse.
--- a/src/events/SDL_keyboard.c Fri Jun 09 07:06:12 2006 +0000
+++ b/src/events/SDL_keyboard.c Sat Jun 10 09:11:59 2006 +0000
@@ -29,307 +29,370 @@
#include "SDL_sysevents.h"
-/* Global keystate information */
-static Uint8 SDL_KeyState[SDLK_LAST];
-static SDLMod SDL_ModState;
+/* Global keyboard information */
+static int SDL_num_keyboards;
+static int SDL_current_keyboard;
+static SDL_Keyboard **SDL_keyboards;
int SDL_TranslateUNICODE = 0;
-static const char *keynames[SDLK_LAST]; /* Array of keycode names */
-
-/*
- * jk 991215 - added
- */
-struct
-{
- int firsttime; /* if we check against the delay or repeat value */
- int delay; /* the delay before we start repeating */
- int interval; /* the delay between key repeat events */
- Uint32 timestamp; /* the time the first keydown event occurred */
-
- SDL_Event evt; /* the event we are supposed to repeat */
-} SDL_KeyRepeat;
+static const char *SDL_keynames[SDLK_LAST]; /* Array of keycode names */
/* Public functions */
int
SDL_KeyboardInit(void)
{
- SDL_VideoDevice *_this = SDL_GetVideoDevice();
+ int i;
/* Set default mode of UNICODE translation */
SDL_EnableUNICODE(DEFAULT_UNICODE_TRANSLATION);
- /* Initialize the tables */
- SDL_ModState = KMOD_NONE;
- SDL_memset((void *) keynames, 0, sizeof(keynames));
- SDL_memset(SDL_KeyState, 0, sizeof(SDL_KeyState));
- _this->InitOSKeymap(_this);
-
+ /* Set default keyboard repeat setting */
SDL_EnableKeyRepeat(0, 0);
- /* Fill in the blanks in keynames */
- keynames[SDLK_BACKSPACE] = "backspace";
- keynames[SDLK_TAB] = "tab";
- keynames[SDLK_CLEAR] = "clear";
- keynames[SDLK_RETURN] = "return";
- keynames[SDLK_PAUSE] = "pause";
- keynames[SDLK_ESCAPE] = "escape";
- keynames[SDLK_SPACE] = "space";
- keynames[SDLK_EXCLAIM] = "!";
- keynames[SDLK_QUOTEDBL] = "\"";
- keynames[SDLK_HASH] = "#";
- keynames[SDLK_DOLLAR] = "$";
- keynames[SDLK_AMPERSAND] = "&";
- keynames[SDLK_QUOTE] = "'";
- keynames[SDLK_LEFTPAREN] = "(";
- keynames[SDLK_RIGHTPAREN] = ")";
- keynames[SDLK_ASTERISK] = "*";
- keynames[SDLK_PLUS] = "+";
- keynames[SDLK_COMMA] = ",";
- keynames[SDLK_MINUS] = "-";
- keynames[SDLK_PERIOD] = ".";
- keynames[SDLK_SLASH] = "/";
- keynames[SDLK_0] = "0";
- keynames[SDLK_1] = "1";
- keynames[SDLK_2] = "2";
- keynames[SDLK_3] = "3";
- keynames[SDLK_4] = "4";
- keynames[SDLK_5] = "5";
- keynames[SDLK_6] = "6";
- keynames[SDLK_7] = "7";
- keynames[SDLK_8] = "8";
- keynames[SDLK_9] = "9";
- keynames[SDLK_COLON] = ":";
- keynames[SDLK_SEMICOLON] = ";";
- keynames[SDLK_LESS] = "<";
- keynames[SDLK_EQUALS] = "=";
- keynames[SDLK_GREATER] = ">";
- keynames[SDLK_QUESTION] = "?";
- keynames[SDLK_AT] = "@";
- keynames[SDLK_LEFTBRACKET] = "[";
- keynames[SDLK_BACKSLASH] = "\\";
- keynames[SDLK_RIGHTBRACKET] = "]";
- keynames[SDLK_CARET] = "^";
- keynames[SDLK_UNDERSCORE] = "_";
- keynames[SDLK_BACKQUOTE] = "`";
- keynames[SDLK_a] = "a";
- keynames[SDLK_b] = "b";
- keynames[SDLK_c] = "c";
- keynames[SDLK_d] = "d";
- keynames[SDLK_e] = "e";
- keynames[SDLK_f] = "f";
- keynames[SDLK_g] = "g";
- keynames[SDLK_h] = "h";
- keynames[SDLK_i] = "i";
- keynames[SDLK_j] = "j";
- keynames[SDLK_k] = "k";
- keynames[SDLK_l] = "l";
- keynames[SDLK_m] = "m";
- keynames[SDLK_n] = "n";
- keynames[SDLK_o] = "o";
- keynames[SDLK_p] = "p";
- keynames[SDLK_q] = "q";
- keynames[SDLK_r] = "r";
- keynames[SDLK_s] = "s";
- keynames[SDLK_t] = "t";
- keynames[SDLK_u] = "u";
- keynames[SDLK_v] = "v";
- keynames[SDLK_w] = "w";
- keynames[SDLK_x] = "x";
- keynames[SDLK_y] = "y";
- keynames[SDLK_z] = "z";
- keynames[SDLK_DELETE] = "delete";
+ /* Initialize the tables */
+ for (i = 0; i < SDL_arraysize(SDL_keynames); ++i) {
+ switch (i) {
+ case SDLK_BACKSPACE:
+ SDL_keynames[i] = "backspace";
+ break;
+ case SDLK_TAB:
+ SDL_keynames[i] = "tab";
+ break;
+ case SDLK_CLEAR:
+ SDL_keynames[i] = "clear";
+ break;
+ case SDLK_RETURN:
+ SDL_keynames[i] = "return";
+ break;
+ case SDLK_PAUSE:
+ SDL_keynames[i] = "pause";
+ break;
+ case SDLK_ESCAPE:
+ SDL_keynames[i] = "escape";
+ break;
+ case SDLK_SPACE:
+ SDL_keynames[i] = "space";
+ break;
+
+ case SDLK_KP0:
+ SDL_keynames[i] = "[0]";
+ break;
+ case SDLK_KP1:
+ SDL_keynames[i] = "[1]";
+ break;
+ case SDLK_KP2:
+ SDL_keynames[i] = "[2]";
+ break;
+ case SDLK_KP3:
+ SDL_keynames[i] = "[3]";
+ break;
+ case SDLK_KP4:
+ SDL_keynames[i] = "[4]";
+ break;
+ case SDLK_KP5:
+ SDL_keynames[i] = "[5]";
+ break;
+ case SDLK_KP6:
+ SDL_keynames[i] = "[6]";
+ break;
+ case SDLK_KP7:
+ SDL_keynames[i] = "[7]";
+ break;
+ case SDLK_KP8:
+ SDL_keynames[i] = "[8]";
+ break;
+ case SDLK_KP9:
+ SDL_keynames[i] = "[9]";
+ break;
+ case SDLK_KP_PERIOD:
+ SDL_keynames[i] = "[.]";
+ break;
+ case SDLK_KP_DIVIDE:
+ SDL_keynames[i] = "[/]";
+ break;
+ case SDLK_KP_MULTIPLY:
+ SDL_keynames[i] = "[*]";
+ break;
+ case SDLK_KP_MINUS:
+ SDL_keynames[i] = "[-]";
+ break;
+ case SDLK_KP_PLUS:
+ SDL_keynames[i] = "[+]";
+ break;
+ case SDLK_KP_ENTER:
+ SDL_keynames[i] = "enter";
+ break;
+ case SDLK_KP_EQUALS:
+ SDL_keynames[i] = "equals";
+ break;
+
+ case SDLK_UP:
+ SDL_keynames[i] = "up";
+ break;
+ case SDLK_DOWN:
+ SDL_keynames[i] = "down";
+ break;
+ case SDLK_RIGHT:
+ SDL_keynames[i] = "right";
+ break;
+ case SDLK_LEFT:
+ SDL_keynames[i] = "left";
+ break;
+ case SDLK_DOWN:
+ SDL_keynames[i] = "down";
+ break;
+ case SDLK_INSERT:
+ SDL_keynames[i] = "insert";
+ break;
+ case SDLK_HOME:
+ SDL_keynames[i] = "home";
+ break;
+ case SDLK_END:
+ SDL_keynames[i] = "end";
+ break;
+ case SDLK_PAGEUP:
+ SDL_keynames[i] = "page up";
+ break;
+ case SDLK_PAGEDOWN:
+ SDL_keynames[i] = "page down";
+ break;
- keynames[SDLK_WORLD_0] = "world 0";
- keynames[SDLK_WORLD_1] = "world 1";
- keynames[SDLK_WORLD_2] = "world 2";
- keynames[SDLK_WORLD_3] = "world 3";
- keynames[SDLK_WORLD_4] = "world 4";
- keynames[SDLK_WORLD_5] = "world 5";
- keynames[SDLK_WORLD_6] = "world 6";
- keynames[SDLK_WORLD_7] = "world 7";
- keynames[SDLK_WORLD_8] = "world 8";
- keynames[SDLK_WORLD_9] = "world 9";
- keynames[SDLK_WORLD_10] = "world 10";
- keynames[SDLK_WORLD_11] = "world 11";
- keynames[SDLK_WORLD_12] = "world 12";
- keynames[SDLK_WORLD_13] = "world 13";
- keynames[SDLK_WORLD_14] = "world 14";
- keynames[SDLK_WORLD_15] = "world 15";
- keynames[SDLK_WORLD_16] = "world 16";
- keynames[SDLK_WORLD_17] = "world 17";
- keynames[SDLK_WORLD_18] = "world 18";
- keynames[SDLK_WORLD_19] = "world 19";
- keynames[SDLK_WORLD_20] = "world 20";
- keynames[SDLK_WORLD_21] = "world 21";
- keynames[SDLK_WORLD_22] = "world 22";
- keynames[SDLK_WORLD_23] = "world 23";
- keynames[SDLK_WORLD_24] = "world 24";
- keynames[SDLK_WORLD_25] = "world 25";
- keynames[SDLK_WORLD_26] = "world 26";
- keynames[SDLK_WORLD_27] = "world 27";
- keynames[SDLK_WORLD_28] = "world 28";
- keynames[SDLK_WORLD_29] = "world 29";
- keynames[SDLK_WORLD_30] = "world 30";
- keynames[SDLK_WORLD_31] = "world 31";
- keynames[SDLK_WORLD_32] = "world 32";
- keynames[SDLK_WORLD_33] = "world 33";
- keynames[SDLK_WORLD_34] = "world 34";
- keynames[SDLK_WORLD_35] = "world 35";
- keynames[SDLK_WORLD_36] = "world 36";
- keynames[SDLK_WORLD_37] = "world 37";
- keynames[SDLK_WORLD_38] = "world 38";
- keynames[SDLK_WORLD_39] = "world 39";
- keynames[SDLK_WORLD_40] = "world 40";
- keynames[SDLK_WORLD_41] = "world 41";
- keynames[SDLK_WORLD_42] = "world 42";
- keynames[SDLK_WORLD_43] = "world 43";
- keynames[SDLK_WORLD_44] = "world 44";
- keynames[SDLK_WORLD_45] = "world 45";
- keynames[SDLK_WORLD_46] = "world 46";
- keynames[SDLK_WORLD_47] = "world 47";
- keynames[SDLK_WORLD_48] = "world 48";
- keynames[SDLK_WORLD_49] = "world 49";
- keynames[SDLK_WORLD_50] = "world 50";
- keynames[SDLK_WORLD_51] = "world 51";
- keynames[SDLK_WORLD_52] = "world 52";
- keynames[SDLK_WORLD_53] = "world 53";
- keynames[SDLK_WORLD_54] = "world 54";
- keynames[SDLK_WORLD_55] = "world 55";
- keynames[SDLK_WORLD_56] = "world 56";
- keynames[SDLK_WORLD_57] = "world 57";
- keynames[SDLK_WORLD_58] = "world 58";
- keynames[SDLK_WORLD_59] = "world 59";
- keynames[SDLK_WORLD_60] = "world 60";
- keynames[SDLK_WORLD_61] = "world 61";
- keynames[SDLK_WORLD_62] = "world 62";
- keynames[SDLK_WORLD_63] = "world 63";
- keynames[SDLK_WORLD_64] = "world 64";
- keynames[SDLK_WORLD_65] = "world 65";
- keynames[SDLK_WORLD_66] = "world 66";
- keynames[SDLK_WORLD_67] = "world 67";
- keynames[SDLK_WORLD_68] = "world 68";
- keynames[SDLK_WORLD_69] = "world 69";
- keynames[SDLK_WORLD_70] = "world 70";
- keynames[SDLK_WORLD_71] = "world 71";
- keynames[SDLK_WORLD_72] = "world 72";
- keynames[SDLK_WORLD_73] = "world 73";
- keynames[SDLK_WORLD_74] = "world 74";
- keynames[SDLK_WORLD_75] = "world 75";
- keynames[SDLK_WORLD_76] = "world 76";
- keynames[SDLK_WORLD_77] = "world 77";
- keynames[SDLK_WORLD_78] = "world 78";
- keynames[SDLK_WORLD_79] = "world 79";
- keynames[SDLK_WORLD_80] = "world 80";
- keynames[SDLK_WORLD_81] = "world 81";
- keynames[SDLK_WORLD_82] = "world 82";
- keynames[SDLK_WORLD_83] = "world 83";
- keynames[SDLK_WORLD_84] = "world 84";
- keynames[SDLK_WORLD_85] = "world 85";
- keynames[SDLK_WORLD_86] = "world 86";
- keynames[SDLK_WORLD_87] = "world 87";
- keynames[SDLK_WORLD_88] = "world 88";
- keynames[SDLK_WORLD_89] = "world 89";
- keynames[SDLK_WORLD_90] = "world 90";
- keynames[SDLK_WORLD_91] = "world 91";
- keynames[SDLK_WORLD_92] = "world 92";
- keynames[SDLK_WORLD_93] = "world 93";
- keynames[SDLK_WORLD_94] = "world 94";
- keynames[SDLK_WORLD_95] = "world 95";
+ case SDLK_F1:
+ SDL_keynames[i] = "f1";
+ break;
+ case SDLK_F2:
+ SDL_keynames[i] = "f2";
+ break;
+ case SDLK_F3:
+ SDL_keynames[i] = "f3";
+ break;
+ case SDLK_F4:
+ SDL_keynames[i] = "f4";
+ break;
+ case SDLK_F5:
+ SDL_keynames[i] = "f5";
+ break;
+ case SDLK_F6:
+ SDL_keynames[i] = "f6";
+ break;
+ case SDLK_F7:
+ SDL_keynames[i] = "f7";
+ break;
+ case SDLK_F8:
+ SDL_keynames[i] = "f8";
+ break;
+ case SDLK_F9:
+ SDL_keynames[i] = "f9";
+ break;
+ case SDLK_F10:
+ SDL_keynames[i] = "f10";
+ break;
+ case SDLK_F11:
+ SDL_keynames[i] = "f11";
+ break;
+ case SDLK_F12:
+ SDL_keynames[i] = "f12";
+ break;
+ case SDLK_F13:
+ SDL_keynames[i] = "f13";
+ break;
+ case SDLK_F14:
+ SDL_keynames[i] = "f14";
+ break;
+ case SDLK_F15:
+ SDL_keynames[i] = "f15";
+ break;
- keynames[SDLK_KP0] = "[0]";
- keynames[SDLK_KP1] = "[1]";
- keynames[SDLK_KP2] = "[2]";
- keynames[SDLK_KP3] = "[3]";
- keynames[SDLK_KP4] = "[4]";
- keynames[SDLK_KP5] = "[5]";
- keynames[SDLK_KP6] = "[6]";
- keynames[SDLK_KP7] = "[7]";
- keynames[SDLK_KP8] = "[8]";
- keynames[SDLK_KP9] = "[9]";
- keynames[SDLK_KP_PERIOD] = "[.]";
- keynames[SDLK_KP_DIVIDE] = "[/]";
- keynames[SDLK_KP_MULTIPLY] = "[*]";
- keynames[SDLK_KP_MINUS] = "[-]";
- keynames[SDLK_KP_PLUS] = "[+]";
- keynames[SDLK_KP_ENTER] = "enter";
- keynames[SDLK_KP_EQUALS] = "equals";
-
- keynames[SDLK_UP] = "up";
- keynames[SDLK_DOWN] = "down";
- keynames[SDLK_RIGHT] = "right";
- keynames[SDLK_LEFT] = "left";
- keynames[SDLK_DOWN] = "down";
- keynames[SDLK_INSERT] = "insert";
- keynames[SDLK_HOME] = "home";
- keynames[SDLK_END] = "end";
- keynames[SDLK_PAGEUP] = "page up";
- keynames[SDLK_PAGEDOWN] = "page down";
+ case SDLK_NUMLOCK:
+ SDL_keynames[i] = "numlock";
+ break;
+ case SDLK_CAPSLOCK:
+ SDL_keynames[i] = "caps lock";
+ break;
+ case SDLK_SCROLLOCK:
+ SDL_keynames[i] = "scroll lock";
+ break;
+ case SDLK_RSHIFT:
+ SDL_keynames[i] = "right shift";
+ break;
+ case SDLK_LSHIFT:
+ SDL_keynames[i] = "left shift";
+ break;
+ case SDLK_RCTRL:
+ SDL_keynames[i] = "right ctrl";
+ break;
+ case SDLK_LCTRL:
+ SDL_keynames[i] = "left ctrl";
+ break;
+ case SDLK_RALT:
+ SDL_keynames[i] = "right alt";
+ break;
+ case SDLK_LALT:
+ SDL_keynames[i] = "left alt";
+ break;
+ case SDLK_RMETA:
+ SDL_keynames[i] = "right meta";
+ break;
+ case SDLK_LMETA:
+ SDL_keynames[i] = "left meta";
+ break;
+ case SDLK_LSUPER:
+ SDL_keynames[i] = "left super"; /* "Windows" keys */
+ break;
+ case SDLK_RSUPER:
+ SDL_keynames[i] = "right super";
+ break;
+ case SDLK_MODE:
+ SDL_keynames[i] = "alt gr";
+ break;
+ case SDLK_COMPOSE:
+ SDL_keynames[i] = "compose";
+ break;
- keynames[SDLK_F1] = "f1";
- keynames[SDLK_F2] = "f2";
- keynames[SDLK_F3] = "f3";
- keynames[SDLK_F4] = "f4";
- keynames[SDLK_F5] = "f5";
- keynames[SDLK_F6] = "f6";
- keynames[SDLK_F7] = "f7";
- keynames[SDLK_F8] = "f8";
- keynames[SDLK_F9] = "f9";
- keynames[SDLK_F10] = "f10";
- keynames[SDLK_F11] = "f11";
- keynames[SDLK_F12] = "f12";
- keynames[SDLK_F13] = "f13";
- keynames[SDLK_F14] = "f14";
- keynames[SDLK_F15] = "f15";
+ case SDLK_HELP:
+ SDL_keynames[i] = "help";
+ break;
+ case SDLK_PRINT:
+ SDL_keynames[i] = "print screen";
+ break;
+ case SDLK_SYSREQ:
+ SDL_keynames[i] = "sys req";
+ break;
+ case SDLK_BREAK:
+ SDL_keynames[i] = "break";
+ break;
+ case SDLK_MENU:
+ SDL_keynames[i] = "menu";
+ break;
+ case SDLK_POWER:
+ SDL_keynames[i] = "power";
+ break;
+ case SDLK_EURO:
+ SDL_keynames[i] = "euro";
+ break;
+ case SDLK_UNDO:
+ SDL_keynames[i] = "undo";
+ break;
- keynames[SDLK_NUMLOCK] = "numlock";
- keynames[SDLK_CAPSLOCK] = "caps lock";
- keynames[SDLK_SCROLLOCK] = "scroll lock";
- keynames[SDLK_RSHIFT] = "right shift";
- keynames[SDLK_LSHIFT] = "left shift";
- keynames[SDLK_RCTRL] = "right ctrl";
- keynames[SDLK_LCTRL] = "left ctrl";
- keynames[SDLK_RALT] = "right alt";
- keynames[SDLK_LALT] = "left alt";
- keynames[SDLK_RMETA] = "right meta";
- keynames[SDLK_LMETA] = "left meta";
- keynames[SDLK_LSUPER] = "left super"; /* "Windows" keys */
- keynames[SDLK_RSUPER] = "right super";
- keynames[SDLK_MODE] = "alt gr";
- keynames[SDLK_COMPOSE] = "compose";
-
- keynames[SDLK_HELP] = "help";
- keynames[SDLK_PRINT] = "print screen";
- keynames[SDLK_SYSREQ] = "sys req";
- keynames[SDLK_BREAK] = "break";
- keynames[SDLK_MENU] = "menu";
- keynames[SDLK_POWER] = "power";
- keynames[SDLK_EURO] = "euro";
- keynames[SDLK_UNDO] = "undo";
+ default:
+ SDL_keynames[i] = NULL;
+ break;
+ }
+ }
/* Done. Whew. */
return (0);
}
+SDL_Keyboard *
+SDL_GetKeyboard(int index)
+{
+ if (index < 0 || index >= SDL_num_keyboards) {
+ return NULL;
+ }
+ return SDL_keyboards[index];
+}
+
+int
+SDL_AddKeyboard(const SDL_Keyboard * keyboard, int index)
+{
+ SDL_Keyboard **keyboards;
+ SDL_Cursor *cursor;
+ int selected_keyboard;
+
+ /* Add the keyboard to the list of keyboards */
+ if (index < 0 || index >= SDL_num_keyboards || SDL_keyboards[index]) {
+ keyboards =
+ (SDL_Keyboard **) SDL_realloc(SDL_keyboards,
+ (SDL_num_keyboards +
+ 1) * sizeof(*keyboards));
+ if (!keyboards) {
+ SDL_OutOfMemory();
+ return -1;
+ }
+
+ SDL_keyboards = keyboards;
+ index = SDL_num_keyboards++;
+ }
+ SDL_keyboards[index] =
+ (SDL_Keyboard *) SDL_malloc(sizeof(*SDL_keyboards[index]));
+ if (!SDL_keyboards[index]) {
+ SDL_OutOfMemory();
+ return -1;
+ }
+ *SDL_keyboards[index] = *keyboard;
+
+ return index;
+}
+
+void
+SDL_DelKeyboard(int index)
+{
+ SDL_Keyboard *keyboard = SDL_GetKeyboard(index);
+
+ if (!keyboard) {
+ return;
+ }
+
+ if (keyboard->FreeKeyboard) {
+ keyboard->FreeKeyboard(keyboard);
+ }
+ SDL_free(keyboard);
+
+ SDL_keyboards[index] = NULL;
+}
+
+void
+SDL_ResetKeyboard(int index)
+{
+ SDL_Keyboard *keyboard = SDL_GetKeyboard(index);
+ SDL_keysym keysym;
+ SDLKey key;
+
+ if (!keyboard) {
+ return;
+ }
+
+ SDL_memset(&keysym, 0, (sizeof keysym));
+ for (key = SDLK_FIRST; key < SDLK_LAST; ++key) {
+ if (keyboard->keystate[key] == SDL_PRESSED) {
+ keysym.sym = key;
+ SDL_SendKeyboardKey(index, SDL_RELEASED, &keysym);
+ }
+ }
+ keyboard->keyrepeat.timestamp = 0;
+}
+
void
SDL_KeyboardQuit(void)
{
+ int i;
+
+ for (i = 0; i < SDL_num_keyboards; ++i) {
+ SDL_DelKeyboard(i);
+ }
+ SDL_num_keyboards = 0;
+ SDL_current_keyboard = 0;
+
+ if (SDL_keyboards) {
+ SDL_free(SDL_keyboards);
+ SDL_keyboards = NULL;
+ }
}
-/* We lost the keyboard, so post key up messages for all pressed keys */
-void
-SDL_ResetKeyboard(void)
+int
+SDL_GetNumKeyboards(void)
{
- SDL_keysym keysym;
- SDLKey key;
+ return SDL_num_keyboards;
+}
- SDL_memset(&keysym, 0, (sizeof keysym));
- for (key = SDLK_FIRST; key < SDLK_LAST; ++key) {
- if (SDL_KeyState[key] == SDL_PRESSED) {
- keysym.sym = key;
- SDL_SendKeyboard(SDL_RELEASED, &keysym);
- }
+int
+SDL_SelectKeyboard(int index)
+{
+ if (index >= 0 && index < SDL_num_keyboards) {
+ SDL_current_keyboard = index;
}
- SDL_KeyRepeat.timestamp = 0;
+ return SDL_current_keyboard;
}
int
@@ -355,34 +418,45 @@
SDLMod
SDL_GetModState(void)
{
- return (SDL_ModState);
+ SDL_Keyboard *keyboard = SDL_GetKeyboard(index);
+
+ if (!keyboard) {
+ return KMOD_NONE;
+ }
+ return keyboard->modstate;
}
void
SDL_SetModState(SDLMod modstate)
{
- SDL_ModState = modstate;
+ SDL_Keyboard *keyboard = SDL_GetKeyboard(index);
+
+ if (!keyboard) {
+ return;
+ }
+ keyboard->modstate = modstate;
}
-char *
+const char *
SDL_GetKeyName(SDLKey key)
{
const char *keyname;
- keyname = NULL;
- if (key < SDLK_LAST) {
- keyname = keynames[key];
- }
+ keyname = keynames[key];
if (keyname == NULL) {
- keyname = "unknown key";
+ if (key < 256) {
+ static char temp[4];
+ FIXME:Convert to UTF - 8 keyname = temp;
+ } else {
+ keyname = "unknown key";
+ }
}
- /* FIXME: make this function const in 1.3 */
- return (char *) (keyname);
+ return keyname;
}
/* These are global for SDL_eventloop.c */
int
-SDL_SendKeyboard(Uint8 state, SDL_keysym * keysym)
+SDL_SendKeyboardKey(int index, Uint8 state, const SDL_keysym * keysym)
{
SDL_Event event;
int posted, repeatable;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/events/SDL_keyboard_c.h Sat Jun 10 09:11:59 2006 +0000
@@ -0,0 +1,77 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 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
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#ifndef _SDL_keyboard_c_h
+#define _SDL_keyboard_c_h
+
+typedef struct SDL_Keyboard SDL_Keyboard;
+
+struct SDL_Keyboard
+{
+ /* Free the keyboard when it's time */
+ void (*FreeKeyboard) (SDL_Keyboard * keyboard);
+
+ SDLMod modstate;
+ Uint8 keystate[SDLK_LAST];
+
+ struct
+ {
+ int firsttime; /* if we check against the delay or repeat value */
+ int delay; /* the delay before we start repeating */
+ int interval; /* the delay between key repeat events */
+ Uint32 timestamp; /* the time the first keydown event occurred */
+
+ SDL_Event evt; /* the event we are supposed to repeat */
+ } keyrepeat;
+
+ void *driverdata;
+};
+
+
+/* Initialize the keyboard subsystem */
+extern int SDL_KeyboardInit(void);
+
+/* Get the keyboard at an index */
+extern SDL_Keyboard *SDL_GetKeyboard(int index);
+
+/* Add a keyboard, possibly reattaching at a particular index (or -1),
+ returning the index of the keyboard, or -1 if there was an error.
+ */
+extern int SDL_AddKeyboard(const SDL_Keyboard * keyboard, int index);
+
+/* Remove a keyboard at an index, clearing the slot for later */
+extern void SDL_DelKeyboard(int index);
+
+/* Clear the state of a keyboard at an index */
+extern void SDL_ResetKeyboard(int index);
+
+/* Send a keyboard event for a keyboard at an index */
+extern int SDL_SendKeyboardKey(int index, Uint8 state,
+ const SDL_keysym * keysym);
+
+/* Shutdown the keyboard subsystem */
+extern void SDL_KeyboardQuit(void);
+
+#endif /* _SDL_keyboard_c_h */
+
+/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_sysvideo.h Fri Jun 09 07:06:12 2006 +0000
+++ b/src/video/SDL_sysvideo.h Sat Jun 10 09:11:59 2006 +0000
@@ -213,37 +213,6 @@
void (*VideoQuit) (_THIS);
/* * * */
- /* Hardware acceleration functions */
-
- /* The pixel format used when SDL_CreateRGBSurface creates SDL_HWSURFACEs with alpha */
- SDL_PixelFormat *displayformatalphapixel;
-
- /* Allocates a surface in video memory */
- int (*AllocHWSurface) (_THIS, SDL_Surface * surface);
-
- /* Sets the hardware accelerated blit function, if any, based
- on the current flags of the surface (colorkey, alpha, etc.)
- */
- int (*CheckHWBlit) (_THIS, SDL_Surface * src, SDL_Surface * dst);
-
- /* Fills a surface rectangle with the given color */
- int (*FillHWRect) (_THIS, SDL_Surface * dst, SDL_Rect * rect,
- Uint32 color);
-
- /* Sets video mem colorkey and accelerated blit function */
- int (*SetHWColorKey) (_THIS, SDL_Surface * surface, Uint32 key);
-
- /* Sets per surface hardware alpha value */
- int (*SetHWAlpha) (_THIS, SDL_Surface * surface, Uint8 value);
-
- /* Returns a readable/writable surface */
- int (*LockHWSurface) (_THIS, SDL_Surface * surface);
- void (*UnlockHWSurface) (_THIS, SDL_Surface * surface);
-
- /* Frees a previously allocated video surface */
- void (*FreeHWSurface) (_THIS, SDL_Surface * surface);
-
- /* * * */
/* Gamma support */
/* Set the gamma correction directly (emulated with gamma ramps) */
@@ -303,9 +272,6 @@
/* * * */
/* Event manager functions */
- /* Initialize keyboard mapping for this driver */
- void (*InitOSKeymap) (_THIS);
-
/* Handle any queued OS events */
void (*PumpEvents) (_THIS);