Skip to content

Commit

Permalink
include: Added category docs for SDL_mouse.h
Browse files Browse the repository at this point in the history
Reference Issue #11847.
  • Loading branch information
icculus committed Jan 18, 2025
1 parent c7d1fd9 commit 75317da
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion include/SDL3/SDL_mouse.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,36 @@
/**
* # CategoryMouse
*
* SDL mouse handling.
* Any GUI application has to deal with the mouse, and SDL provides functions
* to manage mouse input and the displayed cursor.
*
* Most interactions with the mouse will come through the event subsystem.
* Moving a mouse generates an SDL_EVENT_MOUSE_MOTION event, pushing a button
* generates SDL_EVENT_MOUSE_BUTTON_DOWN, etc, but one can also query the
* current state of the mouse at any time with SDL_GetMouseState().
*
* For certain games, it's useful to disassociate the mouse cursor from mouse
* input. An FPS, for example, would not want the player's motion to stop as
* the mouse hits the edge of the window. For these scenarios, use
* SDL_SetWindowRelativeMouseMode(), which hides the cursor, grabs mouse input
* to the window, and reads mouse input no matter how far it moves.
*
* Games that want the system to track the mouse but want to draw their own
* cursor can use SDL_HideCursor() and SDL_ShowCursor(). It might be more
* efficient to let the system manage the cursor, if possible, using
* SDL_SetCursor() with a custom image made through SDL_CreateColorCursor(),
* or perhaps just a specific system cursor from SDL_CreateSystemCursor().
*
* SDL can, on many platforms, differentiate between multiple connected mice,
* allowing for interesting input scenarios and multiplayer games. They can
* be enumerated with SDL_GetMice(), and SDL will send SDL_EVENT_MOUSE_ADDED
* and SDL_EVENT_MOUSE_REMOVED events as they are connected and unplugged.
*
* Since many apps only care about basic mouse input, SDL offers a virtual
* mouse device for touch and pen input, which often can make a desktop
* application work on a touchscreen phone without any code changes. Apps that
* care about touch/pen separately from mouse input should filter out
* events with a `which` field of SDL_TOUCH_MOUSEID/SDL_PEN_MOUSEID.
*/

#ifndef SDL_mouse_h_
Expand Down

0 comments on commit 75317da

Please sign in to comment.