Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

217 lines
6.3 KiB

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