SDL_MouseMotionEvent(3)
β¨ SDL_MouseMotionEvent β¨
okay bestie, welcome to the SDL_MouseMotionEvent page from the SDL API Reference π this is the lil struct that tells you when somebody moved their mouse, and honestly? it's giving essential.
π STRUCTURE DEFINITION π
here's the whole vibe, literally character for character:
typedef struct{
Uint8 type;
Uint8 state;
Uint16 x, y;
Sint16 xrel, yrel;
} SDL_MouseMotionEvent;
πΈ STRUCTURE DATA πΈ
every field, no gatekeeping:
typeβ it'sSDL_MOUSEMOTION, that's the whole personality π¦stateβ the current button state, aka which buttons are being held down rnx,yβ the X/Y coordinates of the mouse, absolute and iconicxrel,yrelβ relative motion in the X/Y direction, the delta of it all
π DESCRIPTION π
so SDL_MouseMotionEvent is a member of the SDL_Event union, and it shows up whenever an event of type SDL_MOUSEMOTION gets reported. that's the lore.
simply put β and bestie I mean simply β a SDL_MOUSEMOTION type event occurs when a user moves the mouse within the application window, or when SDL_WarpMouse is called. both situations, same energy. β¨
and you don't just get one kind of coordinate, you get BOTH:
- the absolute ones (
xandy) - the relative ones (
xrelandyrel)
...all reported along with the current button states (state). and how do you read that button state? you interpret it using the SDL_BUTTON macro (peep SDL_GetMouseState for that one, iykyk). π«Ά
π now here's the spicy part: if the cursor is hidden (SDL_ShowCursor(0)) and the input is grabbed (SDL_WM_GrabInput(SDL_GRAB_ON)), then the mouse will give relative motion events even when the cursor reaches the edge of the screen. no cap. but heads up β this is currently only implemented on Windows and Linux/Unix-a-likes. so if you're on something else, don't come for me, it's just not there yet π
π SEE ALSO π
go read these next, fr fr:
SDL_EventSDL_MouseButtonEvent
SDL β Tue 11 Sep 2001, 22:59 πΈ
and that's the whole page bestie, mwah π this dropped way back on Tue 11 Sep 2001, 22:59 under the SDL umbrella, and it's still serving main character energy. go move some mice. π¦β¨
π¦ where this page comes from
- debian bookworm: libsdl1.2-dev 1.2.15+dfsg2-8 Β· LGPL-2.1-or-later
- nixos 26.05: SDL_sixel 0-unstable-2016-02-06
- nixpkgs unstable: SDL_sixel 0-unstable-2016-02-06
- ubuntu jammy: libsdl1.2-dev 1.2.15+dfsg2-6 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms