From a19f1451cdff5f441e3d6d4794cfaf5f36fc2de0 Mon Sep 17 00:00:00 2001 From: Yoshi Sugawara Date: Sun, 19 Jul 2020 00:11:15 -1000 Subject: [PATCH] removed debug logging statements; enable multi touch on metal view to support touchscreen controls; fixed setting the metal view drawable size based on the view bounds size in pixels --- gfx/common/metal_common.m | 13 ++++++++----- retroarch.c | 3 --- ui/drivers/ui_cocoatouch.m | 20 +++++++------------- 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/gfx/common/metal_common.m b/gfx/common/metal_common.m index ba1e297b97..9846c944b5 100644 --- a/gfx/common/metal_common.m +++ b/gfx/common/metal_common.m @@ -501,12 +501,15 @@ - (void)mtkView:(MTKView *)view drawableSizeWillChange:(CGSize)size { NSLog(@"mtkView drawableSizeWillChange to: %f x %f",size.width,size.height); - // due to autolayout constraints? - if (size.width == INFINITY || size.height == INFINITY) { - NSLog(@"mtkView drawableSizeWillChange width or height is inifinity, skipping..."); - return; - } +#ifdef HAVE_COCOATOUCH + CGFloat scale = [[UIScreen mainScreen] scale]; +// // due to autolayout constraints? +//// if (size.width == INFINITY || size.height == INFINITY) { +// NSLog(@"mtkView drawableSizeWillChange width or height is infinity, flipping..."); + [self setViewportWidth:(unsigned int)view.bounds.size.width*scale height:(unsigned int)view.bounds.size.height*scale forceFull:NO allowRotate:YES]; +#else [self setViewportWidth:(unsigned int)size.width height:(unsigned int)size.height forceFull:NO allowRotate:YES]; +#endif } - (void)drawInMTKView:(MTKView *)view diff --git a/retroarch.c b/retroarch.c index eaec1c5f34..15ee9ef9e5 100644 --- a/retroarch.c +++ b/retroarch.c @@ -31196,8 +31196,6 @@ bool video_driver_translate_coord_viewport( int norm_vp_height = (int)vp->height; int norm_full_vp_width = (int)vp->full_width; int norm_full_vp_height = (int)vp->full_height; - printf("yoshi debug: video size: %i, %i full size: %i, %i \n",norm_vp_width,norm_vp_height,norm_full_vp_width,norm_full_vp_height); - printf("yoshi debug: video_driver_translate_coord_viewport: incoming mouse coord: %i,%i \n",mouse_x,mouse_y); if (norm_vp_width <= 0 || norm_vp_height <= 0 || norm_full_vp_width <= 0 || @@ -31235,7 +31233,6 @@ bool video_driver_translate_coord_viewport( *res_y = scaled_y; *res_screen_x = scaled_screen_x; *res_screen_y = scaled_screen_y; - printf("yoshi debug: translated coordinates: res: (%i,%i) res_screen:(%i,%i) \n",scaled_x,scaled_y,scaled_screen_x,scaled_screen_y); return true; } diff --git a/ui/drivers/ui_cocoatouch.m b/ui/drivers/ui_cocoatouch.m index 000f9ce339..ec7a52e299 100644 --- a/ui/drivers/ui_cocoatouch.m +++ b/ui/drivers/ui_cocoatouch.m @@ -129,8 +129,6 @@ static void handle_touch_event(NSArray* touches) // continue; coord = [touch locationInView:[touch view]]; - NSLog(@"yoshi debug: handle_touch_event: coord = %f,%f , scaled = %f,%f",coord.x,coord.y,coord.x*scale,coord.y*scale); - if (touch.phase != UITouchPhaseEnded && touch.phase != UITouchPhaseCancelled) { apple->touches[apple->touch_count ].screen_x = coord.x * scale; @@ -350,6 +348,7 @@ enum MetalView *v = [MetalView new]; v.paused = YES; v.enableSetNeedsDisplay = NO; + v.multipleTouchEnabled = YES; _renderView = v; } break; @@ -365,8 +364,6 @@ enum return; } -// _renderView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable; -// [_renderView setFrame:self.window.bounds]; _renderView.translatesAutoresizingMaskIntoConstraints = NO; UIView *rootView = [CocoaView get].view; [rootView addSubview:_renderView]; @@ -374,10 +371,6 @@ enum [[_renderView.bottomAnchor constraintEqualToAnchor:rootView.bottomAnchor] setActive:YES]; [[_renderView.leadingAnchor constraintEqualToAnchor:rootView.leadingAnchor] setActive:YES]; [[_renderView.trailingAnchor constraintEqualToAnchor:rootView.trailingAnchor] setActive:YES]; - - -// [self.window addSubview:_renderView]; -// self.window.contentView.nextResponder = _listener; } - (apple_view_type_t)viewType { @@ -385,12 +378,13 @@ enum } - (void)setVideoMode:(gfx_ctx_mode_t)mode { - // hmm might need some scaling factor... MetalView *metalView = (MetalView*) _renderView; - [metalView setDrawableSize:CGSizeMake(mode.width, mode.height)]; - NSLog(@"setVideoMode set drawable size to %i x %i",mode.width,mode.height); - // hardcoding test! - [metalView setDrawableSize:CGSizeMake(1242.0,2668.0)]; + CGFloat scale = [[UIScreen mainScreen] scale]; + [metalView setDrawableSize:CGSizeMake( + _renderView.bounds.size.width * scale, + _renderView.bounds.size.height * scale + ) + ]; } - (void)setCursorVisible:(bool)v {