SDL: joystick: SDL_VirtualJoystickDesc no longer takes a struct version.

From d252a8fe126b998bd1b0f4e4cf52312cd11de378 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Sat, 13 Apr 2024 14:15:16 -0400
Subject: [PATCH] joystick: SDL_VirtualJoystickDesc no longer takes a struct
 version.

If we need to extend this in the future, we'll make a second struct and
a second SDL_AttachVirtualJoystickEx-style function that uses it.

Just zero the struct and don't set a version.

Fixes #9489.
---
 docs/README-migration.md                   |  3 +++
 include/SDL3/SDL_joystick.h                | 14 +-------------
 src/joystick/SDL_joystick.c                |  1 -
 src/joystick/virtual/SDL_virtualjoystick.c |  4 ----
 test/testautomation_joystick.c             |  1 -
 test/testcontroller.c                      |  1 -
 6 files changed, 4 insertions(+), 20 deletions(-)

diff --git a/docs/README-migration.md b/docs/README-migration.md
index 64d53b8905d75..29c6ca37b1502 100644
--- a/docs/README-migration.md
+++ b/docs/README-migration.md
@@ -794,6 +794,8 @@ The functions SDL_GetJoysticks(), SDL_GetJoystickInstanceName(), SDL_GetJoystick
 
 SDL_AttachVirtualJoystick() and SDL_AttachVirtualJoystickEx() now return the joystick instance ID instead of a device index, and return 0 if there was an error.
 
+SDL_VirtualJoystickDesc no longer takes a struct version; if we need to extend this in the future, we'll make a second struct and a second SDL_AttachVirtualJoystickEx-style function that uses it. Just zero the struct and don't set a version.
+
 The following functions have been renamed:
 * SDL_JoystickAttachVirtual() => SDL_AttachVirtualJoystick()
 * SDL_JoystickAttachVirtualEx() => SDL_AttachVirtualJoystickEx()
@@ -855,6 +857,7 @@ The following functions have been removed:
 * SDL_JoystickNameForIndex() - replaced with SDL_GetJoystickInstanceName()
 * SDL_JoystickPathForIndex() - replaced with SDL_GetJoystickInstancePath()
 * SDL_NumJoysticks() - replaced with SDL_GetJoysticks()
+* SDL_VIRTUAL_JOYSTICK_DESC_VERSION - no longer needed, version info has been removed from SDL_VirtualJoystickDesc.
 
 The following symbols have been removed:
 * SDL_JOYBALLMOTION
diff --git a/include/SDL3/SDL_joystick.h b/include/SDL3/SDL_joystick.h
index 2d898e5bcdb64..321daf1259996 100644
--- a/include/SDL3/SDL_joystick.h
+++ b/include/SDL3/SDL_joystick.h
@@ -360,10 +360,7 @@ extern DECLSPEC SDL_JoystickID SDLCALL SDL_AttachVirtualJoystick(SDL_JoystickTyp
 /**
  * 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_AttachVirtualJoystickEx() All other elements of this structure are
- * optional and can be left 0.
+ * All other elements of this structure are optional and can be left 0.
  *
  * \since This struct is available since SDL 3.0.0.
  *
@@ -371,7 +368,6 @@ extern DECLSPEC SDL_JoystickID SDLCALL SDL_AttachVirtualJoystick(SDL_JoystickTyp
  */
 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 */
@@ -392,16 +388,8 @@ typedef struct SDL_VirtualJoystickDesc
     int (SDLCALL *RumbleTriggers)(void *userdata, Uint16 left_rumble, Uint16 right_rumble); /**< Implements SDL_RumbleJoystickTriggers() */
     int (SDLCALL *SetLED)(void *userdata, Uint8 red, Uint8 green, Uint8 blue); /**< Implements SDL_SetJoystickLED() */
     int (SDLCALL *SendEffect)(void *userdata, const void *data, int size); /**< Implements SDL_SendJoystickEffect() */
-
 } SDL_VirtualJoystickDesc;
 
-/**
- * The current version of the SDL_VirtualJoystickDesc structure.
- *
- * \since This macro is available since SDL 3.0.0.
- */
-#define SDL_VIRTUAL_JOYSTICK_DESC_VERSION   1
-
 /**
  * Attach a new virtual joystick with extended properties.
  *
diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c
index f0d4ad7180a9c..8882e58f7f9f7 100644
--- a/src/joystick/SDL_joystick.c
+++ b/src/joystick/SDL_joystick.c
@@ -1170,7 +1170,6 @@ SDL_JoystickID SDL_AttachVirtualJoystick(SDL_JoystickType type, int naxes, int n
     SDL_VirtualJoystickDesc desc;
 
     SDL_zero(desc);
-    desc.version = SDL_VIRTUAL_JOYSTICK_DESC_VERSION;
     desc.type = (Uint16)type;
     desc.naxes = (Uint16)naxes;
     desc.nbuttons = (Uint16)nbuttons;
diff --git a/src/joystick/virtual/SDL_virtualjoystick.c b/src/joystick/virtual/SDL_virtualjoystick.c
index f55da7f64252c..f6e1930819831 100644
--- a/src/joystick/virtual/SDL_virtualjoystick.c
+++ b/src/joystick/virtual/SDL_virtualjoystick.c
@@ -117,10 +117,6 @@ SDL_JoystickID SDL_JoystickAttachVirtualInner(const SDL_VirtualJoystickDesc *des
     if (!desc) {
         return SDL_InvalidParamError("desc");
     }
-    if (desc->version != SDL_VIRTUAL_JOYSTICK_DESC_VERSION) {
-        /* Is this an old version that we can support? */
-        return SDL_SetError("Unsupported virtual joystick description version %u", desc->version);
-    }
 
     hwdata = (joystick_hwdata *)SDL_calloc(1, sizeof(joystick_hwdata));
     if (!hwdata) {
diff --git a/test/testautomation_joystick.c b/test/testautomation_joystick.c
index b78770fee9464..226cc90228df1 100644
--- a/test/testautomation_joystick.c
+++ b/test/testautomation_joystick.c
@@ -28,7 +28,6 @@ static int TestVirtualJoystick(void *arg)
     SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
 
     SDL_zero(desc);
-    desc.version = SDL_VIRTUAL_JOYSTICK_DESC_VERSION;
     desc.type = SDL_JOYSTICK_TYPE_GAMEPAD;
     desc.naxes = SDL_GAMEPAD_AXIS_MAX;
     desc.nbuttons = SDL_GAMEPAD_BUTTON_MAX;
diff --git a/test/testcontroller.c b/test/testcontroller.c
index 5a14307118dcb..8c450ac6c3e91 100644
--- a/test/testcontroller.c
+++ b/test/testcontroller.c
@@ -1117,7 +1117,6 @@ static void OpenVirtualGamepad(void)
     }
 
     SDL_zero(desc);
-    desc.version = SDL_VIRTUAL_JOYSTICK_DESC_VERSION;
     desc.type = SDL_JOYSTICK_TYPE_GAMEPAD;
     desc.naxes = SDL_GAMEPAD_AXIS_MAX;
     desc.nbuttons = SDL_GAMEPAD_BUTTON_MAX;