SDL_GetTouchDevices(3)

πŸ’– SDL_GetTouchDevices(3) πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, and today we're getting a list of registered touch devices. yes, all of them. the whole squad. let's go 🫢


🌸 NAME 🌸

SDL_GetTouchDevices β€” get a list of registered touch devices ✨


πŸŽ€ SYNOPSIS πŸŽ€

#include <SDL3/SDL_touch.h>

SDL_TouchID * SDL_GetTouchDevices(int *count);

like. that's the whole thing. one function. one pointer. one out-param. iconic behavior honestly πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the tea, and it's lowkey important: on some platforms SDL literally does not see a touch device until that device has actually been used. like it's shy?? it's not showing up until it touches something?? anyway.

so because of that, the list you get back might be empty even though devices are available. not a bug, just the vibe. the count only becomes correct after all the devices have been used at least once. so if you're sitting there like "bestie where are my devices 😭" β€” use them first, then ask again.


πŸ“ FUNCTION PARAMETERS πŸ“

  • count β€” a pointer that gets filled in with the number of devices returned. it may be NULL, so if you don't care how many there are, you can just pass NULL and mind your business πŸ’–

πŸ‘‘ RETURN VALUE πŸ‘‘

returns a 0 terminated array of touch device IDs. or NULL on failure β€” and if that happens, call SDL_GetError() for more info, she will tell you what went wrong.

⚠️ heads up bestie: this array should be freed with SDL_free() when it is no longer needed. do not leave it hanging. that's not the vibe. free your memory. periodt. πŸ’€

🌈 AVAILABILITY 🌈

this function is available since SDL 3.2.0. so if you're on anything older... nope, not for you, sorry 🧚


and that's the whole page, no cap. written up by Simple Directmedia Layer, version SDL 3.4.18, in the fine tradition of SDL_GetTouchDevices(3). go forth and enumerate your touches, bestie πŸ’…βœ¨πŸŒΈπŸ¦‹πŸŽ€

πŸ“¦ where this page comes from