iOS: Disable the swipe-back gesture in-game, to maximize touch responsiveness

This commit is contained in:
Henrik Rydgård 2024-06-19 22:43:42 +02:00
parent 1f8a0add22
commit 4c4fcabc5e
2 changed files with 25 additions and 6 deletions

View File

@ -125,6 +125,8 @@ void TextDrawerCocoa::MeasureString(std::string_view str, float *w, float *h) {
if (iter != sizeCache_.end()) { if (iter != sizeCache_.end()) {
entry = iter->second.get(); entry = iter->second.get();
} else { } else {
// INFO_LOG(SYSTEM, "Measuring %.*s", (int)str.length(), str.data());
auto iter = fontMap_.find(fontHash_); auto iter = fontMap_.find(fontHash_);
NSDictionary *attributes = nil; NSDictionary *attributes = nil;
if (iter != fontMap_.end()) { if (iter != fontMap_.end()) {

View File

@ -113,7 +113,9 @@ id<PPSSPPViewController> sharedViewController;
@end @end
@implementation PPSSPPViewControllerGL @implementation PPSSPPViewControllerGL {
UIScreenEdgePanGestureRecognizer *mBackGestureRecognizer;
}
-(id) init { -(id) init {
self = [super init]; self = [super init];
@ -220,6 +222,7 @@ void GLRenderLoop(IOSGLESContext *graphicsContext) {
- (void)viewDidAppear:(BOOL)animated { - (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated]; [super viewDidAppear:animated];
[self hideKeyboard]; [self hideKeyboard];
[self updateGesture];
} }
- (void)viewDidLoad { - (void)viewDidLoad {
@ -269,10 +272,6 @@ void GLRenderLoop(IOSGLESContext *graphicsContext) {
[self hideKeyboard]; [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. // Initialize the motion manager for accelerometer control.
self.motionManager = [[CMMotionManager alloc] init]; self.motionManager = [[CMMotionManager alloc] init];
INFO_LOG(G3D, "Done with viewDidLoad."); INFO_LOG(G3D, "Done with viewDidLoad.");
@ -447,7 +446,7 @@ void GLRenderLoop(IOSGLESContext *graphicsContext) {
} else { } else {
INFO_LOG(SYSTEM, "Allow system gestures on the bottom"); INFO_LOG(SYSTEM, "Allow system gestures on the bottom");
// Allow task switching gestures to take precedence, without causing // 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; return UIRectEdgeTop | UIRectEdgeLeft | UIRectEdgeRight;
} }
} }
@ -456,6 +455,24 @@ void GLRenderLoop(IOSGLESContext *graphicsContext) {
{ {
[self setNeedsUpdateOfScreenEdgesDeferringSystemGestures]; [self setNeedsUpdateOfScreenEdgesDeferringSystemGestures];
[self hideKeyboard]; [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 { - (UIView *)getView {