2 Simple DirectMedia Layer
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
23 * \file SDL_keyboard.h
25 * Include file for SDL keyboard event handling
28 #ifndef _SDL_keyboard_h
29 #define _SDL_keyboard_h
31 #include "SDL_stdinc.h"
32 #include "SDL_error.h"
33 #include "SDL_keycode.h"
34 #include "SDL_video.h"
36 #include "begin_code.h"
37 /* Set up for C function definitions, even when using C++ */
43 * \brief The SDL keysym structure, used in key events.
45 * \note If you are looking for translated character input, see the ::SDL_TEXTINPUT event.
47 typedef struct SDL_Keysym
49 SDL_Scancode scancode; /**< SDL physical key code - see ::SDL_Scancode for details */
50 SDL_Keycode sym; /**< SDL virtual key code - see ::SDL_Keycode for details */
51 Uint16 mod; /**< current key modifiers */
55 /* Function prototypes */
58 * \brief Get the window which currently has keyboard focus.
60 extern DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void);
63 * \brief Get a snapshot of the current state of the keyboard.
65 * \param numkeys if non-NULL, receives the length of the returned array.
67 * \return An array of key states. Indexes into this array are obtained by using ::SDL_Scancode values.
71 * const Uint8 *state = SDL_GetKeyboardState(NULL);
72 * if ( state[SDL_SCANCODE_RETURN] ) {
73 * printf("<RETURN> is pressed.\n");
77 extern DECLSPEC const Uint8 *SDLCALL SDL_GetKeyboardState(int *numkeys);
80 * \brief Get the current key modifier state for the keyboard.
82 extern DECLSPEC SDL_Keymod SDLCALL SDL_GetModState(void);
85 * \brief Set the current key modifier state for the keyboard.
87 * \note This does not change the keyboard state, only the key modifier flags.
89 extern DECLSPEC void SDLCALL SDL_SetModState(SDL_Keymod modstate);
92 * \brief Get the key code corresponding to the given scancode according
93 * to the current keyboard layout.
95 * See ::SDL_Keycode for details.
97 * \sa SDL_GetKeyName()
99 extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromScancode(SDL_Scancode scancode);
102 * \brief Get the scancode corresponding to the given key code according to the
103 * current keyboard layout.
105 * See ::SDL_Scancode for details.
107 * \sa SDL_GetScancodeName()
109 extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromKey(SDL_Keycode key);
112 * \brief Get a human-readable name for a scancode.
114 * \return A pointer to the name for the scancode.
115 * If the scancode doesn't have a name, this function returns
116 * an empty string ("").
120 extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_Scancode scancode);
123 * \brief Get a scancode from a human-readable name
125 * \return scancode, or SDL_SCANCODE_UNKNOWN if the name wasn't recognized
129 extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromName(const char *name);
132 * \brief Get a human-readable name for a key.
134 * \return A pointer to a UTF-8 string that stays valid at least until the next
135 * call to this function. If you need it around any longer, you must
136 * copy it. If the key doesn't have a name, this function returns an
141 extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDL_Keycode key);
144 * \brief Get a key code from a human-readable name
146 * \return key code, or SDLK_UNKNOWN if the name wasn't recognized
150 extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromName(const char *name);
153 * \brief Start accepting Unicode text input events.
154 * This function will show the on-screen keyboard if supported.
156 * \sa SDL_StopTextInput()
157 * \sa SDL_SetTextInputRect()
158 * \sa SDL_HasScreenKeyboardSupport()
160 extern DECLSPEC void SDLCALL SDL_StartTextInput(void);
163 * \brief Return whether or not Unicode text input events are enabled.
165 * \sa SDL_StartTextInput()
166 * \sa SDL_StopTextInput()
168 extern DECLSPEC SDL_bool SDLCALL SDL_IsTextInputActive(void);
171 * \brief Stop receiving any text input events.
172 * This function will hide the on-screen keyboard if supported.
174 * \sa SDL_StartTextInput()
175 * \sa SDL_HasScreenKeyboardSupport()
177 extern DECLSPEC void SDLCALL SDL_StopTextInput(void);
180 * \brief Set the rectangle used to type Unicode text inputs.
181 * This is used as a hint for IME and on-screen keyboard placement.
183 * \sa SDL_StartTextInput()
185 extern DECLSPEC void SDLCALL SDL_SetTextInputRect(SDL_Rect *rect);
188 * \brief Returns whether the platform has some screen keyboard support.
190 * \return SDL_TRUE if some keyboard support is available else SDL_FALSE.
192 * \note Not all screen keyboard functions are supported on all platforms.
194 * \sa SDL_IsScreenKeyboardShown()
196 extern DECLSPEC SDL_bool SDLCALL SDL_HasScreenKeyboardSupport(void);
199 * \brief Returns whether the screen keyboard is shown for given window.
201 * \param window The window for which screen keyboard should be queried.
203 * \return SDL_TRUE if screen keyboard is shown else SDL_FALSE.
205 * \sa SDL_HasScreenKeyboardSupport()
207 extern DECLSPEC SDL_bool SDLCALL SDL_IsScreenKeyboardShown(SDL_Window *window);
209 /* Ends C function definitions when using C++ */
213 #include "close_code.h"
215 #endif /* _SDL_keyboard_h */
217 /* vi: set ts=4 sw=4 expandtab: */