summaryrefslogtreecommitdiff
path: root/Externals/hidapi
diff options
context:
space:
mode:
authorOatmealDome <julian@oatmealdome.me>2021-08-09 21:15:17 -0400
committerOatmealDome <julian@oatmealdome.me>2021-08-09 21:15:17 -0400
commitb24599cf5bf07f0f4d12e197e61c8f107a042dd4 (patch)
tree65f4a76675849c096ee74f32ed6780cd88370fd6 /Externals/hidapi
parent942545b7fca15a442c8dfa14b73c7227c13c8217 (diff)
hidapi: Stop current run loop in removal callback instead of fetching from context
Diffstat (limited to 'Externals/hidapi')
-rw-r--r--Externals/hidapi/mac/hid.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/Externals/hidapi/mac/hid.c b/Externals/hidapi/mac/hid.c
index 70b615d40d..d8055f372c 100644
--- a/Externals/hidapi/mac/hid.c
+++ b/Externals/hidapi/mac/hid.c
@@ -562,11 +562,10 @@ hid_device * HID_API_EXPORT hid_open(unsigned short vendor_id, unsigned short pr
static void hid_device_removal_callback(void *context, IOReturn result,
void *sender)
{
- /* Stop the Run Loop for this device. */
- hid_device *d = context;
-
- d->disconnected = 1;
- CFRunLoopStop(d->run_loop);
+ /* Stop the Run Loop for this device. This callback will always
+ be called on the device's registered run loop, so we can just
+ get the current loop. */
+ CFRunLoopStop(CFRunLoopGetCurrent());
}
/* The Run Loop calls this function for each input report received.
@@ -658,7 +657,7 @@ static void *read_thread(void *param)
while (!dev->shutdown_thread && !dev->disconnected) {
code = CFRunLoopRunInMode(dev->run_loop_mode, 1000/*sec*/, FALSE);
/* Return if the device has been disconnected */
- if (code == kCFRunLoopRunFinished) {
+ if (code == kCFRunLoopRunFinished || code == kCFRunLoopRunStopped) {
dev->disconnected = 1;
break;
}