SDL_mouse.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  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. * # CategoryMouse
  20. *
  21. * SDL mouse handling.
  22. */
  23. #ifndef SDL_mouse_h_
  24. #define SDL_mouse_h_
  25. #include <SDL3/SDL_stdinc.h>
  26. #include <SDL3/SDL_error.h>
  27. #include <SDL3/SDL_surface.h>
  28. #include <SDL3/SDL_video.h>
  29. #include <SDL3/SDL_begin_code.h>
  30. /* Set up for C function definitions, even when using C++ */
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. /**
  35. * This is a unique ID for a mouse for the time it is connected to the system,
  36. * and is never reused for the lifetime of the application.
  37. *
  38. * If the mouse is disconnected and reconnected, it will get a new ID.
  39. *
  40. * The value 0 is an invalid ID.
  41. *
  42. * \since This datatype is available since SDL 3.1.3.
  43. */
  44. typedef Uint32 SDL_MouseID;
  45. /**
  46. * The structure used to identify an SDL cursor.
  47. *
  48. * This is opaque data.
  49. *
  50. * \since This struct is available since SDL 3.1.3.
  51. */
  52. typedef struct SDL_Cursor SDL_Cursor;
  53. /**
  54. * Cursor types for SDL_CreateSystemCursor().
  55. *
  56. * \since This enum is available since SDL 3.1.3.
  57. */
  58. typedef enum SDL_SystemCursor
  59. {
  60. SDL_SYSTEM_CURSOR_DEFAULT, /**< Default cursor. Usually an arrow. */
  61. SDL_SYSTEM_CURSOR_TEXT, /**< Text selection. Usually an I-beam. */
  62. SDL_SYSTEM_CURSOR_WAIT, /**< Wait. Usually an hourglass or watch or spinning ball. */
  63. SDL_SYSTEM_CURSOR_CROSSHAIR, /**< Crosshair. */
  64. SDL_SYSTEM_CURSOR_PROGRESS, /**< Program is busy but still interactive. Usually it's WAIT with an arrow. */
  65. SDL_SYSTEM_CURSOR_NWSE_RESIZE, /**< Double arrow pointing northwest and southeast. */
  66. SDL_SYSTEM_CURSOR_NESW_RESIZE, /**< Double arrow pointing northeast and southwest. */
  67. SDL_SYSTEM_CURSOR_EW_RESIZE, /**< Double arrow pointing west and east. */
  68. SDL_SYSTEM_CURSOR_NS_RESIZE, /**< Double arrow pointing north and south. */
  69. SDL_SYSTEM_CURSOR_MOVE, /**< Four pointed arrow pointing north, south, east, and west. */
  70. SDL_SYSTEM_CURSOR_NOT_ALLOWED, /**< Not permitted. Usually a slashed circle or crossbones. */
  71. SDL_SYSTEM_CURSOR_POINTER, /**< Pointer that indicates a link. Usually a pointing hand. */
  72. SDL_SYSTEM_CURSOR_NW_RESIZE, /**< Window resize top-left. This may be a single arrow or a double arrow like NWSE_RESIZE. */
  73. SDL_SYSTEM_CURSOR_N_RESIZE, /**< Window resize top. May be NS_RESIZE. */
  74. SDL_SYSTEM_CURSOR_NE_RESIZE, /**< Window resize top-right. May be NESW_RESIZE. */
  75. SDL_SYSTEM_CURSOR_E_RESIZE, /**< Window resize right. May be EW_RESIZE. */
  76. SDL_SYSTEM_CURSOR_SE_RESIZE, /**< Window resize bottom-right. May be NWSE_RESIZE. */
  77. SDL_SYSTEM_CURSOR_S_RESIZE, /**< Window resize bottom. May be NS_RESIZE. */
  78. SDL_SYSTEM_CURSOR_SW_RESIZE, /**< Window resize bottom-left. May be NESW_RESIZE. */
  79. SDL_SYSTEM_CURSOR_W_RESIZE, /**< Window resize left. May be EW_RESIZE. */
  80. SDL_SYSTEM_CURSOR_COUNT
  81. } SDL_SystemCursor;
  82. /**
  83. * Scroll direction types for the Scroll event
  84. *
  85. * \since This enum is available since SDL 3.1.3.
  86. */
  87. typedef enum SDL_MouseWheelDirection
  88. {
  89. SDL_MOUSEWHEEL_NORMAL, /**< The scroll direction is normal */
  90. SDL_MOUSEWHEEL_FLIPPED /**< The scroll direction is flipped / natural */
  91. } SDL_MouseWheelDirection;
  92. /**
  93. * A bitmask of pressed mouse buttons, as reported by SDL_GetMouseState, etc.
  94. *
  95. * - Button 1: Left mouse button
  96. * - Button 2: Middle mouse button
  97. * - Button 3: Right mouse button
  98. * - Button 4: Side mouse button 1
  99. * - Button 5: Side mouse button 2
  100. *
  101. * \since This datatype is available since SDL 3.1.3.
  102. *
  103. * \sa SDL_GetMouseState
  104. * \sa SDL_GetGlobalMouseState
  105. * \sa SDL_GetRelativeMouseState
  106. */
  107. typedef Uint32 SDL_MouseButtonFlags;
  108. #define SDL_BUTTON_LEFT 1
  109. #define SDL_BUTTON_MIDDLE 2
  110. #define SDL_BUTTON_RIGHT 3
  111. #define SDL_BUTTON_X1 4
  112. #define SDL_BUTTON_X2 5
  113. #define SDL_BUTTON_MASK(X) (1u << ((X)-1))
  114. #define SDL_BUTTON_LMASK SDL_BUTTON_MASK(SDL_BUTTON_LEFT)
  115. #define SDL_BUTTON_MMASK SDL_BUTTON_MASK(SDL_BUTTON_MIDDLE)
  116. #define SDL_BUTTON_RMASK SDL_BUTTON_MASK(SDL_BUTTON_RIGHT)
  117. #define SDL_BUTTON_X1MASK SDL_BUTTON_MASK(SDL_BUTTON_X1)
  118. #define SDL_BUTTON_X2MASK SDL_BUTTON_MASK(SDL_BUTTON_X2)
  119. /* Function prototypes */
  120. /**
  121. * Return whether a mouse is currently connected.
  122. *
  123. * \returns true if a mouse is connected, false otherwise.
  124. *
  125. * \threadsafety This function should only be called on the main thread.
  126. *
  127. * \since This function is available since SDL 3.1.3.
  128. *
  129. * \sa SDL_GetMice
  130. */
  131. extern SDL_DECLSPEC bool SDLCALL SDL_HasMouse(void);
  132. /**
  133. * Get a list of currently connected mice.
  134. *
  135. * Note that this will include any device or virtual driver that includes
  136. * mouse functionality, including some game controllers, KVM switches, etc.
  137. * You should wait for input from a device before you consider it actively in
  138. * use.
  139. *
  140. * \param count a pointer filled in with the number of mice returned, may be
  141. * NULL.
  142. * \returns a 0 terminated array of mouse instance IDs or NULL on failure;
  143. * call SDL_GetError() for more information. This should be freed
  144. * with SDL_free() when it is no longer needed.
  145. *
  146. * \threadsafety This function should only be called on the main thread.
  147. *
  148. * \since This function is available since SDL 3.1.3.
  149. *
  150. * \sa SDL_GetMouseNameForID
  151. * \sa SDL_HasMouse
  152. */
  153. extern SDL_DECLSPEC SDL_MouseID * SDLCALL SDL_GetMice(int *count);
  154. /**
  155. * Get the name of a mouse.
  156. *
  157. * This function returns "" if the mouse doesn't have a name.
  158. *
  159. * \param instance_id the mouse instance ID.
  160. * \returns the name of the selected mouse, or NULL on failure; call
  161. * SDL_GetError() for more information.
  162. *
  163. * \threadsafety This function should only be called on the main thread.
  164. *
  165. * \since This function is available since SDL 3.1.3.
  166. *
  167. * \sa SDL_GetMice
  168. */
  169. extern SDL_DECLSPEC const char * SDLCALL SDL_GetMouseNameForID(SDL_MouseID instance_id);
  170. /**
  171. * Get the window which currently has mouse focus.
  172. *
  173. * \returns the window with mouse focus.
  174. *
  175. * \threadsafety This function should only be called on the main thread.
  176. *
  177. * \since This function is available since SDL 3.1.3.
  178. */
  179. extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocus(void);
  180. /**
  181. * Query SDL's cache for the synchronous mouse button state and the
  182. * window-relative SDL-cursor position.
  183. *
  184. * This function returns the cached synchronous state as SDL understands it
  185. * from the last pump of the event queue.
  186. *
  187. * To query the platform for immediate asynchronous state, use
  188. * SDL_GetGlobalMouseState.
  189. *
  190. * Passing non-NULL pointers to `x` or `y` will write the destination with
  191. * respective x or y coordinates relative to the focused window.
  192. *
  193. * In Relative Mode, the SDL-cursor's position usually contradicts the
  194. * platform-cursor's position as manually calculated from
  195. * SDL_GetGlobalMouseState() and SDL_GetWindowPosition.
  196. *
  197. * \param x a pointer to receive the SDL-cursor's x-position from the focused
  198. * window's top left corner, can be NULL if unused.
  199. * \param y a pointer to receive the SDL-cursor's y-position from the focused
  200. * window's top left corner, can be NULL if unused.
  201. * \returns a 32-bit bitmask of the button state that can be bitwise-compared
  202. * against the SDL_BUTTON_MASK(X) macro.
  203. *
  204. * \threadsafety This function should only be called on the main thread.
  205. *
  206. * \since This function is available since SDL 3.1.3.
  207. *
  208. * \sa SDL_GetGlobalMouseState
  209. * \sa SDL_GetRelativeMouseState
  210. */
  211. extern SDL_DECLSPEC SDL_MouseButtonFlags SDLCALL SDL_GetMouseState(float *x, float *y);
  212. /**
  213. * Query the platform for the asynchronous mouse button state and the
  214. * desktop-relative platform-cursor position.
  215. *
  216. * This function immediately queries the platform for the most recent
  217. * asynchronous state, more costly than retrieving SDL's cached state in
  218. * SDL_GetMouseState().
  219. *
  220. * Passing non-NULL pointers to `x` or `y` will write the destination with
  221. * respective x or y coordinates relative to the desktop.
  222. *
  223. * In Relative Mode, the platform-cursor's position usually contradicts the
  224. * SDL-cursor's position as manually calculated from SDL_GetMouseState() and
  225. * SDL_GetWindowPosition.
  226. *
  227. * This function can be useful if you need to track the mouse outside of a
  228. * specific window and SDL_CaptureMouse() doesn't fit your needs. For example,
  229. * it could be useful if you need to track the mouse while dragging a window,
  230. * where coordinates relative to a window might not be in sync at all times.
  231. *
  232. * \param x a pointer to receive the platform-cursor's x-position from the
  233. * desktop's top left corner, can be NULL if unused.
  234. * \param y a pointer to receive the platform-cursor's y-position from the
  235. * desktop's top left corner, can be NULL if unused.
  236. * \returns a 32-bit bitmask of the button state that can be bitwise-compared
  237. * against the SDL_BUTTON_MASK(X) macro.
  238. *
  239. * \threadsafety This function should only be called on the main thread.
  240. *
  241. * \since This function is available since SDL 3.1.3.
  242. *
  243. * \sa SDL_CaptureMouse
  244. * \sa SDL_GetMouseState
  245. * \sa SDL_GetGlobalMouseState
  246. */
  247. extern SDL_DECLSPEC SDL_MouseButtonFlags SDLCALL SDL_GetGlobalMouseState(float *x, float *y);
  248. /**
  249. * Query SDL's cache for the synchronous mouse button state and accumulated
  250. * mouse delta since last call.
  251. *
  252. * This function returns the cached synchronous state as SDL understands it
  253. * from the last pump of the event queue.
  254. *
  255. * To query the platform for immediate asynchronous state, use
  256. * SDL_GetGlobalMouseState.
  257. *
  258. * Passing non-NULL pointers to `x` or `y` will write the destination with
  259. * respective x or y deltas accumulated since the last call to this function
  260. * (or since event initialization).
  261. *
  262. * This function is useful for reducing overhead by processing relative mouse
  263. * inputs in one go per-frame instead of individually per-event, at the
  264. * expense of losing the order between events within the frame (e.g. quickly
  265. * pressing and releasing a button within the same frame).
  266. *
  267. * \param x a pointer to receive the x mouse delta accumulated since last
  268. * call, can be NULL if unused.
  269. * \param y a pointer to receive the y mouse delta accumulated since last
  270. * call, can be NULL if unused.
  271. * \returns a 32-bit bitmask of the button state that can be bitwise-compared
  272. * against the SDL_BUTTON_MASK(X) macro.
  273. *
  274. * \threadsafety This function should only be called on the main thread.
  275. *
  276. * \since This function is available since SDL 3.1.3.
  277. *
  278. * \sa SDL_GetMouseState
  279. * \sa SDL_GetGlobalMouseState
  280. */
  281. extern SDL_DECLSPEC SDL_MouseButtonFlags SDLCALL SDL_GetRelativeMouseState(float *x, float *y);
  282. /**
  283. * Move the mouse cursor to the given position within the window.
  284. *
  285. * This function generates a mouse motion event if relative mode is not
  286. * enabled. If relative mode is enabled, you can force mouse events for the
  287. * warp by setting the SDL_HINT_MOUSE_RELATIVE_WARP_MOTION hint.
  288. *
  289. * Note that this function will appear to succeed, but not actually move the
  290. * mouse when used over Microsoft Remote Desktop.
  291. *
  292. * \param window the window to move the mouse into, or NULL for the current
  293. * mouse focus.
  294. * \param x the x coordinate within the window.
  295. * \param y the y coordinate within the window.
  296. *
  297. * \threadsafety This function should only be called on the main thread.
  298. *
  299. * \since This function is available since SDL 3.1.3.
  300. *
  301. * \sa SDL_WarpMouseGlobal
  302. */
  303. extern SDL_DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window,
  304. float x, float y);
  305. /**
  306. * Move the mouse to the given position in global screen space.
  307. *
  308. * This function generates a mouse motion event.
  309. *
  310. * A failure of this function usually means that it is unsupported by a
  311. * platform.
  312. *
  313. * Note that this function will appear to succeed, but not actually move the
  314. * mouse when used over Microsoft Remote Desktop.
  315. *
  316. * \param x the x coordinate.
  317. * \param y the y coordinate.
  318. * \returns true on success or false on failure; call SDL_GetError() for more
  319. * information.
  320. *
  321. * \threadsafety This function should only be called on the main thread.
  322. *
  323. * \since This function is available since SDL 3.1.3.
  324. *
  325. * \sa SDL_WarpMouseInWindow
  326. */
  327. extern SDL_DECLSPEC bool SDLCALL SDL_WarpMouseGlobal(float x, float y);
  328. /**
  329. * Set relative mouse mode for a window.
  330. *
  331. * While the window has focus and relative mouse mode is enabled, the cursor
  332. * is hidden, the mouse position is constrained to the window, and SDL will
  333. * report continuous relative mouse motion even if the mouse is at the edge of
  334. * the window.
  335. *
  336. * This function will flush any pending mouse motion for this window.
  337. *
  338. * \param window the window to change.
  339. * \param enabled true to enable relative mode, false to disable.
  340. * \returns true on success or false on failure; call SDL_GetError() for more
  341. * information.
  342. *
  343. * \threadsafety This function should only be called on the main thread.
  344. *
  345. * \since This function is available since SDL 3.1.3.
  346. *
  347. * \sa SDL_GetWindowRelativeMouseMode
  348. */
  349. extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowRelativeMouseMode(SDL_Window *window, bool enabled);
  350. /**
  351. * Query whether relative mouse mode is enabled for a window.
  352. *
  353. * \param window the window to query.
  354. * \returns true if relative mode is enabled for a window or false otherwise.
  355. *
  356. * \threadsafety This function should only be called on the main thread.
  357. *
  358. * \since This function is available since SDL 3.1.3.
  359. *
  360. * \sa SDL_SetWindowRelativeMouseMode
  361. */
  362. extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowRelativeMouseMode(SDL_Window *window);
  363. /**
  364. * Capture the mouse and to track input outside an SDL window.
  365. *
  366. * Capturing enables your app to obtain mouse events globally, instead of just
  367. * within your window. Not all video targets support this function. When
  368. * capturing is enabled, the current window will get all mouse events, but
  369. * unlike relative mode, no change is made to the cursor and it is not
  370. * restrained to your window.
  371. *
  372. * This function may also deny mouse input to other windows--both those in
  373. * your application and others on the system--so you should use this function
  374. * sparingly, and in small bursts. For example, you might want to track the
  375. * mouse while the user is dragging something, until the user releases a mouse
  376. * button. It is not recommended that you capture the mouse for long periods
  377. * of time, such as the entire time your app is running. For that, you should
  378. * probably use SDL_SetWindowRelativeMouseMode() or SDL_SetWindowMouseGrab(),
  379. * depending on your goals.
  380. *
  381. * While captured, mouse events still report coordinates relative to the
  382. * current (foreground) window, but those coordinates may be outside the
  383. * bounds of the window (including negative values). Capturing is only allowed
  384. * for the foreground window. If the window loses focus while capturing, the
  385. * capture will be disabled automatically.
  386. *
  387. * While capturing is enabled, the current window will have the
  388. * `SDL_WINDOW_MOUSE_CAPTURE` flag set.
  389. *
  390. * Please note that SDL will attempt to "auto capture" the mouse while the
  391. * user is pressing a button; this is to try and make mouse behavior more
  392. * consistent between platforms, and deal with the common case of a user
  393. * dragging the mouse outside of the window. This means that if you are
  394. * calling SDL_CaptureMouse() only to deal with this situation, you do not
  395. * have to (although it is safe to do so). If this causes problems for your
  396. * app, you can disable auto capture by setting the
  397. * `SDL_HINT_MOUSE_AUTO_CAPTURE` hint to zero.
  398. *
  399. * \param enabled true to enable capturing, false to disable.
  400. * \returns true on success or false on failure; call SDL_GetError() for more
  401. * information.
  402. *
  403. * \threadsafety This function should only be called on the main thread.
  404. *
  405. * \since This function is available since SDL 3.1.3.
  406. *
  407. * \sa SDL_GetGlobalMouseState
  408. */
  409. extern SDL_DECLSPEC bool SDLCALL SDL_CaptureMouse(bool enabled);
  410. /**
  411. * Create a cursor using the specified bitmap data and mask (in MSB format).
  412. *
  413. * `mask` has to be in MSB (Most Significant Bit) format.
  414. *
  415. * The cursor width (`w`) must be a multiple of 8 bits.
  416. *
  417. * The cursor is created in black and white according to the following:
  418. *
  419. * - data=0, mask=1: white
  420. * - data=1, mask=1: black
  421. * - data=0, mask=0: transparent
  422. * - data=1, mask=0: inverted color if possible, black if not.
  423. *
  424. * Cursors created with this function must be freed with SDL_DestroyCursor().
  425. *
  426. * If you want to have a color cursor, or create your cursor from an
  427. * SDL_Surface, you should use SDL_CreateColorCursor(). Alternately, you can
  428. * hide the cursor and draw your own as part of your game's rendering, but it
  429. * will be bound to the framerate.
  430. *
  431. * Also, SDL_CreateSystemCursor() is available, which provides several
  432. * readily-available system cursors to pick from.
  433. *
  434. * \param data the color value for each pixel of the cursor.
  435. * \param mask the mask value for each pixel of the cursor.
  436. * \param w the width of the cursor.
  437. * \param h the height of the cursor.
  438. * \param hot_x the x-axis offset from the left of the cursor image to the
  439. * mouse x position, in the range of 0 to `w` - 1.
  440. * \param hot_y the y-axis offset from the top of the cursor image to the
  441. * mouse y position, in the range of 0 to `h` - 1.
  442. * \returns a new cursor with the specified parameters on success or NULL on
  443. * failure; call SDL_GetError() for more information.
  444. *
  445. * \threadsafety This function should only be called on the main thread.
  446. *
  447. * \since This function is available since SDL 3.1.3.
  448. *
  449. * \sa SDL_CreateColorCursor
  450. * \sa SDL_CreateSystemCursor
  451. * \sa SDL_DestroyCursor
  452. * \sa SDL_SetCursor
  453. */
  454. extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_CreateCursor(const Uint8 * data,
  455. const Uint8 * mask,
  456. int w, int h, int hot_x,
  457. int hot_y);
  458. /**
  459. * Create a color cursor.
  460. *
  461. * If this function is passed a surface with alternate representations, the
  462. * surface will be interpreted as the content to be used for 100% display
  463. * scale, and the alternate representations will be used for high DPI
  464. * situations. For example, if the original surface is 32x32, then on a 2x
  465. * macOS display or 200% display scale on Windows, a 64x64 version of the
  466. * image will be used, if available. If a matching version of the image isn't
  467. * available, the closest larger size image will be downscaled to the
  468. * appropriate size and be used instead, if available. Otherwise, the closest
  469. * smaller image will be upscaled and be used instead.
  470. *
  471. * \param surface an SDL_Surface structure representing the cursor image.
  472. * \param hot_x the x position of the cursor hot spot.
  473. * \param hot_y the y position of the cursor hot spot.
  474. * \returns the new cursor on success or NULL on failure; call SDL_GetError()
  475. * for more information.
  476. *
  477. * \threadsafety This function should only be called on the main thread.
  478. *
  479. * \since This function is available since SDL 3.1.3.
  480. *
  481. * \sa SDL_CreateCursor
  482. * \sa SDL_CreateSystemCursor
  483. * \sa SDL_DestroyCursor
  484. * \sa SDL_SetCursor
  485. */
  486. extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_CreateColorCursor(SDL_Surface *surface,
  487. int hot_x,
  488. int hot_y);
  489. /**
  490. * Create a system cursor.
  491. *
  492. * \param id an SDL_SystemCursor enum value.
  493. * \returns a cursor on success or NULL on failure; call SDL_GetError() for
  494. * more information.
  495. *
  496. * \threadsafety This function should only be called on the main thread.
  497. *
  498. * \since This function is available since SDL 3.1.3.
  499. *
  500. * \sa SDL_DestroyCursor
  501. */
  502. extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_CreateSystemCursor(SDL_SystemCursor id);
  503. /**
  504. * Set the active cursor.
  505. *
  506. * This function sets the currently active cursor to the specified one. If the
  507. * cursor is currently visible, the change will be immediately represented on
  508. * the display. SDL_SetCursor(NULL) can be used to force cursor redraw, if
  509. * this is desired for any reason.
  510. *
  511. * \param cursor a cursor to make active.
  512. * \returns true on success or false on failure; call SDL_GetError() for more
  513. * information.
  514. *
  515. * \threadsafety This function should only be called on the main thread.
  516. *
  517. * \since This function is available since SDL 3.1.3.
  518. *
  519. * \sa SDL_GetCursor
  520. */
  521. extern SDL_DECLSPEC bool SDLCALL SDL_SetCursor(SDL_Cursor *cursor);
  522. /**
  523. * Get the active cursor.
  524. *
  525. * This function returns a pointer to the current cursor which is owned by the
  526. * library. It is not necessary to free the cursor with SDL_DestroyCursor().
  527. *
  528. * \returns the active cursor or NULL if there is no mouse.
  529. *
  530. * \threadsafety This function should only be called on the main thread.
  531. *
  532. * \since This function is available since SDL 3.1.3.
  533. *
  534. * \sa SDL_SetCursor
  535. */
  536. extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_GetCursor(void);
  537. /**
  538. * Get the default cursor.
  539. *
  540. * You do not have to call SDL_DestroyCursor() on the return value, but it is
  541. * safe to do so.
  542. *
  543. * \returns the default cursor on success or NULL on failuree; call
  544. * SDL_GetError() for more information.
  545. *
  546. * \threadsafety This function should only be called on the main thread.
  547. *
  548. * \since This function is available since SDL 3.1.3.
  549. */
  550. extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_GetDefaultCursor(void);
  551. /**
  552. * Free a previously-created cursor.
  553. *
  554. * Use this function to free cursor resources created with SDL_CreateCursor(),
  555. * SDL_CreateColorCursor() or SDL_CreateSystemCursor().
  556. *
  557. * \param cursor the cursor to free.
  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_CreateColorCursor
  564. * \sa SDL_CreateCursor
  565. * \sa SDL_CreateSystemCursor
  566. */
  567. extern SDL_DECLSPEC void SDLCALL SDL_DestroyCursor(SDL_Cursor *cursor);
  568. /**
  569. * Show the cursor.
  570. *
  571. * \returns true on success or false on failure; call SDL_GetError() for more
  572. * information.
  573. *
  574. * \threadsafety This function should only be called on the main thread.
  575. *
  576. * \since This function is available since SDL 3.1.3.
  577. *
  578. * \sa SDL_CursorVisible
  579. * \sa SDL_HideCursor
  580. */
  581. extern SDL_DECLSPEC bool SDLCALL SDL_ShowCursor(void);
  582. /**
  583. * Hide the cursor.
  584. *
  585. * \returns true on success or false on failure; call SDL_GetError() for more
  586. * information.
  587. *
  588. * \threadsafety This function should only be called on the main thread.
  589. *
  590. * \since This function is available since SDL 3.1.3.
  591. *
  592. * \sa SDL_CursorVisible
  593. * \sa SDL_ShowCursor
  594. */
  595. extern SDL_DECLSPEC bool SDLCALL SDL_HideCursor(void);
  596. /**
  597. * Return whether the cursor is currently being shown.
  598. *
  599. * \returns `true` if the cursor is being shown, or `false` if the cursor is
  600. * hidden.
  601. *
  602. * \threadsafety This function should only be called on the main thread.
  603. *
  604. * \since This function is available since SDL 3.1.3.
  605. *
  606. * \sa SDL_HideCursor
  607. * \sa SDL_ShowCursor
  608. */
  609. extern SDL_DECLSPEC bool SDLCALL SDL_CursorVisible(void);
  610. /* Ends C function definitions when using C++ */
  611. #ifdef __cplusplus
  612. }
  613. #endif
  614. #include <SDL3/SDL_close_code.h>
  615. #endif /* SDL_mouse_h_ */