Fixed build

This commit is contained in:
Sam Lantinga 2019-11-22 14:09:24 -08:00
parent 13006ba9e1
commit 733f25252a
8 changed files with 20 additions and 27 deletions

View File

@ -1418,8 +1418,7 @@ SDL_GameControllerNameForIndex(int device_index)
SDL_GameControllerType
SDL_GameControllerTypeForIndex(int joystick_index)
{
SDL_JoystickGUID guid = SDL_JoystickGetDeviceGUID(joystick_index);
return SDL_GetGameControllerTypeFromGUID(guid);
return SDL_GetJoystickGameControllerTypeFromGUID(SDL_JoystickGetDeviceGUID(joystick_index), SDL_JoystickNameForIndex(joystick_index));
}
@ -1757,10 +1756,7 @@ SDL_GameControllerName(SDL_GameController * gamecontroller)
SDL_GameControllerType
SDL_GameControllerGetType(SDL_GameController *gamecontroller)
{
if (!gamecontroller) {
return SDL_CONTROLLER_TYPE_UNKNOWN;
}
return SDL_GetGameControllerTypeFromGUID(gamecontroller->joystick->guid);
return SDL_GetJoystickGameControllerTypeFromGUID(SDL_JoystickGetGUID(SDL_GameControllerGetJoystick(gamecontroller)), SDL_JoystickName(SDL_GameControllerGetJoystick(gamecontroller)));
}
int

View File

