SDL standard library

Dependents:   H261_encoder

Committer:
miruga27
Date:
Wed Sep 07 18:46:53 2016 +0000
Revision:
0:dda4f4550403
7/09/2016;

Who changed what in which revision?

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