gamepad overlay crash fix

This commit is contained in:
True Zhuanjia committed 2026-04-14 11:08:59 +08:00
1 parent 3e1423ff46
commit 9807a77d9b
1 file changed
+24 -20
@@ -1795,26 +1795,30 @@
} }
- (void)loadAbstractGamepadOverlayIfNeeded API_AVAILABLE(ios(13.0)){ - (void)loadAbstractGamepadOverlayIfNeeded API_AVAILABLE(ios(13.0)){
if (_virtualGamepadOverlay != nil || self.view.window == nil) { dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)),
return; dispatch_get_main_queue(), ^{
}
if (self->_virtualGamepadOverlay != nil || self.view.window == nil) {
BOOL usesXboxFaceButtons = _settings.emulatedControllerType.intValue == LI_CTYPE_XBOX; return;
}
// CGFloat maxWidth = MIN(CGRectGetWidth(self.view.bounds) * 0.72, 620);
// CGFloat standardWidth = MAX(420, maxWidth); BOOL usesXboxFaceButtons = self->_settings.emulatedControllerType.intValue == LI_CTYPE_XBOX;
CGFloat standardWidth = GenericUtils.isIPhone ? 165 : 200; // CGFloat maxWidth = MIN(CGRectGetWidth(self.view.bounds) * 0.72, 620);
// CGFloat standardWidth = MAX(420, maxWidth);
CGFloat standardhHeight = standardWidth / 1.82;
CGRect overlayFrame = CGRectMake(0, 0, standardWidth, standardhHeight); CGFloat standardWidth = GenericUtils.isIPhone ? 165 : 200;
AbstractGamepadOverlayView *overlayView = [[AbstractGamepadOverlayView alloc] initWithFrame:overlayFrame usesPlayStationFaceButtons:!usesXboxFaceButtons]; CGFloat standardhHeight = standardWidth / 1.82;
overlayView.center = CGPointMake(self.view.bounds.size.width-standardWidth/2-20, self.view.bounds.size.height-standardhHeight/2-20); CGRect overlayFrame = CGRectMake(0, 0, standardWidth, standardhHeight);
overlayView.userInteractionEnabled = YES;
[self.view addSubview:overlayView]; AbstractGamepadOverlayView *overlayView = [[AbstractGamepadOverlayView alloc] initWithFrame:overlayFrame usesPlayStationFaceButtons:!usesXboxFaceButtons];
overlayView.center = CGPointMake(self.view.bounds.size.width-standardWidth/2-20, self.view.bounds.size.height-standardhHeight/2-20);
_virtualGamepadOverlay = overlayView; overlayView.userInteractionEnabled = YES;
[self.view addSubview:overlayView];
self->_virtualGamepadOverlay = overlayView;
});
} }