include/SDL_keyboard.h
author Sam Lantinga <slouken@libsdl.org>
Mon, 10 Jul 2006 21:04:37 +0000
changeset 1895 c121d94672cb
parent 1507 1ff64ad478b2
child 2129 047245361002
permissions -rw-r--r--
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
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 int SDL_EnableKeyRepeat(int delay, int interval)
slouken@1895
    97
 * 
slouken@1895
    98
 * \brief Enable keyboard repeat for the selected keyboard.
slouken@1895
    99
 *
slouken@1895
   100
 * \param delay The initial delay in milliseconds between the time when a
slouken@1895
   101
 *              key is pressed and keyboard repeat begins.  Setting a delay
slouken@1895
   102
 *              of 0 will disable keyboard repeat.
slouken@1895
   103
 * \param interval The time in milliseconds between keyboard repeat events.
slouken@1895
   104
 *
slouken@1895
   105
 * \return 0 on success, or -1 if there was an error.
slouken@1895
   106
 *
slouken@1895
   107
 * \note Keyboard repeat defaults to off.
slouken@0
   108
 */
slouken@0
   109
#define SDL_DEFAULT_REPEAT_DELAY	500
slouken@0
   110
#define SDL_DEFAULT_REPEAT_INTERVAL	30
slouken@1895
   111
 /**/
slouken@1895
   112
    extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval);
slouken@1895
   113
slouken@1895
   114
/**
slouken@1895
   115
 * \fn void SDL_GetKeyRepeat(int *delay, int *interval)
slouken@1895
   116
 *
slouken@1895
   117
 * \brief Get the current keyboard repeat setting for the selected keyboard.
slouken@0
   118
 */
slouken@1507
   119
extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval);
slouken@0
   120
slouken@1895
   121
/**
slouken@1895
   122
 * \fn Uint8 *SDL_GetKeyState(int *numkeys)
slouken@1895
   123
 *
slouken@1895
   124
 * \brief Get a snapshot of the current state of the selected keyboard.
slouken@1895
   125
 *
slouken@1895
   126
 * \return An array of keystates, indexed by the SDLK_* syms.
slouken@1895
   127
 *
slouken@1895
   128
 * Example:
slouken@0
   129
 * 	Uint8 *keystate = SDL_GetKeyState(NULL);
slouken@0
   130
 *	if ( keystate[SDLK_RETURN] ) ... <RETURN> is pressed.
slouken@0
   131
 */
slouken@1895
   132
extern DECLSPEC Uint8 *SDLCALL SDL_GetKeyState(int *numkeys);
slouken@0
   133
slouken@1895
   134
/**
slouken@1895
   135
 * \fn SDLMod SDL_GetModState(void)
slouken@1895
   136
 *
slouken@1895
   137
 * \brief Get the current key modifier state for the selected keyboard.
slouken@0
   138
 */
slouken@337
   139
extern DECLSPEC SDLMod SDLCALL SDL_GetModState(void);
slouken@0
   140
slouken@1895
   141
/**
slouken@1895
   142
 * \fn void SDL_SetModState(SDLMod modstate)
slouken@1895
   143
 *
slouken@1895
   144
 * \brief Set the current key modifier state for the selected keyboard.
slouken@1895
   145
 *
slouken@1895
   146
 * \note This does not change the keyboard state, only the key modifier flags.
slouken@0
   147
 */
slouken@337
   148
extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate);
slouken@0
   149
slouken@1895
   150
/**
slouken@1895
   151
 * \fn const char *SDL_GetKeyName(SDLKey key)
slouken@1895
   152
 * 
slouken@1895
   153
 * \brief Get the name of an SDL virtual keysym
slouken@0
   154
 */
slouken@1895
   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: */