SDL_PenMotionEvent(3type)
π SDL_PenMotionEvent β a datatype, bestie π
okay so this is from the SDL3 DATATYPES corner of the SDL3 manual, and it's literally the page for SDL_PenMotionEvent(3type). it's giving "pen goes wiggle, struct tells you about it". no cap. ποΈβ¨
πΈ NAME πΈ
SDL_PenMotionEvent β the pressure-sensitive pen motion event structure (you'll find it living at event.pmotion.*, iykyk) π
π¦ SYNOPSIS π¦
#include <SDL3/SDL_events.h>
typedef struct SDL_PenMotionEvent
{
SDL_EventType type; /**< SDL_EVENT_PEN_MOTION */
Uint32 reserved;
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
SDL_WindowID windowID; /**< The window with pen 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 */
SDL_PenDeviceType device_type; /**< the device type of the pen, if known (added in 3.4.18). */
} SDL_PenMotionEvent;
so yeah, that's the whole struct, verbatim, every field accounted for, we do not skip a single one here π
typeβ alwaysSDL_EVENT_PEN_MOTION, that's the whole personality of this event π«Άreservedβ reserved. don't touch it. it's not for you, bestie πtimestampβ in nanoseconds, populated usingSDL_GetTicksNS(). yes, nanoseconds, we're precise like that βwindowIDβ the window with pen focus, if any. "if any" is doing a lot of work there πwhichβ the pen instance id ποΈpen_stateβ the complete pen input state at time of event. the whole vibe check, captured in one field πxβ X coordinate, relative to window πyβ Y coordinate, relative to window πdevice_typeβ the device type of the pen, if known (added in3.4.18). lowkey a newer field, we love growth π
π DESCRIPTION π
okay so here's the tea β depending on the hardware, you may get motion events when the pen is not touching a tablet β that's for tracking a pen even when it isn't drawing. so like, the pen is hovering, being mysterious, main character energy, and you're still getting motion events. iconic honestly. β¨
so how do you know if the pen is actually "drawing"?? you should either:
- listen for
SDL_EVENT_PEN_DOWNandSDL_EVENT_PEN_UPevents, or - check
pen_state & SDL_PEN_INPUT_DOWN
either way, do that when you're dealing with pen motion. that's the move. periodt. π
ngl, don't just assume a motion event means the pen is down β the hardware might be tracking a hovering pen, and that's a whole different situation π«Ά
π AVAILABILITY π
This struct is available since SDL 3.2.0. yes bestie, it's been around, it's not new-new, it's just that one field that's newer π
that's the whole page, fr fr π thanks for reading to the end, you ate that. this was brought to you by Simple Directmedia Layer, version SDL 3.4.18, and yes the manual section is SDL_PenMotionEvent(3type) in case you need to cite your sources. slay, bye π¦πΈπ
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms