SDL_SendJoys...ualSensorData(3)
๐ SDL_SendJoystickVirtualSensorData ๐
okay bestie, welcome to the SDL3 FUNCTIONS manual, page SDL_SendJoys...ualSensorData(3) ๐ this one is literally all about sending a sensor update for an opened virtual joystick. no cap. let's get into it โจ
๐ธ NAME ๐ธ
SDL_SendJoystickVirtualSensorData โ Send a sensor update for an opened virtual joystick. that's the whole vibe, she does one thing and she does it slayfully ๐
๐ฆ SYNOPSIS ๐ฆ
#include <SDL3/SDL_joystick.h>
bool SDL_SendJoystickVirtualSensorData(SDL_Joystick *joystick, SDL_SensorType type, Uint64 sensor_timestamp, const float *data, int num_values);
look at her. iconic signature. ๐ซถ
โจ DESCRIPTION โจ
okay so this is the part where I have to be the responsible bestie and tell you something important, so listen up ๐
Please note that values set here will not be applied until the next call to SDL_UpdateJoysticks, which can either be called directly, or can be called indirectly through various other SDL APIs, including, but not limited to the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout, SDL_WaitEvent.
so basically you're dropping the data off and it sits there like "hi ๐" until one of those functions comes along and actually makes it real. it's giving โจdelayed gratificationโจ. plan accordingly, queen ๐
๐ FUNCTION PARAMETERS ๐
joystickโ the virtual joystick on which to set state. that's your girl, the one you're updating ๐ฎtypeโ the type of the sensor on the virtual joystick to update.SDL_SensorType, tell her what she is ๐ซsensor_timestampโ a 64-bit timestamp in nanoseconds associated with the sensor reading. nanoseconds bestie. NANO. โฑ๏ธdataโ the data associated with the sensor reading. the actual numbers, the lore ๐num_valuesโ the number of values pointed to bydata. count 'em, don't guess ๐ข
๐ RETURN VALUE ๐
Returns true on success or false on failure; call SDL_GetError() for more information.
so if it's false, don't panic, just hit up SDL_GetError() and she will tell you exactly what went wrong ๐ โ ๐
๐ง THREAD SAFETY ๐ง
It is safe to call this function from any thread.
not me being able to call this from literally anywhere ๐ญ multi-threaded main character energy, we love to see it ๐ฅ
๐ AVAILABILITY ๐
This function is available since SDL 3.2.0. so if you're on something older... girl. upgrade. ๐
โญ SEE ALSO โญ
SDL_SetJoystickVirtualAxis(3)SDL_SetJoystickVirtualButton(3)SDL_SetJoystickVirtualBall(3)SDL_SetJoystickVirtualHat(3)SDL_SetJoystickVirtualTouchpad(3)
the whole virtual joystick friend group ๐ซถ go say hi to all of them.
reminder bestie: the sensor data you send here is lowkey just chillin' until SDL_UpdateJoysticks (or one of her indirect besties) runs. don't come for me when nothing happens immediately, I warned you ๐๐
and that's the page!! brought to you by Simple Directmedia Layer, SDL 3.4.18, and this little corner of the SDL3 FUNCTIONS manual, SDL_SendJoys...ualSensorData(3). thanks for reading, ily, go update your joysticks ๐โจ๐
๐ฆ 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