Generalized the idea of joystick driver priority
Joystick drivers are sorted by priority in the driver list, and higher priority drivers report whether they are handling a device when lower priority drivers want to add it to their device list. This has been handled ad-hoc with the Windows and HIDAPI drivers, but this formalizes the idea and makes sure that GameInput has the highest priority of the Windows drivers.
This commit is contained in:
parent
7f33464bed
commit
f35ede7281
25 changed files with 298 additions and 272 deletions
|
@ -49,16 +49,16 @@
|
|||
#endif
|
||||
|
||||
static SDL_JoystickDriver *SDL_joystick_drivers[] = {
|
||||
#ifdef SDL_JOYSTICK_HIDAPI /* Before WINDOWS_ driver, as WINDOWS wants to check if this driver is handling things */
|
||||
#ifdef SDL_JOYSTICK_HIDAPI /* Highest priority driver for supported devices */
|
||||
&SDL_HIDAPI_JoystickDriver,
|
||||
#endif
|
||||
#ifdef SDL_JOYSTICK_RAWINPUT /* Before WINDOWS_ driver, as WINDOWS wants to check if this driver is handling things */
|
||||
&SDL_RAWINPUT_JoystickDriver,
|
||||
#endif
|
||||
#ifdef SDL_JOYSTICK_GAMEINPUT /* Before WINDOWS_ driver, as GameInput takes priority over XInputOnGameInput for GDK platforms */
|
||||
#ifdef SDL_JOYSTICK_GAMEINPUT /* Higher priority than other Windows drivers */
|
||||
&SDL_GAMEINPUT_JoystickDriver,
|
||||
#endif
|
||||
#if defined(SDL_JOYSTICK_DINPUT) || defined(SDL_JOYSTICK_XINPUT) /* Before WGI driver, as WGI wants to check if this driver is handling things */
|
||||
#ifdef SDL_JOYSTICK_RAWINPUT
|
||||
&SDL_RAWINPUT_JoystickDriver,
|
||||
#endif
|
||||
#if defined(SDL_JOYSTICK_DINPUT) || defined(SDL_JOYSTICK_XINPUT)
|
||||
&SDL_WINDOWS_JoystickDriver,
|
||||
#endif
|
||||
#ifdef SDL_JOYSTICK_WGI
|
||||
|
@ -659,6 +659,29 @@ SDL_bool SDL_JoysticksOpened(void)
|
|||
return opened;
|
||||
}
|
||||
|
||||
SDL_bool SDL_JoystickHandledByAnotherDriver(struct SDL_JoystickDriver *driver, Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name)
|
||||
{
|
||||
int i;
|
||||
SDL_bool result = SDL_FALSE;
|
||||
|
||||
SDL_LockJoysticks();
|
||||
{
|
||||
for (i = 0; i < SDL_arraysize(SDL_joystick_drivers); ++i) {
|
||||
if (driver == SDL_joystick_drivers[i]) {
|
||||
/* Higher priority drivers do not have this device */
|
||||
break;
|
||||
}
|
||||
if (SDL_joystick_drivers[i]->IsDevicePresent(vendor_id, product_id, version, name)) {
|
||||
result = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
SDL_UnlockJoysticks();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
SDL_JoystickID *SDL_GetJoysticks(int *count)
|
||||
{
|
||||
int i, num_joysticks, device_index;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue