include/SDL_keyboard.h
author Ryan C. Gordon <icculus@icculus.org>
Tue, 15 Dec 2009 18:00:16 +0000
changeset 3567 fb9ea4b549c3
parent 3407 d3baf5ac4e37
child 3697 f7b03b6838cb
permissions -rw-r--r--
Added a warning comment to SDL_putenv().

"Fixes" Bugzilla #779.
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2009 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 
    36 #include "begin_code.h"
    37 /* Set up for C function definitions, even when using C++ */
    38 #ifdef __cplusplus
    39 /* *INDENT-OFF* */
    40 extern "C" {
    41 /* *INDENT-ON* */
    42 #endif
    43 
    44 /**
    45  *  \brief The SDL keysym structure, used in key events.
    46  */
    47 typedef struct SDL_keysym
    48 {
    49     SDL_scancode scancode;      /**< SDL physical key code - see ::SDL_scancode for details */
    50     SDLKey sym;                 /**< SDL virtual key code - see ::SDLKey for details */
    51     Uint16 mod;                 /**< current key modifiers */
    52     Uint32 unicode;             /**< \deprecated use SDL_TextInputEvent instead */
    53 } SDL_keysym;
    54 
    55 /* Function prototypes */
    56 
    57 /**
    58  *  \brief Get the number of keyboard input devices available.
    59  *  
    60  *  \sa SDL_SelectKeyboard()
    61  */
    62 extern DECLSPEC int SDLCALL SDL_GetNumKeyboards(void);
    63 
    64 /**
    65  *  \brief Set the index of the currently selected keyboard.
    66  *  
    67  *  \return The index of the previously selected keyboard.
    68  *  
    69  *  \note You can query the currently selected keyboard by passing an index of -1.
    70  *  
    71  *  \sa SDL_GetNumKeyboards()
    72  */
    73 extern DECLSPEC int SDLCALL SDL_SelectKeyboard(int index);
    74 
    75 /**
    76  *  \brief Get a snapshot of the current state of the selected keyboard.
    77  *  
    78  *  \param numkeys if non-NULL, receives the length of the returned array.
    79  *  
    80  *  \return An array of key states. Indexes into this array are obtained by using ::SDL_scancode values.
    81  *  
    82  *  \b Example:
    83  *  \code
    84  *  Uint8 *state = SDL_GetKeyboardState(NULL);
    85  *  if ( state[SDL_SCANCODE_RETURN] )   {
    86  *      printf("<RETURN> is pressed.\n");
    87  *  }
    88  *  \endcode
    89  */
    90 extern DECLSPEC Uint8 *SDLCALL SDL_GetKeyboardState(int *numkeys);
    91 
    92 /**
    93  *  \brief Get the current key modifier state for the selected keyboard.
    94  */
    95 extern DECLSPEC SDLMod SDLCALL SDL_GetModState(void);
    96 
    97 /**
    98  *  \brief Set the current key modifier state for the selected keyboard.
    99  *  
   100  *  \note This does not change the keyboard state, only the key modifier flags.
   101  */
   102 extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate);
   103 
   104 /**
   105  *  \brief Get the key code corresponding to the given scancode according to the
   106  *         current keyboard layout.
   107  *  
   108  *  See ::SDLKey for details.
   109  *  
   110  *  \sa SDL_GetKeyName()
   111  */
   112 extern DECLSPEC SDLKey SDLCALL SDL_GetKeyFromScancode(SDL_scancode scancode);
   113 
   114 /**
   115  *  \brief Get the scancode corresponding to the given key code according to the
   116  *         current keyboard layout.
   117  *  
   118  *  See ::SDL_scancode for details.
   119  *  
   120  *  \sa SDL_GetScancodeName()
   121  */
   122 extern DECLSPEC SDL_scancode SDLCALL SDL_GetScancodeFromKey(SDLKey key);
   123 
   124 /**
   125  *  \brief Get a human-readable name for a scancode.
   126  *  
   127  *  \return A pointer to a UTF-8 string that stays valid at least until the next
   128  *          call to this function. If you need it around any longer, you must 
   129  *          copy it.  If the scancode doesn't have a name, this function returns
   130  *          an empty string ("").
   131  *
   132  *  \sa SDL_scancode
   133  */
   134 extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_scancode
   135                                                         scancode);
   136 
   137 /**
   138  *  \brief Get a human-readable name for a key.
   139  *  
   140  *  \return A pointer to a UTF-8 string that stays valid at least until the next
   141  *          call to this function. If you need it around any longer, you must 
   142  *          copy it.  If the key doesn't have a name, this function returns an 
   143  *          empty string ("").
   144  *  
   145  *  \sa SDLKey
   146  */
   147 extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDLKey key);
   148 
   149 /**
   150  *  \brief Start accepting Unicode text input events.
   151  *  
   152  *  \sa SDL_StopTextInput()
   153  *  \sa SDL_SetTextInputRect()
   154  */
   155 extern DECLSPEC void SDLCALL SDL_StartTextInput(void);
   156 
   157 /**
   158  *  \brief Stop receiving any text input events.
   159  *  
   160  *  \sa SDL_StartTextInput()
   161  */
   162 extern DECLSPEC void SDLCALL SDL_StopTextInput(void);
   163 
   164 /**
   165  *  \brief Set the rectangle used to type Unicode text inputs.
   166  *  
   167  *  \sa SDL_StartTextInput()
   168  */
   169 extern DECLSPEC void SDLCALL SDL_SetTextInputRect(SDL_Rect *rect);
   170 
   171 
   172 /* Ends C function definitions when using C++ */
   173 #ifdef __cplusplus
   174 /* *INDENT-OFF* */
   175 }
   176 /* *INDENT-ON* */
   177 #endif
   178 #include "close_code.h"
   179 
   180 #endif /* _SDL_keyboard_h */
   181 
   182 /* vi: set ts=4 sw=4 expandtab: */