include/SDL_keyboard.h
author Sam Lantinga <slouken@libsdl.org>
Sun, 04 Jan 2004 16:49:27 +0000
changeset 769 b8d311d90021
parent 337 9154ec9ca3d2
child 911 04a403e4ccf5
permissions -rw-r--r--
Updated copyright information for 2004 (Happy New Year!)
slouken@0
     1
/*
slouken@0
     2
    SDL - Simple DirectMedia Layer
slouken@769
     3
    Copyright (C) 1997-2004 Sam Lantinga
slouken@0
     4
slouken@0
     5
    This library is free software; you can redistribute it and/or
slouken@0
     6
    modify it under the terms of the GNU Library General Public
slouken@0
     7
    License as published by the Free Software Foundation; either
slouken@0
     8
    version 2 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@0
    13
    Library General Public License for more details.
slouken@0
    14
slouken@0
    15
    You should have received a copy of the GNU Library General Public
slouken@0
    16
    License along with this library; if not, write to the Free
slouken@0
    17
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
slouken@0
    18
slouken@0
    19
    Sam Lantinga
slouken@251
    20
    slouken@libsdl.org
slouken@0
    21
*/
slouken@0
    22
slouken@0
    23
#ifdef SAVE_RCSID
slouken@0
    24
static char rcsid =
slouken@0
    25
 "@(#) $Id$";
slouken@0
    26
#endif
slouken@0
    27
slouken@0
    28
/* Include file for SDL keyboard event handling */
slouken@0
    29
slouken@0
    30
#ifndef _SDL_keyboard_h
slouken@0
    31
#define _SDL_keyboard_h
slouken@0
    32
slouken@0
    33
#include "SDL_types.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@0
    39
extern "C" {
slouken@0
    40
#endif
slouken@0
    41
slouken@0
    42
/* Keysym structure
slouken@0
    43
   - The scancode is hardware dependent, and should not be used by general
slouken@0
    44
     applications.  If no hardware scancode is available, it will be 0.
slouken@0
    45
slouken@0
    46
   - The 'unicode' translated character is only available when character
slouken@0
    47
     translation is enabled by the SDL_EnableUNICODE() API.  If non-zero,
slouken@0
    48
     this is a UNICODE character corresponding to the keypress.  If the
slouken@0
    49
     high 9 bits of the character are 0, then this maps to the equivalent
slouken@0
    50
     ASCII character:
slouken@0
    51
	char ch;
slouken@0
    52
	if ( (keysym.unicode & 0xFF80) == 0 ) {
slouken@0
    53
		ch = keysym.unicode & 0x7F;
slouken@0
    54
	} else {
slouken@0
    55
		An international character..
slouken@0
    56
	}
slouken@0
    57
 */
slouken@0
    58
typedef struct {
slouken@0
    59
	Uint8 scancode;			/* hardware specific scancode */
slouken@0
    60
	SDLKey sym;			/* SDL virtual keysym */
slouken@0
    61
	SDLMod mod;			/* current key modifiers */
slouken@0
    62
	Uint16 unicode;			/* translated character */
slouken@0
    63
} SDL_keysym;
slouken@0
    64
slouken@0
    65
/* This is the mask which refers to all hotkey bindings */
slouken@0
    66
#define SDL_ALL_HOTKEYS		0xFFFFFFFF
slouken@0
    67
slouken@0
    68
/* Function prototypes */
slouken@0
    69
/*
slouken@0
    70
 * Enable/Disable UNICODE translation of keyboard input.
slouken@0
    71
 * This translation has some overhead, so translation defaults off.
slouken@0
    72
 * If 'enable' is 1, translation is enabled.
slouken@0
    73
 * If 'enable' is 0, translation is disabled.
slouken@0
    74
 * If 'enable' is -1, the translation state is not changed.
slouken@0
    75
 * It returns the previous state of keyboard translation.
slouken@0
    76
 */
slouken@337
    77
extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable);
slouken@0
    78
slouken@0
    79
/*
slouken@0
    80
 * Enable/Disable keyboard repeat.  Keyboard repeat defaults to off.
slouken@0
    81
 * 'delay' is the initial delay in ms between the time when a key is
slouken@0
    82
 * pressed, and keyboard repeat begins.
slouken@0
    83
 * 'interval' is the time in ms between keyboard repeat events.
slouken@0
    84
 */
slouken@0
    85
#define SDL_DEFAULT_REPEAT_DELAY	500
slouken@0
    86
#define SDL_DEFAULT_REPEAT_INTERVAL	30
slouken@0
    87
/*
slouken@0
    88
 * If 'delay' is set to 0, keyboard repeat is disabled.
slouken@0
    89
 */
slouken@337
    90
extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval);
slouken@0
    91
slouken@0
    92
/*
slouken@0
    93
 * Get a snapshot of the current state of the keyboard.
slouken@0
    94
 * Returns an array of keystates, indexed by the SDLK_* syms.
slouken@0
    95
 * Used:
slouken@0
    96
 * 	Uint8 *keystate = SDL_GetKeyState(NULL);
slouken@0
    97
 *	if ( keystate[SDLK_RETURN] ) ... <RETURN> is pressed.
slouken@0
    98
 */
slouken@337
    99
extern DECLSPEC Uint8 * SDLCALL SDL_GetKeyState(int *numkeys);
slouken@0
   100
slouken@0
   101
/*
slouken@0
   102
 * Get the current key modifier state
slouken@0
   103
 */
slouken@337
   104
extern DECLSPEC SDLMod SDLCALL SDL_GetModState(void);
slouken@0
   105
slouken@0
   106
/*
slouken@0
   107
 * Set the current key modifier state
slouken@0
   108
 * This does not change the keyboard state, only the key modifier flags.
slouken@0
   109
 */
slouken@337
   110
extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate);
slouken@0
   111
slouken@0
   112
/*
slouken@0
   113
 * Get the name of an SDL virtual keysym
slouken@0
   114
 */
slouken@337
   115
extern DECLSPEC char * SDLCALL SDL_GetKeyName(SDLKey key);
slouken@0
   116
slouken@0
   117
slouken@0
   118
/* Ends C function definitions when using C++ */
slouken@0
   119
#ifdef __cplusplus
slouken@0
   120
}
slouken@0
   121
#endif
slouken@0
   122
#include "close_code.h"
slouken@0
   123
slouken@0
   124
#endif /* _SDL_keyboard_h */