From 4c4fcabc5ef5c01d9674a728a54eb83dab96981c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 19 Jun 2024 22:43:42 +0200 Subject: [PATCH] iOS: Disable the swipe-back gesture in-game, to maximize touch responsiveness --- Common/Render/Text/draw_text_cocoa.mm | 2 ++ ios/ViewController.mm | 29 +++++++++++++++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) 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..ff08c01b5a 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]; @@ -220,6 +222,7 @@ void GLRenderLoop(IOSGLESContext *graphicsContext) { - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [self hideKeyboard]; + [self updateGesture]; } - (void)viewDidLoad { @@ -269,10 +272,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 +446,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 +455,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 {