mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-21 06:45:44 +00:00
Removed SDL_GAMEPAD_TYPE_VIRTUAL, SDL_GAMEPAD_TYPE_AMAZON_LUNA, SDL_GAMEPAD_TYPE_GOOGLE_STADIA, and SDL_GAMEPAD_TYPE_NVIDIA_SHIELD
Removing SDL_GAMEPAD_TYPE_VIRTUAL allows a virtual controller to emulate another gamepad type. The other controller types can be treated as generic controllers by applications without special glyph or functionality treatment.
This commit is contained in:
@@ -670,6 +670,20 @@ static GamepadMapping_t *SDL_CreateMappingForHIDAPIGamepad(SDL_JoystickGUID guid
|
||||
} else if (SDL_IsJoystickNintendoSwitchJoyConPair(vendor, product)) {
|
||||
/* The Nintendo Switch Joy-Con combined controllers has a share button and paddles */
|
||||
SDL_strlcat(mapping_string, "misc1:b15,paddle1:b16,paddle2:b17,paddle3:b18,paddle4:b19,", sizeof(mapping_string));
|
||||
} else if (SDL_IsJoystickAmazonLunaController(vendor, product)) {
|
||||
/* Amazon Luna Controller has a mic button under the guide button */
|
||||
SDL_strlcat(mapping_string, "misc1:b15,", sizeof(mapping_string));
|
||||
} else if (SDL_IsJoystickGoogleStadiaController(vendor, product)) {
|
||||
/* The Google Stadia controller has a share button and a Google Assistant button */
|
||||
SDL_strlcat(mapping_string, "misc1:b15,", sizeof(mapping_string));
|
||||
} else if (SDL_IsJoystickNVIDIASHIELDController(vendor, product)) {
|
||||
/* The NVIDIA SHIELD controller has a share button between back and start buttons */
|
||||
SDL_strlcat(mapping_string, "misc1:b15,", sizeof(mapping_string));
|
||||
|
||||
if (product == USB_PRODUCT_NVIDIA_SHIELD_CONTROLLER_V103) {
|
||||
/* The original SHIELD controller has a touchpad as well */
|
||||
SDL_strlcat(mapping_string, "touchpad:b16,", sizeof(mapping_string));
|
||||
}
|
||||
} else {
|
||||
switch (SDL_GetGamepadTypeFromGUID(guid, NULL)) {
|
||||
case SDL_GAMEPAD_TYPE_PS4:
|
||||
@@ -688,23 +702,6 @@ static GamepadMapping_t *SDL_CreateMappingForHIDAPIGamepad(SDL_JoystickGUID guid
|
||||
/* Nintendo Switch Pro controllers have a screenshot button */
|
||||
SDL_strlcat(mapping_string, "misc1:b15,", sizeof(mapping_string));
|
||||
break;
|
||||
case SDL_GAMEPAD_TYPE_AMAZON_LUNA:
|
||||
/* Amazon Luna Controller has a mic button under the guide button */
|
||||
SDL_strlcat(mapping_string, "misc1:b15,", sizeof(mapping_string));
|
||||
break;
|
||||
case SDL_GAMEPAD_TYPE_GOOGLE_STADIA:
|
||||
/* The Google Stadia controller has a share button and a Google Assistant button */
|
||||
SDL_strlcat(mapping_string, "misc1:b15,", sizeof(mapping_string));
|
||||
break;
|
||||
case SDL_GAMEPAD_TYPE_NVIDIA_SHIELD:
|
||||
/* The NVIDIA SHIELD controller has a share button between back and start buttons */
|
||||
SDL_strlcat(mapping_string, "misc1:b15,", sizeof(mapping_string));
|
||||
|
||||
if (product == USB_PRODUCT_NVIDIA_SHIELD_CONTROLLER_V103) {
|
||||
/* The original SHIELD controller has a touchpad as well */
|
||||
SDL_strlcat(mapping_string, "touchpad:b16,", sizeof(mapping_string));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (vendor == 0 && product == 0) {
|
||||
/* This is a Bluetooth Nintendo Switch Pro controller */
|
||||
|
||||
@@ -2289,13 +2289,6 @@ SDL_GamepadType SDL_GetGamepadTypeFromVIDPID(Uint16 vendor, Uint16 product, cons
|
||||
} else if (vendor == USB_VENDOR_MICROSOFT && product == USB_PRODUCT_XBOX_ONE_XINPUT_CONTROLLER) {
|
||||
type = SDL_GAMEPAD_TYPE_XBOXONE;
|
||||
|
||||
} else if ((vendor == USB_VENDOR_AMAZON && product == USB_PRODUCT_AMAZON_LUNA_CONTROLLER) ||
|
||||
(vendor == BLUETOOTH_VENDOR_AMAZON && product == BLUETOOTH_PRODUCT_LUNA_CONTROLLER)) {
|
||||
type = SDL_GAMEPAD_TYPE_AMAZON_LUNA;
|
||||
|
||||
} else if (vendor == USB_VENDOR_GOOGLE && product == USB_PRODUCT_GOOGLE_STADIA_CONTROLLER) {
|
||||
type = SDL_GAMEPAD_TYPE_GOOGLE_STADIA;
|
||||
|
||||
} else if (vendor == USB_VENDOR_NINTENDO && product == USB_PRODUCT_NINTENDO_SWITCH_JOYCON_LEFT) {
|
||||
type = SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT;
|
||||
|
||||
@@ -2317,11 +2310,6 @@ SDL_GamepadType SDL_GetGamepadTypeFromVIDPID(Uint16 vendor, Uint16 product, cons
|
||||
} else if (vendor == USB_VENDOR_NINTENDO && product == USB_PRODUCT_NINTENDO_SWITCH_JOYCON_PAIR) {
|
||||
type = SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR;
|
||||
|
||||
} else if (vendor == USB_VENDOR_NVIDIA &&
|
||||
(product == USB_PRODUCT_NVIDIA_SHIELD_CONTROLLER_V103 ||
|
||||
product == USB_PRODUCT_NVIDIA_SHIELD_CONTROLLER_V104)) {
|
||||
type = SDL_GAMEPAD_TYPE_NVIDIA_SHIELD;
|
||||
|
||||
} else {
|
||||
switch (GuessControllerType(vendor, product)) {
|
||||
case k_eControllerType_XBox360Controller:
|
||||
@@ -2376,9 +2364,6 @@ SDL_GamepadType SDL_GetGamepadTypeFromGUID(SDL_JoystickGUID guid, const char *na
|
||||
/* This is probably an Xbox One controller */
|
||||
return SDL_GAMEPAD_TYPE_XBOXONE;
|
||||
}
|
||||
if (SDL_IsJoystickVIRTUAL(guid)) {
|
||||
return SDL_GAMEPAD_TYPE_VIRTUAL;
|
||||
}
|
||||
#ifdef SDL_JOYSTICK_HIDAPI
|
||||
if (SDL_IsJoystickHIDAPI(guid)) {
|
||||
return HIDAPI_GetGamepadTypeFromGUID(guid);
|
||||
@@ -2545,6 +2530,24 @@ SDL_bool SDL_IsJoystickNintendoSwitchJoyConPair(Uint16 vendor_id, Uint16 product
|
||||
return vendor_id == USB_VENDOR_NINTENDO && product_id == USB_PRODUCT_NINTENDO_SWITCH_JOYCON_PAIR;
|
||||
}
|
||||
|
||||
SDL_bool SDL_IsJoystickAmazonLunaController(Uint16 vendor_id, Uint16 product_id)
|
||||
{
|
||||
return ((vendor_id == USB_VENDOR_AMAZON && product_id == USB_PRODUCT_AMAZON_LUNA_CONTROLLER) ||
|
||||
(vendor_id == BLUETOOTH_VENDOR_AMAZON && product_id == BLUETOOTH_PRODUCT_LUNA_CONTROLLER));
|
||||
}
|
||||
|
||||
SDL_bool SDL_IsJoystickGoogleStadiaController(Uint16 vendor_id, Uint16 product_id)
|
||||
{
|
||||
return vendor_id == USB_VENDOR_GOOGLE && product_id == USB_PRODUCT_GOOGLE_STADIA_CONTROLLER;
|
||||
}
|
||||
|
||||
SDL_bool SDL_IsJoystickNVIDIASHIELDController(Uint16 vendor_id, Uint16 product_id)
|
||||
{
|
||||
return (vendor_id == USB_VENDOR_NVIDIA &&
|
||||
(product_id == USB_PRODUCT_NVIDIA_SHIELD_CONTROLLER_V103 ||
|
||||
product_id == USB_PRODUCT_NVIDIA_SHIELD_CONTROLLER_V104));
|
||||
}
|
||||
|
||||
SDL_bool SDL_IsJoystickSteamController(Uint16 vendor_id, Uint16 product_id)
|
||||
{
|
||||
EControllerType eType = GuessControllerType(vendor_id, product_id);
|
||||
|
||||
@@ -111,6 +111,15 @@ extern SDL_bool SDL_IsJoystickNintendoSwitchJoyConRight(Uint16 vendor_id, Uint16
|
||||
extern SDL_bool SDL_IsJoystickNintendoSwitchJoyConGrip(Uint16 vendor_id, Uint16 product_id);
|
||||
extern SDL_bool SDL_IsJoystickNintendoSwitchJoyConPair(Uint16 vendor_id, Uint16 product_id);
|
||||
|
||||
/* Function to return whether a joystick is an Amazon Luna controller */
|
||||
extern SDL_bool SDL_IsJoystickAmazonLunaController(Uint16 vendor_id, Uint16 product_id);
|
||||
|
||||
/* Function to return whether a joystick is a Google Stadia controller */
|
||||
extern SDL_bool SDL_IsJoystickGoogleStadiaController(Uint16 vendor_id, Uint16 product_id);
|
||||
|
||||
/* Function to return whether a joystick is an NVIDIA SHIELD controller */
|
||||
extern SDL_bool SDL_IsJoystickNVIDIASHIELDController(Uint16 vendor_id, Uint16 product_id);
|
||||
|
||||
/* Function to return whether a joystick is a Steam Controller */
|
||||
extern SDL_bool SDL_IsJoystickSteamController(Uint16 vendor_id, Uint16 product_id);
|
||||
|
||||
|
||||
@@ -289,7 +289,7 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
|
||||
(is_ps5 && HIDAPI_IsDeviceTypePresent(SDL_GAMEPAD_TYPE_PS5)) ||
|
||||
(is_switch_pro && HIDAPI_IsDeviceTypePresent(SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_PRO)) ||
|
||||
(is_switch_joycon_pair && HIDAPI_IsDevicePresent(USB_VENDOR_NINTENDO, USB_PRODUCT_NINTENDO_SWITCH_JOYCON_PAIR, 0, "")) ||
|
||||
(is_stadia && HIDAPI_IsDeviceTypePresent(SDL_GAMEPAD_TYPE_GOOGLE_STADIA))) {
|
||||
(is_stadia && HIDAPI_IsDevicePresent(USB_VENDOR_GOOGLE, USB_PRODUCT_GOOGLE_STADIA_CONTROLLER, 0, ""))) {
|
||||
/* The HIDAPI driver is taking care of this device */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ static SDL_bool HIDAPI_DriverLuna_IsEnabled(void)
|
||||
|
||||
static SDL_bool HIDAPI_DriverLuna_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol)
|
||||
{
|
||||
return (type == SDL_GAMEPAD_TYPE_AMAZON_LUNA) ? SDL_TRUE : SDL_FALSE;
|
||||
return SDL_IsJoystickAmazonLunaController(vendor_id, product_id);
|
||||
}
|
||||
|
||||
static SDL_bool HIDAPI_DriverLuna_InitDevice(SDL_HIDAPI_Device *device)
|
||||
@@ -78,7 +78,6 @@ static SDL_bool HIDAPI_DriverLuna_InitDevice(SDL_HIDAPI_Device *device)
|
||||
}
|
||||
device->context = ctx;
|
||||
|
||||
device->type = SDL_GAMEPAD_TYPE_AMAZON_LUNA;
|
||||
HIDAPI_SetDeviceName(device, "Amazon Luna Controller");
|
||||
|
||||
return HIDAPI_JoystickConnected(device, NULL);
|
||||
|
||||
@@ -106,7 +106,7 @@ static SDL_bool HIDAPI_DriverShield_IsEnabled(void)
|
||||
|
||||
static SDL_bool HIDAPI_DriverShield_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol)
|
||||
{
|
||||
return (type == SDL_GAMEPAD_TYPE_NVIDIA_SHIELD) ? SDL_TRUE : SDL_FALSE;
|
||||
return SDL_IsJoystickNVIDIASHIELDController(vendor_id, product_id);
|
||||
}
|
||||
|
||||
static SDL_bool HIDAPI_DriverShield_InitDevice(SDL_HIDAPI_Device *device)
|
||||
@@ -120,7 +120,6 @@ static SDL_bool HIDAPI_DriverShield_InitDevice(SDL_HIDAPI_Device *device)
|
||||
}
|
||||
device->context = ctx;
|
||||
|
||||
device->type = SDL_GAMEPAD_TYPE_NVIDIA_SHIELD;
|
||||
HIDAPI_SetDeviceName(device, "NVIDIA SHIELD Controller");
|
||||
|
||||
return HIDAPI_JoystickConnected(device, NULL);
|
||||
|
||||
@@ -61,7 +61,7 @@ static SDL_bool HIDAPI_DriverStadia_IsEnabled(void)
|
||||
|
||||
static SDL_bool HIDAPI_DriverStadia_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol)
|
||||
{
|
||||
return (type == SDL_GAMEPAD_TYPE_GOOGLE_STADIA) ? SDL_TRUE : SDL_FALSE;
|
||||
return SDL_IsJoystickGoogleStadiaController(vendor_id, product_id);
|
||||
}
|
||||
|
||||
static SDL_bool HIDAPI_DriverStadia_InitDevice(SDL_HIDAPI_Device *device)
|
||||
@@ -84,7 +84,6 @@ static SDL_bool HIDAPI_DriverStadia_InitDevice(SDL_HIDAPI_Device *device)
|
||||
}
|
||||
}
|
||||
|
||||
device->type = SDL_GAMEPAD_TYPE_GOOGLE_STADIA;
|
||||
HIDAPI_SetDeviceName(device, "Google Stadia Controller");
|
||||
|
||||
return HIDAPI_JoystickConnected(device, NULL);
|
||||
|
||||
@@ -1176,7 +1176,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_GAMEPAD_TYPE_NVIDIA_SHIELD) {
|
||||
SDL_IsJoystickNVIDIASHIELDController(vendor_id, product_id)) {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user