SDL_mouse.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2024 Sam Lantinga <[email protected]>
  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. * \since This function is available since SDL 3.1.3.
  126. *
  127. * \sa SDL_GetMice
  128. */
  129. extern SDL_DECLSPEC bool SDLCALL SDL_HasMouse(void);
  130. /**
  131. * Get a list of currently connected mice.
  132. *
  133. * Note that this will include any device or virtual driver that includes
  134. * mouse functionality, including some game controllers, KVM switches, etc.
  135. * You should wait for input from a device before you consider it actively in
  136. * use.
  137. *
  138. * \param count a pointer filled in with the number of mice returned, may be
  139. * NULL.
  140. * \returns a 0 terminated array of mouse instance IDs or NULL on failure;
  141. * call SDL_GetError() for more information. This should be freed
  142. * with SDL_free() when it is no longer needed.
  143. *
  144. * \since This function is available since SDL 3.1.3.
  145. *
  146. * \sa SDL_GetMouseNameForID
  147. * \sa SDL_HasMouse
  148. */
  149. extern SDL_DECLSPEC SDL_MouseID * SDLCALL SDL_GetMice(int *count);
  150. /**
  151. * Get the name of a mouse.
  152. *
  153. * This function returns "" if the mouse doesn't have a name.
  154. *
  155. * \param instance_id the mouse instance ID.
  156. * \returns the name of the selected mouse, or NULL on failure; call
  157. * SDL_GetError() for more information.
  158. *
  159. * \since This function is available since SDL 3.1.3.
  160. *
  161. * \sa SDL_GetMice
  162. */
  163. extern SDL_DECLSPEC const char * SDLCALL SDL_GetMouseNameForID(SDL_MouseID instance_id);
  164. /**
  165. * Get the window which currently has mouse focus.
  166. *
  167. * \returns the window with mouse focus.
  168. *
  169. * \since This function is available since SDL 3.1.3.
  170. */
  171. extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocus(void);
  172. /**
  173. * Query SDL's cache for the synchronous mouse button state and the
  174. * window-relative SDL-cursor position.
  175. *
  176. * This function returns the cached synchronous state as SDL understands it
  177. * from the last pump of the event queue.
  178. *
  179. * To query the platform for immediate asynchronous state, use
  180. * SDL_GetGlobalMouseState.
  181. *
  182. * Passing non-NULL pointers to `x` or `y` will write the destination with
  183. * respective x or y coordinates relative to the focused window.
  184. *
  185. * In Relative Mode, the SDL-cursor's position usually contradicts the
  186. * platform-cursor's position as manually calculated from
  187. * SDL_GetGlobalMouseState() and SDL_GetWindowPosition.
  188. *
  189. * \param x a pointer to receive the SDL-cursor's x-position from the focused
  190. * window's top left corner, can be NULL if unused.
  191. * \param y a pointer to receive the SDL-cursor's y-position from the focused
  192. * window's top left corner, can be NULL if unused.
  193. * \returns a 32-bit bitmask of the button state that can be bitwise-compared
  194. * against the SDL_BUTTON_MASK(X) macro.
  195. *
  196. * \since This function is available since SDL 3.1.3.
  197. *
  198. * \sa SDL_GetGlobalMouseState
  199. * \sa SDL_GetRelativeMouseState
  200. */
  201. extern SDL_DECLSPEC SDL_MouseButtonFlags SDLCALL SDL_GetMouseState(float *x, float *y);
  202. /**
  203. * Query the platform for the asynchronous mouse button state and the
  204. * desktop-relative platform-cursor position.
  205. *
  206. * This function immediately queries the platform for the most recent
  207. * asynchronous state, more costly than retrieving SDL's cached state in
  208. * SDL_GetMouseState().
  209. *
  210. * Passing non-NULL pointers to `x` or `y` will write the destination with
  211. * respective x or y coordinates relative to the desktop.
  212. *
  213. * In Relative Mode, the platform-cursor's position usually contradicts the
  214. * SDL-cursor's position as manually calculated from SDL_GetMouseState() and
  215. * SDL_GetWindowPosition.
  216. *
  217. * This function can be useful if you need to track the mouse outside of a
  218. * specific window and SDL_CaptureMouse() doesn't fit your needs. For example,
  219. * it could be useful if you need to track the mouse while dragging a window,
  220. * where coordinates relative to a window might not be in sync at all times.
  221. *
  222. * \param x a pointer to receive the platform-cursor's x-position from the
  223. * desktop's top left corner, can be NULL if unused.
  224. * \param y a pointer to receive the platform-cursor's y-position from the
  225. * desktop's top left corner, can be NULL if unused.
  226. * \returns a 32-bit bitmask of the button state that can be bitwise-compared
  227. * against the SDL_BUTTON_MASK(X) macro.
  228. *
  229. * \since This function is available since SDL 3.1.3.
  230. *
  231. * \sa SDL_CaptureMouse
  232. * \sa SDL_GetMouseState
  233. * \sa SDL_GetGlobalMouseState
  234. */
  235. extern SDL_DECLSPEC SDL_MouseButtonFlags SDLCALL SDL_GetGlobalMouseState(float *x, float *y);
  236. /**
  237. * Query SDL's cache for the synchronous mouse button state and accumulated
  238. * mouse delta since last call.
  239. *
  240. * This function returns the cached synchronous state as SDL understands it
  241. * from the last pump of the event queue.
  242. *
  243. * To query the platform for immediate asynchronous state, use
  244. * SDL_GetGlobalMouseState.
  245. *
  246. * Passing non-NULL pointers to `x` or `y` will write the destination with
  247. * respective x or y deltas accumulated since the last call to this function
  248. * (or since event initialization).
  249. *
  250. * This function is useful for reducing overhead by processing relative mouse
  251. * inputs in one go per-frame instead of individually per-event, at the
  252. * expense of losing the order between events within the frame (e.g. quickly
  253. * pressing and releasing a button within the same frame).
  254. *
  255. * \param x a pointer to receive the x mouse delta accumulated since last
  256. * call, can be NULL if unused.
  257. * \param y a pointer to receive the y mouse delta accumulated since last
  258. * call, can be NULL if unused.
  259. * \returns a 32-bit bitmask of the button state that can be bitwise-compared
  260. * against the SDL_BUTTON_MASK(X) macro.
  261. *
  262. * \since This function is available since SDL 3.1.3.
  263. *
  264. * \sa SDL_GetMouseState
  265. * \sa SDL_GetGlobalMouseState
  266. */
  267. extern SDL_DECLSPEC SDL_MouseButtonFlags SDLCALL SDL_GetRelativeMouseState(float *x, float *y);
  268. /**
  269. * Move the mouse cursor to the given position within the window.
  270. *
  271. * This function generates a mouse motion event if relative mode is not
  272. * enabled. If relative mode is enabled, you can force mouse events for the
  273. * warp by setting the SDL_HINT_MOUSE_RELATIVE_WARP_MOTION hint.
  274. *
  275. * Note that this function will appear to succeed, but not actually move the
  276. * mouse when used over Microsoft Remote Desktop.
  277. *
  278. * \param window the window to move the mouse into, or NULL for the current
  279. * mouse focus.
  280. * \param x the x coordinate within the window.
  281. * \param y the y coordinate within the window.
  282. *
  283. * \since This function is available since SDL 3.1.3.
  284. *
  285. * \sa SDL_WarpMouseGlobal
  286. */
  287. extern SDL_DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window,
  288. float x, float y);
  289. /**
  290. * Move the mouse to the given position in global screen space.
  291. *
  292. * This function generates a mouse motion event.
  293. *
  294. * A failure of this function usually means that it is unsupported by a
  295. * platform.
  296. *
  297. * Note that this function will appear to succeed, but not actually move the
  298. * mouse when used over Microsoft Remote Desktop.
  299. *
  300. * \param x the x coordinate.
  301. * \param y the y coordinate.
  302. * \returns true on success or false on failure; call SDL_GetError() for more
  303. * information.
  304. *
  305. * \since This function is available since SDL 3.1.3.
  306. *
  307. * \sa SDL_WarpMouseInWindow
  308. */
  309. extern SDL_DECLSPEC bool SDLCALL SDL_WarpMouseGlobal(float x, float y);
  310. /**
  311. * Set relative mouse mode for a window.
  312. *
  313. * While the window has focus and relative mouse mode is enabled, the cursor
  314. * is hidden, the mouse position is constrained to the window, and SDL will
  315. * report continuous relative mouse motion even if the mouse is at the edge of
  316. * the window.
  317. *
  318. * This function will flush any pending mouse motion for this window.
  319. *
  320. * \param window the window to change.
  321. * \param enabled true to enable relative mode, false to disable.
  322. * \returns true on success or false on failure; call SDL_GetError() for more
  323. * information.
  324. *
  325. * \since This function is available since SDL 3.1.3.
  326. *
  327. * \sa SDL_GetWindowRelativeMouseMode
  328. */
  329. extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowRelativeMouseMode(SDL_Window *window, bool enabled);
  330. /**
  331. * Query whether relative mouse mode is enabled for a window.
  332. *
  333. * \param window the window to query.
  334. * \returns true if relative mode is enabled for a window or false otherwise.
  335. *
  336. * \since This function is available since SDL 3.1.3.
  337. *
  338. * \sa SDL_SetWindowRelativeMouseMode
  339. */
  340. extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowRelativeMouseMode(SDL_Window *window);
  341. /**
  342. * Capture the mouse and to track input outside an SDL window.
  343. *
  344. * Capturing enables your app to obtain mouse events globally, instead of just
  345. * within your window. Not all video targets support this function. When
  346. * capturing is enabled, the current window will get all mouse events, but
  347. * unlike relative mode, no change is made to the cursor and it is not
  348. * restrained to your window.
  349. *
  350. * This function may also deny mouse input to other windows--both those in
  351. * your application and others on the system--so you should use this function
  352. * sparingly, and in small bursts. For example, you might want to track the
  353. * mouse while the user is dragging something, until the user releases a mouse
  354. * button. It is not recommended that you capture the mouse for long periods
  355. * of time, such as the entire time your app is running. For that, you should
  356. * probably use SDL_SetWindowRelativeMouseMode() or SDL_SetWindowMouseGrab(),
  357. * depending on your goals.
  358. *
  359. * While captured, mouse events still report coordinates relative to the
  360. * current (foreground) window, but those coordinates may be outside the
  361. * bounds of the window (including negative values). Capturing is only allowed
  362. * for the foreground window. If the window loses focus while capturing, the
  363. * capture will be disabled automatically.
  364. *
  365. * While capturing is enabled, the current window will have the
  366. * `SDL_WINDOW_MOUSE_CAPTURE` flag set.
  367. *
  368. * Please note that SDL will attempt to "auto capture" the mouse while the
  369. * user is pressing a button; this is to try and make mouse behavior more
  370. * consistent between platforms, and deal with the common case of a user
  371. * dragging the mouse outside of the window. This means that if you are
  372. * calling SDL_CaptureMouse() only to deal with this situation, you do not
  373. * have to (although it is safe to do so). If this causes problems for your
  374. * app, you can disable auto capture by setting the
  375. * `SDL_HINT_MOUSE_AUTO_CAPTURE` hint to zero.
  376. *
  377. * \param enabled true to enable capturing, false to disable.
  378. * \returns true on success or false on failure; call SDL_GetError() for more
  379. * information.
  380. *
  381. * \since This function is available since SDL 3.1.3.
  382. *
  383. * \sa SDL_GetGlobalMouseState
  384. */
  385. extern SDL_DECLSPEC bool SDLCALL SDL_CaptureMouse(bool enabled);
  386. /**
  387. * Create a cursor using the specified bitmap data and mask (in MSB format).
  388. *
  389. * `mask` has to be in MSB (Most Significant Bit) format.
  390. *
  391. * The cursor width (`w`) must be a multiple of 8 bits.
  392. *
  393. * The cursor is created in black and white according to the following:
  394. *
  395. * - data=0, mask=1: white
  396. * - data=1, mask=1: black
  397. * - data=0, mask=0: transparent
  398. * - data=1, mask=0: inverted color if possible, black if not.
  399. *
  400. * Cursors created with this function must be freed with SDL_DestroyCursor().
  401. *
  402. * If you want to have a color cursor, or create your cursor from an
  403. * SDL_Surface, you should use SDL_CreateColorCursor(). Alternately, you can
  404. * hide the cursor and draw your own as part of your game's rendering, but it
  405. * will be bound to the framerate.
  406. *
  407. * Also, SDL_CreateSystemCursor() is available, which provides several
  408. * readily-available system cursors to pick from.
  409. *
  410. * \param data the color value for each pixel of the cursor.
  411. * \param mask the mask value for each pixel of the cursor.
  412. * \param w the width of the cursor.
  413. * \param h the height of the cursor.
  414. * \param hot_x the x-axis offset from the left of the cursor image to the
  415. * mouse x position, in the range of 0 to `w` - 1.
  416. * \param hot_y the y-axis offset from the top of the cursor image to the
  417. * mouse y position, in the range of 0 to `h` - 1.
  418. * \returns a new cursor with the specified parameters on success or NULL on
  419. * failure; call SDL_GetError() for more information.
  420. *
  421. * \since This function is available since SDL 3.1.3.
  422. *
  423. * \sa SDL_CreateColorCursor
  424. * \sa SDL_CreateSystemCursor
  425. * \sa SDL_DestroyCursor
  426. * \sa SDL_SetCursor
  427. */
  428. extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_CreateCursor(const Uint8 * data,
  429. const Uint8 * mask,
  430. int w, int h, int hot_x,
  431. int hot_y);
  432. /**
  433. * Create a color cursor.
  434. *
  435. * If this function is passed a surface with alternate representations, the
  436. * surface will be interpreted as the content to be used for 100% display
  437. * scale, and the alternate representations will be used for high DPI
  438. * situations. For example, if the original surface is 32x32, then on a 2x
  439. * macOS display or 200% display scale on Windows, a 64x64 version of the
  440. * image will be used, if available. If a matching version of the image isn't
  441. * available, the closest larger size image will be downscaled to the
  442. * appropriate size and be used instead, if available. Otherwise, the closest
  443. * smaller image will be upscaled and be used instead.
  444. *
  445. * \param surface an SDL_Surface structure representing the cursor image.
  446. * \param hot_x the x position of the cursor hot spot.
  447. * \param hot_y the y position of the cursor hot spot.
  448. * \returns the new cursor on success or NULL on failure; call SDL_GetError()
  449. * for more information.
  450. *
  451. * \since This function is available since SDL 3.1.3.
  452. *
  453. * \sa SDL_CreateCursor
  454. * \sa SDL_CreateSystemCursor
  455. * \sa SDL_DestroyCursor
  456. * \sa SDL_SetCursor
  457. */
  458. extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_CreateColorCursor(SDL_Surface *surface,
  459. int hot_x,
  460. int hot_y);
  461. /**
  462. * Create a system cursor.
  463. *
  464. * \param id an SDL_SystemCursor enum value.
  465. * \returns a cursor on success or NULL on failure; call SDL_GetError() for
  466. * more information.
  467. *
  468. * \since This function is available since SDL 3.1.3.
  469. *
  470. * \sa SDL_DestroyCursor
  471. */
  472. extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_CreateSystemCursor(SDL_SystemCursor id);
  473. /**
  474. * Set the active cursor.
  475. *
  476. * This function sets the currently active cursor to the specified one. If the
  477. * cursor is currently visible, the change will be immediately represented on
  478. * the display. SDL_SetCursor(NULL) can be used to force cursor redraw, if
  479. * this is desired for any reason.
  480. *
  481. * \param cursor a cursor to make active.
  482. * \returns true on success or false on failure; call SDL_GetError() for more
  483. * information.
  484. *
  485. * \since This function is available since SDL 3.1.3.
  486. *
  487. * \sa SDL_GetCursor
  488. */
  489. extern SDL_DECLSPEC bool SDLCALL SDL_SetCursor(SDL_Cursor *cursor);
  490. /**
  491. * Get the active cursor.
  492. *
  493. * This function returns a pointer to the current cursor which is owned by the
  494. * library. It is not necessary to free the cursor with SDL_DestroyCursor().
  495. *
  496. * \returns the active cursor or NULL if there is no mouse.
  497. *
  498. * \since This function is available since SDL 3.1.3.
  499. *
  500. * \sa SDL_SetCursor
  501. */
  502. extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_GetCursor(void);
  503. /**
  504. * Get the default cursor.
  505. *
  506. * You do not have to call SDL_DestroyCursor() on the return value, but it is
  507. * safe to do so.
  508. *
  509. * \returns the default cursor on success or NULL on failuree; call
  510. * SDL_GetError() for more information.
  511. *
  512. * \since This function is available since SDL 3.1.3.
  513. */
  514. extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_GetDefaultCursor(void);
  515. /**
  516. * Free a previously-created cursor.
  517. *
  518. * Use this function to free cursor resources created with SDL_CreateCursor(),
  519. * SDL_CreateColorCursor() or SDL_CreateSystemCursor().
  520. *
  521. * \param cursor the cursor to free.
  522. *
  523. * \since This function is available since SDL 3.1.3.
  524. *
  525. * \sa SDL_CreateColorCursor
  526. * \sa SDL_CreateCursor
  527. * \sa SDL_CreateSystemCursor
  528. */
  529. extern SDL_DECLSPEC void SDLCALL SDL_DestroyCursor(SDL_Cursor *cursor);
  530. /**
  531. * Show the cursor.
  532. *
  533. * \returns true on success or false on failure; call SDL_GetError() for more
  534. * information.
  535. *
  536. * \since This function is available since SDL 3.1.3.
  537. *
  538. * \sa SDL_CursorVisible
  539. * \sa SDL_HideCursor
  540. */
  541. extern SDL_DECLSPEC bool SDLCALL SDL_ShowCursor(void);
  542. /**
  543. * Hide the cursor.
  544. *
  545. * \returns true on success or false on failure; call SDL_GetError() for more
  546. * information.
  547. *
  548. * \since This function is available since SDL 3.1.3.
  549. *
  550. * \sa SDL_CursorVisible
  551. * \sa SDL_ShowCursor
  552. */
  553. extern SDL_DECLSPEC bool SDLCALL SDL_HideCursor(void);
  554. /**
  555. * Return whether the cursor is currently being shown.
  556. *
  557. * \returns `true` if the cursor is being shown, or `false` if the cursor is
  558. * hidden.
  559. *
  560. * \since This function is available since SDL 3.1.3.
  561. *
  562. * \sa SDL_HideCursor
  563. * \sa SDL_ShowCursor
  564. */
  565. extern SDL_DECLSPEC bool SDLCALL SDL_CursorVisible(void);
  566. /* Ends C function definitions when using C++ */
  567. #ifdef __cplusplus
  568. }
  569. #endif
  570. #include <SDL3/SDL_close_code.h>
  571. #endif /* SDL_mouse_h_ */