slouken@0: /* slouken@0: SDL - Simple DirectMedia Layer slouken@3697: Copyright (C) 1997-2010 Sam Lantinga slouken@0: slouken@0: This library is free software; you can redistribute it and/or slouken@1312: modify it under the terms of the GNU Lesser General Public slouken@0: License as published by the Free Software Foundation; either slouken@1312: version 2.1 of the License, or (at your option) any later version. slouken@0: slouken@0: This library is distributed in the hope that it will be useful, slouken@0: but WITHOUT ANY WARRANTY; without even the implied warranty of slouken@0: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU slouken@1312: Lesser General Public License for more details. slouken@0: slouken@1312: You should have received a copy of the GNU Lesser General Public slouken@1312: License along with this library; if not, write to the Free Software slouken@1312: Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA slouken@0: slouken@0: Sam Lantinga slouken@251: slouken@libsdl.org slouken@0: */ slouken@0: slouken@1895: /** slouken@3407: * \file SDL_keyboard.h slouken@3407: * slouken@3407: * Include file for SDL keyboard event handling slouken@1895: */ slouken@0: slouken@0: #ifndef _SDL_keyboard_h slouken@0: #define _SDL_keyboard_h slouken@0: slouken@1356: #include "SDL_stdinc.h" slouken@1358: #include "SDL_error.h" slouken@0: #include "SDL_keysym.h" slouken@4465: #include "SDL_video.h" slouken@0: slouken@0: #include "begin_code.h" slouken@0: /* Set up for C function definitions, even when using C++ */ slouken@0: #ifdef __cplusplus slouken@1895: /* *INDENT-OFF* */ slouken@0: extern "C" { slouken@1895: /* *INDENT-ON* */ slouken@0: #endif slouken@0: slouken@1895: /** slouken@3407: * \brief The SDL keysym structure, used in key events. slouken@0: */ slouken@1895: typedef struct SDL_keysym slouken@1895: { slouken@2303: SDL_scancode scancode; /**< SDL physical key code - see ::SDL_scancode for details */ slouken@2268: SDLKey sym; /**< SDL virtual key code - see ::SDLKey for details */ slouken@1895: Uint16 mod; /**< current key modifiers */ slouken@3407: Uint32 unicode; /**< \deprecated use SDL_TextInputEvent instead */ slouken@0: } SDL_keysym; slouken@0: slouken@1895: /* Function prototypes */ slouken@0: slouken@1895: /** slouken@4465: * \brief Get the window which currently has keyboard focus. slouken@1895: */ slouken@4465: extern DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void); slouken@1895: slouken@1895: /** slouken@4465: * \brief Get a snapshot of the current state of the keyboard. slouken@3407: * slouken@3407: * \param numkeys if non-NULL, receives the length of the returned array. slouken@3407: * slouken@3407: * \return An array of key states. Indexes into this array are obtained by using ::SDL_scancode values. slouken@3407: * slouken@3407: * \b Example: slouken@3407: * \code slouken@3407: * Uint8 *state = SDL_GetKeyboardState(NULL); slouken@3407: * if ( state[SDL_SCANCODE_RETURN] ) { slouken@3407: * printf(" is pressed.\n"); slouken@3407: * } slouken@3407: * \endcode slouken@0: */ slouken@2303: extern DECLSPEC Uint8 *SDLCALL SDL_GetKeyboardState(int *numkeys); slouken@0: slouken@1895: /** slouken@4465: * \brief Get the current key modifier state for the keyboard. slouken@0: */ slouken@337: extern DECLSPEC SDLMod SDLCALL SDL_GetModState(void); slouken@0: slouken@1895: /** slouken@4465: * \brief Set the current key modifier state for the keyboard. slouken@3407: * slouken@3407: * \note This does not change the keyboard state, only the key modifier flags. slouken@0: */ slouken@337: extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate); slouken@0: slouken@1895: /** slouken@4465: * \brief Get the key code corresponding to the given scancode according slouken@4465: * to the current keyboard layout. slouken@3407: * slouken@3407: * See ::SDLKey for details. slouken@3407: * slouken@3407: * \sa SDL_GetKeyName() slouken@0: */ slouken@2303: extern DECLSPEC SDLKey SDLCALL SDL_GetKeyFromScancode(SDL_scancode scancode); slouken@2268: slouken@2268: /** slouken@3407: * \brief Get the scancode corresponding to the given key code according to the slouken@3407: * current keyboard layout. slouken@3407: * slouken@3407: * See ::SDL_scancode for details. slouken@3407: * slouken@3407: * \sa SDL_GetScancodeName() slouken@2303: */ slouken@2303: extern DECLSPEC SDL_scancode SDLCALL SDL_GetScancodeFromKey(SDLKey key); slouken@2303: slouken@2303: /** slouken@3407: * \brief Get a human-readable name for a scancode. slouken@3407: * slouken@3407: * \return A pointer to a UTF-8 string that stays valid at least until the next slouken@3407: * call to this function. If you need it around any longer, you must slouken@3407: * copy it. If the scancode doesn't have a name, this function returns slouken@3407: * an empty string (""). slouken@2303: * slouken@3407: * \sa SDL_scancode slouken@2303: */ slouken@2303: extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_scancode slouken@2303: scancode); slouken@2303: slouken@2303: /** slouken@3407: * \brief Get a human-readable name for a key. slouken@3407: * slouken@3407: * \return A pointer to a UTF-8 string that stays valid at least until the next slouken@3407: * call to this function. If you need it around any longer, you must slouken@3407: * copy it. If the key doesn't have a name, this function returns an slouken@3407: * empty string (""). slouken@3407: * slouken@3407: * \sa SDLKey slouken@2268: */ slouken@2303: extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDLKey key); slouken@0: slouken@3280: /** slouken@3407: * \brief Start accepting Unicode text input events. slouken@3407: * slouken@3407: * \sa SDL_StopTextInput() slouken@3407: * \sa SDL_SetTextInputRect() slouken@3280: */ dewyatt@4750: extern DECLSPEC void SDLCALL SDL_StartTextInput(SDL_Window *window); slouken@3280: slouken@3280: /** slouken@3407: * \brief Stop receiving any text input events. slouken@3407: * slouken@3407: * \sa SDL_StartTextInput() slouken@3280: */ dewyatt@4751: extern DECLSPEC void SDLCALL SDL_StopTextInput(SDL_Window *window); slouken@3280: slouken@3280: /** slouken@3407: * \brief Set the rectangle used to type Unicode text inputs. slouken@3407: * slouken@3407: * \sa SDL_StartTextInput() slouken@3280: */ slouken@3280: extern DECLSPEC void SDLCALL SDL_SetTextInputRect(SDL_Rect *rect); slouken@3280: slouken@0: slouken@0: /* Ends C function definitions when using C++ */ slouken@0: #ifdef __cplusplus slouken@1895: /* *INDENT-OFF* */ slouken@0: } slouken@1895: /* *INDENT-ON* */ slouken@0: #endif slouken@0: #include "close_code.h" slouken@0: slouken@0: #endif /* _SDL_keyboard_h */ slouken@1895: slouken@1895: /* vi: set ts=4 sw=4 expandtab: */