From 251dd15ff91cf7638a93d8386f4eee3af3b4fcdd Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Sun, 11 Apr 2021 23:36:42 +0300 Subject: [PATCH] Fixed a bug where the screen would not redraw when certain controllers are rumbling in specific strengths in the Cocoa port --- JoyKit/JOYController.m | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/JoyKit/JOYController.m b/JoyKit/JOYController.m index ca2d1b1..8ec1279 100644 --- a/JoyKit/JOYController.m +++ b/JoyKit/JOYController.m @@ -166,6 +166,7 @@ typedef union { double _sentRumbleAmp; unsigned _rumbleCounter; bool _deviceCantSendReports; + dispatch_queue_t _rumbleQueue; } - (instancetype)initWithDevice:(IOHIDDeviceRef) device hacks:(NSDictionary *)hacks @@ -490,9 +491,11 @@ typedef union { {.timeEnabled = 0, .dutyLength = 0, .enabled = 0, .dutyOff = 0, .dutyOn = 0}, } }; - } + _rumbleQueue = dispatch_queue_create([NSString stringWithFormat:@"Rumble Queue for %@", self.deviceName].UTF8String, + NULL); + return self; } @@ -564,7 +567,9 @@ typedef union { } } } - [self updateRumble]; + dispatch_async(_rumbleQueue, ^{ + [self updateRumble]; + }); } - (void)elementChanged:(IOHIDElementRef)element @@ -699,7 +704,9 @@ typedef union { _physicallyConnected = false; [exposedControllers removeObject:self]; [self setRumbleAmplitude:0]; - [self updateRumble]; + dispatch_sync(_rumbleQueue, ^{ + [self updateRumble]; + }); _device = nil; }