SDL API renaming: SDL_gamecontroller.h

SDL_gamecontroller.h has been renamed SDL_gamepad.h, and all APIs have been renamed to match.

Fixes https://github.com/libsdl-org/SDL/issues/6885
This commit is contained in:
Sam Lantinga 2022-12-27 09:46:24 -08:00
parent ab0c5cf07d
commit 659abc721a
73 changed files with 3890 additions and 3391 deletions

View file

@ -121,7 +121,7 @@ float HIDAPI_RemapVal(float val, float val_min, float val_max, float output_min,
static void HIDAPI_UpdateDeviceList(void);
static void HIDAPI_JoystickClose(SDL_Joystick *joystick);
static SDL_GameControllerType SDL_GetJoystickGameControllerProtocol(const char *name, Uint16 vendor, Uint16 product, int interface_number, int interface_class, int interface_subclass, int interface_protocol)
static SDL_GamepadType SDL_GetJoystickGameControllerProtocol(const char *name, Uint16 vendor, Uint16 product, int interface_number, int interface_class, int interface_subclass, int interface_protocol)
{
static const int LIBUSB_CLASS_VENDOR_SPEC = 0xFF;
static const int XB360_IFACE_SUBCLASS = 93;
@ -130,7 +130,7 @@ static SDL_GameControllerType SDL_GetJoystickGameControllerProtocol(const char *
static const int XBONE_IFACE_SUBCLASS = 71;
static const int XBONE_IFACE_PROTOCOL = 208;
SDL_GameControllerType type = SDL_CONTROLLER_TYPE_UNKNOWN;
SDL_GamepadType type = SDL_GAMEPAD_TYPE_UNKNOWN;
/* This code should match the checks in libusb/hid.c and HIDDeviceManager.java */
if (interface_class == LIBUSB_CLASS_VENDOR_SPEC &&
@ -169,7 +169,7 @@ static SDL_GameControllerType SDL_GetJoystickGameControllerProtocol(const char *
int i;
for (i = 0; i < SDL_arraysize(SUPPORTED_VENDORS); ++i) {
if (vendor == SUPPORTED_VENDORS[i]) {
type = SDL_CONTROLLER_TYPE_XBOX360;
type = SDL_GAMEPAD_TYPE_XBOX360;
break;
}
}
@ -195,14 +195,14 @@ static SDL_GameControllerType SDL_GetJoystickGameControllerProtocol(const char *
int i;
for (i = 0; i < SDL_arraysize(SUPPORTED_VENDORS); ++i) {
if (vendor == SUPPORTED_VENDORS[i]) {
type = SDL_CONTROLLER_TYPE_XBOXONE;
type = SDL_GAMEPAD_TYPE_XBOXONE;
break;
}
}
}
if (type == SDL_CONTROLLER_TYPE_UNKNOWN) {
type = SDL_GetJoystickGameControllerTypeFromVIDPID(vendor, product, name, SDL_FALSE);
if (type == SDL_GAMEPAD_TYPE_UNKNOWN) {
type = SDL_GetGamepadTypeFromVIDPID(vendor, product, name, SDL_FALSE);
}
return type;
}
@ -210,7 +210,7 @@ static SDL_GameControllerType SDL_GetJoystickGameControllerProtocol(const char *
static SDL_bool HIDAPI_IsDeviceSupported(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name)
{
int i;
SDL_GameControllerType type = SDL_GetJoystickGameControllerProtocol(name, vendor_id, product_id, -1, 0, 0, 0);
SDL_GamepadType type = SDL_GetJoystickGameControllerProtocol(name, vendor_id, product_id, -1, 0, 0, 0);
for (i = 0; i < SDL_arraysize(SDL_HIDAPI_drivers); ++i) {
SDL_HIDAPI_DeviceDriver *driver = SDL_HIDAPI_drivers[i];
@ -1016,13 +1016,13 @@ static SDL_bool HIDAPI_IsEquivalentToDevice(Uint16 vendor_id, Uint16 product_id,
/* If we're looking for the raw input Xbox One controller, match it against any other Xbox One controller */
if (product_id == USB_PRODUCT_XBOX_ONE_XBOXGIP_CONTROLLER &&
device->type == SDL_CONTROLLER_TYPE_XBOXONE) {
device->type == SDL_GAMEPAD_TYPE_XBOXONE) {
return SDL_TRUE;
}
/* If we're looking for an XInput controller, match it against any other Xbox controller */
if (product_id == USB_PRODUCT_XBOX_ONE_XINPUT_CONTROLLER) {
if (device->type == SDL_CONTROLLER_TYPE_XBOX360 || device->type == SDL_CONTROLLER_TYPE_XBOXONE) {
if (device->type == SDL_GAMEPAD_TYPE_XBOX360 || device->type == SDL_GAMEPAD_TYPE_XBOXONE) {
return SDL_TRUE;
}
}
@ -1031,7 +1031,7 @@ static SDL_bool HIDAPI_IsEquivalentToDevice(Uint16 vendor_id, Uint16 product_id,
if (vendor_id == USB_VENDOR_NVIDIA) {
/* If we're looking for the NVIDIA SHIELD controller Xbox interface, match it against any NVIDIA SHIELD controller */
if (product_id == 0xb400 &&
device->type == SDL_CONTROLLER_TYPE_NVIDIA_SHIELD) {
device->type == SDL_GAMEPAD_TYPE_NVIDIA_SHIELD) {
return SDL_TRUE;
}
}
@ -1039,7 +1039,7 @@ static SDL_bool HIDAPI_IsEquivalentToDevice(Uint16 vendor_id, Uint16 product_id,
}
SDL_bool
HIDAPI_IsDeviceTypePresent(SDL_GameControllerType type)
HIDAPI_IsDeviceTypePresent(SDL_GamepadType type)
{
SDL_HIDAPI_Device *device;
SDL_bool result = SDL_FALSE;
@ -1139,11 +1139,11 @@ HIDAPI_GetJoystickTypeFromGUID(SDL_JoystickGUID guid)
return type;
}
SDL_GameControllerType
HIDAPI_GetGameControllerTypeFromGUID(SDL_JoystickGUID guid)
SDL_GamepadType
HIDAPI_GetGamepadTypeFromGUID(SDL_JoystickGUID guid)
{
SDL_HIDAPI_Device *device;
SDL_GameControllerType type = SDL_CONTROLLER_TYPE_UNKNOWN;
SDL_GamepadType type = SDL_GAMEPAD_TYPE_UNKNOWN;
SDL_LockJoysticks();
for (device = SDL_HIDAPI_devices; device; device = device->next) {