include/SDL_keyboard.h
author Sam Lantinga <slouken@libsdl.org>
Sat, 10 Jun 2006 09:11:59 +0000
branchSDL-1.3
changeset 1673 624e1412fbba
parent 1668 4da1ee79c9af
child 1674 7688a73b25b1
permissions -rw-r--r--
Keyboard code update in progress
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@1662
    23
/**
slouken@1662
    24
 * \file SDL_keyboard.h
slouken@1662
    25
 *
slouken@1662
    26
 * Include file for SDL keyboard event handling
slouken@1662
    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@1662
    39
/* *INDENT-OFF* */
slouken@0
    40
extern "C" {
slouken@1662
    41
/* *INDENT-ON* */
slouken@0
    42
#endif
slouken@0
    43
slouken@1673
    44
/**
slouken@1673
    45
 * \struct SDL_keysym
slouken@1673
    46
 *
slouken@1673
    47
 * \brief The SDL keysym structure, used in key events.
slouken@0
    48
 */
slouken@1662
    49
typedef struct SDL_keysym
slouken@1662
    50
{
slouken@1673
    51
    Uint8 scancode;             /**< keyboard specific scancode */
slouken@1673
    52
    SDLKey sym;                 /**< SDL virtual keysym */
slouken@1673
    53
    SDLMod mod;                 /**< current key modifiers */
slouken@0
    54
} SDL_keysym;
slouken@0
    55
slouken@1673
    56
/* Function prototypes */
slouken@0
    57
slouken@1673
    58
/**
slouken@1673
    59
 * \fn int SDL_GetNumKeyboards(void)
slouken@1673
    60
 *
slouken@1673
    61
 * \brief Get the number of keyboard input devices available.
slouken@1673
    62
 *
slouken@1673
    63
 * \sa SDL_SelectKeyboard()
slouken@1673
    64
 */
slouken@1673
    65
extern DECLSPEC int SDLCALL SDL_GetNumKeyboards(void);
slouken@1673
    66
slouken@1673
    67
/**
slouken@1673
    68
 * \fn int SDL_SelectKeyboard(int index)
slouken@1673
    69
 *
slouken@1673
    70
 * \brief Set the index of the currently selected keyboard.
slouken@1673
    71
 *
slouken@1673
    72
 * \return The index of the previously selected keyboard.
slouken@1673
    73
 *
slouken@1673
    74
 * \note You can query the currently selected keyboard by passing an index of -1.
slouken@1673
    75
 *
slouken@1673
    76
 * \sa SDL_GetNumKeyboards()
slouken@1673
    77
 */
slouken@1673
    78
extern DECLSPEC int SDLCALL SDL_SelectKeyboard(int index);
slouken@1673
    79
slouken@1673
    80
/**
slouken@1673
    81
 * \fn int SDL_EnableUNICODE(int enable)
slouken@1673
    82
 *
slouken@1673
    83
 * \brief Enable/Disable UNICODE translation of keyboard input.
slouken@1673
    84
 *
slouken@1673
    85
 * \param enable 1 to enable translation, 0 to disable translation, -1 to query translation
slouken@1673
    86
 *
slouken@1673
    87
 * \return The previous state of keyboard translation
slouken@1673
    88
 *
slouken@1673
    89
 * \note This translation has some overhead, so translation defaults off.
slouken@0
    90
 */
slouken@1668
    91
extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable);
slouken@0
    92
slouken@1673
    93
/**
slouken@1673
    94
 * \fn int SDL_EnableKeyRepeat(int delay, int interval)
slouken@1673
    95
 * 
slouken@1673
    96
 * \brief Enable keyboard repeat for the selected keyboard.
slouken@1673
    97
 *
slouken@1673
    98
 * \param delay The initial delay in milliseconds between the time when a
slouken@1673
    99
 *              key is pressed and keyboard repeat begins.  Setting a delay
slouken@1673
   100
 *              of 0 will disable keyboard repeat.
slouken@1673
   101
 * \param interval The time in milliseconds between keyboard repeat events.
slouken@1673
   102
 *
slouken@1673
   103
 * \return 0 on success, or -1 if there was an error.
slouken@1673
   104
 *
slouken@1673
   105
 * \note Keyboard repeat defaults to off.
slouken@0
   106
 */
slouken@0
   107
#define SDL_DEFAULT_REPEAT_DELAY	500
slouken@0
   108
#define SDL_DEFAULT_REPEAT_INTERVAL	30
slouken@1673
   109
 /**/
slouken@1673
   110
    extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval);
slouken@1673
   111
slouken@1673
   112
/**
slouken@1673
   113
 * \fn void SDL_GetKeyRepeat(int *delay, int *interval)
slouken@1673
   114
 *
slouken@1673
   115
 * \brief Get the current keyboard repeat setting for the selected keyboard.
slouken@0
   116
 */
slouken@1668
   117
extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval);
slouken@0
   118
slouken@1673
   119
/**
slouken@1673
   120
 * \fn Uint8 *SDL_GetKeyState(int *numkeys)
slouken@1673
   121
 *
slouken@1673
   122
 * \brief Get a snapshot of the current state of the selected keyboard.
slouken@1673
   123
 *
slouken@1673
   124
 * \return An array of keystates, indexed by the SDLK_* syms.
slouken@1673
   125
 *
slouken@1673
   126
 * Example:
slouken@0
   127
 * 	Uint8 *keystate = SDL_GetKeyState(NULL);
slouken@0
   128
 *	if ( keystate[SDLK_RETURN] ) ... <RETURN> is pressed.
slouken@0
   129
 */
slouken@1668
   130
extern DECLSPEC Uint8 *SDLCALL SDL_GetKeyState(int *numkeys);
slouken@0
   131
slouken@1673
   132
/**
slouken@1673
   133
 * \fn SDLMod SDL_GetModState(void)
slouken@1673
   134
 *
slouken@1673
   135
 * \brief Get the current key modifier state for the selected keyboard.
slouken@0
   136
 */
slouken@1668
   137
extern DECLSPEC SDLMod SDLCALL SDL_GetModState(void);
slouken@0
   138
slouken@1673
   139
/**
slouken@1673
   140
 * \fn void SDL_SetModState(SDLMod modstate)
slouken@1673
   141
 *
slouken@1673
   142
 * \brief Set the current key modifier state for the selected keyboard.
slouken@1673
   143
 *
slouken@1673
   144
 * \note This does not change the keyboard state, only the key modifier flags.
slouken@0
   145
 */
slouken@1668
   146
extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate);
slouken@0
   147
slouken@1673
   148
/**
slouken@1673
   149
 * \fn const char *SDL_GetKeyName(SDLKey key)
slouken@1673
   150
 * 
slouken@1673
   151
 * \brief Get the name of an SDL virtual keysym
slouken@0
   152
 */
slouken@1673
   153
extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDLKey key);
slouken@0
   154
slouken@0
   155
slouken@0
   156
/* Ends C function definitions when using C++ */
slouken@0
   157
#ifdef __cplusplus
slouken@1662
   158
/* *INDENT-OFF* */
slouken@0
   159
}
slouken@1662
   160
/* *INDENT-ON* */
slouken@0
   161
#endif
slouken@0
   162
#include "close_code.h"
slouken@0
   163
slouken@0
   164
#endif /* _SDL_keyboard_h */
slouken@1662
   165
slouken@1662
   166
/* vi: set ts=4 sw=4 expandtab: */