From fbe4153214f546853d97d021b09c8824017194c2 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 17 Feb 2024 19:13:04 -0800 Subject: [PATCH] The HIDAPI driver takes precedence over the GameInput driver The HIDAPI driver has more functionality for supported controllers. --- src/joystick/gdk/SDL_gameinputjoystick.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/joystick/gdk/SDL_gameinputjoystick.c b/src/joystick/gdk/SDL_gameinputjoystick.c index 4b5489b4ad..bc1c01cbf0 100644 --- a/src/joystick/gdk/SDL_gameinputjoystick.c +++ b/src/joystick/gdk/SDL_gameinputjoystick.c @@ -85,6 +85,19 @@ static int GAMEINPUT_InternalAddOrFind(IGameInputDevice *pDevice) return SDL_SetError("GAMEINPUT_InternalAddOrFind GetDeviceInfo returned NULL"); } + if (devinfo->capabilities & GameInputDeviceCapabilityWireless) { + bus = SDL_HARDWARE_BUS_BLUETOOTH; + } else { + bus = SDL_HARDWARE_BUS_USB; + } + vendor = devinfo->vendorId; + product = devinfo->productId; + version = (devinfo->firmwareVersion.major << 8) | devinfo->firmwareVersion.minor; + + if (SDL_JoystickHandledByAnotherDriver(&SDL_GAMEINPUT_JoystickDriver, vendor, product, version, "")) { + return 0; + } + for (idx = 0; idx < g_GameInputList.count; ++idx) { elem = g_GameInputList.devices[idx]; if (elem && elem->device == pDevice) { @@ -109,14 +122,6 @@ static int GAMEINPUT_InternalAddOrFind(IGameInputDevice *pDevice) SDL_snprintf(tmp, SDL_arraysize(tmp), "%02hhX", devinfo->deviceId.value[idx]); SDL_strlcat(elem->path, tmp, SDL_arraysize(tmp)); } - if (devinfo->capabilities & GameInputDeviceCapabilityWireless) { - bus = SDL_HARDWARE_BUS_BLUETOOTH; - } else { - bus = SDL_HARDWARE_BUS_USB; - } - vendor = devinfo->vendorId; - product = devinfo->productId; - version = (devinfo->firmwareVersion.major << 8) | devinfo->firmwareVersion.minor; g_GameInputList.devices = devicelist; IGameInputDevice_AddRef(pDevice);