Minor tweaks
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
diff --git a/src/joystick/hidapi/SDL_hidapi_ps4.c b/src/joystick/hidapi/SDL_hidapi_ps4.c
index 6925be4..c9c24a3 100644
--- a/src/joystick/hidapi/SDL_hidapi_ps4.c
+++ b/src/joystick/hidapi/SDL_hidapi_ps4.c
@@ -958,8 +958,8 @@ HIDAPI_DriverPS4_UpdateDevice(SDL_HIDAPI_Device *device)
int packet_count = 0;
/* Reconnect the Bluetooth device once the USB device is gone */
- if (device->is_bluetooth &&
- device->num_joysticks == 0 &&
+ if (device->num_joysticks == 0 &&
+ device->is_bluetooth &&
!HIDAPI_HasConnectedUSBDevice(device->serial)) {
HIDAPI_JoystickConnected(device, NULL);
}
diff --git a/src/joystick/hidapi/SDL_hidapi_ps5.c b/src/joystick/hidapi/SDL_hidapi_ps5.c
index 390a9c2..423d4e9 100644
--- a/src/joystick/hidapi/SDL_hidapi_ps5.c
+++ b/src/joystick/hidapi/SDL_hidapi_ps5.c
@@ -1266,8 +1266,8 @@ HIDAPI_DriverPS5_UpdateDevice(SDL_HIDAPI_Device *device)
int packet_count = 0;
/* Reconnect the Bluetooth device once the USB device is gone */
- if (device->is_bluetooth &&
- device->num_joysticks == 0 &&
+ if (device->num_joysticks == 0 &&
+ device->is_bluetooth &&
!HIDAPI_HasConnectedUSBDevice(device->serial)) {
HIDAPI_JoystickConnected(device, NULL);
}
diff --git a/src/joystick/hidapi/SDL_hidapi_switch.c b/src/joystick/hidapi/SDL_hidapi_switch.c
index b2cbcd1..86f8638 100644
--- a/src/joystick/hidapi/SDL_hidapi_switch.c
+++ b/src/joystick/hidapi/SDL_hidapi_switch.c
@@ -2077,8 +2077,8 @@ HIDAPI_DriverSwitch_UpdateDevice(SDL_HIDAPI_Device *device)
Uint32 now;
/* Reconnect the Bluetooth device once the USB device is gone */
- if (device->is_bluetooth &&
- device->num_joysticks == 0 &&
+ if (device->num_joysticks == 0 &&
+ device->is_bluetooth &&
!HIDAPI_HasConnectedUSBDevice(device->serial)) {
HIDAPI_JoystickConnected(device, NULL);
}
diff --git a/src/joystick/hidapi/SDL_hidapijoystick.c b/src/joystick/hidapi/SDL_hidapijoystick.c
index 4900b38..e3db2cf 100644
--- a/src/joystick/hidapi/SDL_hidapijoystick.c
+++ b/src/joystick/hidapi/SDL_hidapijoystick.c
@@ -535,6 +535,10 @@ HIDAPI_HasConnectedUSBDevice(const char *serial)
SDL_HIDAPI_Device *device;
for (device = SDL_HIDAPI_devices; device; device = device->next) {
+ if (!device->driver) {
+ continue;
+ }
+
if (device->is_bluetooth) {
continue;
}
@@ -552,6 +556,10 @@ HIDAPI_DisconnectBluetoothDevice(const char *serial)
SDL_HIDAPI_Device *device;
for (device = SDL_HIDAPI_devices; device; device = device->next) {
+ if (!device->driver) {
+ continue;
+ }
+
if (!device->is_bluetooth) {
continue;
}