include/SDL_keyboard.h
author Sam Lantinga <slouken@libsdl.org>
Mon, 17 Jan 2011 09:09:15 -0800
changeset 5009 b21ad135d86b
parent 4753 11b0a6a3eb4d
child 5081 25d4feb7c127
permissions -rw-r--r--
Minor documentation consistency cleanup
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2010 Sam Lantinga
     4 
     5     This library is free software; you can redistribute it and/or
     6     modify it under the terms of the GNU Lesser General Public
     7     License as published by the Free Software Foundation; either
     8     version 2.1 of the License, or (at your option) any later version.
     9 
    10     This library is distributed in the hope that it will be useful,
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    13     Lesser General Public License for more details.
    14 
    15     You should have received a copy of the GNU Lesser General Public
    16     License along with this library; if not, write to the Free Software
    17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    18 
    19     Sam Lantinga
    20     slouken@libsdl.org
    21 */
    22 
    23 /**
    24  *  \file SDL_keyboard.h
    25  *  
    26  *  Include file for SDL keyboard event handling
    27  */
    28 
    29 #ifndef _SDL_keyboard_h
    30 #define _SDL_keyboard_h
    31 
    32 #include "SDL_stdinc.h"
    33 #include "SDL_error.h"
    34 #include "SDL_keysym.h"
    35 #include "SDL_video.h"
    36 
    37 #include "begin_code.h"
    38 /* Set up for C function definitions, even when using C++ */
    39 #ifdef __cplusplus
    40 /* *INDENT-OFF* */
    41 extern "C" {
    42 /* *INDENT-ON* */
    43 #endif
    44 
    45 /**
    46  *  \brief The SDL keysym structure, used in key events.
    47  */
    48 typedef struct SDL_keysym
    49 {
    50     SDL_scancode scancode;      /**< SDL physical key code - see ::SDL_scancode for details */
    51     SDLKey sym;                 /**< SDL virtual key code - see ::SDLKey for details */
    52     Uint16 mod;                 /**< current key modifiers */
    53     Uint32 unicode;             /**< \deprecated use SDL_TextInputEvent instead */
    54 } SDL_keysym;
    55 
    56 /* Function prototypes */
    57 
    58 /**
    59  *  \brief Get the window which currently has keyboard focus.
    60  */
    61 extern DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void);
    62 
    63 /**
    64  *  \brief Get a snapshot of the current state of the keyboard.
    65  *  
    66  *  \param numkeys if non-NULL, receives the length of the returned array.
    67  *  
    68  *  \return An array of key states. Indexes into this array are obtained by using ::SDL_scancode values.
    69  *  
    70  *  \b Example:
    71  *  \code
    72  *  Uint8 *state = SDL_GetKeyboardState(NULL);
    73  *  if ( state[SDL_SCANCODE_RETURN] )   {
    74  *      printf("<RETURN> is pressed.\n");
    75  *  }
    76  *  \endcode
    77  */
    78 extern DECLSPEC Uint8 *SDLCALL SDL_GetKeyboardState(int *numkeys);
    79 
    80 /**
    81  *  \brief Get the current key modifier state for the keyboard.
    82  */
    83 extern DECLSPEC SDLMod SDLCALL SDL_GetModState(void);
    84 
    85 /**
    86  *  \brief Set the current key modifier state for the keyboard.
    87  *  
    88  *  \note This does not change the keyboard state, only the key modifier flags.
    89  */
    90 extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate);
    91 
    92 /**
    93  *  \brief Get the key code corresponding to the given scancode according
    94  *         to the current keyboard layout.
    95  *  
    96  *  See ::SDLKey for details.
    97  *  
    98  *  \sa SDL_GetKeyName()
    99  */
   100 extern DECLSPEC SDLKey SDLCALL SDL_GetKeyFromScancode(SDL_scancode scancode);
   101 
   102 /**
   103  *  \brief Get the scancode corresponding to the given key code according to the
   104  *         current keyboard layout.
   105  *  
   106  *  See ::SDL_scancode for details.
   107  *  
   108  *  \sa SDL_GetScancodeName()
   109  */
   110 extern DECLSPEC SDL_scancode SDLCALL SDL_GetScancodeFromKey(SDLKey key);
   111 
   112 /**
   113  *  \brief Get a human-readable name for a scancode.
   114  *  
   115  *  \return A pointer to a UTF-8 string that stays valid at least until the next
   116  *          call to this function. If you need it around any longer, you must 
   117  *          copy it.  If the scancode doesn't have a name, this function returns
   118  *          an empty string ("").
   119  *
   120  *  \sa SDL_scancode
   121  */
   122 extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_scancode
   123                                                         scancode);
   124 
   125 /**
   126  *  \brief Get a human-readable name for a key.
   127  *  
   128  *  \return A pointer to a UTF-8 string that stays valid at least until the next
   129  *          call to this function. If you need it around any longer, you must 
   130  *          copy it.  If the key doesn't have a name, this function returns an 
   131  *          empty string ("").
   132  *  
   133  *  \sa SDLKey
   134  */
   135 extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDLKey key);
   136 
   137 /**
   138  *  \brief Start accepting Unicode text input events.
   139  *  
   140  *  \sa SDL_StopTextInput()
   141  *  \sa SDL_SetTextInputRect()
   142  */
   143 extern DECLSPEC void SDLCALL SDL_StartTextInput(void);
   144 
   145 /**
   146  *  \brief Stop receiving any text input events.
   147  *  
   148  *  \sa SDL_StartTextInput()
   149  */
   150 extern DECLSPEC void SDLCALL SDL_StopTextInput(void);
   151 
   152 /**
   153  *  \brief Set the rectangle used to type Unicode text inputs.
   154  *  
   155  *  \sa SDL_StartTextInput()
   156  */
   157 extern DECLSPEC void SDLCALL SDL_SetTextInputRect(SDL_Rect *rect);
   158 
   159 
   160 /* Ends C function definitions when using C++ */
   161 #ifdef __cplusplus
   162 /* *INDENT-OFF* */
   163 }
   164 /* *INDENT-ON* */
   165 #endif
   166 #include "close_code.h"
   167 
   168 #endif /* _SDL_keyboard_h */
   169 
   170 /* vi: set ts=4 sw=4 expandtab: */