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