diff --git a/gfx/common/metal_common.m b/gfx/common/metal_common.m index 3240df3dd3..ba1e297b97 100644 --- a/gfx/common/metal_common.m +++ b/gfx/common/metal_common.m @@ -500,6 +500,12 @@ - (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; + } [self setViewportWidth:(unsigned int)size.width height:(unsigned int)size.height forceFull:NO allowRotate:YES]; } diff --git a/retroarch.c b/retroarch.c index fc216d8713..eaec1c5f34 100644 --- a/retroarch.c +++ b/retroarch.c @@ -31196,7 +31196,8 @@ 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 || @@ -31234,7 +31235,7 @@ 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 3478cea5fb..b7020ec22f 100644 --- a/ui/drivers/ui_cocoatouch.m +++ b/ui/drivers/ui_cocoatouch.m @@ -125,10 +125,11 @@ static void handle_touch_event(NSArray* touches) CGPoint coord; UITouch *touch = [touches objectAtIndex:i]; - if (touch.view != [CocoaView get].view) - continue; +// if (touch.view != [CocoaView get].view) +// 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) { @@ -365,8 +366,15 @@ enum } // _renderView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable; - [_renderView setFrame:self.window.bounds]; - [[CocoaView get].view addSubview:_renderView]; +// [_renderView setFrame:self.window.bounds]; + _renderView.translatesAutoresizingMaskIntoConstraints = NO; + UIView *rootView = [CocoaView get].view; + [rootView addSubview:_renderView]; + [[_renderView.topAnchor constraintEqualToAnchor:rootView.topAnchor] setActive:YES]; + [[_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; @@ -377,7 +385,10 @@ enum } - (void)setVideoMode:(gfx_ctx_mode_t)mode { - // no-op for iOS? + // 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); } - (void)setCursorVisible:(bool)v {