SDL_MouseMotionEvent(3type)

πŸ’– SDL_MouseMotionEvent β€” like, the mouse moved, bestie πŸ’–

okay so welcome to the SDL_MouseMotionEvent page, from the SDL3 DATATYPES corner of the Simple Directmedia Layer manual πŸ¦‹. This is the struct that shows up as event.motion.* when your mouse is out here living its main character life across the screen. Every twitch, every glide, every lil wiggle. We're obsessed. ✨


🌸 NAME 🌸

SDL_MouseMotionEvent β€” the Mouse motion event structure, aka event.motion.* πŸ­πŸ’«


✨ SYNOPSIS ✨

Include it like the good little coder you are:

#include <SDL3/SDL_events.h>

And here's the whole struct, every single field, no cap β€” I'm giving it to you verbatim because facts are facts πŸ’…:

typedef struct SDL_MouseMotionEvent
{
    SDL_EventType type; /**< SDL_EVENT_MOUSE_MOTION */
    Uint32 reserved;
    Uint64 timestamp;   /**< In nanoseconds, populated using SDL_GetTicksNS() */
    SDL_WindowID windowID; /**< The window with mouse focus, if any */
    SDL_MouseID which;  /**< The mouse instance id in relative mode, SDL_TOUCH_MOUSEID for touch events, SDL_PEN_MOUSEID for pen events, or 0 */
    SDL_MouseButtonFlags state;       /**< The current button state */
    float x;            /**< X coordinate, relative to window */
    float y;            /**< Y coordinate, relative to window */
    float xrel;         /**< The relative motion in the X direction */
    float yrel;         /**< The relative motion in the Y direction */
} SDL_MouseMotionEvent;

πŸŽ€ what every field is giving πŸŽ€

  • type β€” it's SDL_EVENT_MOUSE_MOTION, that's the vibe check this struct always passes 🫢
  • reserved β€” not yours to touch, bestie, hands off πŸ™ˆ
  • timestamp β€” in nanoseconds, filled in using SDL_GetTicksNS(), so it's giving very precise ⏱️✨
  • windowID β€” the window that has mouse focus, if any (keyword: if any)
  • which β€” the mouse instance id in relative mode, or SDL_TOUCH_MOUSEID for touch events, or SDL_PEN_MOUSEID for pen events, or 0. so many options, so iconic πŸ‘‘
  • state β€” the current button state, literally just what buttons are doing rn
  • x β€” X coordinate, relative to window πŸ“
  • y β€” Y coordinate, relative to window πŸ“
  • xrel β€” the relative motion in the X direction, the how far did it slide energy
  • yrel β€” the relative motion in the Y direction, same but vertical, periodt

πŸ’œ AVAILABILITY πŸ’œ

This struct has been available since SDL 3.2.0 β€” so if you're on anything older, it's not you, it's the version πŸ’€


heads up bestie: don't go renaming or merging these fields, x and xrel are NOT the same thing and the compiler will absolutely catch you lacking πŸ™ˆ

okay that's the whole page, you ate it, go make something cute with your mouse events πŸŒˆπŸŽ€

later, bestie β€” this was the Simple Directmedia Layer manual, SDL 3.4.18, and the page is SDL_MouseMotionEvent(3type) πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from