include/SDL_keyboard.h
author Sam Lantinga <slouken@libsdl.org>
Mon, 29 May 2006 04:04:35 +0000
branchSDL-1.3
changeset 1668 4da1ee79c9af
parent 1662 782fd950bd46
child 1673 624e1412fbba
permissions -rw-r--r--
more tweaking indent options
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@0
    44
/* Keysym structure
slouken@0
    45
   - The scancode is hardware dependent, and should not be used by general
slouken@0
    46
     applications.  If no hardware scancode is available, it will be 0.
slouken@0
    47
slouken@0
    48
   - The 'unicode' translated character is only available when character
slouken@0
    49
     translation is enabled by the SDL_EnableUNICODE() API.  If non-zero,
slouken@0
    50
     this is a UNICODE character corresponding to the keypress.  If the
slouken@0
    51
     high 9 bits of the character are 0, then this maps to the equivalent
slouken@0
    52
     ASCII character:
slouken@0
    53
	char ch;
slouken@0
    54
	if ( (keysym.unicode & 0xFF80) == 0 ) {
slouken@0
    55
		ch = keysym.unicode & 0x7F;
slouken@0
    56
	} else {
slouken@0
    57
		An international character..
slouken@0
    58
	}
slouken@0
    59
 */
slouken@1662
    60
typedef struct SDL_keysym
slouken@1662
    61
{
slouken@1662
    62
    Uint8 scancode;             /* hardware specific scancode */
slouken@1662
    63
    SDLKey sym;                 /* SDL virtual keysym */
slouken@1662
    64
    SDLMod mod;                 /* current key modifiers */
slouken@1662
    65
    Uint16 unicode;             /* translated character */
slouken@0
    66
} SDL_keysym;
slouken@0
    67
slouken@0
    68
/* This is the mask which refers to all hotkey bindings */
slouken@0
    69
#define SDL_ALL_HOTKEYS		0xFFFFFFFF
slouken@0
    70
slouken@0
    71
/* Function prototypes */
slouken@0
    72
/*
slouken@0
    73
 * Enable/Disable UNICODE translation of keyboard input.
slouken@0
    74
 * This translation has some overhead, so translation defaults off.
slouken@0
    75
 * If 'enable' is 1, translation is enabled.
slouken@0
    76
 * If 'enable' is 0, translation is disabled.
slouken@0
    77
 * If 'enable' is -1, the translation state is not changed.
slouken@0
    78
 * It returns the previous state of keyboard translation.
slouken@0
    79
 */
slouken@1668
    80
extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable);
slouken@0
    81
slouken@0
    82
/*
slouken@0
    83
 * Enable/Disable keyboard repeat.  Keyboard repeat defaults to off.
slouken@0
    84
 * 'delay' is the initial delay in ms between the time when a key is
slouken@0
    85
 * pressed, and keyboard repeat begins.
slouken@0
    86
 * 'interval' is the time in ms between keyboard repeat events.
slouken@0
    87
 */
slouken@0
    88
#define SDL_DEFAULT_REPEAT_DELAY	500
slouken@0
    89
#define SDL_DEFAULT_REPEAT_INTERVAL	30
slouken@0
    90
/*
slouken@0
    91
 * If 'delay' is set to 0, keyboard repeat is disabled.
slouken@0
    92
 */
slouken@1668
    93
extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval);
slouken@1668
    94
extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval);
slouken@0
    95
slouken@0
    96
/*
slouken@0
    97
 * Get a snapshot of the current state of the keyboard.
slouken@0
    98
 * Returns an array of keystates, indexed by the SDLK_* syms.
slouken@0
    99
 * Used:
slouken@0
   100
 * 	Uint8 *keystate = SDL_GetKeyState(NULL);
slouken@0
   101
 *	if ( keystate[SDLK_RETURN] ) ... <RETURN> is pressed.
slouken@0
   102
 */
slouken@1668
   103
extern DECLSPEC Uint8 *SDLCALL SDL_GetKeyState(int *numkeys);
slouken@0
   104
slouken@0
   105
/*
slouken@0
   106
 * Get the current key modifier state
slouken@0
   107
 */
slouken@1668
   108
extern DECLSPEC SDLMod SDLCALL SDL_GetModState(void);
slouken@0
   109
slouken@0
   110
/*
slouken@0
   111
 * Set the current key modifier state
slouken@0
   112
 * This does not change the keyboard state, only the key modifier flags.
slouken@0
   113
 */
slouken@1668
   114
extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate);
slouken@0
   115
slouken@0
   116
/*
slouken@0
   117
 * Get the name of an SDL virtual keysym
slouken@0
   118
 */
slouken@1668
   119
extern DECLSPEC char *SDLCALL SDL_GetKeyName(SDLKey key);
slouken@0
   120
slouken@0
   121
slouken@0
   122
/* Ends C function definitions when using C++ */
slouken@0
   123
#ifdef __cplusplus
slouken@1662
   124
/* *INDENT-OFF* */
slouken@0
   125
}
slouken@1662
   126
/* *INDENT-ON* */
slouken@0
   127
#endif
slouken@0
   128
#include "close_code.h"
slouken@0
   129
slouken@0
   130
#endif /* _SDL_keyboard_h */
slouken@1662
   131
slouken@1662
   132
/* vi: set ts=4 sw=4 expandtab: */