SDL_MouseWheelEvent(3type)

πŸ’– SDL_MouseWheelEvent πŸ’–

okay bestie, so this page lives in the SDL3 DATATYPES corner of the manual and it's all about SDL_MouseWheelEvent β€” literally the struct that carries your scroll wheel vibes, aka everything in event.wheel.*. πŸ–±οΈβœ¨


🌸 NAME 🌸

SDL_MouseWheelEvent β€” the mouse wheel event structure, no cap, it's giving event.wheel.*


✨ SYNOPSIS ✨

#include <SDL3/SDL_events.h>

typedef struct SDL_MouseWheelEvent
{
    SDL_EventType type; /**< SDL_EVENT_MOUSE_WHEEL */
    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 or 0 */
    float x;            /**< The amount scrolled horizontally, positive to the right and negative to the left */
    float y;            /**< The amount scrolled vertically, positive away from the user and negative toward the user */
    SDL_MouseWheelDirection direction; /**< Set to one of the SDL_MOUSEWHEEL_* defines. When FLIPPED the values in X and Y will be opposite. Multiply by -1 to change them back */
    float mouse_x;      /**< X coordinate, relative to window */
    float mouse_y;      /**< Y coordinate, relative to window */
    Sint32 integer_x;   /**< The amount scrolled horizontally, accumulated to whole scroll "ticks" (added in 3.2.12) */
    Sint32 integer_y;   /**< The amount scrolled vertically, accumulated to whole scroll "ticks" (added in 3.2.12) */
} SDL_MouseWheelEvent;

πŸ¦‹ DESCRIPTION πŸ¦‹

so like. let me break down every single field because you deserve to know exactly what you're working with, and also because skipping fields is a crime I simply will not commit. 🫢

  • type β€” it's an SDL_EventType, and for this struct it's SDL_EVENT_MOUSE_WHEEL. that's the whole personality.
  • reserved β€” a Uint32 just chillin'. hands off, bestie.
  • timestamp β€” a Uint64 measured in nanoseconds, populated using SDL_GetTicksNS(). time is fake but this number is very real.
  • windowID β€” an SDL_WindowID: the window that has mouse focus, if any. sometimes there's just... no window. we've all been there. πŸ’€
  • which β€” an SDL_MouseID: the mouse instance id in relative mode, or 0. yes, zero. iconic behavior honestly.
  • x β€” a float, the amount scrolled horizontally. positive to the right, negative to the left. directions! we love a coordinate with opinions.
  • y β€” a float, the amount scrolled vertically. positive away from the user, negative toward the user. it's the y axis doing its little thing.
  • direction β€” an SDL_MouseWheelDirection, set to one of the SDL_MOUSEWHEEL_* defines. and here's the tea: when it's FLIPPED the values in X and Y will be opposite β€” so multiply by -1 to change them back. do not skip this, I'm begging. 😭
  • mouse_x β€” a float, the X coordinate, relative to the window.
  • mouse_y β€” a float, the Y coordinate, relative to the window.
  • integer_x β€” a Sint32, the amount scrolled horizontally, accumulated to whole scroll "ticks" (added in 3.2.12). ticks!! like a clock but for scrolling.
  • integer_y β€” a Sint32, the amount scrolled vertically, accumulated to whole scroll "ticks" (added in 3.2.12). matching set, obviously.
πŸ’‘ gentle reminder: x and y are the smooth float vibes, and integer_x / integer_y are the accumulated whole-"tick" versions. both are here. both matter. don't make me choose favorites.

🌈 AVAILABILITY 🌈

this struct has been available since SDL 3.2.0. periodt. ✨


and that's the whole page, bestie β€” written by the Simple Directmedia Layer girlies, from SDL 3.4.18. now go forth and scroll responsibly. πŸ’…πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from