mirror of
https://github.com/encounter/SDL.git
synced 2025-12-09 21:47:44 +00:00
First pass at extending virtual controller functionality
Added the ability to specify a name and the product VID/PID for a virtual controller Also added a test case to testgamecontroller, if you pass --virtual as a parameter
This commit is contained in:
@@ -348,6 +348,44 @@ extern DECLSPEC int SDLCALL SDL_JoystickAttachVirtual(SDL_JoystickType type,
|
||||
int nbuttons,
|
||||
int nhats);
|
||||
|
||||
/**
|
||||
* The structure that defines an extended virtual joystick description
|
||||
*
|
||||
* The caller must zero the structure and then initialize the version with `SDL_VIRTUAL_JOYSTICK_DESC_VERSION` before passing it to SDL_JoystickAttachVirtualEx()
|
||||
*
|
||||
* \sa SDL_JoystickAttachVirtualEx
|
||||
*/
|
||||
typedef struct SDL_VirtualJoystickDesc
|
||||
{
|
||||
Uint16 version; /**< `SDL_VIRTUAL_JOYSTICK_DESC_VERSION` */
|
||||
Uint16 type; /**< `SDL_JoystickType` */
|
||||
Uint16 naxes; /**< the number of axes on this joystick */
|
||||
Uint16 nbuttons; /**< the number of buttons on this joystick */
|
||||
Uint16 nhats; /**< the number of hats on this joystick */
|
||||
Uint16 vendor_id; /**< the USB vendor ID of this joystick */
|
||||
Uint16 product_id; /**< the USB product ID of this joystick */
|
||||
Uint16 padding; /**< unused */
|
||||
const char *name; /**< the name of the joystick */
|
||||
|
||||
void *userdata; /**< User data pointer passed to callbacks */
|
||||
void (*Update)(void *userdata); /**< Called when the joystick state should be updated */
|
||||
|
||||
} SDL_VirtualJoystickDesc;
|
||||
|
||||
/**
|
||||
* \brief The current version of the SDL_VirtualJoystickDesc structure
|
||||
*/
|
||||
#define SDL_VIRTUAL_JOYSTICK_DESC_VERSION 1
|
||||
|
||||
/**
|
||||
* Attach a new virtual joystick with extended properties.
|
||||
*
|
||||
* \returns the joystick's device index, or -1 if an error occurred.
|
||||
*
|
||||
* \since This function is available since SDL 2.24.0.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickAttachVirtualEx(const SDL_VirtualJoystickDesc *desc);
|
||||
|
||||
/**
|
||||
* Detach a virtual joystick.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user