SDL_PenButtonEvent(3type)

πŸ’– SDL_PenButtonEvent β€” bestie, it's the pen button event struct πŸ’–

okay so real quick, this page is SDL_PenButtonEvent(3type) from the SDL3 datatypes crew, and it's all about the lil buttons on your pen itself. yes, the pen has buttons. no cap. let's get into it πŸ–ŠοΈβœ¨


✨ NAME ✨

SDL_PenButtonEvent β€” the pressure-sensitive pen button event structure, aka event.pbutton.* πŸŽ€


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_events.h>

typedef struct SDL_PenButtonEvent
{
    SDL_EventType type; /**< SDL_EVENT_PEN_BUTTON_DOWN or SDL_EVENT_PEN_BUTTON_UP */
    Uint32 reserved;
    Uint64 timestamp;   /**< In nanoseconds, populated using SDL_GetTicksNS() */
    SDL_WindowID windowID; /**< The window with mouse focus, if any */
    SDL_PenID which;        /**< The pen instance id */
    SDL_PenInputFlags pen_state;   /**< Complete pen input state at time of event */
    float x;                /**< X coordinate, relative to window */
    float y;                /**< Y coordinate, relative to window */
    Uint8 button;       /**< The pen button index (first button is 1). */
    bool down;      /**< true if the button is pressed */
    SDL_PenDeviceType device_type; /**< the device type of the pen, if known (added in 3.4.18). */
} SDL_PenButtonEvent;

πŸ¦‹ DESCRIPTION πŸ¦‹

so this one is for the buttons that live on the pen itself β€” the ones your finger goes click on, yk? that's what this struct is for πŸ’…

but here's the plot twist, bestie: when you press the pen down to draw, that's not this event. that one is SDL_EVENT_PEN_DOWN. totally different vibe. the way these two are always getting confused... πŸ™ˆ

do not mix them up. drawing-down β‰  button-click. two separate events, two separate structs. periodt.

⭐ AVAILABILITY ⭐

this struct has been serving since SDL 3.2.0. iconic behavior honestly πŸ‘‘


that's the whole page fr fr 🫢 this came to you from the fine folks at Simple Directmedia Layer, running SDL 3.4.18 β€” and yeah the footer's date slot was looking a lil empty ngl, so just picture a sparkly timestamp there πŸŽ€βœ¨ bye bestie, go make some pen buttons pop! πŸ’–πŸ¦‹

πŸ“¦ where this page comes from