mirror of
https://github.com/libretro/RetroArch
synced 2025-03-17 10:21:26 +00:00
iOS: remove pause indicator; show the native UI menu using 4-finger swipe down gesture
This commit is contained in:
parent
b38994461c
commit
45b36d7d47
@ -60,7 +60,6 @@ static enum gfx_ctx_api cocoagl_api = GFX_CTX_NONE;
|
||||
|
||||
#if defined(HAVE_COCOATOUCH)
|
||||
static GLKView *g_view;
|
||||
UIView *g_pause_indicator_view;
|
||||
#endif
|
||||
|
||||
static GLContextClass* g_hw_ctx;
|
||||
@ -151,16 +150,9 @@ static void cocoagl_gfx_ctx_set_flags(void *data, uint32_t flags)
|
||||
void *glkitview_init(void)
|
||||
{
|
||||
#if defined(HAVE_COCOATOUCH)
|
||||
#if TARGET_OS_IOS
|
||||
/* iOS Pause menu and lifecycle. */
|
||||
UINib *xib = (UINib*)[UINib nibWithNibName:BOXSTRING("PauseIndicatorView") bundle:nil];
|
||||
g_pause_indicator_view = [[xib instantiateWithOwner:[RetroArch_iOS get] options:nil] lastObject];
|
||||
#endif
|
||||
|
||||
g_view = [GLKView new];
|
||||
#if TARGET_OS_IOS
|
||||
g_view.multipleTouchEnabled = YES;
|
||||
[g_view addSubview:g_pause_indicator_view];
|
||||
#endif
|
||||
g_view.enableSetNeedsDisplay = NO;
|
||||
|
||||
|
@ -31,7 +31,6 @@
|
||||
#import "GCDWebUploader.h"
|
||||
#import "WebServer.h"
|
||||
|
||||
extern UIView *g_pause_indicator_view;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_METAL
|
||||
@ -113,7 +112,10 @@ void *glkitview_init(void);
|
||||
#elif defined(HAVE_COCOATOUCH)
|
||||
self.view = (BRIDGE GLKView*)glkitview_init();
|
||||
#if TARGET_OS_IOS
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showPauseIndicator) name:UIApplicationWillEnterForegroundNotification object:nil];
|
||||
UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(showNativeMenu)];
|
||||
swipe.numberOfTouchesRequired = 4;
|
||||
swipe.direction = UISwipeGestureRecognizerDirectionDown;
|
||||
[self.view addGestureRecognizer:swipe];
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -179,6 +181,10 @@ void *glkitview_init(void);
|
||||
}
|
||||
|
||||
#elif TARGET_OS_IOS
|
||||
-(void) showNativeMenu {
|
||||
[[RetroArch_iOS get] toggleUI];
|
||||
}
|
||||
|
||||
- (UIRectEdge)preferredScreenEdgesDeferringSystemGestures
|
||||
{
|
||||
return UIRectEdgeBottom;
|
||||
@ -218,13 +224,6 @@ void *glkitview_init(void);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showPauseIndicator
|
||||
{
|
||||
g_pause_indicator_view.alpha = 1.0f;
|
||||
[NSObject cancelPreviousPerformRequestsWithTarget:g_instance];
|
||||
[g_instance performSelector:@selector(hidePauseButton) withObject:g_instance afterDelay:3.0f];
|
||||
}
|
||||
|
||||
- (void)viewWillLayoutSubviews
|
||||
{
|
||||
float width = 0.0f, height = 0.0f, tenpctw, tenpcth;
|
||||
@ -248,21 +247,9 @@ void *glkitview_init(void);
|
||||
tenpctw = width / 10.0f;
|
||||
tenpcth = height / 10.0f;
|
||||
|
||||
g_pause_indicator_view.frame = CGRectMake(tenpctw * 4.0f, 0.0f, tenpctw * 2.0f, tenpcth);
|
||||
[g_pause_indicator_view viewWithTag:1].frame = CGRectMake(0, 0, tenpctw * 2.0f, tenpcth);
|
||||
[self adjustViewFrameForSafeArea];
|
||||
}
|
||||
|
||||
#define ALMOST_INVISIBLE (.021f)
|
||||
|
||||
- (void)hidePauseButton
|
||||
{
|
||||
[UIView animateWithDuration:0.2
|
||||
animations:^{ g_pause_indicator_view.alpha = ALMOST_INVISIBLE; }
|
||||
completion:^(BOOL finished) { }
|
||||
];
|
||||
}
|
||||
|
||||
/* NOTE: This version runs on iOS6+. */
|
||||
- (NSUInteger)supportedInterfaceOrientations
|
||||
{
|
||||
@ -295,8 +282,6 @@ void *glkitview_init(void);
|
||||
- (void)viewDidAppear:(BOOL)animated
|
||||
{
|
||||
#if TARGET_OS_IOS
|
||||
/* Pause Menus. */
|
||||
[self showPauseIndicator];
|
||||
if (@available(iOS 11.0, *)) {
|
||||
[self setNeedsUpdateOfHomeIndicatorAutoHidden];
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user