|
@@ -193,14 +193,19 @@ HIDAPI_DriverGameCube_InitDevice(SDL_HIDAPI_Device *device)
|
|
|
return SDL_TRUE;
|
|
|
|
|
|
error:
|
|
|
- if (device->dev) {
|
|
|
- hid_close(device->dev);
|
|
|
- device->dev = NULL;
|
|
|
- }
|
|
|
- if (device->context) {
|
|
|
- SDL_free(device->context);
|
|
|
- device->context = NULL;
|
|
|
+ SDL_LockMutex(device->dev_lock);
|
|
|
+ {
|
|
|
+ if (device->dev) {
|
|
|
+ hid_close(device->dev);
|
|
|
+ device->dev = NULL;
|
|
|
+ }
|
|
|
+ if (device->context) {
|
|
|
+ SDL_free(device->context);
|
|
|
+ device->context = NULL;
|
|
|
+ }
|
|
|
}
|
|
|
+ SDL_UnlockMutex(device->dev_lock);
|
|
|
+
|
|
|
return SDL_FALSE;
|
|
|
}
|
|
|
|
|
@@ -404,14 +409,18 @@ HIDAPI_DriverGameCube_FreeDevice(SDL_HIDAPI_Device *device)
|
|
|
{
|
|
|
SDL_DriverGameCube_Context *ctx = (SDL_DriverGameCube_Context *)device->context;
|
|
|
|
|
|
- hid_close(device->dev);
|
|
|
- device->dev = NULL;
|
|
|
-
|
|
|
SDL_DelHintCallback(SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS,
|
|
|
SDL_GameControllerButtonReportingHintChanged, ctx);
|
|
|
|
|
|
- SDL_free(device->context);
|
|
|
- device->context = NULL;
|
|
|
+ SDL_LockMutex(device->dev_lock);
|
|
|
+ {
|
|
|
+ hid_close(device->dev);
|
|
|
+ device->dev = NULL;
|
|
|
+
|
|
|
+ SDL_free(device->context);
|
|
|
+ device->context = NULL;
|
|
|
+ }
|
|
|
+ SDL_UnlockMutex(device->dev_lock);
|
|
|
}
|
|
|
|
|
|
SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverGameCube =
|