Fixed a bug where the screen would not redraw when certain controllers are rumbling in specific strengths in the Cocoa port

This commit is contained in:
Lior Halphon 2021-04-11 23:36:42 +03:00
parent 80f422d0ca
commit 251dd15ff9

View File

@ -166,6 +166,7 @@ typedef union {
double _sentRumbleAmp; double _sentRumbleAmp;
unsigned _rumbleCounter; unsigned _rumbleCounter;
bool _deviceCantSendReports; bool _deviceCantSendReports;
dispatch_queue_t _rumbleQueue;
} }
- (instancetype)initWithDevice:(IOHIDDeviceRef) device hacks:(NSDictionary *)hacks - (instancetype)initWithDevice:(IOHIDDeviceRef) device hacks:(NSDictionary *)hacks
@ -490,9 +491,11 @@ typedef union {
{.timeEnabled = 0, .dutyLength = 0, .enabled = 0, .dutyOff = 0, .dutyOn = 0}, {.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; return self;
} }
@ -564,7 +567,9 @@ typedef union {
} }
} }
} }
dispatch_async(_rumbleQueue, ^{
[self updateRumble]; [self updateRumble];
});
} }
- (void)elementChanged:(IOHIDElementRef)element - (void)elementChanged:(IOHIDElementRef)element
@ -699,7 +704,9 @@ typedef union {
_physicallyConnected = false; _physicallyConnected = false;
[exposedControllers removeObject:self]; [exposedControllers removeObject:self];
[self setRumbleAmplitude:0]; [self setRumbleAmplitude:0];
dispatch_sync(_rumbleQueue, ^{
[self updateRumble]; [self updateRumble];
});
_device = nil; _device = nil;
} }