include/SDL_keyboard.h
author Sam Lantinga <slouken@libsdl.org>
Wed, 01 Feb 2006 06:32:25 +0000
changeset 1312 c9b51268668f
parent 911 04a403e4ccf5
child 1356 67114343400d
permissions -rw-r--r--
Updated copyright information and removed rcs id lines (problematic in branch merges)
I batch edited these files, so please let me know if I've accidentally removed anybody's
credit here.
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@0
    23
/* Include file for SDL keyboard event handling */
slouken@0
    24
slouken@0
    25
#ifndef _SDL_keyboard_h
slouken@0
    26
#define _SDL_keyboard_h
slouken@0
    27
slouken@0
    28
#include "SDL_types.h"
slouken@0
    29
#include "SDL_keysym.h"
slouken@0
    30
slouken@0
    31
#include "begin_code.h"
slouken@0
    32
/* Set up for C function definitions, even when using C++ */
slouken@0
    33
#ifdef __cplusplus
slouken@0
    34
extern "C" {
slouken@0
    35
#endif
slouken@0
    36
slouken@0
    37
/* Keysym structure
slouken@0
    38
   - The scancode is hardware dependent, and should not be used by general
slouken@0
    39
     applications.  If no hardware scancode is available, it will be 0.
slouken@0
    40
slouken@0
    41
   - The 'unicode' translated character is only available when character
slouken@0
    42
     translation is enabled by the SDL_EnableUNICODE() API.  If non-zero,
slouken@0
    43
     this is a UNICODE character corresponding to the keypress.  If the
slouken@0
    44
     high 9 bits of the character are 0, then this maps to the equivalent
slouken@0
    45
     ASCII character:
slouken@0
    46
	char ch;
slouken@0
    47
	if ( (keysym.unicode & 0xFF80) == 0 ) {
slouken@0
    48
		ch = keysym.unicode & 0x7F;
slouken@0
    49
	} else {
slouken@0
    50
		An international character..
slouken@0
    51
	}
slouken@0
    52
 */
slouken@911
    53
typedef struct SDL_keysym {
slouken@0
    54
	Uint8 scancode;			/* hardware specific scancode */
slouken@0
    55
	SDLKey sym;			/* SDL virtual keysym */
slouken@0
    56
	SDLMod mod;			/* current key modifiers */
slouken@0
    57
	Uint16 unicode;			/* translated character */
slouken@0
    58
} SDL_keysym;
slouken@0
    59
slouken@0
    60
/* This is the mask which refers to all hotkey bindings */
slouken@0
    61
#define SDL_ALL_HOTKEYS		0xFFFFFFFF
slouken@0
    62
slouken@0
    63
/* Function prototypes */
slouken@0
    64
/*
slouken@0
    65
 * Enable/Disable UNICODE translation of keyboard input.
slouken@0
    66
 * This translation has some overhead, so translation defaults off.
slouken@0
    67
 * If 'enable' is 1, translation is enabled.
slouken@0
    68
 * If 'enable' is 0, translation is disabled.
slouken@0
    69
 * If 'enable' is -1, the translation state is not changed.
slouken@0
    70
 * It returns the previous state of keyboard translation.
slouken@0
    71
 */
slouken@337
    72
extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable);
slouken@0
    73
slouken@0
    74
/*
slouken@0
    75
 * Enable/Disable keyboard repeat.  Keyboard repeat defaults to off.
slouken@0
    76
 * 'delay' is the initial delay in ms between the time when a key is
slouken@0
    77
 * pressed, and keyboard repeat begins.
slouken@0
    78
 * 'interval' is the time in ms between keyboard repeat events.
slouken@0
    79
 */
slouken@0
    80
#define SDL_DEFAULT_REPEAT_DELAY	500
slouken@0
    81
#define SDL_DEFAULT_REPEAT_INTERVAL	30
slouken@0
    82
/*
slouken@0
    83
 * If 'delay' is set to 0, keyboard repeat is disabled.
slouken@0
    84
 */
slouken@337
    85
extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval);
slouken@0
    86
slouken@0
    87
/*
slouken@0
    88
 * Get a snapshot of the current state of the keyboard.
slouken@0
    89
 * Returns an array of keystates, indexed by the SDLK_* syms.
slouken@0
    90
 * Used:
slouken@0
    91
 * 	Uint8 *keystate = SDL_GetKeyState(NULL);
slouken@0
    92
 *	if ( keystate[SDLK_RETURN] ) ... <RETURN> is pressed.
slouken@0
    93
 */
slouken@337
    94
extern DECLSPEC Uint8 * SDLCALL SDL_GetKeyState(int *numkeys);
slouken@0
    95
slouken@0
    96
/*
slouken@0
    97
 * Get the current key modifier state
slouken@0
    98
 */
slouken@337
    99
extern DECLSPEC SDLMod SDLCALL SDL_GetModState(void);
slouken@0
   100
slouken@0
   101
/*
slouken@0
   102
 * Set the current key modifier state
slouken@0
   103
 * This does not change the keyboard state, only the key modifier flags.
slouken@0
   104
 */
slouken@337
   105
extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate);
slouken@0
   106
slouken@0
   107
/*
slouken@0
   108
 * Get the name of an SDL virtual keysym
slouken@0
   109
 */
slouken@337
   110
extern DECLSPEC char * SDLCALL SDL_GetKeyName(SDLKey key);
slouken@0
   111
slouken@0
   112
slouken@0
   113
/* Ends C function definitions when using C++ */
slouken@0
   114
#ifdef __cplusplus
slouken@0
   115
}
slouken@0
   116
#endif
slouken@0
   117
#include "close_code.h"
slouken@0
   118
slouken@0
   119
#endif /* _SDL_keyboard_h */