Path: blob/main/system/include/SDL/SDL_keyboard.h
6169 views
/*1Simple DirectMedia Layer2Copyright (C) 1997-2011 Sam Lantinga <[email protected]>34This software is provided 'as-is', without any express or implied5warranty. In no event will the authors be held liable for any damages6arising from the use of this software.78Permission is granted to anyone to use this software for any purpose,9including commercial applications, and to alter it and redistribute it10freely, subject to the following restrictions:11121. The origin of this software must not be misrepresented; you must not13claim that you wrote the original software. If you use this software14in a product, an acknowledgment in the product documentation would be15appreciated but is not required.162. Altered source versions must be plainly marked as such, and must not be17misrepresented as being the original software.183. This notice may not be removed or altered from any source distribution.19*/2021/**22* \file SDL_keyboard.h23*24* Include file for SDL keyboard event handling25*/2627#ifndef _SDL_keyboard_h28#define _SDL_keyboard_h2930#include "SDL_stdinc.h"31#include "SDL_error.h"32#include "SDL_keycode.h"33#include "SDL_video.h"3435#include "begin_code.h"36/* Set up for C function definitions, even when using C++ */37#ifdef __cplusplus38/* *INDENT-OFF* */39extern "C" {40/* *INDENT-ON* */41#endif4243/**44* \brief The SDL keysym structure, used in key events.45*/46typedef struct SDL_Keysym47{48SDL_Scancode scancode; /**< SDL physical key code - see ::SDL_Scancode for details */49SDL_Keycode sym; /**< SDL virtual key code - see ::SDL_Keycode for details */50Uint16 mod; /**< current key modifiers */51Uint32 unicode; /**< \deprecated use SDL_TextInputEvent instead */52} SDL_Keysym;5354/* Function prototypes */5556/**57* \brief Get the window which currently has keyboard focus.58*/59extern DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void);6061/**62* \brief Get a snapshot of the current state of the keyboard.63*64* \param numkeys if non-NULL, receives the length of the returned array.65*66* \return An array of key states. Indexes into this array are obtained by using ::SDL_Scancode values.67*68* \b Example:69* \code70* Uint8 *state = SDL_GetKeyboardState(NULL);71* if ( state[SDL_SCANCODE_RETURN] ) {72* printf("<RETURN> is pressed.\n");73* }74* \endcode75*/76extern DECLSPEC Uint8 *SDLCALL SDL_GetKeyboardState(int *numkeys);7778/**79* \brief Get the current key modifier state for the keyboard.80*/81extern DECLSPEC SDL_Keymod SDLCALL SDL_GetModState(void);8283/**84* \brief Set the current key modifier state for the keyboard.85*86* \note This does not change the keyboard state, only the key modifier flags.87*/88extern DECLSPEC void SDLCALL SDL_SetModState(SDL_Keymod modstate);8990/**91* \brief Get the key code corresponding to the given scancode according92* to the current keyboard layout.93*94* See ::SDL_Keycode for details.95*96* \sa SDL_GetKeyName()97*/98extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromScancode(SDL_Scancode scancode);99100/**101* \brief Get the scancode corresponding to the given key code according to the102* current keyboard layout.103*104* See ::SDL_Scancode for details.105*106* \sa SDL_GetScancodeName()107*/108extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromKey(SDL_Keycode key);109110/**111* \brief Get a human-readable name for a scancode.112*113* \return A pointer to a UTF-8 string that stays valid at least until the next114* call to this function. If you need it around any longer, you must115* copy it. If the scancode doesn't have a name, this function returns116* an empty string ("").117*118* \sa SDL_Scancode119*/120extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_Scancode121scancode);122123/**124* \brief Get a human-readable name for a key.125*126* \return A pointer to a UTF-8 string that stays valid at least until the next127* call to this function. If you need it around any longer, you must128* copy it. If the key doesn't have a name, this function returns an129* empty string ("").130*131* \sa SDL_Key132*/133extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDL_Keycode key);134135/**136* \brief Start accepting Unicode text input events.137*138* \sa SDL_StopTextInput()139* \sa SDL_SetTextInputRect()140*/141extern DECLSPEC void SDLCALL SDL_StartTextInput(void);142143/**144* \brief Stop receiving any text input events.145*146* \sa SDL_StartTextInput()147*/148extern DECLSPEC void SDLCALL SDL_StopTextInput(void);149150/**151* \brief Set the rectangle used to type Unicode text inputs.152*153* \sa SDL_StartTextInput()154*/155extern DECLSPEC void SDLCALL SDL_SetTextInputRect(SDL_Rect *rect);156157158/* Ends C function definitions when using C++ */159#ifdef __cplusplus160/* *INDENT-OFF* */161}162/* *INDENT-ON* */163#endif164#include "close_code.h"165166#endif /* _SDL_keyboard_h */167168/* vi: set ts=4 sw=4 expandtab: */169170171