SDL_HintCallback(3type)
π SDL_HintCallback π
okay so bestie, welcome to the SDL3 DATATYPES corner of the manual, and today's main character is SDL_HintCallback β the little function-pointer glow-up that lets you get pinged every time a hint value changes. yes, we're doing callbacks. no, it's not scary. i promise. π«Ά
β¨ NAME β¨
SDL_HintCallback β a callback used to send notifications of hint value changes. it's giving "call me when things change" but, like, in C. π
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_hints.h>
typedef void(SDLCALL *SDL_HintCallback)(void *userdata, const char *name, const char *oldValue, const char *newValue);
that's the whole signature, bestie. four params, no return value, SDLCALL right there in the middle like the icon it is. π
π¦ DESCRIPTION π¦
so here's the tea: this callback gets called an initial time during SDL_AddHintCallback, handing you the hint's current value. after that, it fires again each time the hint's value changes. π₯
and listen β in that very first call, the current value is sitting in both oldValue and newValue. like, both. same value. twice. that's not a bug, that's just the vibe. don't @ me. π
π FUNCTION PARAMETERS π
userdataβ literally just whatever you passed asuserdatatoSDL_AddHintCallback(). it comes right back to you. bestie behavior. πnameβ what you passed asnametoSDL_AddHintCallback(). the hint's name, hand-delivered.oldValueβ the previous hint value. the before pic. πΈnewValueβ the new value the hint is to be set to. the after pic. β¨
π§ THREAD SAFETY π§
lowkey important, so pay attention: this callback is fired from whatever thread is setting a new hint value. π
and SDL holds a lock on the hint subsystem while calling this callback. so yes, there's a lock. respect the lock. π
β AVAILABILITY β
this datatype has been available since SDL 3.2.0. so if you're on something olderβ¦ babe, upgrade. π
π SEE ALSO π
okay that's the whole page, bestie, you ate that π go forth and register your callbacks. this iconic little writeup came to you courtesy of Simple Directmedia Layer for SDL 3.4.18 β mwah, talk later πβ¨π
π¦ 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