include/SDL_keyboard.h
changeset 2303 d87417504c75
parent 2268 4baee598306d
child 2859 99210400e8b9
     1.1 --- a/include/SDL_keyboard.h	Mon Feb 04 17:25:33 2008 +0000
     1.2 +++ b/include/SDL_keyboard.h	Tue Feb 05 07:19:23 2008 +0000
     1.3 @@ -48,8 +48,7 @@
     1.4   */
     1.5  typedef struct SDL_keysym
     1.6  {
     1.7 -    Uint8 scancode;             /**< keyboard specific scancode */
     1.8 -    Uint8 padding[3];           /**< alignment padding */
     1.9 +    SDL_scancode scancode;      /**< SDL physical key code - see ::SDL_scancode for details */
    1.10      SDLKey sym;                 /**< SDL virtual key code - see ::SDLKey for details */
    1.11      Uint16 mod;                 /**< current key modifiers */
    1.12      Uint32 unicode;             /**< OBSOLETE, use SDL_TextInputEvent instead */
    1.13 @@ -80,32 +79,19 @@
    1.14  extern DECLSPEC int SDLCALL SDL_SelectKeyboard(int index);
    1.15  
    1.16  /**
    1.17 - * \fn int SDL_EnableUNICODE(int enable)
    1.18 - *
    1.19 - * \brief Enable/Disable UNICODE translation of keyboard input.
    1.20 - *
    1.21 - * \param enable 1 to enable translation, 0 to disable translation, -1 to query translation
    1.22 - *
    1.23 - * \return The previous state of keyboard translation
    1.24 - *
    1.25 - * \note This translation has some overhead, so translation defaults off.
    1.26 - */
    1.27 -extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable);
    1.28 -
    1.29 -/**
    1.30 - * \fn Uint8 *SDL_GetKeyState(int *numkeys)
    1.31 + * \fn Uint8 *SDL_GetKeyboardState(int *numkeys)
    1.32   *
    1.33   * \brief Get a snapshot of the current state of the selected keyboard.
    1.34   *
    1.35   * \param numkeys if non-NULL, receives the length of the returned array.
    1.36   *
    1.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.
    1.38 + * \return An array of key states. Indexes into this array are obtained by using ::SDL_scancode values.
    1.39   *
    1.40   * Example:
    1.41 - * 	Uint8 *keystate = SDL_GetKeyState(NULL);
    1.42 - *	if ( keystate[SDLK_INDEX(SDLK_RETURN)] ) ... <RETURN> is pressed.
    1.43 + * 	Uint8 *state = SDL_GetKeyboardState(NULL);
    1.44 + *	if ( state[SDL_SCANCODE_RETURN)] ) ... <RETURN> is pressed.
    1.45   */
    1.46 -extern DECLSPEC Uint8 *SDLCALL SDL_GetKeyState(int *numkeys);
    1.47 +extern DECLSPEC Uint8 *SDLCALL SDL_GetKeyboardState(int *numkeys);
    1.48  
    1.49  /**
    1.50   * \fn SDLMod SDL_GetModState(void)
    1.51 @@ -124,32 +110,49 @@
    1.52  extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate);
    1.53  
    1.54  /**
    1.55 - * \fn SDLKey SDL_GetLayoutKey(SDLKey physicalKey)
    1.56 + * \fn SDLKey SDL_GetKeyFromScancode(SDL_scancode scancode)
    1.57   * 
    1.58 - * \brief Get the layout key code corresponding to the given physical key code according to the current keyboard layout.
    1.59 + * \brief Get the key code corresponding to the given scancode according to the current keyboard layout.
    1.60   *
    1.61   * See ::SDLKey for details.
    1.62   *
    1.63 - * If \a physicalKey is not a physical key code, it is returned unchanged.
    1.64 - *
    1.65   * \sa SDL_GetKeyName()
    1.66   */
    1.67 -extern DECLSPEC SDLKey SDLCALL SDL_GetLayoutKey(SDLKey physicalKey);
    1.68 +extern DECLSPEC SDLKey SDLCALL SDL_GetKeyFromScancode(SDL_scancode scancode);
    1.69 +
    1.70 +/**
    1.71 + * \fn SDL_scancode SDL_GetScancodeFromKey(SDLKey key)
    1.72 + * 
    1.73 + * \brief Get the scancode corresponding to the given key code according to the current keyboard layout.
    1.74 + *
    1.75 + * See ::SDL_scancode for details.
    1.76 + *
    1.77 + * \sa SDL_GetScancodeName()
    1.78 + */
    1.79 +extern DECLSPEC SDL_scancode SDLCALL SDL_GetScancodeFromKey(SDLKey key);
    1.80  
    1.81  /**
    1.82 - * \fn const char *SDL_GetKeyName(SDLKey layoutKey)
    1.83 + * \fn const char *SDL_GetScancodeName(SDL_scancode scancode)
    1.84 + * 
    1.85 + * \brief Get a human-readable name for a scancode.
    1.86 + *
    1.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 "".
    1.88 + *
    1.89 + * \sa SDL_scancode
    1.90 + */
    1.91 +extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_scancode
    1.92 +                                                        scancode);
    1.93 +
    1.94 +/**
    1.95 + * \fn const char *SDL_GetKeyName(SDLKey key)
    1.96   * 
    1.97   * \brief Get a human-readable name for a key.
    1.98   *
    1.99 - * \param layoutKey An SDL layout key code.
   1.100 - *
   1.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.
   1.102 - *
   1.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.
   1.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 "".
   1.105   *
   1.106   * \sa SDLKey
   1.107   */
   1.108 -extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDLKey layoutKey);
   1.109 +extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDLKey key);
   1.110  
   1.111  
   1.112  /* Ends C function definitions when using C++ */