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