iOS swipe gesture recognizer experiment

This commit is contained in:
Henrik Rydgård 2024-05-20 16:12:25 +02:00
parent 8756a2100e
commit aa6962df4a
3 changed files with 20 additions and 2 deletions

View file

@ -10,7 +10,7 @@
#import "LocationHelper.h"
@interface ViewController : GLKViewController <iCadeEventDelegate,
LocationHandlerDelegate, CameraFrameDelegate>
LocationHandlerDelegate, CameraFrameDelegate, UIGestureRecognizerDelegate>
- (void)shareText:(NSString *)text;
- (void)shutdown;

View file

@ -192,6 +192,12 @@ extern float g_safeInsetBottom;
self.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
}
UISwipeGestureRecognizer *mSwipeLeftRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
[mSwipeLeftRecognizer setDirection:(UISwipeGestureRecognizerDirectionLeft | UISwipeGestureRecognizerDirectionRight)];
[[self view] addGestureRecognizer:mSwipeLeftRecognizer];
GLKView* view = (GLKView *)self.view;
view.context = self.context;
view.drawableDepthFormat = GLKViewDrawableDepthFormat24;
@ -250,6 +256,17 @@ extern float g_safeInsetBottom;
});
}
- (void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer
{
if (recognizer.direction == UISwipeGestureRecognizerDirectionLeft) {
INFO_LOG(SYSTEM, "LEFT");
} else if (recognizer.direction == UISwipeGestureRecognizerDirectionRight) {
INFO_LOG(SYSTEM, "RIGHT");
} else {
INFO_LOG(SYSTEM, "OTHER SWIPE: %d", (int)recognizer.direction);
}
}
- (void)appWillTerminate:(NSNotification *)notification
{
[self shutdown];
@ -753,7 +770,7 @@ void System_LaunchUrl(LaunchUrlType urlType, char const* url)
{
NSURL *nsUrl = [NSURL URLWithString:[NSString stringWithCString:url encoding:NSStringEncodingConversionAllowLossy]];
dispatch_async(dispatch_get_main_queue(), ^{
[[UIApplication sharedApplication] openURL:nsUrl] options:@{} completionHandler:nil];
[[UIApplication sharedApplication] openURL:nsUrl options:@{} completionHandler:nil];
});
}

View file

@ -560,3 +560,4 @@ int main(int argc, char *argv[])
return UIApplicationMain(argc, argv, NSStringFromClass([PPSSPPUIApplication class]), NSStringFromClass([AppDelegate class]));
}
}