SDL_GetSensors(3)

πŸ’– SDL_GetSensors πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, this one's called SDL_GetSensors and it's literally your little headcount for every sensor currently vibing with your machine πŸŽ€


✨ NAME ✨

SDL_GetSensors β€” get a list of currently connected sensors. that's it, that's the whole job, and she does it flawlessly πŸ’…


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_sensor.h>

SDL_SensorID * SDL_GetSensors(int *count);

like. look at her. one include, one function, zero drama πŸ¦‹


🫢 FUNCTION PARAMETERS 🫢

  • count β€” a pointer that gets filled in with the number of sensors returned. and yes, she's chill, this one may be NULL if you don't care about the count. no pressure, no judgement, we love a low-stakes parameter πŸ’œ

πŸ‘‘ RETURN VALUE πŸ‘‘

Returns a 0 terminated array of sensor instance IDs. slay. πŸŽ‰

But listen β€” if things go sideways it returns NULL on failure, and then you gotta call SDL_GetError() for more information, because she will not be telling you what went wrong directly, you have to go ask 😭

🚨 IMPORTANT BESTIE ALERT 🚨 β€” this array is yours to free with SDL_free() when it is no longer needed. do not just walk away from it. free your girl. she deserves peace. 🌈

⭐ AVAILABILITY ⭐

This function is available since SDL 3.2.0. so if you're on anything older, sorry babe, it's giving "not yet" πŸ’€


and that's the whole page, you ate it, go forth and enumerate your sensors responsibly 🧚✨

this has been your girl from Simple Directmedia Layer, running the SDL 3.4.18 era, signing off with the same energy as always β€” stay iconic, free your arrays, and don't forget to check SDL_GetError() when the vibes go wrong πŸ’–πŸŽ€πŸ¦‹πŸ’…

πŸ“¦ where this page comes from