include/SDL_keyboard.h
author Bob Pendleton <bob@pendleton.com>
Thu, 09 Jul 2009 21:31:27 +0000
changeset 3216 48a80f2a7ff2
parent 2859 99210400e8b9
child 3280 00cace2d9080
permissions -rw-r--r--
volitile... duh, yeah the variable need to be labeled volitile
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@1895
    24
 * \file SDL_keyboard.h
slouken@1895
    25
 *
slouken@1895
    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@1895
    45
 * \struct SDL_keysym
slouken@1895
    46
 *
slouken@1895
    47
 * \brief The SDL keysym structure, used in key events.
slouken@0
    48
 */
slouken@1895
    49
typedef struct SDL_keysym
slouken@1895
    50
{
slouken@2303
    51
    SDL_scancode scancode;      /**< SDL physical key code - see ::SDL_scancode for details */
slouken@2268
    52
    SDLKey sym;                 /**< SDL virtual key code - see ::SDLKey for details */
slouken@1895
    53
    Uint16 mod;                 /**< current key modifiers */
slouken@1895
    54
    Uint32 unicode;             /**< OBSOLETE, use SDL_TextInputEvent instead */
slouken@0
    55
} SDL_keysym;
slouken@0
    56
slouken@1895
    57
/* Function prototypes */
slouken@0
    58
slouken@1895
    59
/**
slouken@1895
    60
 * \fn int SDL_GetNumKeyboards(void)
slouken@1895
    61
 *
slouken@1895
    62
 * \brief Get the number of keyboard input devices available.
slouken@1895
    63
 *
slouken@1895
    64
 * \sa SDL_SelectKeyboard()
slouken@1895
    65
 */
slouken@1895
    66
extern DECLSPEC int SDLCALL SDL_GetNumKeyboards(void);
slouken@1895
    67
slouken@1895
    68
/**
slouken@1895
    69
 * \fn int SDL_SelectKeyboard(int index)
slouken@1895
    70
 *
slouken@1895
    71
 * \brief Set the index of the currently selected keyboard.
slouken@1895
    72
 *
slouken@1895
    73
 * \return The index of the previously selected keyboard.
slouken@1895
    74
 *
slouken@1895
    75
 * \note You can query the currently selected keyboard by passing an index of -1.
slouken@1895
    76
 *
slouken@1895
    77
 * \sa SDL_GetNumKeyboards()
slouken@1895
    78
 */
slouken@1895
    79
extern DECLSPEC int SDLCALL SDL_SelectKeyboard(int index);
slouken@1895
    80
slouken@1895
    81
/**
slouken@2303
    82
 * \fn Uint8 *SDL_GetKeyboardState(int *numkeys)
slouken@1895
    83
 *
slouken@1895
    84
 * \brief Get a snapshot of the current state of the selected keyboard.
slouken@1895
    85
 *
slouken@2268
    86
 * \param numkeys if non-NULL, receives the length of the returned array.
slouken@2268
    87
 *
slouken@2303
    88
 * \return An array of key states. Indexes into this array are obtained by using ::SDL_scancode values.
slouken@1895
    89
 *
slouken@1895
    90
 * Example:
slouken@2303
    91
 * 	Uint8 *state = SDL_GetKeyboardState(NULL);
slouken@2303
    92
 *	if ( state[SDL_SCANCODE_RETURN)] ) ... <RETURN> is pressed.
slouken@0
    93
 */
slouken@2303
    94
extern DECLSPEC Uint8 *SDLCALL SDL_GetKeyboardState(int *numkeys);
slouken@0
    95
slouken@1895
    96
/**
slouken@1895
    97
 * \fn SDLMod SDL_GetModState(void)
slouken@1895
    98
 *
slouken@1895
    99
 * \brief Get the current key modifier state for the selected keyboard.
slouken@0
   100
 */
slouken@337
   101
extern DECLSPEC SDLMod SDLCALL SDL_GetModState(void);
slouken@0
   102
slouken@1895
   103
/**
slouken@1895
   104
 * \fn void SDL_SetModState(SDLMod modstate)
slouken@1895
   105
 *
slouken@1895
   106
 * \brief Set the current key modifier state for the selected keyboard.
slouken@1895
   107
 *
slouken@1895
   108
 * \note This does not change the keyboard state, only the key modifier flags.
slouken@0
   109
 */
slouken@337
   110
extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate);
slouken@0
   111
slouken@1895
   112
/**
slouken@2303
   113
 * \fn SDLKey SDL_GetKeyFromScancode(SDL_scancode scancode)
slouken@1895
   114
 * 
slouken@2303
   115
 * \brief Get the key code corresponding to the given scancode according to the current keyboard layout.
slouken@2268
   116
 *
slouken@2268
   117
 * See ::SDLKey for details.
slouken@2268
   118
 *
slouken@2268
   119
 * \sa SDL_GetKeyName()
slouken@0
   120
 */
slouken@2303
   121
extern DECLSPEC SDLKey SDLCALL SDL_GetKeyFromScancode(SDL_scancode scancode);
slouken@2268
   122
slouken@2268
   123
/**
slouken@2303
   124
 * \fn SDL_scancode SDL_GetScancodeFromKey(SDLKey key)
slouken@2303
   125
 * 
slouken@2303
   126
 * \brief Get the scancode corresponding to the given key code according to the current keyboard layout.
slouken@2303
   127
 *
slouken@2303
   128
 * See ::SDL_scancode for details.
slouken@2303
   129
 *
slouken@2303
   130
 * \sa SDL_GetScancodeName()
slouken@2303
   131
 */
slouken@2303
   132
extern DECLSPEC SDL_scancode SDLCALL SDL_GetScancodeFromKey(SDLKey key);
slouken@2303
   133
slouken@2303
   134
/**
slouken@2303
   135
 * \fn const char *SDL_GetScancodeName(SDL_scancode scancode)
slouken@2303
   136
 * 
slouken@2303
   137
 * \brief Get a human-readable name for a scancode.
slouken@2303
   138
 *
slouken@2303
   139
 * \return A pointer to a UTF-8 string that stays valid at least until the next call to this function. If you need it around any longer, you must copy it.  If the scancode doesn't have a name, this function returns "".
slouken@2303
   140
 *
slouken@2303
   141
 * \sa SDL_scancode
slouken@2303
   142
 */
slouken@2303
   143
extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_scancode
slouken@2303
   144
                                                        scancode);
slouken@2303
   145
slouken@2303
   146
/**
slouken@2303
   147
 * \fn const char *SDL_GetKeyName(SDLKey key)
slouken@2268
   148
 * 
slouken@2268
   149
 * \brief Get a human-readable name for a key.
slouken@2268
   150
 *
slouken@2303
   151
 * \return A pointer to a UTF-8 string that stays valid at least until the next call to this function. If you need it around any longer, you must copy it.  If the key doesn't have a name, this function returns "".
slouken@2268
   152
 *
slouken@2268
   153
 * \sa SDLKey
slouken@2268
   154
 */
slouken@2303
   155
extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDLKey key);
slouken@0
   156
slouken@0
   157
slouken@0
   158
/* Ends C function definitions when using C++ */
slouken@0
   159
#ifdef __cplusplus
slouken@1895
   160
/* *INDENT-OFF* */
slouken@0
   161
}
slouken@1895
   162
/* *INDENT-ON* */
slouken@0
   163
#endif
slouken@0
   164
#include "close_code.h"
slouken@0
   165
slouken@0
   166
#endif /* _SDL_keyboard_h */
slouken@1895
   167
slouken@1895
   168
/* vi: set ts=4 sw=4 expandtab: */