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