SDL_HINT_MOUSE_AUTO_CAPTURE(3)

✨ SDL_HINT_MOUSE_AUTO_CAPTURE(3) ✨

part of the SDL3 FUNCTIONS fam, bestie πŸ’–


🌸 NAME 🌸

SDL_HINT_MOUSE_AUTO_CAPTURE β€” it's the variable that decides whether your mouse gets captured while mouse buttons are pressed. that's the whole job. iconic behavior honestly.


πŸŽ€ SYNOPSIS πŸŽ€

#include <SDL3/SDL_hints.h>

#define SDL_HINT_MOUSE_AUTO_CAPTURE "SDL_MOUSE_AUTO_CAPTURE"

πŸ’… DESCRIPTION πŸ’…

okay so this variable takes these values, no more no less:

  • "0" β€” the mouse is not captured while mouse buttons are pressed.
  • "1" β€” the mouse is captured while mouse buttons are pressed.

and here's the tea about the default: by default the mouse is captured while mouse buttons are pressed 🫢 which means if you drag that mouse outside the window, your application keeps receiving mouse events until the button is released. no ghosting, no dropped events, the app stays in the group chat. periodt.

This hint can be set anytime. yes bestie, literally whenever, no timing stress πŸ’œ


🌈 AVAILABILITY 🌈

this hint has been around since SDL 3.2.0. she's not new new, she's established πŸ‘‘


⭐ cute little sign-off ⭐

this page came to you courtesy of Simple Directmedia Layer, running the SDL 3.4.18 era of things β€” so if you're on that version, you're golden, go capture that mouse (or don't, your call, you have the hint now) πŸ¦‹βœ¨πŸ’–

πŸ“¦ where this page comes from