Don't use the WGI driver if another driver is already handling the joystick

This commit is contained in:
Sam Lantinga
2020-04-23 10:13:17 -07:00
parent 6ca7f510ae
commit 4727f79416
3 changed files with 69 additions and 7 deletions

View File

@@ -698,6 +698,47 @@ SDL_DINPUT_JoystickDetect(JoyStick_DeviceData **pContext)
SDL_RawDevListCount = 0;
}
typedef struct
{
Uint16 vendor;
Uint16 product;
Uint16 version;
SDL_bool present;
} EnumJoystickPresentData;
static BOOL CALLBACK
EnumJoystickPresentCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext)
{
EnumJoystickPresentData *data = (EnumJoystickPresentData *)pContext;
Uint16 vendor = 0;
Uint16 product = 0;
Uint16 version = 0;
if (SDL_memcmp(&pdidInstance->guidProduct.Data4[2], "PIDVID", 6) == 0) {
vendor = (Uint16)LOWORD(pdidInstance->guidProduct.Data1);
product = (Uint16)HIWORD(pdidInstance->guidProduct.Data1);
if (data->vendor == vendor && data->product == product && data->version == version) {
data->present = SDL_TRUE;
return DIENUM_STOP;
}
}
return DIENUM_CONTINUE;
}
SDL_bool
SDL_DINPUT_JoystickPresent(Uint16 vendor, Uint16 product, Uint16 version)
{
EnumJoystickPresentData data;
data.vendor = vendor;
data.product = product;
data.version = version;
data.present = SDL_FALSE;
IDirectInput8_EnumDevices(dinput, DI8DEVCLASS_GAMECTRL, EnumJoystickPresentCallback, &data, DIEDFL_ATTACHEDONLY);
return data.present;
}
static BOOL CALLBACK
EnumDevObjectsCallback(LPCDIDEVICEOBJECTINSTANCE dev, LPVOID pvRef)
{
@@ -1261,6 +1302,12 @@ SDL_DINPUT_JoystickDetect(JoyStick_DeviceData **pContext)
{
}
SDL_bool
SDL_DINPUT_JoystickPresent(Uint16 vendor, Uint16 product, Uint16 version)
{
return SDL_FALSE;
}
int
SDL_DINPUT_JoystickOpen(SDL_Joystick * joystick, JoyStick_DeviceData *joystickdevice)
{