diff --git a/Common/Render/Text/draw_text_cocoa.mm b/Common/Render/Text/draw_text_cocoa.mm index ff7ac1b0d6..2ee51c8d60 100644 --- a/Common/Render/Text/draw_text_cocoa.mm +++ b/Common/Render/Text/draw_text_cocoa.mm @@ -125,6 +125,8 @@ void TextDrawerCocoa::MeasureString(std::string_view str, float *w, float *h) { if (iter != sizeCache_.end()) { entry = iter->second.get(); } else { + // INFO_LOG(SYSTEM, "Measuring %.*s", (int)str.length(), str.data()); + auto iter = fontMap_.find(fontHash_); NSDictionary *attributes = nil; if (iter != fontMap_.end()) { diff --git a/ios/ViewController.mm b/ios/ViewController.mm index 765dc9f563..6462d6a8a7 100644 --- a/ios/ViewController.mm +++ b/ios/ViewController.mm @@ -113,7 +113,9 @@ id sharedViewController; @end -@implementation PPSSPPViewControllerGL +@implementation PPSSPPViewControllerGL { + UIScreenEdgePanGestureRecognizer *mBackGestureRecognizer; +} -(id) init { self = [super init]; @@ -219,7 +221,9 @@ void GLRenderLoop(IOSGLESContext *graphicsContext) { - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; + INFO_LOG(G3D, "viewDidAppear"); [self hideKeyboard]; + [self updateGesture]; } - (void)viewDidLoad { @@ -269,10 +273,6 @@ void GLRenderLoop(IOSGLESContext *graphicsContext) { [self hideKeyboard]; - UIScreenEdgePanGestureRecognizer *mBackGestureRecognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:) ]; - [mBackGestureRecognizer setEdges:UIRectEdgeLeft]; - [[self view] addGestureRecognizer:mBackGestureRecognizer]; - // Initialize the motion manager for accelerometer control. self.motionManager = [[CMMotionManager alloc] init]; INFO_LOG(G3D, "Done with viewDidLoad."); @@ -447,7 +447,7 @@ void GLRenderLoop(IOSGLESContext *graphicsContext) { } else { INFO_LOG(SYSTEM, "Allow system gestures on the bottom"); // Allow task switching gestures to take precedence, without causing - // scroll events in the UI. + // scroll events in the UI. Otherwise, we get "ghost" scrolls when switching tasks. return UIRectEdgeTop | UIRectEdgeLeft | UIRectEdgeRight; } } @@ -456,6 +456,24 @@ void GLRenderLoop(IOSGLESContext *graphicsContext) { { [self setNeedsUpdateOfScreenEdgesDeferringSystemGestures]; [self hideKeyboard]; + [self updateGesture]; +} + +- (void)updateGesture { + INFO_LOG(SYSTEM, "Updating swipe gesture."); + + if (mBackGestureRecognizer) { + INFO_LOG(SYSTEM, "Removing swipe gesture."); + [[self view] removeGestureRecognizer:mBackGestureRecognizer]; + mBackGestureRecognizer = nil; + } + + if (GetUIState() != UISTATE_INGAME) { + INFO_LOG(SYSTEM, "Adding swipe gesture."); + mBackGestureRecognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:) ]; + [mBackGestureRecognizer setEdges:UIRectEdgeLeft]; + [[self view] addGestureRecognizer:mBackGestureRecognizer]; + } } - (UIView *)getView { diff --git a/ios/ViewControllerMetal.mm b/ios/ViewControllerMetal.mm index d57e20ba6f..c543b4822b 100644 --- a/ios/ViewControllerMetal.mm +++ b/ios/ViewControllerMetal.mm @@ -217,7 +217,9 @@ static std::thread g_renderLoopThread; @end // @interface -@implementation PPSSPPViewControllerMetal +@implementation PPSSPPViewControllerMetal { + UIScreenEdgePanGestureRecognizer *mBackGestureRecognizer; +} - (id)init { self = [super init]; @@ -440,10 +442,6 @@ void VulkanRenderLoop(IOSVulkanContext *graphicsContext, CAMetalLayer *metalLaye locationHelper = [[LocationHelper alloc] init]; [locationHelper setDelegate:self]; - UIScreenEdgePanGestureRecognizer *mBackGestureRecognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:) ]; - [mBackGestureRecognizer setEdges:UIRectEdgeLeft]; - [[self view] addGestureRecognizer:mBackGestureRecognizer]; - // Initialize the motion manager for accelerometer control. self.motionManager = [[CMMotionManager alloc] init]; } @@ -478,7 +476,8 @@ void VulkanRenderLoop(IOSVulkanContext *graphicsContext, CAMetalLayer *metalLaye [super viewDidAppear:animated]; INFO_LOG(G3D, "viewDidAppear"); [self hideKeyboard]; - INFO_LOG(G3D, "viewDidAppearDone"); + [self updateGesture]; + } - (BOOL)prefersHomeIndicatorAutoHidden { @@ -529,6 +528,25 @@ extern float g_safeInsetBottom; { [self setNeedsUpdateOfScreenEdgesDeferringSystemGestures]; [self hideKeyboard]; + [self updateGesture]; +} + + +- (void)updateGesture { + INFO_LOG(SYSTEM, "Updating swipe gesture."); + + if (mBackGestureRecognizer) { + INFO_LOG(SYSTEM, "Removing swipe gesture."); + [[self view] removeGestureRecognizer:mBackGestureRecognizer]; + mBackGestureRecognizer = nil; + } + + if (GetUIState() != UISTATE_INGAME) { + INFO_LOG(SYSTEM, "Adding swipe gesture."); + mBackGestureRecognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:) ]; + [mBackGestureRecognizer setEdges:UIRectEdgeLeft]; + [[self view] addGestureRecognizer:mBackGestureRecognizer]; + } } - (void)bindDefaultFBO