Less ugly hacks
This commit is contained in:
parent
021cdb402d
commit
2854578527
@ -116,7 +116,6 @@
|
||||
}
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
[lastController setRumbleAmplitude:0];
|
||||
[lastController _forceStopPWMThread];
|
||||
[JOYController unregisterListener:self];
|
||||
}
|
||||
- (instancetype)initWithCoder:(NSCoder *)coder
|
||||
@ -303,7 +302,6 @@
|
||||
if (![self.window isMainWindow]) return;
|
||||
if (controller != lastController) {
|
||||
[lastController setRumbleAmplitude:0];
|
||||
[lastController _forceStopPWMThread];
|
||||
lastController = controller;
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,6 @@ static NSString const *JOYHatsEmulateButtonsKey = @"JOYHatsEmulateButtons";
|
||||
- (NSArray<JOYHat *> *) hats;
|
||||
- (void)setRumbleAmplitude:(double)amp;
|
||||
- (void)setPlayerLEDs:(uint8_t)mask;
|
||||
- (void)_forceStopPWMThread; // Hack
|
||||
@property (readonly, getter=isConnected) bool connected;
|
||||
@end
|
||||
|
||||
|
@ -607,7 +607,12 @@ typedef struct __attribute__((packed)) {
|
||||
- (void)pwmThread
|
||||
{
|
||||
/* TODO: This does not handle correctly the case of having a multi-port controller where more than one controller
|
||||
uses rumble. */
|
||||
uses rumble. At least make sure any sibling controllers don't have their PWM thread running. */
|
||||
for (JOYController *controller in [JOYController allControllers]) {
|
||||
if (controller != self && controller->_device == _device) {
|
||||
[controller _forceStopPWMThread];
|
||||
}
|
||||
}
|
||||
unsigned rumbleCounter = 0;
|
||||
while (self.connected && !_forceStopPWMThread) {
|
||||
if ([_rumbleElement setValue:rumbleCounter < round(_rumblePWMRatio * PWM_RESOLUTION)]) {
|
||||
@ -619,6 +624,7 @@ typedef struct __attribute__((packed)) {
|
||||
}
|
||||
}
|
||||
[_rumblePWMThreadLock lock];
|
||||
[_rumbleElement setValue:0];
|
||||
_rumblePWMThreadRunning = false;
|
||||
_forceStopPWMThread = false;
|
||||
[_rumblePWMThreadLock unlock];
|
||||
|
Loading…
Reference in New Issue
Block a user