SDL_AttachVirtualJoystick - Man Page
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
- desc
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)
Referenced By
SDL_DetachVirtualJoystick(3), SDL_VirtualJoystickDesc.3type(3).