include/SDL_keyboard.h
author Sam Lantinga <slouken@libsdl.org>
Sun, 11 Jun 2006 05:27:10 +0000
branchSDL-1.3
changeset 1674 7688a73b25b1
parent 1673 624e1412fbba
child 1686 8d7fecceb9ef
permissions -rw-r--r--
Finishing up keyboard code revamp, at least for now...
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2006 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  * \struct SDL_keysym
    46  *
    47  * \brief The SDL keysym structure, used in key events.
    48  */
    49 typedef struct SDL_keysym
    50 {
    51     Uint8 scancode;             /**< keyboard specific scancode */
    52     Uint8 padding[3];           /**< alignment padding */
    53     Uint16 sym;                 /**< SDL virtual keysym */
    54     Uint16 mod;                 /**< current key modifiers */
    55 } SDL_keysym;
    56 
    57 /* Function prototypes */
    58 
    59 /**
    60  * \fn int SDL_GetNumKeyboards(void)
    61  *
    62  * \brief Get the number of keyboard input devices available.
    63  *
    64  * \sa SDL_SelectKeyboard()
    65  */
    66 extern DECLSPEC int SDLCALL SDL_GetNumKeyboards(void);
    67 
    68 /**
    69  * \fn int SDL_SelectKeyboard(int index)
    70  *
    71  * \brief Set the index of the currently selected keyboard.
    72  *
    73  * \return The index of the previously selected keyboard.
    74  *
    75  * \note You can query the currently selected keyboard by passing an index of -1.
    76  *
    77  * \sa SDL_GetNumKeyboards()
    78  */
    79 extern DECLSPEC int SDLCALL SDL_SelectKeyboard(int index);
    80 
    81 /**
    82  * \fn int SDL_EnableUNICODE(int enable)
    83  *
    84  * \brief Enable/Disable UNICODE translation of keyboard input.
    85  *
    86  * \param enable 1 to enable translation, 0 to disable translation, -1 to query translation
    87  *
    88  * \return The previous state of keyboard translation
    89  *
    90  * \note This translation has some overhead, so translation defaults off.
    91  */
    92 extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable);
    93 
    94 /**
    95  * \fn int SDL_EnableKeyRepeat(int delay, int interval)
    96  * 
    97  * \brief Enable keyboard repeat for the selected keyboard.
    98  *
    99  * \param delay The initial delay in milliseconds between the time when a
   100  *              key is pressed and keyboard repeat begins.  Setting a delay
   101  *              of 0 will disable keyboard repeat.
   102  * \param interval The time in milliseconds between keyboard repeat events.
   103  *
   104  * \return 0 on success, or -1 if there was an error.
   105  *
   106  * \note Keyboard repeat defaults to off.
   107  */
   108 #define SDL_DEFAULT_REPEAT_DELAY	500
   109 #define SDL_DEFAULT_REPEAT_INTERVAL	30
   110  /**/
   111     extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval);
   112 
   113 /**
   114  * \fn void SDL_GetKeyRepeat(int *delay, int *interval)
   115  *
   116  * \brief Get the current keyboard repeat setting for the selected keyboard.
   117  */
   118 extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval);
   119 
   120 /**
   121  * \fn Uint8 *SDL_GetKeyState(int *numkeys)
   122  *
   123  * \brief Get a snapshot of the current state of the selected keyboard.
   124  *
   125  * \return An array of keystates, indexed by the SDLK_* syms.
   126  *
   127  * Example:
   128  * 	Uint8 *keystate = SDL_GetKeyState(NULL);
   129  *	if ( keystate[SDLK_RETURN] ) ... <RETURN> is pressed.
   130  */
   131 extern DECLSPEC Uint8 *SDLCALL SDL_GetKeyState(int *numkeys);
   132 
   133 /**
   134  * \fn SDLMod SDL_GetModState(void)
   135  *
   136  * \brief Get the current key modifier state for the selected keyboard.
   137  */
   138 extern DECLSPEC SDLMod SDLCALL SDL_GetModState(void);
   139 
   140 /**
   141  * \fn void SDL_SetModState(SDLMod modstate)
   142  *
   143  * \brief Set the current key modifier state for the selected keyboard.
   144  *
   145  * \note This does not change the keyboard state, only the key modifier flags.
   146  */
   147 extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate);
   148 
   149 /**
   150  * \fn const char *SDL_GetKeyName(SDLKey key)
   151  * 
   152  * \brief Get the name of an SDL virtual keysym
   153  */
   154 extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDLKey key);
   155 
   156 
   157 /* Ends C function definitions when using C++ */
   158 #ifdef __cplusplus
   159 /* *INDENT-OFF* */
   160 }
   161 /* *INDENT-ON* */
   162 #endif
   163 #include "close_code.h"
   164 
   165 #endif /* _SDL_keyboard_h */
   166 
   167 /* vi: set ts=4 sw=4 expandtab: */