SDL 3.0
SDL_mouse.h
Go to the documentation of this file.
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 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 * If you'd like to keep the mouse position fixed while in relative mode you
363 * can use SDL_SetWindowMouseRect(). If you'd like the cursor to be at a
364 * specific location when relative mode ends, you should use
365 * SDL_WarpMouseInWindow() before disabling relative mode.
366 *
367 * This function will flush any pending mouse motion for this window.
368 *
369 * \param window the window to change.
370 * \param enabled true to enable relative mode, false to disable.
371 * \returns true on success or false on failure; call SDL_GetError() for more
372 * information.
373 *
374 * \threadsafety This function should only be called on the main thread.
375 *
376 * \since This function is available since SDL 3.1.3.
377 *
378 * \sa SDL_GetWindowRelativeMouseMode
379 */
380extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowRelativeMouseMode(SDL_Window *window, bool enabled);
381
382/**
383 * Query whether relative mouse mode is enabled for a window.
384 *
385 * \param window the window to query.
386 * \returns true if relative mode is enabled for a window or false otherwise.
387 *
388 * \threadsafety This function should only be called on the main thread.
389 *
390 * \since This function is available since SDL 3.1.3.
391 *
392 * \sa SDL_SetWindowRelativeMouseMode
393 */
394extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowRelativeMouseMode(SDL_Window *window);
395
396/**
397 * Capture the mouse and to track input outside an SDL window.
398 *
399 * Capturing enables your app to obtain mouse events globally, instead of just
400 * within your window. Not all video targets support this function. When
401 * capturing is enabled, the current window will get all mouse events, but
402 * unlike relative mode, no change is made to the cursor and it is not
403 * restrained to your window.
404 *
405 * This function may also deny mouse input to other windows--both those in
406 * your application and others on the system--so you should use this function
407 * sparingly, and in small bursts. For example, you might want to track the
408 * mouse while the user is dragging something, until the user releases a mouse
409 * button. It is not recommended that you capture the mouse for long periods
410 * of time, such as the entire time your app is running. For that, you should
411 * probably use SDL_SetWindowRelativeMouseMode() or SDL_SetWindowMouseGrab(),
412 * depending on your goals.
413 *
414 * While captured, mouse events still report coordinates relative to the
415 * current (foreground) window, but those coordinates may be outside the
416 * bounds of the window (including negative values). Capturing is only allowed
417 * for the foreground window. If the window loses focus while capturing, the
418 * capture will be disabled automatically.
419 *
420 * While capturing is enabled, the current window will have the
421 * `SDL_WINDOW_MOUSE_CAPTURE` flag set.
422 *
423 * Please note that SDL will attempt to "auto capture" the mouse while the
424 * user is pressing a button; this is to try and make mouse behavior more
425 * consistent between platforms, and deal with the common case of a user
426 * dragging the mouse outside of the window. This means that if you are
427 * calling SDL_CaptureMouse() only to deal with this situation, you do not
428 * have to (although it is safe to do so). If this causes problems for your
429 * app, you can disable auto capture by setting the
430 * `SDL_HINT_MOUSE_AUTO_CAPTURE` hint to zero.
431 *
432 * \param enabled true to enable capturing, false to disable.
433 * \returns true on success or false on failure; call SDL_GetError() for more
434 * information.
435 *
436 * \threadsafety This function should only be called on the main thread.
437 *
438 * \since This function is available since SDL 3.1.3.
439 *
440 * \sa SDL_GetGlobalMouseState
441 */
442extern SDL_DECLSPEC bool SDLCALL SDL_CaptureMouse(bool enabled);
443
444/**
445 * Create a cursor using the specified bitmap data and mask (in MSB format).
446 *
447 * `mask` has to be in MSB (Most Significant Bit) format.
448 *
449 * The cursor width (`w`) must be a multiple of 8 bits.
450 *
451 * The cursor is created in black and white according to the following:
452 *
453 * - data=0, mask=1: white
454 * - data=1, mask=1: black
455 * - data=0, mask=0: transparent
456 * - data=1, mask=0: inverted color if possible, black if not.
457 *
458 * Cursors created with this function must be freed with SDL_DestroyCursor().
459 *
460 * If you want to have a color cursor, or create your cursor from an
461 * SDL_Surface, you should use SDL_CreateColorCursor(). Alternately, you can
462 * hide the cursor and draw your own as part of your game's rendering, but it
463 * will be bound to the framerate.
464 *
465 * Also, SDL_CreateSystemCursor() is available, which provides several
466 * readily-available system cursors to pick from.
467 *
468 * \param data the color value for each pixel of the cursor.
469 * \param mask the mask value for each pixel of the cursor.
470 * \param w the width of the cursor.
471 * \param h the height of the cursor.
472 * \param hot_x the x-axis offset from the left of the cursor image to the
473 * mouse x position, in the range of 0 to `w` - 1.
474 * \param hot_y the y-axis offset from the top of the cursor image to the
475 * mouse y position, in the range of 0 to `h` - 1.
476 * \returns a new cursor with the specified parameters on success or NULL on
477 * failure; call SDL_GetError() for more information.
478 *
479 * \threadsafety This function should only be called on the main thread.
480 *
481 * \since This function is available since SDL 3.1.3.
482 *
483 * \sa SDL_CreateColorCursor
484 * \sa SDL_CreateSystemCursor
485 * \sa SDL_DestroyCursor
486 * \sa SDL_SetCursor
487 */
488extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_CreateCursor(const Uint8 * data,
489 const Uint8 * mask,
490 int w, int h, int hot_x,
491 int hot_y);
492
493/**
494 * Create a color cursor.
495 *
496 * If this function is passed a surface with alternate representations, the
497 * surface will be interpreted as the content to be used for 100% display
498 * scale, and the alternate representations will be used for high DPI
499 * situations. For example, if the original surface is 32x32, then on a 2x
500 * macOS display or 200% display scale on Windows, a 64x64 version of the
501 * image will be used, if available. If a matching version of the image isn't
502 * available, the closest larger size image will be downscaled to the
503 * appropriate size and be used instead, if available. Otherwise, the closest
504 * smaller image will be upscaled and be used instead.
505 *
506 * \param surface an SDL_Surface structure representing the cursor image.
507 * \param hot_x the x position of the cursor hot spot.
508 * \param hot_y the y position of the cursor hot spot.
509 * \returns the new cursor on success or NULL on failure; call SDL_GetError()
510 * for more information.
511 *
512 * \threadsafety This function should only be called on the main thread.
513 *
514 * \since This function is available since SDL 3.1.3.
515 *
516 * \sa SDL_CreateCursor
517 * \sa SDL_CreateSystemCursor
518 * \sa SDL_DestroyCursor
519 * \sa SDL_SetCursor
520 */
521extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_CreateColorCursor(SDL_Surface *surface,
522 int hot_x,
523 int hot_y);
524
525/**
526 * Create a system cursor.
527 *
528 * \param id an SDL_SystemCursor enum value.
529 * \returns a cursor on success or NULL on failure; call SDL_GetError() for
530 * more 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_DestroyCursor
537 */
538extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_CreateSystemCursor(SDL_SystemCursor id);
539
540/**
541 * Set the active cursor.
542 *
543 * This function sets the currently active cursor to the specified one. If the
544 * cursor is currently visible, the change will be immediately represented on
545 * the display. SDL_SetCursor(NULL) can be used to force cursor redraw, if
546 * this is desired for any reason.
547 *
548 * \param cursor a cursor to make active.
549 * \returns true on success or false on failure; call SDL_GetError() for more
550 * information.
551 *
552 * \threadsafety This function should only be called on the main thread.
553 *
554 * \since This function is available since SDL 3.1.3.
555 *
556 * \sa SDL_GetCursor
557 */
558extern SDL_DECLSPEC bool SDLCALL SDL_SetCursor(SDL_Cursor *cursor);
559
560/**
561 * Get the active cursor.
562 *
563 * This function returns a pointer to the current cursor which is owned by the
564 * library. It is not necessary to free the cursor with SDL_DestroyCursor().
565 *
566 * \returns the active cursor or NULL if there is no mouse.
567 *
568 * \threadsafety This function should only be called on the main thread.
569 *
570 * \since This function is available since SDL 3.1.3.
571 *
572 * \sa SDL_SetCursor
573 */
574extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_GetCursor(void);
575
576/**
577 * Get the default cursor.
578 *
579 * You do not have to call SDL_DestroyCursor() on the return value, but it is
580 * safe to do so.
581 *
582 * \returns the default cursor on success or NULL on failuree; call
583 * SDL_GetError() for more information.
584 *
585 * \threadsafety This function should only be called on the main thread.
586 *
587 * \since This function is available since SDL 3.1.3.
588 */
589extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_GetDefaultCursor(void);
590
591/**
592 * Free a previously-created cursor.
593 *
594 * Use this function to free cursor resources created with SDL_CreateCursor(),
595 * SDL_CreateColorCursor() or SDL_CreateSystemCursor().
596 *
597 * \param cursor the cursor to free.
598 *
599 * \threadsafety This function should only be called on the main thread.
600 *
601 * \since This function is available since SDL 3.1.3.
602 *
603 * \sa SDL_CreateColorCursor
604 * \sa SDL_CreateCursor
605 * \sa SDL_CreateSystemCursor
606 */
607extern SDL_DECLSPEC void SDLCALL SDL_DestroyCursor(SDL_Cursor *cursor);
608
609/**
610 * Show the cursor.
611 *
612 * \returns true on success or false on failure; call SDL_GetError() for more
613 * information.
614 *
615 * \threadsafety This function should only be called on the main thread.
616 *
617 * \since This function is available since SDL 3.1.3.
618 *
619 * \sa SDL_CursorVisible
620 * \sa SDL_HideCursor
621 */
622extern SDL_DECLSPEC bool SDLCALL SDL_ShowCursor(void);
623
624/**
625 * Hide the cursor.
626 *
627 * \returns true on success or false on failure; call SDL_GetError() for more
628 * information.
629 *
630 * \threadsafety This function should only be called on the main thread.
631 *
632 * \since This function is available since SDL 3.1.3.
633 *
634 * \sa SDL_CursorVisible
635 * \sa SDL_ShowCursor
636 */
637extern SDL_DECLSPEC bool SDLCALL SDL_HideCursor(void);
638
639/**
640 * Return whether the cursor is currently being shown.
641 *
642 * \returns `true` if the cursor is being shown, or `false` if the cursor is
643 * hidden.
644 *
645 * \threadsafety This function should only be called on the main thread.
646 *
647 * \since This function is available since SDL 3.1.3.
648 *
649 * \sa SDL_HideCursor
650 * \sa SDL_ShowCursor
651 */
652extern SDL_DECLSPEC bool SDLCALL SDL_CursorVisible(void);
653
654/* Ends C function definitions when using C++ */
655#ifdef __cplusplus
656}
657#endif
658#include <SDL3/SDL_close_code.h>
659
660#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:425
uint32_t Uint32
Definition SDL_stdinc.h:461
struct SDL_Window SDL_Window
Definition SDL_video.h:173
static SDL_Window * window
Definition hello.c:16