SDL_JoyDeviceEvent(3type)
π SDL_JoyDeviceEvent β like, the joystick device event struct π
okay so bestie, welcome to the SDL3 DATATYPES corner of the manual, page SDL_JoyDeviceEvent(3type). this one is short and sweet and it's giving "tiny struct, big feelings". let's get into it π«Ά
β¨ NAME β¨
SDL_JoyDeviceEvent β the joystick device event structure, aka the whole event.jdevice.* situation π
π SYNOPSIS π
#include <SDL3/SDL_events.h>
typedef struct SDL_JoyDeviceEvent
{
SDL_EventType type; /**< SDL_EVENT_JOYSTICK_ADDED or SDL_EVENT_JOYSTICK_REMOVED or SDL_EVENT_JOYSTICK_UPDATE_COMPLETE */
Uint32 reserved;
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
SDL_JoystickID which; /**< The joystick instance id */
} SDL_JoyDeviceEvent;
no cap, that's the whole thing. four fields, zero drama πΈ
π DESCRIPTION π
okay so the vibe here: SDL will send JOYSTICK_ADDED events for devices that are already plugged in during SDL_Init. literally β if your controller was already chilling in the USB port before you even called SDL_Init, SDL is NOT gonna pretend it doesn't exist. it sends the event. iconic behaviour tbh π₯
so if you're sitting there like "why am I getting an added event for something that was already added", that's why. it's intentional. it's the main character move. periodt β¨
π AVAILABILITY π
this struct has been around since SDL 3.2.0. so if you're on anything older, sorry bestie, she's not there π
π¦ SEE ALSO π¦
SDL_GamepadDeviceEvent(3type)β the gamepad-flavoured sibling, go say hi π
heads up bestie: thetimestampis in nanoseconds and gets populated usingSDL_GetTicksNS(), andwhichis the joystick instance id β don't skip those, they're the whole point π
okay that's the page!! this was brought to you by the fine people at Simple Directmedia Layer, and it's from SDL 3.4.18. mwah, go forth and handle your events ππβ¨
π¦ 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