SDL_GamepadSensorEvent(3type)
๐ SDL_GamepadSensorEvent โ bestie, it's a 3type and it's iconic
okay so first things first: the manual page is called SDL_GamepadSensorEvent(3type), and it lives in the SDL3 DATATYPES section of the manual. yes we're reading a datatype page. yes it's gonna be fun. buckle up ๐
โจ NAME โจ
SDL_GamepadSensorEvent โ the Gamepad sensor event structure, aka event.gsensor.*
like. that's the whole vibe. when your gamepad's lil sensors go brrr, this is the struct that shows up to the party ๐
๐ธ SYNOPSIS ๐ธ
pull it in with:
#include <SDL3/SDL_events.h>
and here's the whole struct, verbatim, no edits, no notes, no cap:
typedef struct SDL_GamepadSensorEvent
{
SDL_EventType type; /**< SDL_EVENT_GAMEPAD_SENSOR_UPDATE */
Uint32 reserved;
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
SDL_JoystickID which; /**< The joystick instance id */
Sint32 sensor; /**< The type of the sensor, one of the values of SDL_SensorType */
float data[3]; /**< Up to 3 values from the sensor, as defined in SDL_sensor.h */
Uint64 sensor_timestamp; /**< The timestamp of the sensor reading in nanoseconds, not necessarily synchronized with the system clock */
} SDL_GamepadSensorEvent;
let's do a lil tour of the members, because every single one of them matters and I am not skipping any ๐ซถ
typeโ it's anSDL_EventType, and it's literallySDL_EVENT_GAMEPAD_SENSOR_UPDATE. that's the whole personality. when you see this type, you know a sensor just spoke up โจreservedโ aUint32sitting there being mysterious. don't touch it, don't ask it questions, it's reserved bestie ๐timestampโ aUint64, measured in nanoseconds, populated usingSDL_GetTicksNS(). that's your "when did this event happen" clock โฐwhichโ anSDL_JoystickID, and it's the joystick instance id. which gamepad was it? this one. ๐ฎsensorโ aSint32holding the type of the sensor, and it's one of the values ofSDL_SensorType. so like, which sensor is yapping ๐ฃdata[3]โ an array offloat, up to 3 values from the sensor, as defined inSDL_sensor.h. up to three!! not guaranteed three!! ๐sensor_timestampโ aUint64, the timestamp of the sensor reading in nanoseconds, and > heads up: it is not necessarily synchronized with the system clock. so don't go comparing it totimestamplike they're the same clock, because they might not be, and that's just how it is ๐ญ
๐ AVAILABILITY ๐
this struct has been available since SDL 3.2.0. so if you're on something older... girl. upgrade. ๐ฆ
๐ one last thing
that's the whole page, no more sections hiding under the bed, promise ๐ง
and a lil sign-off: this page comes to you from Simple Directmedia Layer, and the version on the tin is SDL 3.4.18. mwah, go read your sensor data responsibly ๐๐
๐ฆ 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