SDL_SETRELATIVEMOUSETRANSFORM(3)

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

πŸ’– SDL_SetRelativeMouseTransform(3) πŸ’–

okay bestie, so we're in the SDL3 FUNCTIONS section of the manual and today's main character is SDL_SetRelativeMouseTransform 🐭✨ she's a little niche but she ATE.


🌸 NAME 🌸

SDL_SetRelativeMouseTransform β€” set a user-defined function by which to transform relative mouse inputs. like, you hand SDL a lil callback and it runs your mouse movement through it before it reaches you. custom mouse math, no cap πŸ’…


✨ SYNOPSIS ✨

#include <SDL3/SDL_mouse.h>

bool SDL_SetRelativeMouseTransform(SDL_MouseMotionTransformCallback callback, void *userdata);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so this one overrides the relative system scale and relative speed scale hints. yes, those hints. she said "I'll take it from here" πŸŽ€

and listen β€” you should be calling this prior to enabling relative mouse mode. if you don't, it fails. periodt. that's not a suggestion, that's the rules πŸ™ˆ


πŸ’œ FUNCTION PARAMETERS πŸ’œ

  • callback β€” a callback used to transform relative mouse motion, or NULL for default behavior. yeah, NULL is valid, that's the "never mind, do it the normal way" option 🫢
  • userdata β€” a pointer that will be passed to callback. your lil bundle of personal data, hand-delivered straight to your function. iconic behavior honestly πŸ’Œ

⭐ RETURN VALUE ⭐

Returns true on success or false on failure. and if it's a false? call SDL_GetError() for more information, because she WILL tell you what went wrong, just ask her nicely 😭


🌈 THREAD SAFETY 🌈

This function should only be called on the main thread. main character energy only, no side-quest threads allowed πŸ‘‘


πŸŽ€ AVAILABILITY πŸŽ€

This function is available since SDL 3.4.0. so if you're on something older... bestie, upgrade, it's giving ancient πŸ’€


lowkey reminder: this overrides the relative system scale and relative speed scale hints, and it fails if you call it after enabling relative mouse mode. do it in the right order and you're slaying ✨

Simple Directmedia Layer 🫢 SDL 3.4.18 πŸ¦‹ and yeah, this whole vibe was SDL_SetRelativeMouseTransform(3), that's the page, that's the girl, mwah πŸ’‹πŸŽ€πŸ’–

πŸ“¦ where this page comes from