SDL_SETJOYSTICKVIRTUALTOUCHPAD(3)

✨ NAME ✨

SDL_SetJoystickVirtualTouchpad β€” bestie, this is the one that sets the touchpad finger state on an opened virtual joystick πŸ’…

(it lives in the SDL3 FUNCTIONS manual, if you were wondering where to find her πŸŽ€)


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_joystick.h>

bool SDL_SetJoystickVirtualTouchpad(SDL_Joystick *joystick, int touchpad, int finger, bool down, float x, float y, float pressure);

πŸ’– DESCRIPTION πŸ’–

okay so here's the tea, and it's important tea πŸ«–: the values you set with this function do not get applied right away. They're just sitting there, waiting, like a text you drafted but haven't sent yet 😭

They only actually land on the next call to SDL_UpdateJoysticks. And you can call that directly, OR it can get called indirectly through a bunch of other SDL APIs β€” including, but not limited to, these icons:

  • SDL_PollEvent
  • SDL_PumpEvents
  • SDL_WaitEventTimeout
  • SDL_WaitEvent

so like, if you're already pumping events, you might be updating your joysticks without even trying. main character energy fr fr ✨


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • joystick β€” the virtual joystick you're setting state on πŸ‘‘
  • touchpad β€” which touchpad on the virtual joystick you're updating (it's an index, bestie) πŸ¦‹
  • finger β€” which finger on the touchpad you're setting (also an index) πŸ’…
  • down β€” true if the finger is pressed, false if the finger is released πŸ™ˆ
  • x β€” the x coordinate of the finger on the touchpad, normalized 0 to 1, with the origin up in the upper left ⭐
  • y β€” the y coordinate of the finger on the touchpad, normalized 0 to 1, with the origin up in the upper left ⭐
  • pressure β€” the pressure of the finger, obviously πŸ’œ

🌈 RETURN VALUE 🌈

Returns true on success or false on failure 😭 and if it fails you gotta call SDL_GetError() for more info β€” that's where the actual explanation lives, so don't skip it.


🧚 THREAD SAFETY 🧚

It is safe to call this function from any thread. no cap. go wild, multithreaded queen πŸ‘‘


πŸ“ AVAILABILITY πŸ“

This function has been available since SDL 3.2.0 ✨ so if you're on something older, that's why it's giving nothing πŸ’€


πŸ’œ SEE ALSO πŸ’œ

the whole virtual joystick setter squad, obsessed with them honestly 🫢


and that's the page bestie!! brought to you by Simple Directmedia Layer, version SDL 3.4.18 🌸 you're welcome, go make something iconic with it πŸ’–πŸŽ€βœ¨

πŸ“¦ where this page comes from