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