Do not randomly disconnect switch pro controllers when closing a game.

Also, fix a comment which erroneously contradicted the code
This commit is contained in:
Daniele Cattaneo
2019-08-31 16:33:52 +02:00
parent ce01c3fd15
commit e145d677ef
@@ -257,16 +257,21 @@ static OEHACProControllerStickCalibration OEHACConvertCalibration(
[self _setPlayerLights:0x0F];
[self _requestCalibrationData];
if ([[[NSBundle mainBundle] bundleIdentifier] isEqual:@"org.openemu.OpenEmu"]) {
/* we don't want to disconnect the controller every time the helper app terminates,
* just when OpenEmu closes */
NSNotificationCenter * __weak nc = [NSNotificationCenter defaultCenter];
id __block token = [nc addObserverForName:NSApplicationWillTerminateNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
[self _setPowerState:OEHACPowerStateSleep];
[nc removeObserver:token];
}];
}
return YES;
}
- (void)disconnect
{
[self _setPowerState:OEHACPowerStateSleep];
}
#pragma mark - Calibration
@@ -332,7 +337,7 @@ static OEHACProControllerStickCalibration OEHACConvertCalibration(
res /= (CGFloat)(selectedCalibration->max - selectedCalibration->zero);
}
/* the factory calibration is a bit conservative at the edges; compensate for that */
/* the factory calibration is a bit generous at the edges; compensate for that */
res /= 0.90;
return MAX(-1, MIN(res, 1));