2
0

SDL_keyboard.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*
  2. SDL - Simple DirectMedia Layer
  3. Copyright (C) 1997-2010 Sam Lantinga
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with this library; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  15. Sam Lantinga
  16. [email protected]
  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_keysym.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. /* *INDENT-OFF* */
  33. extern "C" {
  34. /* *INDENT-ON* */
  35. #endif
  36. /**
  37. * \brief The SDL keysym structure, used in key events.
  38. */
  39. typedef struct SDL_keysym
  40. {
  41. SDL_scancode scancode; /**< SDL physical key code - see ::SDL_scancode for details */
  42. SDLKey sym; /**< SDL virtual key code - see ::SDLKey for details */
  43. Uint16 mod; /**< current key modifiers */
  44. Uint32 unicode; /**< \deprecated use SDL_TextInputEvent instead */
  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. * Uint8 *state = SDL_GetKeyboardState(NULL);
  61. * if ( state[SDL_SCANCODE_RETURN] ) {
  62. * printf("<RETURN> is pressed.\n");
  63. * }
  64. * \endcode
  65. */
  66. extern DECLSPEC Uint8 *SDLCALL SDL_GetKeyboardState(int *numkeys);
  67. /**
  68. * \brief Get the current key modifier state for the keyboard.
  69. */
  70. extern DECLSPEC SDLMod 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(SDLMod modstate);
  77. /**
  78. * \brief Get the key code corresponding to the given scancode according
  79. * to the current keyboard layout.
  80. *
  81. * See ::SDLKey for details.
  82. *
  83. * \sa SDL_GetKeyName()
  84. */
  85. extern DECLSPEC SDLKey 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(SDLKey key);
  95. /**
  96. * \brief Get a human-readable name for a scancode.
  97. *
  98. * \return A pointer to a UTF-8 string that stays valid at least until the next
  99. * call to this function. If you need it around any longer, you must
  100. * copy it. If the scancode doesn't have a name, this function returns
  101. * an empty string ("").
  102. *
  103. * \sa SDL_scancode
  104. */
  105. extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_scancode
  106. scancode);
  107. /**
  108. * \brief Get a human-readable name for a key.
  109. *
  110. * \return A pointer to a UTF-8 string that stays valid at least until the next
  111. * call to this function. If you need it around any longer, you must
  112. * copy it. If the key doesn't have a name, this function returns an
  113. * empty string ("").
  114. *
  115. * \sa SDLKey
  116. */
  117. extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDLKey key);
  118. /**
  119. * \brief Start accepting Unicode text input events.
  120. *
  121. * \sa SDL_StopTextInput()
  122. * \sa SDL_SetTextInputRect()
  123. */
  124. extern DECLSPEC void SDLCALL SDL_StartTextInput(void);
  125. /**
  126. * \brief Stop receiving any text input events.
  127. *
  128. * \sa SDL_StartTextInput()
  129. */
  130. extern DECLSPEC void SDLCALL SDL_StopTextInput(void);
  131. /**
  132. * \brief Set the rectangle used to type Unicode text inputs.
  133. *
  134. * \sa SDL_StartTextInput()
  135. */
  136. extern DECLSPEC void SDLCALL SDL_SetTextInputRect(SDL_Rect *rect);
  137. /* Ends C function definitions when using C++ */
  138. #ifdef __cplusplus
  139. /* *INDENT-OFF* */
  140. }
  141. /* *INDENT-ON* */
  142. #endif
  143. #include "close_code.h"
  144. #endif /* _SDL_keyboard_h */
  145. /* vi: set ts=4 sw=4 expandtab: */