From 428cfddb4c3c998485eed7b65c69931c12a452f0 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 4 Mar 2020 14:59:44 -0800 Subject: [PATCH] Fixed crash when a controller is disconnected while rumble is pending --- src/joystick/hidapi/SDL_hidapi_rumble.c | 4 +++- src/joystick/hidapi/SDL_hidapi_switch.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/joystick/hidapi/SDL_hidapi_rumble.c b/src/joystick/hidapi/SDL_hidapi_rumble.c index a4f05e4a9..c0d932b5e 100644 --- a/src/joystick/hidapi/SDL_hidapi_rumble.c +++ b/src/joystick/hidapi/SDL_hidapi_rumble.c @@ -76,7 +76,9 @@ static int SDL_HIDAPI_RumbleThread(void *data) if (request) { SDL_LockMutex(request->device->dev_lock); - hid_write(request->device->dev, request->data, request->size); + if (request->device->dev) { + hid_write( request->device->dev, request->data, request->size ); + } SDL_UnlockMutex(request->device->dev_lock); (void)SDL_AtomicDecRef(&request->device->rumble_pending); SDL_free(request); diff --git a/src/joystick/hidapi/SDL_hidapi_switch.c b/src/joystick/hidapi/SDL_hidapi_switch.c index 302d89c54..cf94e90e1 100644 --- a/src/joystick/hidapi/SDL_hidapi_switch.c +++ b/src/joystick/hidapi/SDL_hidapi_switch.c @@ -477,7 +477,7 @@ static SDL_bool BTrySetupUSB(SDL_DriverSwitch_Context *ctx) return SDL_FALSE; } if (!WriteProprietary(ctx, k_eSwitchProprietaryCommandIDs_HighSpeed, NULL, 0, SDL_TRUE)) { - /* The 8BitDo M30 doesn't respond to this command, but otherwise works correctly */ + /* The 8BitDo M30 and SF30 Pro don't respond to this command, but otherwise work correctly */ /*return SDL_FALSE;*/ } if (!WriteProprietary(ctx, k_eSwitchProprietaryCommandIDs_Handshake, NULL, 0, SDL_TRUE)) {