From ab2d0079823fe28a60128487f257c7143b597ba2 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 27 Dec 2022 11:31:54 -0800
Subject: [PATCH] More gamepad renaming
---
docs/README-migration.md | 3 +++
include/SDL3/SDL_joystick.h | 2 +-
include/SDL3/SDL_oldnames.h | 2 ++
src/joystick/SDL_gamepad.c | 26 +++++++++----------
src/joystick/SDL_joystick.c | 8 +++---
src/joystick/hidapi/SDL_hidapi_ps4.c | 4 +--
src/joystick/hidapi/SDL_hidapi_ps5.c | 4 +--
src/joystick/hidapi/SDL_hidapijoystick.c | 2 +-
src/joystick/virtual/SDL_virtualjoystick.c | 6 ++---
.../windows/SDL_windows_gaming_input.c | 2 +-
test/testautomation_joystick.c | 2 +-
test/testgamepad.c | 2 +-
test/testjoystick.c | 2 +-
13 files changed, 35 insertions(+), 30 deletions(-)
diff --git a/docs/README-migration.md b/docs/README-migration.md
index e72c90011735..3d229d8b503e 100644
--- a/docs/README-migration.md
+++ b/docs/README-migration.md
@@ -312,6 +312,9 @@ The following functions have been renamed:
* SDL_JoystickUpdate => SDL_UpdateJoysticks
* SDL_NumJoysticks => SDL_GetNumJoysticks
+The following symbols have been renamed:
+* SDL_JOYSTICK_TYPE_GAMECONTROLLER => SDL_JOYSTICK_TYPE_GAMEPAD
+
## SDL_keycode.h
The following symbols have been renamed:
diff --git a/include/SDL3/SDL_joystick.h b/include/SDL3/SDL_joystick.h
index c07e2d0703d7..97ef8be837cd 100644
--- a/include/SDL3/SDL_joystick.h
+++ b/include/SDL3/SDL_joystick.h
@@ -88,7 +88,7 @@ typedef Sint32 SDL_JoystickID;
typedef enum
{
SDL_JOYSTICK_TYPE_UNKNOWN,
- SDL_JOYSTICK_TYPE_GAMECONTROLLER,
+ SDL_JOYSTICK_TYPE_GAMEPAD,
SDL_JOYSTICK_TYPE_WHEEL,
SDL_JOYSTICK_TYPE_ARCADE_STICK,
SDL_JOYSTICK_TYPE_FLIGHT_STICK,
diff --git a/include/SDL3/SDL_oldnames.h b/include/SDL3/SDL_oldnames.h
index 5adc146eff9e..735e1460b569 100644
--- a/include/SDL3/SDL_oldnames.h
+++ b/include/SDL3/SDL_oldnames.h
@@ -182,6 +182,7 @@
#define SDL_IsGameController SDL_IsGamepad
/* ##SDL_joystick.h */
+#define SDL_JOYSTICK_TYPE_GAMECONTROLLER SDL_JOYSTICK_TYPE_GAMEPAD
#define SDL_JoystickAttachVirtual SDL_AttachVirtualJoystick
#define SDL_JoystickAttachVirtualEx SDL_AttachVirtualJoystickEx
#define SDL_JoystickClose SDL_CloseJoystick
@@ -506,6 +507,7 @@
#define SDL_IsGameController SDL_IsGameController_renamed_SDL_IsGamepad
/* ##SDL_joystick.h */
+#define SDL_JOYSTICK_TYPE_GAMECONTROLLER SDL_JOYSTICK_TYPE_GAMECONTROLLER_renamed_SDL_JOYSTICK_TYPE_GAMEPAD
#define SDL_JoystickAttachVirtual SDL_JoystickAttachVirtual_renamed_SDL_AttachVirtualJoystick
#define SDL_JoystickAttachVirtualEx SDL_JoystickAttachVirtualEx_renamed_SDL_AttachVirtualJoystickEx
#define SDL_JoystickClose SDL_JoystickClose_renamed_SDL_CloseJoystick
diff --git a/src/joystick/SDL_gamepad.c b/src/joystick/SDL_gamepad.c
index 302b0dc830f8..049a6857f1d1 100644
--- a/src/joystick/SDL_gamepad.c
+++ b/src/joystick/SDL_gamepad.c
@@ -142,7 +142,7 @@ struct SDL_Gamepad
#undef _guarded
-#define CHECK_GAMECONTROLLER_MAGIC(gamepad, retval) \
+#define CHECK_GAMEPAD_MAGIC(gamepad, retval) \
if (!gamepad || gamepad->magic != &gamepad_magic || \
!SDL_PrivateJoystickValid(gamepad->joystick)) { \
SDL_InvalidParamError("gamepad"); \
@@ -709,7 +709,7 @@ static ControllerMapping_t *SDL_CreateMappingForWGIController(SDL_JoystickGUID g
SDL_bool existing;
char mapping_string[1024];
- if (guid.data[15] != SDL_JOYSTICK_TYPE_GAMECONTROLLER) {
+ if (guid.data[15] != SDL_JOYSTICK_TYPE_GAMEPAD) {
return NULL;
}
@@ -1795,7 +1795,7 @@ char *SDL_GetGamepadMapping(SDL_Gamepad *gamepad)
SDL_LockJoysticks();
{
- CHECK_GAMECONTROLLER_MAGIC(gamepad, NULL);
+ CHECK_GAMEPAD_MAGIC(gamepad, NULL);
retval = CreateMappingString(gamepad->mapping, gamepad->joystick->guid);
}
@@ -2227,7 +2227,7 @@ SDL_bool SDL_GamepadHasAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis)
SDL_LockJoysticks();
{
- CHECK_GAMECONTROLLER_MAGIC(gamepad, SDL_FALSE);
+ CHECK_GAMEPAD_MAGIC(gamepad, SDL_FALSE);
bind = SDL_GetGamepadBindForAxis(gamepad, axis);
}
@@ -2247,7 +2247,7 @@ Sint16 SDL_GetGamepadAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis)
{
int i;
- CHECK_GAMECONTROLLER_MAGIC(gamepad, 0);
+ CHECK_GAMEPAD_MAGIC(gamepad, 0);
for (i = 0; i < gamepad->num_bindings; ++i) {
SDL_ExtendedGamepadBind *binding = &gamepad->bindings[i];
@@ -2310,7 +2310,7 @@ SDL_bool SDL_GamepadHasButton(SDL_Gamepad *gamepad, SDL_GamepadButton button)
SDL_LockJoysticks();
{
- CHECK_GAMECONTROLLER_MAGIC(gamepad, SDL_FALSE);
+ CHECK_GAMEPAD_MAGIC(gamepad, SDL_FALSE);
bind = SDL_GetGamepadBindForButton(gamepad, button);
}
@@ -2330,7 +2330,7 @@ Uint8 SDL_GetGamepadButton(SDL_Gamepad *gamepad, SDL_GamepadButton button)
{
int i;
- CHECK_GAMECONTROLLER_MAGIC(gamepad, 0);
+ CHECK_GAMEPAD_MAGIC(gamepad, 0);
for (i = 0; i < gamepad->num_bindings; ++i) {
SDL_ExtendedGamepadBind *binding = &gamepad->bindings[i];
@@ -2612,7 +2612,7 @@ const char *SDL_GetGamepadName(SDL_Gamepad *gamepad)
SDL_LockJoysticks();
{
- CHECK_GAMECONTROLLER_MAGIC(gamepad, NULL);
+ CHECK_GAMEPAD_MAGIC(gamepad, NULL);
if (SDL_strcmp(gamepad->name, "*") == 0) {
retval = SDL_GetJoystickName(gamepad->joystick);
@@ -2741,7 +2741,7 @@ SDL_Joystick *SDL_GetGamepadJoystick(SDL_Gamepad *gamepad)
SDL_LockJoysticks();
{
- CHECK_GAMECONTROLLER_MAGIC(gamepad, NULL);
+ CHECK_GAMEPAD_MAGIC(gamepad, NULL);
joystick = gamepad->joystick;
}
@@ -2800,7 +2800,7 @@ SDL_GamepadBinding SDL_GetGamepadBindForAxis(SDL_Gamepad *gamepad, SDL_GamepadAx
SDL_LockJoysticks();
{
- CHECK_GAMECONTROLLER_MAGIC(gamepad, bind);
+ CHECK_GAMEPAD_MAGIC(gamepad, bind);
if (axis != SDL_GAMEPAD_AXIS_INVALID) {
int i;
@@ -2838,7 +2838,7 @@ SDL_GamepadBinding SDL_GetGamepadBindForButton(SDL_Gamepad *gamepad, SDL_Gamepad
SDL_LockJoysticks();
{
- CHECK_GAMECONTROLLER_MAGIC(gamepad, bind);
+ CHECK_GAMEPAD_MAGIC(gamepad, bind);
if (button != SDL_GAMEPAD_BUTTON_INVALID) {
int i;
@@ -3171,7 +3171,7 @@ const char *SDL_GetGamepadAppleSFSymbolsNameForButton(SDL_Gamepad *gamepad, SDL_
SDL_LockJoysticks();
{
- CHECK_GAMECONTROLLER_MAGIC(gamepad, NULL);
+ CHECK_GAMEPAD_MAGIC(gamepad, NULL);
retval = IOS_GetAppleSFSymbolsNameForButton(gamepad, button);
}
@@ -3191,7 +3191,7 @@ const char *SDL_GetGamepadAppleSFSymbolsNameForAxis(SDL_Gamepad *gamepad, SDL_Ga
SDL_LockJoysticks();
{
- CHECK_GAMECONTROLLER_MAGIC(gamepad, NULL);
+ CHECK_GAMEPAD_MAGIC(gamepad, NULL);
retval = IOS_GetAppleSFSymbolsNameForAxis(gamepad, axis);
}
diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c
index e1854c3ae174..596077a21e2a 100644
--- a/src/joystick/SDL_joystick.c
+++ b/src/joystick/SDL_joystick.c
@@ -2468,7 +2468,7 @@ static SDL_JoystickType SDL_GetJoystickGUIDType(SDL_JoystickGUID guid)
/* XInput GUID, get the type based on the XInput device subtype */
switch (guid.data[15]) {
case 0x01: /* XINPUT_DEVSUBTYPE_GAMEPAD */
- return SDL_JOYSTICK_TYPE_GAMECONTROLLER;
+ return SDL_JOYSTICK_TYPE_GAMEPAD;
case 0x02: /* XINPUT_DEVSUBTYPE_WHEEL */
return SDL_JOYSTICK_TYPE_WHEEL;
case 0x03: /* XINPUT_DEVSUBTYPE_ARCADE_STICK */
@@ -2524,7 +2524,7 @@ static SDL_JoystickType SDL_GetJoystickGUIDType(SDL_JoystickGUID guid)
#endif /* SDL_JOYSTICK_HIDAPI */
if (GuessControllerType(vendor, product) != k_eControllerType_UnknownNonSteamController) {
- return SDL_JOYSTICK_TYPE_GAMECONTROLLER;
+ return SDL_JOYSTICK_TYPE_GAMEPAD;
}
return SDL_JOYSTICK_TYPE_UNKNOWN;
@@ -2735,7 +2735,7 @@ SDL_JoystickType SDL_GetJoystickDeviceType(int device_index)
type = SDL_GetJoystickGUIDType(guid);
if (type == SDL_JOYSTICK_TYPE_UNKNOWN) {
if (SDL_IsGamepad(device_index)) {
- type = SDL_JOYSTICK_TYPE_GAMECONTROLLER;
+ type = SDL_JOYSTICK_TYPE_GAMEPAD;
}
}
return type;
@@ -2858,7 +2858,7 @@ SDL_JoystickType SDL_GetJoystickType(SDL_Joystick *joystick)
CHECK_JOYSTICK_MAGIC(joystick, SDL_JOYSTICK_TYPE_UNKNOWN);
if (joystick->is_game_controller) {
- type = SDL_JOYSTICK_TYPE_GAMECONTROLLER;
+ type = SDL_JOYSTICK_TYPE_GAMEPAD;
}
}
SDL_UnlockJoysticks();
diff --git a/src/joystick/hidapi/SDL_hidapi_ps4.c b/src/joystick/hidapi/SDL_hidapi_ps4.c
index 6d72871365a2..da0eac6ab532 100644
--- a/src/joystick/hidapi/SDL_hidapi_ps4.c
+++ b/src/joystick/hidapi/SDL_hidapi_ps4.c
@@ -233,7 +233,7 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device)
Uint8 data[USB_PACKET_LENGTH];
int size;
char serial[18];
- SDL_JoystickType joystick_type = SDL_JOYSTICK_TYPE_GAMECONTROLLER;
+ SDL_JoystickType joystick_type = SDL_JOYSTICK_TYPE_GAMEPAD;
ctx = (SDL_DriverPS4_Context *)SDL_calloc(1, sizeof(*ctx));
if (ctx == NULL) {
@@ -332,7 +332,7 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device)
switch (device_type) {
case 0x00:
- joystick_type = SDL_JOYSTICK_TYPE_GAMECONTROLLER;
+ joystick_type = SDL_JOYSTICK_TYPE_GAMEPAD;
break;
case 0x01:
joystick_type = SDL_JOYSTICK_TYPE_GUITAR;
diff --git a/src/joystick/hidapi/SDL_hidapi_ps5.c b/src/joystick/hidapi/SDL_hidapi_ps5.c
index a35bb21bc7e3..b432bec7683e 100644
--- a/src/joystick/hidapi/SDL_hidapi_ps5.c
+++ b/src/joystick/hidapi/SDL_hidapi_ps5.c
@@ -345,7 +345,7 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device)
Uint8 data[USB_PACKET_LENGTH * 2];
int size;
char serial[18];
- SDL_JoystickType joystick_type = SDL_JOYSTICK_TYPE_GAMECONTROLLER;
+ SDL_JoystickType joystick_type = SDL_JOYSTICK_TYPE_GAMEPAD;
ctx = (SDL_DriverPS5_Context *)SDL_calloc(1, sizeof(*ctx));
if (ctx == NULL) {
@@ -451,7 +451,7 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device)
switch (device_type) {
case 0x00:
- joystick_type = SDL_JOYSTICK_TYPE_GAMECONTROLLER;
+ joystick_type = SDL_JOYSTICK_TYPE_GAMEPAD;
break;
case 0x01:
joystick_type = SDL_JOYSTICK_TYPE_GUITAR;
diff --git a/src/joystick/hidapi/SDL_hidapijoystick.c b/src/joystick/hidapi/SDL_hidapijoystick.c
index 74b42bd887b8..fdf7228fe815 100644
--- a/src/joystick/hidapi/SDL_hidapijoystick.c
+++ b/src/joystick/hidapi/SDL_hidapijoystick.c
@@ -781,7 +781,7 @@ static SDL_HIDAPI_Device *HIDAPI_AddDevice(const struct SDL_hid_device_info *inf
/* FIXME: Is there any way to tell whether this is a Bluetooth device? */
device->guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_USB, device->vendor_id, device->product_id, device->version, device->name, 'h', 0);
- device->joystick_type = SDL_JOYSTICK_TYPE_GAMECONTROLLER;
+ device->joystick_type = SDL_JOYSTICK_TYPE_GAMEPAD;
device->type = SDL_GetJoystickGameControllerProtocol(device->name, device->vendor_id, device->product_id, device->interface_number, device->interface_class, device->interface_subclass, device->interface_protocol);
if (num_children > 0) {
diff --git a/src/joystick/virtual/SDL_virtualjoystick.c b/src/joystick/virtual/SDL_virtualjoystick.c
index 3ba65b2b0139..aaabea8cabdd 100644
--- a/src/joystick/virtual/SDL_virtualjoystick.c
+++ b/src/joystick/virtual/SDL_virtualjoystick.c
@@ -120,7 +120,7 @@ int SDL_JoystickAttachVirtualInner(const SDL_VirtualJoystickDesc *desc)
name = hwdata->desc.name;
} else {
switch (hwdata->desc.type) {
- case SDL_JOYSTICK_TYPE_GAMECONTROLLER:
+ case SDL_JOYSTICK_TYPE_GAMEPAD:
name = "Virtual Controller";
break;
case SDL_JOYSTICK_TYPE_WHEEL:
@@ -154,7 +154,7 @@ int SDL_JoystickAttachVirtualInner(const SDL_VirtualJoystickDesc *desc)
}
hwdata->name = SDL_strdup(name);
- if (hwdata->desc.type == SDL_JOYSTICK_TYPE_GAMECONTROLLER) {
+ if (hwdata->desc.type == SDL_JOYSTICK_TYPE_GAMEPAD) {
int i, axis;
if (hwdata->desc.button_mask == 0) {
@@ -579,7 +579,7 @@ static SDL_bool VIRTUAL_JoystickGetGamepadMapping(int device_index, SDL_GamepadM
int current_button = 0;
int current_axis = 0;
- if (hwdata->desc.type != SDL_JOYSTICK_TYPE_GAMECONTROLLER) {
+ if (hwdata->desc.type != SDL_JOYSTICK_TYPE_GAMEPAD) {
return SDL_FALSE;
}
diff --git a/src/joystick/windows/SDL_windows_gaming_input.c b/src/joystick/windows/SDL_windows_gaming_input.c
index 029a5f98dd76..a646a538c15c 100644
--- a/src/joystick/windows/SDL_windows_gaming_input.c
+++ b/src/joystick/windows/SDL_windows_gaming_input.c
@@ -316,7 +316,7 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeAdde
boolean wireless;
if (wgi.gamepad_statics2 && SUCCEEDED(__x_ABI_CWindows_CGaming_CInput_CIGamepadStatics2_FromGameController(wgi.gamepad_statics2, gamecontroller, &gamepad)) && gamepad) {
- type = SDL_JOYSTICK_TYPE_GAMECONTROLLER;
+ type = SDL_JOYSTICK_TYPE_GAMEPAD;
__x_ABI_CWindows_CGaming_CInput_CIGamepad_Release(gamepad);
} else if (wgi.arcade_stick_statics2 && SUCCEEDED(__x_ABI_CWindows_CGaming_CInput_CIArcadeStickStatics2_FromGameController(wgi.arcade_stick_statics2, gamecontroller, &arcade_stick)) && arcade_stick) {
type = SDL_JOYSTICK_TYPE_ARCADE_STICK;
diff --git a/test/testautomation_joystick.c b/test/testautomation_joystick.c
index 97f92b0b822e..bb7589f32f88 100644
--- a/test/testautomation_joystick.c
+++ b/test/testautomation_joystick.c
@@ -26,7 +26,7 @@ TestVirtualJoystick(void *arg)
SDL_zero(desc);
desc.version = SDL_VIRTUAL_JOYSTICK_DESC_VERSION;
- desc.type = SDL_JOYSTICK_TYPE_GAMECONTROLLER;
+ desc.type = SDL_JOYSTICK_TYPE_GAMEPAD;
desc.naxes = SDL_GAMEPAD_AXIS_MAX;
desc.nbuttons = SDL_GAMEPAD_BUTTON_MAX;
desc.vendor_id = USB_VENDOR_NVIDIA;
diff --git a/test/testgamepad.c b/test/testgamepad.c
index b4ee96959303..6057d4d94640 100644
--- a/test/testgamepad.c
+++ b/test/testgamepad.c
@@ -392,7 +392,7 @@ static void OpenVirtualGamepad()
SDL_zero(desc);
desc.version = SDL_VIRTUAL_JOYSTICK_DESC_VERSION;
- desc.type = SDL_JOYSTICK_TYPE_GAMECONTROLLER;
+ desc.type = SDL_JOYSTICK_TYPE_GAMEPAD;
desc.naxes = SDL_GAMEPAD_AXIS_MAX;
desc.nbuttons = SDL_GAMEPAD_BUTTON_MAX;
desc.SetPlayerIndex = VirtualGamepadSetPlayerIndex;
diff --git a/test/testjoystick.c b/test/testjoystick.c
index a94d5370b012..c1f92f0352b5 100644
--- a/test/testjoystick.c
+++ b/test/testjoystick.c
@@ -43,7 +43,7 @@ PrintJoystick(SDL_Joystick *joy)
SDL_assert(SDL_GetJoystickFromInstanceID(SDL_GetJoystickInstanceID(joy)) == joy);
SDL_GetJoystickGUIDString(SDL_GetJoystickGUID(joy), guid, sizeof(guid));
switch (SDL_GetJoystickType(joy)) {
- case SDL_JOYSTICK_TYPE_GAMECONTROLLER:
+ case SDL_JOYSTICK_TYPE_GAMEPAD:
type = "Game Controller";
break;
case SDL_JOYSTICK_TYPE_WHEEL: