include/SDL_keyboard.h
author Sam Lantinga <slouken@libsdl.org>
Sat, 16 Jun 2007 15:32:04 +0000
changeset 2129 047245361002
parent 1895 c121d94672cb
child 2268 4baee598306d
permissions -rw-r--r--
Key repeat is handled by the OS, since text input is now decoupled from physical key events.
slouken@0
     1
/*
slouken@0
     2
    SDL - Simple DirectMedia Layer
slouken@1312
     3
    Copyright (C) 1997-2006 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@1895
    51
    Uint8 scancode;             /**< keyboard specific scancode */
slouken@1895
    52
    Uint8 padding[3];           /**< alignment padding */
slouken@1895
    53
    Uint16 sym;                 /**< SDL virtual keysym */
slouken@1895
    54
    Uint16 mod;                 /**< current key modifiers */
slouken@1895
    55
    Uint32 unicode;             /**< OBSOLETE, use SDL_TextInputEvent instead */
slouken@0
    56
} SDL_keysym;
slouken@0
    57
slouken@1895
    58
/* Function prototypes */
slouken@0
    59
slouken@1895
    60
/**
slouken@1895
    61
 * \fn int SDL_GetNumKeyboards(void)
slouken@1895
    62
 *
slouken@1895
    63
 * \brief Get the number of keyboard input devices available.
slouken@1895
    64
 *
slouken@1895
    65
 * \sa SDL_SelectKeyboard()
slouken@1895
    66
 */
slouken@1895
    67
extern DECLSPEC int SDLCALL SDL_GetNumKeyboards(void);
slouken@1895
    68
slouken@1895
    69
/**
slouken@1895
    70
 * \fn int SDL_SelectKeyboard(int index)
slouken@1895
    71
 *
slouken@1895
    72
 * \brief Set the index of the currently selected keyboard.
slouken@1895
    73
 *
slouken@1895
    74
 * \return The index of the previously selected keyboard.
slouken@1895
    75
 *
slouken@1895
    76
 * \note You can query the currently selected keyboard by passing an index of -1.
slouken@1895
    77
 *
slouken@1895
    78
 * \sa SDL_GetNumKeyboards()
slouken@1895
    79
 */
slouken@1895
    80
extern DECLSPEC int SDLCALL SDL_SelectKeyboard(int index);
slouken@1895
    81
slouken@1895
    82
/**
slouken@1895
    83
 * \fn int SDL_EnableUNICODE(int enable)
slouken@1895
    84
 *
slouken@1895
    85
 * \brief Enable/Disable UNICODE translation of keyboard input.
slouken@1895
    86
 *
slouken@1895
    87
 * \param enable 1 to enable translation, 0 to disable translation, -1 to query translation
slouken@1895
    88
 *
slouken@1895
    89
 * \return The previous state of keyboard translation
slouken@1895
    90
 *
slouken@1895
    91
 * \note This translation has some overhead, so translation defaults off.
slouken@0
    92
 */
slouken@337
    93
extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable);
slouken@0
    94
slouken@1895
    95
/**
slouken@1895
    96
 * \fn Uint8 *SDL_GetKeyState(int *numkeys)
slouken@1895
    97
 *
slouken@1895
    98
 * \brief Get a snapshot of the current state of the selected keyboard.
slouken@1895
    99
 *
slouken@1895
   100
 * \return An array of keystates, indexed by the SDLK_* syms.
slouken@1895
   101
 *
slouken@1895
   102
 * Example:
slouken@0
   103
 * 	Uint8 *keystate = SDL_GetKeyState(NULL);
slouken@0
   104
 *	if ( keystate[SDLK_RETURN] ) ... <RETURN> is pressed.
slouken@0
   105
 */
slouken@1895
   106
extern DECLSPEC Uint8 *SDLCALL SDL_GetKeyState(int *numkeys);
slouken@0
   107
slouken@1895
   108
/**
slouken@1895
   109
 * \fn SDLMod SDL_GetModState(void)
slouken@1895
   110
 *
slouken@1895
   111
 * \brief Get the current key modifier state for the selected keyboard.
slouken@0
   112
 */
slouken@337
   113
extern DECLSPEC SDLMod SDLCALL SDL_GetModState(void);
slouken@0
   114
slouken@1895
   115
/**
slouken@1895
   116
 * \fn void SDL_SetModState(SDLMod modstate)
slouken@1895
   117
 *
slouken@1895
   118
 * \brief Set the current key modifier state for the selected keyboard.
slouken@1895
   119
 *
slouken@1895
   120
 * \note This does not change the keyboard state, only the key modifier flags.
slouken@0
   121
 */
slouken@337
   122
extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate);
slouken@0
   123
slouken@1895
   124
/**
slouken@1895
   125
 * \fn const char *SDL_GetKeyName(SDLKey key)
slouken@1895
   126
 * 
slouken@1895
   127
 * \brief Get the name of an SDL virtual keysym
slouken@0
   128
 */
slouken@1895
   129
extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDLKey key);
slouken@0
   130
slouken@0
   131
slouken@0
   132
/* Ends C function definitions when using C++ */
slouken@0
   133
#ifdef __cplusplus
slouken@1895
   134
/* *INDENT-OFF* */
slouken@0
   135
}
slouken@1895
   136
/* *INDENT-ON* */
slouken@0
   137
#endif
slouken@0
   138
#include "close_code.h"
slouken@0
   139
slouken@0
   140
#endif /* _SDL_keyboard_h */
slouken@1895
   141
slouken@1895
   142
/* vi: set ts=4 sw=4 expandtab: */