Scroll to navigation

SDL_AttachVirtualJoystick(3) SDL3 FUNCTIONS SDL_AttachVirtualJoystick(3)

NAME

SDL_AttachVirtualJoystick - Attach a new virtual joystick.

SYNOPSIS

#include <SDL3/SDL_joystick.h>
SDL_JoystickID SDL_AttachVirtualJoystick(const SDL_VirtualJoystickDesc *desc);

DESCRIPTION

Apps can create virtual joysticks, that exist without hardware directly backing them, and have program-supplied inputs. Once attached, a virtual joystick looks like any other joystick that SDL can access. These can be used to make other things look like joysticks, or provide pre-recorded input, etc.

Once attached, the app can send joystick inputs to the new virtual joystick using SDL_SetJoystickVirtualAxis(), etc.

When no longer needed, the virtual joystick can be removed by calling SDL_DetachVirtualJoystick().

FUNCTION PARAMETERS

joystick description, initialized using SDL_INIT_INTERFACE().

RETURN VALUE

Returns the joystick instance ID, or 0 on failure; call SDL_GetError() for more information.

THREAD SAFETY

It is safe to call this function from any thread.

AVAILABILITY

This function is available since SDL 3.2.0.

SEE ALSO

SDL_DetachVirtualJoystick(3), SDL_SetJoystickVirtualAxis(3), SDL_SetJoystickVirtualButton(3), SDL_SetJoystickVirtualBall(3), SDL_SetJoystickVirtualHat(3), SDL_SetJoystickVirtualTouchpad(3), SDL_SetJoystickVirtualSensorData(3)

SDL 3.3.0 Simple Directmedia Layer