SDL_VirtualJoystickDesc(3type)
SDL_VirtualJoystickDesc π
okay bestie, so this is a page from the SDL3 DATATYPES section of the SDL manual β it's a 3type page, which is just manpage-speak for "this documents a type, not a function". And the type in question? The struct that describes a virtual joystick. Yes. You can just make up a controller and SDL will believe you. main character energy fr fr. π
β¨ NAME β¨
SDL_VirtualJoystickDesc β the structure that describes a virtual joystick.
π SYNOPSIS π
#include <SDL3/SDL_joystick.h>
typedef struct SDL_VirtualJoystickDesc
{
Uint32 version; /**< the version of this interface */
Uint16 type; /**< `SDL_JoystickType` */
Uint16 padding; /**< unused */
Uint16 vendor_id; /**< the USB vendor ID of this joystick */
Uint16 product_id; /**< the USB product ID of this joystick */
Uint16 naxes; /**< the number of axes on this joystick */
Uint16 nbuttons; /**< the number of buttons on this joystick */
Uint16 nballs; /**< the number of balls on this joystick */
Uint16 nhats; /**< the number of hats on this joystick */
Uint16 ntouchpads; /**< the number of touchpads on this joystick, requires `touchpads` to point at valid descriptions */
Uint16 nsensors; /**< the number of sensors on this joystick, requires `sensors` to point at valid descriptions */
Uint16 padding2[2]; /**< unused */
Uint32 button_mask; /**< A mask of which buttons are valid for this controller
e.g. (1 << SDL_GAMEPAD_BUTTON_SOUTH) */
Uint32 axis_mask; /**< A mask of which axes are valid for this controller
e.g. (1 << SDL_GAMEPAD_AXIS_LEFTX) */
const char *name; /**< the name of the joystick */
const SDL_VirtualJoystickTouchpadDesc *touchpads; /**< A pointer to an array of touchpad descriptions, required if `ntouchpads` is > 0 */
const SDL_VirtualJoystickSensorDesc *sensors; /**< A pointer to an array of sensor descriptions, required if `nsensors` is > 0 */
void *userdata; /**< User data pointer passed to callbacks */
void (SDLCALL *Update)(void *userdata); /**< Called when the joystick state should be updated */
void (SDLCALL *SetPlayerIndex)(void *userdata, int player_index); /**< Called when the player index is set */
bool (SDLCALL *Rumble)(void *userdata, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble); /**< Implements SDL_RumbleJoystick() */
bool (SDLCALL *RumbleTriggers)(void *userdata, Uint16 left_rumble, Uint16 right_rumble); /**< Implements SDL_RumbleJoystickTriggers() */
bool (SDLCALL *SetLED)(void *userdata, Uint8 red, Uint8 green, Uint8 blue); /**< Implements SDL_SetJoystickLED() */
bool (SDLCALL *SendEffect)(void *userdata, const void *data, int size); /**< Implements SDL_SendJoystickEffect() */
bool (SDLCALL *SetSensorsEnabled)(void *userdata, bool enabled); /**< Implements SDL_SetGamepadSensorEnabled() */
void (SDLCALL *Cleanup)(void *userdata); /**< Cleans up the userdata when the joystick is detached */
} SDL_VirtualJoystickDesc;
π DESCRIPTION π
So like, plot twist: this whole structure should be initialized using SDL_INIT_INTERFACE(). Do that. Don't be the person who raw-dogs it. π«Ά
And the best part? All elements of this structure are optional. Every single one. It's giving "choose your own adventure" but for gamepads. Slay. β¨
π AVAILABILITY π
This struct has been around since SDL 3.2.0. vintage-ish but make it cunty. π¦
π SEE ALSO π
SDL_AttachVirtualJoystick(3)SDL_INIT_INTERFACE(3)SDL_VirtualJoystickSensorDesc(3type)SDL_VirtualJoystickTouchpadDesc(3type)
π reminder bestie: this page is literally the<pink>SDL3 DATATYPES</pink>section, page name<purple>SDL_VirtualJoystickDesc(3type)</purple>. iykyk.
okay that's the whole page, no cap. brought to you by Simple Directmedia Layer π, running SDL 3.4.18 β¨, and it's the SDL_VirtualJoystickDesc(3type) page so you KNOW where to find it again. periodt. π
ππΈ
π¦ 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