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 as userdata to SDL_AddHintCallback(). it comes right back to you. bestie behavior. πŸ’œ
  • name β€” what you passed as name to SDL_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