SDL_keyboard.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2025 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. * # CategoryKeyboard
  20. *
  21. * SDL keyboard management.
  22. *
  23. * Please refer to the Best Keyboard Practices document for details on how
  24. * best to accept keyboard input in various types of programs:
  25. *
  26. * https://wiki.libsdl.org/SDL3/BestKeyboardPractices
  27. */
  28. #ifndef SDL_keyboard_h_
  29. #define SDL_keyboard_h_
  30. #include <SDL3/SDL_stdinc.h>
  31. #include <SDL3/SDL_error.h>
  32. #include <SDL3/SDL_keycode.h>
  33. #include <SDL3/SDL_properties.h>
  34. #include <SDL3/SDL_rect.h>
  35. #include <SDL3/SDL_scancode.h>
  36. #include <SDL3/SDL_video.h>
  37. #include <SDL3/SDL_begin_code.h>
  38. /* Set up for C function definitions, even when using C++ */
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42. /**
  43. * This is a unique ID for a keyboard for the time it is connected to the
  44. * system, and is never reused for the lifetime of the application.
  45. *
  46. * If the keyboard is disconnected and reconnected, it will get a new ID.
  47. *
  48. * The value 0 is an invalid ID.
  49. *
  50. * \since This datatype is available since SDL 3.1.3.
  51. */
  52. typedef Uint32 SDL_KeyboardID;
  53. /* Function prototypes */
  54. /**
  55. * Return whether a keyboard is currently connected.
  56. *
  57. * \returns true if a keyboard is connected, false otherwise.
  58. *
  59. * \threadsafety This function should only be called on the main thread.
  60. *
  61. * \since This function is available since SDL 3.1.3.
  62. *
  63. * \sa SDL_GetKeyboards
  64. */
  65. extern SDL_DECLSPEC bool SDLCALL SDL_HasKeyboard(void);
  66. /**
  67. * Get a list of currently connected keyboards.
  68. *
  69. * Note that this will include any device or virtual driver that includes
  70. * keyboard functionality, including some mice, KVM switches, motherboard
  71. * power buttons, etc. You should wait for input from a device before you
  72. * consider it actively in use.
  73. *
  74. * \param count a pointer filled in with the number of keyboards returned, may
  75. * be NULL.
  76. * \returns a 0 terminated array of keyboards instance IDs or NULL on failure;
  77. * call SDL_GetError() for more information. This should be freed
  78. * with SDL_free() when it is no longer needed.
  79. *
  80. * \threadsafety This function should only be called on the main thread.
  81. *
  82. * \since This function is available since SDL 3.1.3.
  83. *
  84. * \sa SDL_GetKeyboardNameForID
  85. * \sa SDL_HasKeyboard
  86. */
  87. extern SDL_DECLSPEC SDL_KeyboardID * SDLCALL SDL_GetKeyboards(int *count);
  88. /**
  89. * Get the name of a keyboard.
  90. *
  91. * This function returns "" if the keyboard doesn't have a name.
  92. *
  93. * \param instance_id the keyboard instance ID.
  94. * \returns the name of the selected keyboard or NULL on failure; call
  95. * SDL_GetError() for more information.
  96. *
  97. * \threadsafety This function should only be called on the main thread.
  98. *
  99. * \since This function is available since SDL 3.1.3.
  100. *
  101. * \sa SDL_GetKeyboards
  102. */
  103. extern SDL_DECLSPEC const char * SDLCALL SDL_GetKeyboardNameForID(SDL_KeyboardID instance_id);
  104. /**
  105. * Query the window which currently has keyboard focus.
  106. *
  107. * \returns the window with keyboard focus.
  108. *
  109. * \threadsafety This function should only be called on the main thread.
  110. *
  111. * \since This function is available since SDL 3.1.3.
  112. */
  113. extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void);
  114. /**
  115. * Get a snapshot of the current state of the keyboard.
  116. *
  117. * The pointer returned is a pointer to an internal SDL array. It will be
  118. * valid for the whole lifetime of the application and should not be freed by
  119. * the caller.
  120. *
  121. * A array element with a value of true means that the key is pressed and a
  122. * value of false means that it is not. Indexes into this array are obtained
  123. * by using SDL_Scancode values.
  124. *
  125. * Use SDL_PumpEvents() to update the state array.
  126. *
  127. * This function gives you the current state after all events have been
  128. * processed, so if a key or button has been pressed and released before you
  129. * process events, then the pressed state will never show up in the
  130. * SDL_GetKeyboardState() calls.
  131. *
  132. * Note: This function doesn't take into account whether shift has been
  133. * pressed or not.
  134. *
  135. * \param numkeys if non-NULL, receives the length of the returned array.
  136. * \returns a pointer to an array of key states.
  137. *
  138. * \threadsafety It is safe to call this function from any thread.
  139. *
  140. * \since This function is available since SDL 3.1.3.
  141. *
  142. * \sa SDL_PumpEvents
  143. * \sa SDL_ResetKeyboard
  144. */
  145. extern SDL_DECLSPEC const bool * SDLCALL SDL_GetKeyboardState(int *numkeys);
  146. /**
  147. * Clear the state of the keyboard.
  148. *
  149. * This function will generate key up events for all pressed keys.
  150. *
  151. * \threadsafety This function should only be called on the main thread.
  152. *
  153. * \since This function is available since SDL 3.1.3.
  154. *
  155. * \sa SDL_GetKeyboardState
  156. */
  157. extern SDL_DECLSPEC void SDLCALL SDL_ResetKeyboard(void);
  158. /**
  159. * Get the current key modifier state for the keyboard.
  160. *
  161. * \returns an OR'd combination of the modifier keys for the keyboard. See
  162. * SDL_Keymod for details.
  163. *
  164. * \threadsafety It is safe to call this function from any thread.
  165. *
  166. * \since This function is available since SDL 3.1.3.
  167. *
  168. * \sa SDL_GetKeyboardState
  169. * \sa SDL_SetModState
  170. */
  171. extern SDL_DECLSPEC SDL_Keymod SDLCALL SDL_GetModState(void);
  172. /**
  173. * Set the current key modifier state for the keyboard.
  174. *
  175. * The inverse of SDL_GetModState(), SDL_SetModState() allows you to impose
  176. * modifier key states on your application. Simply pass your desired modifier
  177. * states into `modstate`. This value may be a bitwise, OR'd combination of
  178. * SDL_Keymod values.
  179. *
  180. * This does not change the keyboard state, only the key modifier flags that
  181. * SDL reports.
  182. *
  183. * \param modstate the desired SDL_Keymod for the keyboard.
  184. *
  185. * \threadsafety It is safe to call this function from any thread.
  186. *
  187. * \since This function is available since SDL 3.1.3.
  188. *
  189. * \sa SDL_GetModState
  190. */
  191. extern SDL_DECLSPEC void SDLCALL SDL_SetModState(SDL_Keymod modstate);
  192. /**
  193. * Get the key code corresponding to the given scancode according to the
  194. * current keyboard layout.
  195. *
  196. * If you want to get the keycode as it would be delivered in key events,
  197. * including options specified in SDL_HINT_KEYCODE_OPTIONS, then you should
  198. * pass `key_event` as true. Otherwise this function simply translates the
  199. * scancode based on the given modifier state.
  200. *
  201. * \param scancode the desired SDL_Scancode to query.
  202. * \param modstate the modifier state to use when translating the scancode to
  203. * a keycode.
  204. * \param key_event true if the keycode will be used in key events.
  205. * \returns the SDL_Keycode that corresponds to the given SDL_Scancode.
  206. *
  207. * \threadsafety This function is not thread safe.
  208. *
  209. * \since This function is available since SDL 3.1.3.
  210. *
  211. * \sa SDL_GetKeyName
  212. * \sa SDL_GetScancodeFromKey
  213. */
  214. extern SDL_DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromScancode(SDL_Scancode scancode, SDL_Keymod modstate, bool key_event);
  215. /**
  216. * Get the scancode corresponding to the given key code according to the
  217. * current keyboard layout.
  218. *
  219. * Note that there may be multiple scancode+modifier states that can generate
  220. * this keycode, this will just return the first one found.
  221. *
  222. * \param key the desired SDL_Keycode to query.
  223. * \param modstate a pointer to the modifier state that would be used when the
  224. * scancode generates this key, may be NULL.
  225. * \returns the SDL_Scancode that corresponds to the given SDL_Keycode.
  226. *
  227. * \threadsafety This function is not thread safe.
  228. *
  229. * \since This function is available since SDL 3.1.3.
  230. *
  231. * \sa SDL_GetKeyFromScancode
  232. * \sa SDL_GetScancodeName
  233. */
  234. extern SDL_DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromKey(SDL_Keycode key, SDL_Keymod *modstate);
  235. /**
  236. * Set a human-readable name for a scancode.
  237. *
  238. * \param scancode the desired SDL_Scancode.
  239. * \param name the name to use for the scancode, encoded as UTF-8. The string
  240. * is not copied, so the pointer given to this function must stay
  241. * valid while SDL is being used.
  242. * \returns true on success or false on failure; call SDL_GetError() for more
  243. * information.
  244. *
  245. * \threadsafety This function is not thread safe.
  246. *
  247. * \since This function is available since SDL 3.1.3.
  248. *
  249. * \sa SDL_GetScancodeName
  250. */
  251. extern SDL_DECLSPEC bool SDLCALL SDL_SetScancodeName(SDL_Scancode scancode, const char *name);
  252. /**
  253. * Get a human-readable name for a scancode.
  254. *
  255. * **Warning**: The returned name is by design not stable across platforms,
  256. * e.g. the name for `SDL_SCANCODE_LGUI` is "Left GUI" under Linux but "Left
  257. * Windows" under Microsoft Windows, and some scancodes like
  258. * `SDL_SCANCODE_NONUSBACKSLASH` don't have any name at all. There are even
  259. * scancodes that share names, e.g. `SDL_SCANCODE_RETURN` and
  260. * `SDL_SCANCODE_RETURN2` (both called "Return"). This function is therefore
  261. * unsuitable for creating a stable cross-platform two-way mapping between
  262. * strings and scancodes.
  263. *
  264. * \param scancode the desired SDL_Scancode to query.
  265. * \returns a pointer to the name for the scancode. If the scancode doesn't
  266. * have a name this function returns an empty string ("").
  267. *
  268. * \threadsafety This function is not thread safe.
  269. *
  270. * \since This function is available since SDL 3.1.3.
  271. *
  272. * \sa SDL_GetScancodeFromKey
  273. * \sa SDL_GetScancodeFromName
  274. * \sa SDL_SetScancodeName
  275. */
  276. extern SDL_DECLSPEC const char * SDLCALL SDL_GetScancodeName(SDL_Scancode scancode);
  277. /**
  278. * Get a scancode from a human-readable name.
  279. *
  280. * \param name the human-readable scancode name.
  281. * \returns the SDL_Scancode, or `SDL_SCANCODE_UNKNOWN` if the name wasn't
  282. * recognized; call SDL_GetError() for more information.
  283. *
  284. * \threadsafety This function is not thread safe.
  285. *
  286. * \since This function is available since SDL 3.1.3.
  287. *
  288. * \sa SDL_GetKeyFromName
  289. * \sa SDL_GetScancodeFromKey
  290. * \sa SDL_GetScancodeName
  291. */
  292. extern SDL_DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromName(const char *name);
  293. /**
  294. * Get a human-readable name for a key.
  295. *
  296. * If the key doesn't have a name, this function returns an empty string ("").
  297. *
  298. * Letters will be presented in their uppercase form, if applicable.
  299. *
  300. * \param key the desired SDL_Keycode to query.
  301. * \returns a UTF-8 encoded string of the key name.
  302. *
  303. * \threadsafety This function is not thread safe.
  304. *
  305. * \since This function is available since SDL 3.1.3.
  306. *
  307. * \sa SDL_GetKeyFromName
  308. * \sa SDL_GetKeyFromScancode
  309. * \sa SDL_GetScancodeFromKey
  310. */
  311. extern SDL_DECLSPEC const char * SDLCALL SDL_GetKeyName(SDL_Keycode key);
  312. /**
  313. * Get a key code from a human-readable name.
  314. *
  315. * \param name the human-readable key name.
  316. * \returns key code, or `SDLK_UNKNOWN` if the name wasn't recognized; call
  317. * SDL_GetError() for more information.
  318. *
  319. * \threadsafety This function is not thread safe.
  320. *
  321. * \since This function is available since SDL 3.1.3.
  322. *
  323. * \sa SDL_GetKeyFromScancode
  324. * \sa SDL_GetKeyName
  325. * \sa SDL_GetScancodeFromName
  326. */
  327. extern SDL_DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromName(const char *name);
  328. /**
  329. * Start accepting Unicode text input events in a window.
  330. *
  331. * This function will enable text input (SDL_EVENT_TEXT_INPUT and
  332. * SDL_EVENT_TEXT_EDITING events) in the specified window. Please use this
  333. * function paired with SDL_StopTextInput().
  334. *
  335. * Text input events are not received by default.
  336. *
  337. * On some platforms using this function shows the screen keyboard and/or
  338. * activates an IME, which can prevent some key press events from being passed
  339. * through.
  340. *
  341. * \param window the window to enable text input.
  342. * \returns true on success or false on failure; call SDL_GetError() for more
  343. * information.
  344. *
  345. * \threadsafety This function should only be called on the main thread.
  346. *
  347. * \since This function is available since SDL 3.1.3.
  348. *
  349. * \sa SDL_SetTextInputArea
  350. * \sa SDL_StartTextInputWithProperties
  351. * \sa SDL_StopTextInput
  352. * \sa SDL_TextInputActive
  353. */
  354. extern SDL_DECLSPEC bool SDLCALL SDL_StartTextInput(SDL_Window *window);
  355. /**
  356. * Text input type.
  357. *
  358. * These are the valid values for SDL_PROP_TEXTINPUT_TYPE_NUMBER. Not every
  359. * value is valid on every platform, but where a value isn't supported, a
  360. * reasonable fallback will be used.
  361. *
  362. * \since This enum is available since SDL 3.1.3.
  363. *
  364. * \sa SDL_StartTextInputWithProperties
  365. */
  366. typedef enum SDL_TextInputType
  367. {
  368. SDL_TEXTINPUT_TYPE_TEXT, /**< The input is text */
  369. SDL_TEXTINPUT_TYPE_TEXT_NAME, /**< The input is a person's name */
  370. SDL_TEXTINPUT_TYPE_TEXT_EMAIL, /**< The input is an e-mail address */
  371. SDL_TEXTINPUT_TYPE_TEXT_USERNAME, /**< The input is a username */
  372. SDL_TEXTINPUT_TYPE_TEXT_PASSWORD_HIDDEN, /**< The input is a secure password that is hidden */
  373. SDL_TEXTINPUT_TYPE_TEXT_PASSWORD_VISIBLE, /**< The input is a secure password that is visible */
  374. SDL_TEXTINPUT_TYPE_NUMBER, /**< The input is a number */
  375. SDL_TEXTINPUT_TYPE_NUMBER_PASSWORD_HIDDEN, /**< The input is a secure PIN that is hidden */
  376. SDL_TEXTINPUT_TYPE_NUMBER_PASSWORD_VISIBLE /**< The input is a secure PIN that is visible */
  377. } SDL_TextInputType;
  378. /**
  379. * Auto capitalization type.
  380. *
  381. * These are the valid values for SDL_PROP_TEXTINPUT_CAPITALIZATION_NUMBER.
  382. * Not every value is valid on every platform, but where a value isn't
  383. * supported, a reasonable fallback will be used.
  384. *
  385. * \since This enum is available since SDL 3.1.3.
  386. *
  387. * \sa SDL_StartTextInputWithProperties
  388. */
  389. typedef enum SDL_Capitalization
  390. {
  391. SDL_CAPITALIZE_NONE, /**< No auto-capitalization will be done */
  392. SDL_CAPITALIZE_SENTENCES, /**< The first letter of sentences will be capitalized */
  393. SDL_CAPITALIZE_WORDS, /**< The first letter of words will be capitalized */
  394. SDL_CAPITALIZE_LETTERS /**< All letters will be capitalized */
  395. } SDL_Capitalization;
  396. /**
  397. * Start accepting Unicode text input events in a window, with properties
  398. * describing the input.
  399. *
  400. * This function will enable text input (SDL_EVENT_TEXT_INPUT and
  401. * SDL_EVENT_TEXT_EDITING events) in the specified window. Please use this
  402. * function paired with SDL_StopTextInput().
  403. *
  404. * Text input events are not received by default.
  405. *
  406. * On some platforms using this function shows the screen keyboard and/or
  407. * activates an IME, which can prevent some key press events from being passed
  408. * through.
  409. *
  410. * These are the supported properties:
  411. *
  412. * - `SDL_PROP_TEXTINPUT_TYPE_NUMBER` - an SDL_TextInputType value that
  413. * describes text being input, defaults to SDL_TEXTINPUT_TYPE_TEXT.
  414. * - `SDL_PROP_TEXTINPUT_CAPITALIZATION_NUMBER` - an SDL_Capitalization value
  415. * that describes how text should be capitalized, defaults to
  416. * SDL_CAPITALIZE_SENTENCES for normal text entry, SDL_CAPITALIZE_WORDS for
  417. * SDL_TEXTINPUT_TYPE_TEXT_NAME, and SDL_CAPITALIZE_NONE for e-mail
  418. * addresses, usernames, and passwords.
  419. * - `SDL_PROP_TEXTINPUT_AUTOCORRECT_BOOLEAN` - true to enable auto completion
  420. * and auto correction, defaults to true.
  421. * - `SDL_PROP_TEXTINPUT_MULTILINE_BOOLEAN` - true if multiple lines of text
  422. * are allowed. This defaults to true if SDL_HINT_RETURN_KEY_HIDES_IME is
  423. * "0" or is not set, and defaults to false if SDL_HINT_RETURN_KEY_HIDES_IME
  424. * is "1".
  425. *
  426. * On Android you can directly specify the input type:
  427. *
  428. * - `SDL_PROP_TEXTINPUT_ANDROID_INPUTTYPE_NUMBER` - the text input type to
  429. * use, overriding other properties. This is documented at
  430. * https://developer.android.com/reference/android/text/InputType
  431. *
  432. * \param window the window to enable text input.
  433. * \param props the properties to use.
  434. * \returns true on success or false on failure; call SDL_GetError() for more
  435. * information.
  436. *
  437. * \threadsafety This function should only be called on the main thread.
  438. *
  439. * \since This function is available since SDL 3.1.3.
  440. *
  441. * \sa SDL_SetTextInputArea
  442. * \sa SDL_StartTextInput
  443. * \sa SDL_StopTextInput
  444. * \sa SDL_TextInputActive
  445. */
  446. extern SDL_DECLSPEC bool SDLCALL SDL_StartTextInputWithProperties(SDL_Window *window, SDL_PropertiesID props);
  447. #define SDL_PROP_TEXTINPUT_TYPE_NUMBER "SDL.textinput.type"
  448. #define SDL_PROP_TEXTINPUT_CAPITALIZATION_NUMBER "SDL.textinput.capitalization"
  449. #define SDL_PROP_TEXTINPUT_AUTOCORRECT_BOOLEAN "SDL.textinput.autocorrect"
  450. #define SDL_PROP_TEXTINPUT_MULTILINE_BOOLEAN "SDL.textinput.multiline"
  451. #define SDL_PROP_TEXTINPUT_ANDROID_INPUTTYPE_NUMBER "SDL.textinput.android.inputtype"
  452. /**
  453. * Check whether or not Unicode text input events are enabled for a window.
  454. *
  455. * \param window the window to check.
  456. * \returns true if text input events are enabled else false.
  457. *
  458. * \threadsafety This function should only be called on the main thread.
  459. *
  460. * \since This function is available since SDL 3.1.3.
  461. *
  462. * \sa SDL_StartTextInput
  463. */
  464. extern SDL_DECLSPEC bool SDLCALL SDL_TextInputActive(SDL_Window *window);
  465. /**
  466. * Stop receiving any text input events in a window.
  467. *
  468. * If SDL_StartTextInput() showed the screen keyboard, this function will hide
  469. * it.
  470. *
  471. * \param window the window to disable text input.
  472. * \returns true on success or false on failure; call SDL_GetError() for more
  473. * information.
  474. *
  475. * \threadsafety This function should only be called on the main thread.
  476. *
  477. * \since This function is available since SDL 3.1.3.
  478. *
  479. * \sa SDL_StartTextInput
  480. */
  481. extern SDL_DECLSPEC bool SDLCALL SDL_StopTextInput(SDL_Window *window);
  482. /**
  483. * Dismiss the composition window/IME without disabling the subsystem.
  484. *
  485. * \param window the window to affect.
  486. * \returns true on success or false on failure; call SDL_GetError() for more
  487. * information.
  488. *
  489. * \threadsafety This function should only be called on the main thread.
  490. *
  491. * \since This function is available since SDL 3.1.3.
  492. *
  493. * \sa SDL_StartTextInput
  494. * \sa SDL_StopTextInput
  495. */
  496. extern SDL_DECLSPEC bool SDLCALL SDL_ClearComposition(SDL_Window *window);
  497. /**
  498. * Set the area used to type Unicode text input.
  499. *
  500. * Native input methods may place a window with word suggestions near the
  501. * cursor, without covering the text being entered.
  502. *
  503. * \param window the window for which to set the text input area.
  504. * \param rect the SDL_Rect representing the text input area, in window
  505. * coordinates, or NULL to clear it.
  506. * \param cursor the offset of the current cursor location relative to
  507. * `rect->x`, in window coordinates.
  508. * \returns true on success or false on failure; call SDL_GetError() for more
  509. * information.
  510. *
  511. * \threadsafety This function should only be called on the main thread.
  512. *
  513. * \since This function is available since SDL 3.1.3.
  514. *
  515. * \sa SDL_GetTextInputArea
  516. * \sa SDL_StartTextInput
  517. */
  518. extern SDL_DECLSPEC bool SDLCALL SDL_SetTextInputArea(SDL_Window *window, const SDL_Rect *rect, int cursor);
  519. /**
  520. * Get the area used to type Unicode text input.
  521. *
  522. * This returns the values previously set by SDL_SetTextInputArea().
  523. *
  524. * \param window the window for which to query the text input area.
  525. * \param rect a pointer to an SDL_Rect filled in with the text input area,
  526. * may be NULL.
  527. * \param cursor a pointer to the offset of the current cursor location
  528. * relative to `rect->x`, may be NULL.
  529. * \returns true on success or false on failure; call SDL_GetError() for more
  530. * information.
  531. *
  532. * \threadsafety This function should only be called on the main thread.
  533. *
  534. * \since This function is available since SDL 3.1.3.
  535. *
  536. * \sa SDL_SetTextInputArea
  537. */
  538. extern SDL_DECLSPEC bool SDLCALL SDL_GetTextInputArea(SDL_Window *window, SDL_Rect *rect, int *cursor);
  539. /**
  540. * Check whether the platform has screen keyboard support.
  541. *
  542. * \returns true if the platform has some screen keyboard support or false if
  543. * not.
  544. *
  545. * \threadsafety This function should only be called on the main thread.
  546. *
  547. * \since This function is available since SDL 3.1.3.
  548. *
  549. * \sa SDL_StartTextInput
  550. * \sa SDL_ScreenKeyboardShown
  551. */
  552. extern SDL_DECLSPEC bool SDLCALL SDL_HasScreenKeyboardSupport(void);
  553. /**
  554. * Check whether the screen keyboard is shown for given window.
  555. *
  556. * \param window the window for which screen keyboard should be queried.
  557. * \returns true if screen keyboard is shown or false if not.
  558. *
  559. * \threadsafety This function should only be called on the main thread.
  560. *
  561. * \since This function is available since SDL 3.1.3.
  562. *
  563. * \sa SDL_HasScreenKeyboardSupport
  564. */
  565. extern SDL_DECLSPEC bool SDLCALL SDL_ScreenKeyboardShown(SDL_Window *window);
  566. /* Ends C function definitions when using C++ */
  567. #ifdef __cplusplus
  568. }
  569. #endif
  570. #include <SDL3/SDL_close_code.h>
  571. #endif /* SDL_keyboard_h_ */