include/SDL_keyboard.h
changeset 0 74212992fb08
child 251 b8688cfdc232
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/include/SDL_keyboard.h	Thu Apr 26 16:45:43 2001 +0000
     1.3 @@ -0,0 +1,124 @@
     1.4 +/*
     1.5 +    SDL - Simple DirectMedia Layer
     1.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
     1.7 +
     1.8 +    This library is free software; you can redistribute it and/or
     1.9 +    modify it under the terms of the GNU Library General Public
    1.10 +    License as published by the Free Software Foundation; either
    1.11 +    version 2 of the License, or (at your option) any later version.
    1.12 +
    1.13 +    This library is distributed in the hope that it will be useful,
    1.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.16 +    Library General Public License for more details.
    1.17 +
    1.18 +    You should have received a copy of the GNU Library General Public
    1.19 +    License along with this library; if not, write to the Free
    1.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    1.21 +
    1.22 +    Sam Lantinga
    1.23 +    slouken@devolution.com
    1.24 +*/
    1.25 +
    1.26 +#ifdef SAVE_RCSID
    1.27 +static char rcsid =
    1.28 + "@(#) $Id$";
    1.29 +#endif
    1.30 +
    1.31 +/* Include file for SDL keyboard event handling */
    1.32 +
    1.33 +#ifndef _SDL_keyboard_h
    1.34 +#define _SDL_keyboard_h
    1.35 +
    1.36 +#include "SDL_types.h"
    1.37 +#include "SDL_keysym.h"
    1.38 +
    1.39 +#include "begin_code.h"
    1.40 +/* Set up for C function definitions, even when using C++ */
    1.41 +#ifdef __cplusplus
    1.42 +extern "C" {
    1.43 +#endif
    1.44 +
    1.45 +/* Keysym structure
    1.46 +   - The scancode is hardware dependent, and should not be used by general
    1.47 +     applications.  If no hardware scancode is available, it will be 0.
    1.48 +
    1.49 +   - The 'unicode' translated character is only available when character
    1.50 +     translation is enabled by the SDL_EnableUNICODE() API.  If non-zero,
    1.51 +     this is a UNICODE character corresponding to the keypress.  If the
    1.52 +     high 9 bits of the character are 0, then this maps to the equivalent
    1.53 +     ASCII character:
    1.54 +	char ch;
    1.55 +	if ( (keysym.unicode & 0xFF80) == 0 ) {
    1.56 +		ch = keysym.unicode & 0x7F;
    1.57 +	} else {
    1.58 +		An international character..
    1.59 +	}
    1.60 + */
    1.61 +typedef struct {
    1.62 +	Uint8 scancode;			/* hardware specific scancode */
    1.63 +	SDLKey sym;			/* SDL virtual keysym */
    1.64 +	SDLMod mod;			/* current key modifiers */
    1.65 +	Uint16 unicode;			/* translated character */
    1.66 +} SDL_keysym;
    1.67 +
    1.68 +/* This is the mask which refers to all hotkey bindings */
    1.69 +#define SDL_ALL_HOTKEYS		0xFFFFFFFF
    1.70 +
    1.71 +/* Function prototypes */
    1.72 +/*
    1.73 + * Enable/Disable UNICODE translation of keyboard input.
    1.74 + * This translation has some overhead, so translation defaults off.
    1.75 + * If 'enable' is 1, translation is enabled.
    1.76 + * If 'enable' is 0, translation is disabled.
    1.77 + * If 'enable' is -1, the translation state is not changed.
    1.78 + * It returns the previous state of keyboard translation.
    1.79 + */
    1.80 +extern DECLSPEC int SDL_EnableUNICODE(int enable);
    1.81 +
    1.82 +/*
    1.83 + * Enable/Disable keyboard repeat.  Keyboard repeat defaults to off.
    1.84 + * 'delay' is the initial delay in ms between the time when a key is
    1.85 + * pressed, and keyboard repeat begins.
    1.86 + * 'interval' is the time in ms between keyboard repeat events.
    1.87 + */
    1.88 +#define SDL_DEFAULT_REPEAT_DELAY	500
    1.89 +#define SDL_DEFAULT_REPEAT_INTERVAL	30
    1.90 +/*
    1.91 + * If 'delay' is set to 0, keyboard repeat is disabled.
    1.92 + */
    1.93 +extern DECLSPEC int SDL_EnableKeyRepeat(int delay, int interval);
    1.94 +
    1.95 +/*
    1.96 + * Get a snapshot of the current state of the keyboard.
    1.97 + * Returns an array of keystates, indexed by the SDLK_* syms.
    1.98 + * Used:
    1.99 + * 	Uint8 *keystate = SDL_GetKeyState(NULL);
   1.100 + *	if ( keystate[SDLK_RETURN] ) ... <RETURN> is pressed.
   1.101 + */
   1.102 +extern DECLSPEC Uint8 * SDL_GetKeyState(int *numkeys);
   1.103 +
   1.104 +/*
   1.105 + * Get the current key modifier state
   1.106 + */
   1.107 +extern DECLSPEC SDLMod SDL_GetModState(void);
   1.108 +
   1.109 +/*
   1.110 + * Set the current key modifier state
   1.111 + * This does not change the keyboard state, only the key modifier flags.
   1.112 + */
   1.113 +extern DECLSPEC void SDL_SetModState(SDLMod modstate);
   1.114 +
   1.115 +/*
   1.116 + * Get the name of an SDL virtual keysym
   1.117 + */
   1.118 +extern DECLSPEC char * SDL_GetKeyName(SDLKey key);
   1.119 +
   1.120 +
   1.121 +/* Ends C function definitions when using C++ */
   1.122 +#ifdef __cplusplus
   1.123 +}
   1.124 +#endif
   1.125 +#include "close_code.h"
   1.126 +
   1.127 +#endif /* _SDL_keyboard_h */