include/SDL_keyboard.h
author Ozkan Sezer <sezeroz@gmail.com>
Sun, 01 Jul 2018 17:00:02 +0300
branchSDL-1.2
changeset 12053 edddd89f910d
parent 6137 4720145f848b
permissions -rw-r--r--
SDL_svgaevents.c: add missing ioctl.h include
slouken@0
     1
/*
slouken@0
     2
    SDL - Simple DirectMedia Layer
slouken@6137
     3
    Copyright (C) 1997-2012 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@4217
    23
/** @file SDL_keyboard.h
slouken@4217
    24
 *  Include file for SDL keyboard event handling
slouken@4217
    25
 */
slouken@0
    26
slouken@0
    27
#ifndef _SDL_keyboard_h
slouken@0
    28
#define _SDL_keyboard_h
slouken@0
    29
slouken@1356
    30
#include "SDL_stdinc.h"
slouken@1358
    31
#include "SDL_error.h"
slouken@0
    32
#include "SDL_keysym.h"
slouken@0
    33
slouken@0
    34
#include "begin_code.h"
slouken@0
    35
/* Set up for C function definitions, even when using C++ */
slouken@0
    36
#ifdef __cplusplus
slouken@0
    37
extern "C" {
slouken@0
    38
#endif
slouken@0
    39
slouken@4217
    40
/** Keysym structure
slouken@4217
    41
 *
slouken@4217
    42
 *  - The scancode is hardware dependent, and should not be used by general
slouken@4217
    43
 *    applications.  If no hardware scancode is available, it will be 0.
slouken@4217
    44
 *
slouken@4217
    45
 *  - The 'unicode' translated character is only available when character
slouken@4217
    46
 *    translation is enabled by the SDL_EnableUNICODE() API.  If non-zero,
slouken@4217
    47
 *    this is a UNICODE character corresponding to the keypress.  If the
slouken@4217
    48
 *    high 9 bits of the character are 0, then this maps to the equivalent
slouken@4217
    49
 *    ASCII character:
slouken@4217
    50
 *      @code
slouken@4217
    51
 *	char ch;
slouken@4217
    52
 *	if ( (keysym.unicode & 0xFF80) == 0 ) {
slouken@4217
    53
 *		ch = keysym.unicode & 0x7F;
slouken@4217
    54
 *	} else {
slouken@4217
    55
 *		An international character..
slouken@4217
    56
 *	}
slouken@4217
    57
 *      @endcode
slouken@0
    58
 */
slouken@911
    59
typedef struct SDL_keysym {
slouken@4217
    60
	Uint8 scancode;			/**< hardware specific scancode */
slouken@4217
    61
	SDLKey sym;			/**< SDL virtual keysym */
slouken@4217
    62
	SDLMod mod;			/**< current key modifiers */
slouken@4217
    63
	Uint16 unicode;			/**< translated character */
slouken@0
    64
} SDL_keysym;
slouken@0
    65
slouken@4217
    66
/** This is the mask which refers to all hotkey bindings */
slouken@0
    67
#define SDL_ALL_HOTKEYS		0xFFFFFFFF
slouken@0
    68
slouken@0
    69
/* Function prototypes */
slouken@4217
    70
/**
slouken@0
    71
 * Enable/Disable UNICODE translation of keyboard input.
slouken@4217
    72
 *
slouken@0
    73
 * This translation has some overhead, so translation defaults off.
slouken@4217
    74
 *
slouken@4217
    75
 * @param[in] enable
slouken@0
    76
 * If 'enable' is 1, translation is enabled.
slouken@0
    77
 * If 'enable' is 0, translation is disabled.
slouken@0
    78
 * If 'enable' is -1, the translation state is not changed.
slouken@4217
    79
 *
slouken@4217
    80
 * @return It returns the previous state of keyboard translation.
slouken@0
    81
 */
slouken@337
    82
extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable);
slouken@0
    83
slouken@0
    84
#define SDL_DEFAULT_REPEAT_DELAY	500
slouken@0
    85
#define SDL_DEFAULT_REPEAT_INTERVAL	30
slouken@4217
    86
/**
slouken@4217
    87
 * Enable/Disable keyboard repeat.  Keyboard repeat defaults to off.
slouken@4217
    88
 *
slouken@4217
    89
 *  @param[in] delay
slouken@4217
    90
 *  'delay' is the initial delay in ms between the time when a key is
slouken@4217
    91
 *  pressed, and keyboard repeat begins.
slouken@4217
    92
 *
slouken@4217
    93
 *  @param[in] interval
slouken@4217
    94
 *  'interval' is the time in ms between keyboard repeat events.
slouken@4217
    95
 *
slouken@4217
    96
 *  If 'delay' is set to 0, keyboard repeat is disabled.
slouken@0
    97
 */
slouken@337
    98
extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval);
slouken@1507
    99
extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval);
slouken@0
   100
slouken@4217
   101
/**
slouken@0
   102
 * Get a snapshot of the current state of the keyboard.
slouken@0
   103
 * Returns an array of keystates, indexed by the SDLK_* syms.
slouken@4217
   104
 * Usage:
slouken@4217
   105
 *	@code
slouken@0
   106
 * 	Uint8 *keystate = SDL_GetKeyState(NULL);
slouken@4217
   107
 *	if ( keystate[SDLK_RETURN] ) //... \<RETURN> is pressed.
slouken@4217
   108
 *	@endcode
slouken@0
   109
 */
slouken@337
   110
extern DECLSPEC Uint8 * SDLCALL SDL_GetKeyState(int *numkeys);
slouken@0
   111
slouken@4217
   112
/**
slouken@0
   113
 * Get the current key modifier state
slouken@0
   114
 */
slouken@337
   115
extern DECLSPEC SDLMod SDLCALL SDL_GetModState(void);
slouken@0
   116
slouken@4217
   117
/**
slouken@4217
   118
 * Set the current key modifier state.
slouken@0
   119
 * This does not change the keyboard state, only the key modifier flags.
slouken@0
   120
 */
slouken@337
   121
extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate);
slouken@0
   122
slouken@4217
   123
/**
slouken@0
   124
 * Get the name of an SDL virtual keysym
slouken@0
   125
 */
slouken@337
   126
extern DECLSPEC char * SDLCALL SDL_GetKeyName(SDLKey key);
slouken@0
   127
slouken@0
   128
slouken@0
   129
/* Ends C function definitions when using C++ */
slouken@0
   130
#ifdef __cplusplus
slouken@0
   131
}
slouken@0
   132
#endif
slouken@0
   133
#include "close_code.h"
slouken@0
   134
slouken@0
   135
#endif /* _SDL_keyboard_h */