Attach a new virtual joystick.
Defined in <SDL3/SDL_joystick.h>
const SDL_VirtualJoystickDesc *desc); SDL_JoystickID SDL_AttachVirtualJoystick(
const SDL_VirtualJoystickDesc * | desc | joystick description, initialized using SDL_INIT_INTERFACE(). |
(SDL_JoystickID) Returns the joystick instance ID, or 0 on failure; call SDL_GetError() for more information.
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().
This function is available since SDL 3.2.0.