mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-10 11:56:26 +00:00
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:
@@ -427,15 +427,8 @@ static int MaybeAddDevice(const char *path)
|
||||
name = SDL_CreateJoystickName(di.udi_vendorNo, di.udi_productNo, di.udi_vendor, di.udi_product);
|
||||
guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_USB, di.udi_vendorNo, di.udi_productNo, di.udi_releaseNo, di.udi_vendor, di.udi_product, 0, 0);
|
||||
|
||||
#ifdef SDL_JOYSTICK_HIDAPI
|
||||
if (HIDAPI_IsDevicePresent(di.udi_vendorNo, di.udi_productNo, di.udi_releaseNo, name)) {
|
||||
/* The HIDAPI driver is taking care of this device */
|
||||
SDL_free(name);
|
||||
FreeHwData(hw);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
if (SDL_ShouldIgnoreJoystick(name, guid)) {
|
||||
if (SDL_ShouldIgnoreJoystick(name, guid) ||
|
||||
SDL_JoystickHandledByAnotherDriver(&SDL_BSD_JoystickDriver, di.udi_vendorNo, di.udi_productNo, di.udi_releaseNo, name)) {
|
||||
SDL_free(name);
|
||||
FreeHwData(hw);
|
||||
return -1;
|
||||
@@ -516,6 +509,12 @@ static void BSD_JoystickDetect(void)
|
||||
{
|
||||
}
|
||||
|
||||
static SDL_bool BSD_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name)
|
||||
{
|
||||
/* We don't override any other drivers */
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
static SDL_joylist_item *GetJoystickByDevIndex(int device_index)
|
||||
{
|
||||
SDL_joylist_item *item = SDL_joylist;
|
||||
@@ -848,6 +847,7 @@ SDL_JoystickDriver SDL_BSD_JoystickDriver = {
|
||||
BSD_JoystickInit,
|
||||
BSD_JoystickGetCount,
|
||||
BSD_JoystickDetect,
|
||||
BSD_JoystickIsDevicePresent,
|
||||
BSD_JoystickGetDeviceName,
|
||||
BSD_JoystickGetDevicePath,
|
||||
BSD_JoystickGetDeviceSteamVirtualGamepadSlot,
|
||||
|
Reference in New Issue
Block a user