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