Skip to content

Commit 75317da

Browse files
committed
include: Added category docs for SDL_mouse.h
Reference Issue #11847.
1 parent c7d1fd9 commit 75317da

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

include/SDL3/SDL_mouse.h

+30-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,36 @@
2222
/**
2323
* # CategoryMouse
2424
*
25-
* SDL mouse handling.
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
47+
* be enumerated with SDL_GetMice(), and SDL will send SDL_EVENT_MOUSE_ADDED
48+
* and 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
54+
* events with a `which` field of SDL_TOUCH_MOUSEID/SDL_PEN_MOUSEID.
2655
*/
2756

2857
#ifndef SDL_mouse_h_

0 commit comments

Comments
 (0)