sdlkeyboard.inc 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. //from "sdl_keyboard.h"
  2. {*
  3. * \file SDL_keyboard.h
  4. *
  5. * Include file for SDL keyboard event handling
  6. }
  7. type
  8. { SDL2-for-Pascal:
  9. - Is this type used/needed anywhere?
  10. - It doesn't seem to be part of sdl_keyboard.h
  11. - If not, should be commented out or deleted }
  12. PPKeyStateArr = ^PKeyStateArr;
  13. PKeyStateArr = ^TKeyStateArr;
  14. TKeyStateArr = array[0..65000] of cuint8;
  15. {*
  16. * \brief The SDL keysym structure, used in key events.
  17. *
  18. * \note If you are looking for translated character input, see the:: SDL_TEXTINPUT event.
  19. }
  20. PPSDL_Keysym = ^PSDL_Keysym;
  21. PSDL_Keysym = ^TSDL_Keysym;
  22. TSDL_Keysym = record
  23. scancode: TSDL_ScanCode; // SDL physical key code - see SDL_Scancode for details
  24. sym: TSDL_KeyCode; // SDL virtual key code - see SDL_Keycode for details
  25. mod_: cuint16; // current key modifiers
  26. unicode: cuint32; // (deprecated) use SDL_TextInputEvent instead
  27. end;
  28. { Function prototypes }
  29. {*
  30. * Query the window which currently has keyboard focus.
  31. *
  32. * \returns the window with keyboard focus.
  33. *
  34. * \since This function is available since SDL 2.0.0.
  35. }
  36. function SDL_GetKeyboardFocus: PSDL_Window; cdecl;
  37. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetKeyboardFocus' {$ENDIF} {$ENDIF};
  38. {*
  39. * Get a snapshot of the current state of the keyboard.
  40. *
  41. * The pointer returned is a pointer to an internal SDL array. It will be
  42. * valid for the whole lifetime of the application and should not be freed by
  43. * the caller.
  44. *
  45. * A array element with a value of 1 means that the key is pressed and a value
  46. * of 0 means that it is not. Indexes into this array are obtained by using
  47. * SDL_Scancode values.
  48. *
  49. * Use SDL_PumpEvents() to update the state array.
  50. *
  51. * This function gives you the current state after all events have been
  52. * processed, so if a key or button has been pressed and released before you
  53. * process events, then the pressed state will never show up in the
  54. * SDL_GetKeyboardState() calls.
  55. *
  56. * Note: This function doesn't take into account whether shift has been
  57. * pressed or not.
  58. *
  59. * \param numkeys if non-nil, receives the length of the returned array
  60. * \returns a pointer to an array of key states.
  61. *
  62. * \since This function is available since SDL 2.0.0.
  63. *
  64. * \sa SDL_PumpEvents
  65. * \sa SDL_ResetKeyboard
  66. }
  67. function SDL_GetKeyboardState(numkeys: pcint): pcuint8; cdecl;
  68. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetKeyboardState' {$ENDIF} {$ENDIF};
  69. {*
  70. * Clear the state of the keyboard
  71. *
  72. * This function will generate key up events for all pressed keys.
  73. *
  74. * \since This function is available since SDL 2.24.0.
  75. *
  76. * \sa SDL_GetKeyboardState
  77. }
  78. procedure SDL_ResetKeyboard; cdecl;
  79. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_ResetKeyboard' {$ENDIF} {$ENDIF};
  80. {*
  81. * Get the current key modifier state for the keyboard.
  82. *
  83. * \returns an OR'd combination of the modifier keys for the keyboard. See
  84. * SDL_Keymod for details.
  85. *
  86. * \since This function is available since SDL 2.0.0.
  87. *
  88. * \sa SDL_GetKeyboardState
  89. * \sa SDL_SetModState
  90. }
  91. function SDL_GetModState: TSDL_Keymod; cdecl;
  92. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetModState' {$ENDIF} {$ENDIF};
  93. {*
  94. * Set the current key modifier state for the keyboard.
  95. *
  96. * The inverse of SDL_GetModState(), SDL_SetModState() allows you to impose
  97. * modifier key states on your application. Simply pass your desired modifier
  98. * states into `modstate`. This value may be a bitwise, OR'd combination of
  99. * SDL_Keymod values.
  100. *
  101. * This does not change the keyboard state, only the key modifier flags that
  102. * SDL reports.
  103. *
  104. * \param modstate the desired SDL_Keymod for the keyboard
  105. *
  106. * \since This function is available since SDL 2.0.0.
  107. *
  108. * \sa SDL_GetModState
  109. }
  110. procedure SDL_SetModState(modstate: TSDL_Keymod); cdecl;
  111. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SetModState' {$ENDIF} {$ENDIF};
  112. {*
  113. * Get the key code corresponding to the given scancode according to the
  114. * current keyboard layout.
  115. *
  116. * See SDL_Keycode for details.
  117. *
  118. * \param scancode the desired SDL_Scancode to query
  119. * \returns the SDL_Keycode that corresponds to the given SDL_Scancode.
  120. *
  121. * \since This function is available since SDL 2.0.0.
  122. *
  123. * \sa SDL_GetKeyName
  124. * \sa SDL_GetScancodeFromKey
  125. }
  126. function SDL_GetKeyFromScancode(scancode: TSDL_Scancode): TSDL_Keycode; cdecl;
  127. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetKeyFromScancode' {$ENDIF} {$ENDIF};
  128. {*
  129. * Get the scancode corresponding to the given key code according to the
  130. * current keyboard layout.
  131. *
  132. * See SDL_Scancode for details.
  133. *
  134. * \param key the desired SDL_Keycode to query
  135. * \returns the SDL_Scancode that corresponds to the given SDL_Keycode.
  136. *
  137. * \since This function is available since SDL 2.0.0.
  138. *
  139. * \sa SDL_GetKeyFromScancode
  140. * \sa SDL_GetScancodeName
  141. }
  142. function SDL_GetScancodeFromKey(key: TSDL_Keycode): TSDL_Scancode; cdecl;
  143. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetScancodeFromKey' {$ENDIF} {$ENDIF};
  144. {*
  145. * Get a human-readable name for a scancode.
  146. *
  147. * See SDL_Scancode for details.
  148. *
  149. * **Warning**: The returned name is by design not stable across platforms,
  150. * e.g. the name for `SDL_SCANCODE_LGUI` is "Left GUI" under Linux but "Left
  151. * Windows" under Microsoft Windows, and some scancodes like
  152. * `SDL_SCANCODE_NONUSBACKSLASH` don't have any name at all. There are even
  153. * scancodes that share names, e.g. `SDL_SCANCODE_RETURN` and
  154. * `SDL_SCANCODE_RETURN2` (both called "Return"). This function is therefore
  155. * unsuitable for creating a stable cross-platform two-way mapping between
  156. * strings and scancodes.
  157. *
  158. * \param scancode the desired SDL_Scancode to query
  159. * \returns a pointer to the name for the scancode. If the scancode doesn't
  160. * have a name this function returns an empty string ("").
  161. *
  162. * \since This function is available since SDL 2.0.0.
  163. *
  164. * \sa SDL_GetScancodeFromKey
  165. * \sa SDL_GetScancodeFromName
  166. }
  167. function SDL_GetScancodeName(scancode: TSDL_Scancode): PAnsiChar; cdecl;
  168. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetScancodeName' {$ENDIF} {$ENDIF};
  169. {*
  170. * Get a scancode from a human-readable name.
  171. *
  172. * \param name the human-readable scancode name
  173. * \returns the SDL_Scancode, or `SDL_SCANCODE_UNKNOWN` if the name wasn't
  174. * recognized; call SDL_GetError() for more information.
  175. *
  176. * \since This function is available since SDL 2.0.0.
  177. *
  178. * \sa SDL_GetKeyFromName
  179. * \sa SDL_GetScancodeFromKey
  180. * \sa SDL_GetScancodeName
  181. }
  182. function SDL_GetScancodeFromName(name: PAnsiChar): TSDL_Scancode; cdecl;
  183. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetScancodeFromName' {$ENDIF} {$ENDIF};
  184. {*
  185. * Get a human-readable name for a key.
  186. *
  187. * See SDL_Scancode and SDL_Keycode for details.
  188. *
  189. * \param key the desired SDL_Keycode to query
  190. * \returns a pointer to a UTF-8 string that stays valid at least until the
  191. * next call to this function. If you need it around any longer, you
  192. * must copy it. If the key doesn't have a name, this function
  193. * returns an empty string ("").
  194. *
  195. * \since This function is available since SDL 2.0.0.
  196. *
  197. * \sa SDL_GetKeyFromName
  198. * \sa SDL_GetKeyFromScancode
  199. * \sa SDL_GetScancodeFromKey
  200. }
  201. function SDL_GetKeyName(key: TSDL_Keycode): PAnsiChar; cdecl;
  202. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetKeyName' {$ENDIF} {$ENDIF};
  203. {*
  204. * Get a key code from a human-readable name.
  205. *
  206. * \param name the human-readable key name
  207. * \returns key code, or `SDLK_UNKNOWN` if the name wasn't recognized; call
  208. * SDL_GetError() for more information.
  209. *
  210. * \since This function is available since SDL 2.0.0.
  211. *
  212. * \sa SDL_GetKeyFromScancode
  213. * \sa SDL_GetKeyName
  214. * \sa SDL_GetScancodeFromName
  215. }
  216. function SDL_GetKeyFromName(name: PAnsiChar): TSDL_Keycode; cdecl;
  217. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetKeyFromName' {$ENDIF} {$ENDIF};
  218. {*
  219. * Start accepting Unicode text input events.
  220. *
  221. * This function will start accepting Unicode text input events in the focused
  222. * SDL window, and start emitting SDL_TextInputEvent (SDL_TEXTINPUT) and
  223. * SDL_TextEditingEvent (SDL_TEXTEDITING) events. Please use this function in
  224. * pair with SDL_StopTextInput().
  225. *
  226. * On some platforms using this function activates the screen keyboard.
  227. *
  228. * \since This function is available since SDL 2.0.0.
  229. *
  230. * \sa SDL_SetTextInputRect
  231. * \sa SDL_StopTextInput
  232. }
  233. procedure SDL_StartTextInput; cdecl;
  234. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_StartTextInput' {$ENDIF} {$ENDIF};
  235. {*
  236. * Check whether or not Unicode text input events are enabled.
  237. *
  238. * \returns SDL_TRUE if text input events are enabled else SDL_FALSE.
  239. *
  240. * \since This function is available since SDL 2.0.0.
  241. *
  242. * \sa SDL_StartTextInput
  243. }
  244. function SDL_IsTextInputActive: TSDL_bool; cdecl;
  245. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_IsTextInputActive' {$ENDIF} {$ENDIF};
  246. {*
  247. * Stop receiving any text input events.
  248. *
  249. * \since This function is available since SDL 2.0.0.
  250. *
  251. * \sa SDL_StartTextInput
  252. }
  253. procedure SDL_StopTextInput; cdecl;
  254. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_StopTextInput' {$ENDIF} {$ENDIF};
  255. {*
  256. * Dismiss the composition window/IME without disabling the subsystem.
  257. *
  258. * \since This function is available since SDL 2.0.22.
  259. *
  260. * \sa SDL_StartTextInput
  261. * \sa SDL_StopTextInput
  262. }
  263. procedure SDL_ClearComposition; cdecl;
  264. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_ClearComposition' {$ENDIF} {$ENDIF};
  265. {*
  266. * Returns if an IME Composite or Candidate window is currently shown.
  267. *
  268. * \since This function is available since SDL 2.0.22.
  269. }
  270. function SDL_IsTextInputShown: TSDL_bool; cdecl;
  271. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_IsTextInputShown' {$ENDIF} {$ENDIF};
  272. {*
  273. * Set the rectangle used to type Unicode text inputs.
  274. *
  275. * To start text input in a given location, this function is intended to be
  276. * called before SDL_StartTextInput, although some platforms support moving
  277. * the rectangle even while text input (and a composition) is active.
  278. *
  279. * Note: If you want to use the system native IME window, try setting hint
  280. * **SDL_HINT_IME_SHOW_UI** to **1**, otherwise this function won't give you
  281. * any feedback.
  282. *
  283. * \param rect the SDL_Rect structure representing the rectangle to receive
  284. * text (ignored if nil)
  285. *
  286. * \since This function is available since SDL 2.0.0.
  287. *
  288. * \sa SDL_StartTextInput
  289. }
  290. procedure SDL_SetTextInputRect(rect: PSDL_Rect); cdecl;
  291. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SetTextInputRect' {$ENDIF} {$ENDIF};
  292. {*
  293. * Check whether the platform has screen keyboard support.
  294. *
  295. * \returns SDL_TRUE if the platform has some screen keyboard support or
  296. * SDL_FALSE if not.
  297. *
  298. * \since This function is available since SDL 2.0.0.
  299. *
  300. * \sa SDL_StartTextInput
  301. * \sa SDL_IsScreenKeyboardShown
  302. }
  303. function SDL_HasScreenKeyboardSupport: TSDL_bool; cdecl;
  304. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HasScreenKeyboardSupport' {$ENDIF} {$ENDIF};
  305. {*
  306. * Check whether the screen keyboard is shown for given window.
  307. *
  308. * \param window the window for which screen keyboard should be queried
  309. * \returns SDL_TRUE if screen keyboard is shown or SDL_FALSE if not.
  310. *
  311. * \since This function is available since SDL 2.0.0.
  312. *
  313. * \sa SDL_HasScreenKeyboardSupport
  314. }
  315. function SDL_IsScreenKeyboardShown(window: PSDL_Window): TSDL_bool; cdecl;
  316. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_IsScreenKeyboardShown' {$ENDIF} {$ENDIF};