@ -1167,13 +1167,13 @@ SDL_IsJoystickNintendoSwitchPro(Uint16 vendor, Uint16 product)
}
SDL_GameControllerType
SDL_GetGameControllerTypeFromGUID(SDL_JoystickGUID guid)
SDL_GetJoystickGameControllerTypeFromGUID(SDL_JoystickGUID guid, const char *name)
{
SDL_GameControllerType type;
Uint16 vendor, product;
SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL);
type = SDL_GetGameControllerType(vendor, product);
type = SDL_GetJoystickGameControllerType(vendor, product, name);
if (type == SDL_CONTROLLER_TYPE_UNKNOWN) {
if (SDL_IsJoystickXInput(guid)) {
/* This is probably an Xbox One controller */
@ -1184,10 +1184,16 @@ SDL_GetGameControllerTypeFromGUID(SDL_JoystickGUID guid)
}
SDL_GameControllerType
SDL_GetGameControllerType(Uint16 vendor, Uint16 product)
SDL_GetJoystickGameControllerType(Uint16 vendor, Uint16 product, const char *name)
{
/* Filter out some bogus values here */
if (vendor == 0x0000 && product == 0x0000) {
/* Some devices are only identifiable by their name */
if (SDL_strcmp(name, "Lic Pro Controller") == 0 ||
SDL_strcmp(name, "Nintendo Wireless Gamepad") == 0 ||
SDL_strcmp(name, "Wireless Gamepad") == 0) {
/* HORI or PowerA Switch Pro Controller clone */
return SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO;
}
return SDL_CONTROLLER_TYPE_UNKNOWN;
}
if (vendor == 0x0001 && product == 0x0001) {
@ -1501,7 +1507,7 @@ SDL_bool SDL_ShouldIgnoreJoystick(const char *name, SDL_JoystickGUID guid)
}
}
if (SDL_GetGameControllerType(vendor, product) == SDL_CONTROLLER_TYPE_PS4 && SDL_IsPS4RemapperRunning()) {
if (SDL_GetJoystickGameControllerType(vendor, product, name) == SDL_CONTROLLER_TYPE_PS4 && SDL_IsPS4RemapperRunning()) {
return SDL_TRUE;
}

View File

@ -53,8 +53,8 @@ extern int SDL_JoystickGetDeviceIndexFromInstanceID(SDL_JoystickID instance_id);
extern void SDL_GetJoystickGUIDInfo(SDL_JoystickGUID guid, Uint16 *vendor, Uint16 *product, Uint16 *version);
/* Function to return the type of a controller */
extern SDL_GameControllerType SDL_GetGameControllerTypeFromGUID(SDL_JoystickGUID guid);
extern SDL_GameControllerType SDL_GetGameControllerType(Uint16 vendor, Uint16 product);
extern SDL_GameControllerType SDL_GetJoystickGameControllerTypeFromGUID(SDL_JoystickGUID guid, const char *name);
extern SDL_GameControllerType SDL_GetJoystickGameControllerType(Uint16 vendor, Uint16 product, const char *name);
/* Function to return whether a joystick is a Nintendo Switch Pro controller */
extern SDL_bool SDL_IsJoystickNintendoSwitchProInputOnly(Uint16 vendor_id, Uint16 product_id);

View File

@ -141,7 +141,7 @@ static Uint32 crc32(Uint32 crc, const void *data, int count)
static SDL_bool
HIDAPI_DriverPS4_IsSupportedDevice(Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, const char *name)
{
return (SDL_GetGameControllerType(vendor_id, product_id) == SDL_CONTROLLER_TYPE_PS4);
return (SDL_GetJoystickGameControllerType(vendor_id, product_id, name) == SDL_CONTROLLER_TYPE_PS4);
}
static const char *

View File

@ -226,16 +226,7 @@ typedef struct {
static SDL_bool
HIDAPI_DriverSwitch_IsSupportedDevice(Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, const char *name)
{
if (vendor_id == 0 && product_id == 0) {
/* Some devices are only identifiable by their name */
if (SDL_strcmp(name, "Lic Pro Controller") == 0 ||
SDL_strcmp(name, "Nintendo Wireless Gamepad") == 0 ||
SDL_strcmp(name, "Wireless Gamepad") == 0) {
/* HORI or PowerA Switch Pro Controller clone */
return SDL_TRUE;
}
}
return SDL_IsJoystickNintendoSwitchPro(vendor_id, product_id);
return (SDL_GetJoystickGameControllerType(vendor_id, product_id, name) == SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO);
}
static const char *

View File

@ -249,7 +249,7 @@ HIDAPI_DriverXbox360_QuitWindowsGamingInput(SDL_DriverXbox360_Context *ctx)
static SDL_bool
HIDAPI_DriverXbox360_IsSupportedDevice(Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, const char *name)
{
SDL_GameControllerType type = SDL_GameControllerType(vendor_id, product_id);
SDL_GameControllerType type = SDL_GetJoystickGameControllerType(vendor_id, product_id, name);
#if defined(__MACOSX__) || defined(__WIN32__)
if (vendor_id == 0x045e && product_id == 0x028e && version == 1) {

View File

@ -197,7 +197,7 @@ HIDAPI_DriverXboxOne_IsSupportedDevice(Uint16 vendor_id, Uint16 product_id, Uint
return SDL_FALSE;
}
#endif
return (SDL_GetGameControllerType(vendor_id, product_id) == SDL_CONTROLLER_TYPE_XBOXONE);
return (SDL_GetJoystickGameControllerType(vendor_id, product_id, name) == SDL_CONTROLLER_TYPE_XBOXONE);
}
static const char *

View File

@ -374,7 +374,7 @@ SDL_IsXInputDevice(const GUID* pGuidProductFromDirectInput)
if (SDL_memcmp(&pGuidProductFromDirectInput->Data4[2], "PIDVID", 6) == 0) {
Uint16 vendor_id = (Uint16)LOWORD(pGuidProductFromDirectInput->Data1);
Uint16 product_id = (Uint16)HIWORD(pGuidProductFromDirectInput->Data1);
SDL_GameControllerType type = SDL_GetGameControllerType(vendor_id, product_id);
SDL_GameControllerType type = SDL_GetJoystickGameControllerType(vendor_id, product_id, "");
if (type == SDL_CONTROLLER_TYPE_XBOX360 ||
type == SDL_CONTROLLER_TYPE_XBOXONE ||
(vendor_id == 0x28DE && product_id == 0x11FF)) {