SDL_GetPenDeviceType(3)

πŸ“¦
version 3.4.18 Β· 5 versions
, in fedora 43, fedora 44

✨ SDL_GetPenDeviceType ✨

okay bestie, so this one lives in the SDL3 functions fam, and it's literally just: tell me what kind of pen this is. that's it. that's the whole vibe. πŸ’…


πŸŽ€ NAME πŸŽ€

SDL_GetPenDeviceType β€” get the device type of the given pen. πŸ–ŠοΈβœ¨


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_pen.h>

SDL_PenDeviceType SDL_GetPenDeviceType(SDL_PenID instance_id);

πŸ¦‹ DESCRIPTION πŸ¦‹

so you wanna know what type of pen you're dealing with. iconic. but here's the tea, and it's important tea: many platforms do not supply this information. like, they just don't have it. not their fault, it's just how it is.

which means your app has to always be prepared to get an SDL_PEN_DEVICE_TYPE_UNKNOWN result back. not "maybe", not "in edge cases" β€” always. so don't you dare write code that assumes you'll get a real answer, because the platform might just shrug at you. πŸ™ˆ


πŸ’– FUNCTION PARAMETERS πŸ’–

  • instance_id β€” the pen instance ID. that's the little ID that tells you which pen we're talking about. πŸ–ŠοΈ

πŸ‘‘ RETURN VALUE πŸ‘‘

returns the device type of the given pen, slay. πŸŽ‰

but if it fails, you get SDL_PEN_DEVICE_TYPE_INVALID back instead β€” and when that happens, call SDL_GetError() for more info, because that's where the actual explanation is hiding. πŸ”


🧚 THREAD SAFETY 🧚

it is safe to call this function from any thread. go off, multithreaded queen. πŸ‘‘βœ¨


🌈 AVAILABILITY 🌈

this function is available since SDL 3.4.0. so if you're on something older... no it's not. upgrade bestie. πŸ’€


reminder reminder reminder: platforms be holding out on us, so always be ready for SDL_PEN_DEVICE_TYPE_UNKNOWN. your future self will thank you. 🫢

and that's the whole page, periodt. this lil' gem comes to you courtesy of Simple Directmedia Layer, version SDL 3.4.18, and it's filed under SDL_GetPenDeviceType(3) in the SDL3 functions section. mwah, go write some pen code. πŸ’œπŸŒΈ

πŸ“¦ where this page comes from