SDL Library
SDL_keyboard.h@0:7fb6877b5d7c, 2016-09-22 (annotated)
- Committer:
- miruga27
- Date:
- Thu Sep 22 00:03:09 2016 +0000
- Revision:
- 0:7fb6877b5d7c
SDL
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
miruga27 | 0:7fb6877b5d7c | 1 | /* |
miruga27 | 0:7fb6877b5d7c | 2 | Simple DirectMedia Layer |
miruga27 | 0:7fb6877b5d7c | 3 | Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org> |
miruga27 | 0:7fb6877b5d7c | 4 | |
miruga27 | 0:7fb6877b5d7c | 5 | This software is provided 'as-is', without any express or implied |
miruga27 | 0:7fb6877b5d7c | 6 | warranty. In no event will the authors be held liable for any damages |
miruga27 | 0:7fb6877b5d7c | 7 | arising from the use of this software. |
miruga27 | 0:7fb6877b5d7c | 8 | |
miruga27 | 0:7fb6877b5d7c | 9 | Permission is granted to anyone to use this software for any purpose, |
miruga27 | 0:7fb6877b5d7c | 10 | including commercial applications, and to alter it and redistribute it |
miruga27 | 0:7fb6877b5d7c | 11 | freely, subject to the following restrictions: |
miruga27 | 0:7fb6877b5d7c | 12 | |
miruga27 | 0:7fb6877b5d7c | 13 | 1. The origin of this software must not be misrepresented; you must not |
miruga27 | 0:7fb6877b5d7c | 14 | claim that you wrote the original software. If you use this software |
miruga27 | 0:7fb6877b5d7c | 15 | in a product, an acknowledgment in the product documentation would be |
miruga27 | 0:7fb6877b5d7c | 16 | appreciated but is not required. |
miruga27 | 0:7fb6877b5d7c | 17 | 2. Altered source versions must be plainly marked as such, and must not be |
miruga27 | 0:7fb6877b5d7c | 18 | misrepresented as being the original software. |
miruga27 | 0:7fb6877b5d7c | 19 | 3. This notice may not be removed or altered from any source distribution. |
miruga27 | 0:7fb6877b5d7c | 20 | */ |
miruga27 | 0:7fb6877b5d7c | 21 | |
miruga27 | 0:7fb6877b5d7c | 22 | /** |
miruga27 | 0:7fb6877b5d7c | 23 | * \file SDL_keyboard.h |
miruga27 | 0:7fb6877b5d7c | 24 | * |
miruga27 | 0:7fb6877b5d7c | 25 | * Include file for SDL keyboard event handling |
miruga27 | 0:7fb6877b5d7c | 26 | */ |
miruga27 | 0:7fb6877b5d7c | 27 | |
miruga27 | 0:7fb6877b5d7c | 28 | #ifndef _SDL_keyboard_h |
miruga27 | 0:7fb6877b5d7c | 29 | #define _SDL_keyboard_h |
miruga27 | 0:7fb6877b5d7c | 30 | |
miruga27 | 0:7fb6877b5d7c | 31 | #include "SDL_stdinc.h" |
miruga27 | 0:7fb6877b5d7c | 32 | #include "SDL_error.h" |
miruga27 | 0:7fb6877b5d7c | 33 | #include "SDL_keycode.h" |
miruga27 | 0:7fb6877b5d7c | 34 | #include "SDL_video.h" |
miruga27 | 0:7fb6877b5d7c | 35 | |
miruga27 | 0:7fb6877b5d7c | 36 | #include "begin_code.h" |
miruga27 | 0:7fb6877b5d7c | 37 | /* Set up for C function definitions, even when using C++ */ |
miruga27 | 0:7fb6877b5d7c | 38 | #ifdef __cplusplus |
miruga27 | 0:7fb6877b5d7c | 39 | extern "C" { |
miruga27 | 0:7fb6877b5d7c | 40 | #endif |
miruga27 | 0:7fb6877b5d7c | 41 | |
miruga27 | 0:7fb6877b5d7c | 42 | /** |
miruga27 | 0:7fb6877b5d7c | 43 | * \brief The SDL keysym structure, used in key events. |
miruga27 | 0:7fb6877b5d7c | 44 | * |
miruga27 | 0:7fb6877b5d7c | 45 | * \note If you are looking for translated character input, see the ::SDL_TEXTINPUT event. |
miruga27 | 0:7fb6877b5d7c | 46 | */ |
miruga27 | 0:7fb6877b5d7c | 47 | typedef struct SDL_Keysym |
miruga27 | 0:7fb6877b5d7c | 48 | { |
miruga27 | 0:7fb6877b5d7c | 49 | SDL_Scancode scancode; /**< SDL physical key code - see ::SDL_Scancode for details */ |
miruga27 | 0:7fb6877b5d7c | 50 | SDL_Keycode sym; /**< SDL virtual key code - see ::SDL_Keycode for details */ |
miruga27 | 0:7fb6877b5d7c | 51 | Uint16 mod; /**< current key modifiers */ |
miruga27 | 0:7fb6877b5d7c | 52 | Uint32 unused; |
miruga27 | 0:7fb6877b5d7c | 53 | } SDL_Keysym; |
miruga27 | 0:7fb6877b5d7c | 54 | |
miruga27 | 0:7fb6877b5d7c | 55 | /* Function prototypes */ |
miruga27 | 0:7fb6877b5d7c | 56 | |
miruga27 | 0:7fb6877b5d7c | 57 | /** |
miruga27 | 0:7fb6877b5d7c | 58 | * \brief Get the window which currently has keyboard focus. |
miruga27 | 0:7fb6877b5d7c | 59 | */ |
miruga27 | 0:7fb6877b5d7c | 60 | extern DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void); |
miruga27 | 0:7fb6877b5d7c | 61 | |
miruga27 | 0:7fb6877b5d7c | 62 | /** |
miruga27 | 0:7fb6877b5d7c | 63 | * \brief Get a snapshot of the current state of the keyboard. |
miruga27 | 0:7fb6877b5d7c | 64 | * |
miruga27 | 0:7fb6877b5d7c | 65 | * \param numkeys if non-NULL, receives the length of the returned array. |
miruga27 | 0:7fb6877b5d7c | 66 | * |
miruga27 | 0:7fb6877b5d7c | 67 | * \return An array of key states. Indexes into this array are obtained by using ::SDL_Scancode values. |
miruga27 | 0:7fb6877b5d7c | 68 | * |
miruga27 | 0:7fb6877b5d7c | 69 | * \b Example: |
miruga27 | 0:7fb6877b5d7c | 70 | * \code |
miruga27 | 0:7fb6877b5d7c | 71 | * const Uint8 *state = SDL_GetKeyboardState(NULL); |
miruga27 | 0:7fb6877b5d7c | 72 | * if ( state[SDL_SCANCODE_RETURN] ) { |
miruga27 | 0:7fb6877b5d7c | 73 | * printf("<RETURN> is pressed.\n"); |
miruga27 | 0:7fb6877b5d7c | 74 | * } |
miruga27 | 0:7fb6877b5d7c | 75 | * \endcode |
miruga27 | 0:7fb6877b5d7c | 76 | */ |
miruga27 | 0:7fb6877b5d7c | 77 | extern DECLSPEC const Uint8 *SDLCALL SDL_GetKeyboardState(int *numkeys); |
miruga27 | 0:7fb6877b5d7c | 78 | |
miruga27 | 0:7fb6877b5d7c | 79 | /** |
miruga27 | 0:7fb6877b5d7c | 80 | * \brief Get the current key modifier state for the keyboard. |
miruga27 | 0:7fb6877b5d7c | 81 | */ |
miruga27 | 0:7fb6877b5d7c | 82 | extern DECLSPEC SDL_Keymod SDLCALL SDL_GetModState(void); |
miruga27 | 0:7fb6877b5d7c | 83 | |
miruga27 | 0:7fb6877b5d7c | 84 | /** |
miruga27 | 0:7fb6877b5d7c | 85 | * \brief Set the current key modifier state for the keyboard. |
miruga27 | 0:7fb6877b5d7c | 86 | * |
miruga27 | 0:7fb6877b5d7c | 87 | * \note This does not change the keyboard state, only the key modifier flags. |
miruga27 | 0:7fb6877b5d7c | 88 | */ |
miruga27 | 0:7fb6877b5d7c | 89 | extern DECLSPEC void SDLCALL SDL_SetModState(SDL_Keymod modstate); |
miruga27 | 0:7fb6877b5d7c | 90 | |
miruga27 | 0:7fb6877b5d7c | 91 | /** |
miruga27 | 0:7fb6877b5d7c | 92 | * \brief Get the key code corresponding to the given scancode according |
miruga27 | 0:7fb6877b5d7c | 93 | * to the current keyboard layout. |
miruga27 | 0:7fb6877b5d7c | 94 | * |
miruga27 | 0:7fb6877b5d7c | 95 | * See ::SDL_Keycode for details. |
miruga27 | 0:7fb6877b5d7c | 96 | * |
miruga27 | 0:7fb6877b5d7c | 97 | * \sa SDL_GetKeyName() |
miruga27 | 0:7fb6877b5d7c | 98 | */ |
miruga27 | 0:7fb6877b5d7c | 99 | extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromScancode(SDL_Scancode scancode); |
miruga27 | 0:7fb6877b5d7c | 100 | |
miruga27 | 0:7fb6877b5d7c | 101 | /** |
miruga27 | 0:7fb6877b5d7c | 102 | * \brief Get the scancode corresponding to the given key code according to the |
miruga27 | 0:7fb6877b5d7c | 103 | * current keyboard layout. |
miruga27 | 0:7fb6877b5d7c | 104 | * |
miruga27 | 0:7fb6877b5d7c | 105 | * See ::SDL_Scancode for details. |
miruga27 | 0:7fb6877b5d7c | 106 | * |
miruga27 | 0:7fb6877b5d7c | 107 | * \sa SDL_GetScancodeName() |
miruga27 | 0:7fb6877b5d7c | 108 | */ |
miruga27 | 0:7fb6877b5d7c | 109 | extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromKey(SDL_Keycode key); |
miruga27 | 0:7fb6877b5d7c | 110 | |
miruga27 | 0:7fb6877b5d7c | 111 | /** |
miruga27 | 0:7fb6877b5d7c | 112 | * \brief Get a human-readable name for a scancode. |
miruga27 | 0:7fb6877b5d7c | 113 | * |
miruga27 | 0:7fb6877b5d7c | 114 | * \return A pointer to the name for the scancode. |
miruga27 | 0:7fb6877b5d7c | 115 | * If the scancode doesn't have a name, this function returns |
miruga27 | 0:7fb6877b5d7c | 116 | * an empty string (""). |
miruga27 | 0:7fb6877b5d7c | 117 | * |
miruga27 | 0:7fb6877b5d7c | 118 | * \sa SDL_Scancode |
miruga27 | 0:7fb6877b5d7c | 119 | */ |
miruga27 | 0:7fb6877b5d7c | 120 | extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_Scancode scancode); |
miruga27 | 0:7fb6877b5d7c | 121 | |
miruga27 | 0:7fb6877b5d7c | 122 | /** |
miruga27 | 0:7fb6877b5d7c | 123 | * \brief Get a scancode from a human-readable name |
miruga27 | 0:7fb6877b5d7c | 124 | * |
miruga27 | 0:7fb6877b5d7c | 125 | * \return scancode, or SDL_SCANCODE_UNKNOWN if the name wasn't recognized |
miruga27 | 0:7fb6877b5d7c | 126 | * |
miruga27 | 0:7fb6877b5d7c | 127 | * \sa SDL_Scancode |
miruga27 | 0:7fb6877b5d7c | 128 | */ |
miruga27 | 0:7fb6877b5d7c | 129 | extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromName(const char *name); |
miruga27 | 0:7fb6877b5d7c | 130 | |
miruga27 | 0:7fb6877b5d7c | 131 | /** |
miruga27 | 0:7fb6877b5d7c | 132 | * \brief Get a human-readable name for a key. |
miruga27 | 0:7fb6877b5d7c | 133 | * |
miruga27 | 0:7fb6877b5d7c | 134 | * \return A pointer to a UTF-8 string that stays valid at least until the next |
miruga27 | 0:7fb6877b5d7c | 135 | * call to this function. If you need it around any longer, you must |
miruga27 | 0:7fb6877b5d7c | 136 | * copy it. If the key doesn't have a name, this function returns an |
miruga27 | 0:7fb6877b5d7c | 137 | * empty string (""). |
miruga27 | 0:7fb6877b5d7c | 138 | * |
miruga27 | 0:7fb6877b5d7c | 139 | * \sa SDL_Key |
miruga27 | 0:7fb6877b5d7c | 140 | */ |
miruga27 | 0:7fb6877b5d7c | 141 | extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDL_Keycode key); |
miruga27 | 0:7fb6877b5d7c | 142 | |
miruga27 | 0:7fb6877b5d7c | 143 | /** |
miruga27 | 0:7fb6877b5d7c | 144 | * \brief Get a key code from a human-readable name |
miruga27 | 0:7fb6877b5d7c | 145 | * |
miruga27 | 0:7fb6877b5d7c | 146 | * \return key code, or SDLK_UNKNOWN if the name wasn't recognized |
miruga27 | 0:7fb6877b5d7c | 147 | * |
miruga27 | 0:7fb6877b5d7c | 148 | * \sa SDL_Keycode |
miruga27 | 0:7fb6877b5d7c | 149 | */ |
miruga27 | 0:7fb6877b5d7c | 150 | extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromName(const char *name); |
miruga27 | 0:7fb6877b5d7c | 151 | |
miruga27 | 0:7fb6877b5d7c | 152 | /** |
miruga27 | 0:7fb6877b5d7c | 153 | * \brief Start accepting Unicode text input events. |
miruga27 | 0:7fb6877b5d7c | 154 | * This function will show the on-screen keyboard if supported. |
miruga27 | 0:7fb6877b5d7c | 155 | * |
miruga27 | 0:7fb6877b5d7c | 156 | * \sa SDL_StopTextInput() |
miruga27 | 0:7fb6877b5d7c | 157 | * \sa SDL_SetTextInputRect() |
miruga27 | 0:7fb6877b5d7c | 158 | * \sa SDL_HasScreenKeyboardSupport() |
miruga27 | 0:7fb6877b5d7c | 159 | */ |
miruga27 | 0:7fb6877b5d7c | 160 | extern DECLSPEC void SDLCALL SDL_StartTextInput(void); |
miruga27 | 0:7fb6877b5d7c | 161 | |
miruga27 | 0:7fb6877b5d7c | 162 | /** |
miruga27 | 0:7fb6877b5d7c | 163 | * \brief Return whether or not Unicode text input events are enabled. |
miruga27 | 0:7fb6877b5d7c | 164 | * |
miruga27 | 0:7fb6877b5d7c | 165 | * \sa SDL_StartTextInput() |
miruga27 | 0:7fb6877b5d7c | 166 | * \sa SDL_StopTextInput() |
miruga27 | 0:7fb6877b5d7c | 167 | */ |
miruga27 | 0:7fb6877b5d7c | 168 | extern DECLSPEC SDL_bool SDLCALL SDL_IsTextInputActive(void); |
miruga27 | 0:7fb6877b5d7c | 169 | |
miruga27 | 0:7fb6877b5d7c | 170 | /** |
miruga27 | 0:7fb6877b5d7c | 171 | * \brief Stop receiving any text input events. |
miruga27 | 0:7fb6877b5d7c | 172 | * This function will hide the on-screen keyboard if supported. |
miruga27 | 0:7fb6877b5d7c | 173 | * |
miruga27 | 0:7fb6877b5d7c | 174 | * \sa SDL_StartTextInput() |
miruga27 | 0:7fb6877b5d7c | 175 | * \sa SDL_HasScreenKeyboardSupport() |
miruga27 | 0:7fb6877b5d7c | 176 | */ |
miruga27 | 0:7fb6877b5d7c | 177 | extern DECLSPEC void SDLCALL SDL_StopTextInput(void); |
miruga27 | 0:7fb6877b5d7c | 178 | |
miruga27 | 0:7fb6877b5d7c | 179 | /** |
miruga27 | 0:7fb6877b5d7c | 180 | * \brief Set the rectangle used to type Unicode text inputs. |
miruga27 | 0:7fb6877b5d7c | 181 | * This is used as a hint for IME and on-screen keyboard placement. |
miruga27 | 0:7fb6877b5d7c | 182 | * |
miruga27 | 0:7fb6877b5d7c | 183 | * \sa SDL_StartTextInput() |
miruga27 | 0:7fb6877b5d7c | 184 | */ |
miruga27 | 0:7fb6877b5d7c | 185 | extern DECLSPEC void SDLCALL SDL_SetTextInputRect(SDL_Rect *rect); |
miruga27 | 0:7fb6877b5d7c | 186 | |
miruga27 | 0:7fb6877b5d7c | 187 | /** |
miruga27 | 0:7fb6877b5d7c | 188 | * \brief Returns whether the platform has some screen keyboard support. |
miruga27 | 0:7fb6877b5d7c | 189 | * |
miruga27 | 0:7fb6877b5d7c | 190 | * \return SDL_TRUE if some keyboard support is available else SDL_FALSE. |
miruga27 | 0:7fb6877b5d7c | 191 | * |
miruga27 | 0:7fb6877b5d7c | 192 | * \note Not all screen keyboard functions are supported on all platforms. |
miruga27 | 0:7fb6877b5d7c | 193 | * |
miruga27 | 0:7fb6877b5d7c | 194 | * \sa SDL_IsScreenKeyboardShown() |
miruga27 | 0:7fb6877b5d7c | 195 | */ |
miruga27 | 0:7fb6877b5d7c | 196 | extern DECLSPEC SDL_bool SDLCALL SDL_HasScreenKeyboardSupport(void); |
miruga27 | 0:7fb6877b5d7c | 197 | |
miruga27 | 0:7fb6877b5d7c | 198 | /** |
miruga27 | 0:7fb6877b5d7c | 199 | * \brief Returns whether the screen keyboard is shown for given window. |
miruga27 | 0:7fb6877b5d7c | 200 | * |
miruga27 | 0:7fb6877b5d7c | 201 | * \param window The window for which screen keyboard should be queried. |
miruga27 | 0:7fb6877b5d7c | 202 | * |
miruga27 | 0:7fb6877b5d7c | 203 | * \return SDL_TRUE if screen keyboard is shown else SDL_FALSE. |
miruga27 | 0:7fb6877b5d7c | 204 | * |
miruga27 | 0:7fb6877b5d7c | 205 | * \sa SDL_HasScreenKeyboardSupport() |
miruga27 | 0:7fb6877b5d7c | 206 | */ |
miruga27 | 0:7fb6877b5d7c | 207 | extern DECLSPEC SDL_bool SDLCALL SDL_IsScreenKeyboardShown(SDL_Window *window); |
miruga27 | 0:7fb6877b5d7c | 208 | |
miruga27 | 0:7fb6877b5d7c | 209 | /* Ends C function definitions when using C++ */ |
miruga27 | 0:7fb6877b5d7c | 210 | #ifdef __cplusplus |
miruga27 | 0:7fb6877b5d7c | 211 | } |
miruga27 | 0:7fb6877b5d7c | 212 | #endif |
miruga27 | 0:7fb6877b5d7c | 213 | #include "close_code.h" |
miruga27 | 0:7fb6877b5d7c | 214 | |
miruga27 | 0:7fb6877b5d7c | 215 | #endif /* _SDL_keyboard_h */ |
miruga27 | 0:7fb6877b5d7c | 216 | |
miruga27 | 0:7fb6877b5d7c | 217 | /* vi: set ts=4 sw=4 expandtab: */ |