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 by data. 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 โญ

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