diff --git a/gfx/common/metal_common.h b/gfx/common/metal_common.h index c325b2d51e..33f7f36ef4 100644 --- a/gfx/common/metal_common.h +++ b/gfx/common/metal_common.h @@ -1,9 +1,18 @@ -// -// metal_common.h -// RetroArch_Metal -// -// Created by Stuart Carnie on 5/14/18. -// +/* RetroArch - A frontend for libretro. + * Copyright (C) 2018-2019 - Stuart Carnie + * Copyright (C) 2011-2017 - Daniel De Matteis + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ #ifndef METAL_COMMON_H__ #define METAL_COMMON_H__ @@ -26,6 +35,38 @@ extern MTLPixelFormat SelectOptimalPixelFormat(MTLPixelFormat fmt); #pragma mark - Classes +#import + +@interface MetalView : MTKView +@end + +#ifdef HAVE_COCOA_METAL + +@protocol ApplePlatform + +/*! @brief renderView returns the current render view based on the viewType */ +@property (readonly) id renderView; + +/*! @brief isActive returns true if the application has focus */ +@property (readonly) bool hasFocus; + +@property (readwrite) apple_view_type_t viewType; + +/*! @brief setVideoMode adjusts the video display to the specified mode */ +- (void)setVideoMode:(gfx_ctx_mode_t)mode; + +/*! @brief setCursorVisible specifies whether the cursor is visible */ +- (void)setCursorVisible:(bool)v; + +/*! @brief controls whether the screen saver should be disabled and + * the displays should not sleep. + */ +- (bool)setDisableDisplaySleep:(bool)disable; +@end + +extern id apple_platform; +#endif + @interface FrameView : NSObject @property (nonatomic, readonly) RPixelFormat format; diff --git a/gfx/common/metal_common.m b/gfx/common/metal_common.m index aeb62340d6..19a9e163f2 100644 --- a/gfx/common/metal_common.m +++ b/gfx/common/metal_common.m @@ -1,8 +1,17 @@ -/* - * metal_common.m - * RetroArch_Metal +/* RetroArch - A frontend for libretro. + * Copyright (C) 2018-2019 - Stuart Carnie + * Copyright (C) 2011-2017 - Daniel De Matteis * - * Created by Stuart Carnie on 5/14/18. + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . */ #import @@ -39,6 +48,24 @@ x = (__bridge __typeof__(x))(__bridge_retained void *)((NSObject *)__y); \ } +@implementation MetalView + +- (void)keyDown:(NSEvent*)theEvent +{ +} + +/* Stop the annoying sound when pressing a key. */ +- (BOOL)acceptsFirstResponder +{ + return YES; +} + +- (BOOL)isFlipped +{ + return YES; +} +@end + #pragma mark - private categories @interface FrameView() diff --git a/ui/drivers/cocoa/cocoa_common.h b/ui/drivers/cocoa/cocoa_common.h index 81be4afd20..f7aeb94008 100644 --- a/ui/drivers/cocoa/cocoa_common.h +++ b/ui/drivers/cocoa/cocoa_common.h @@ -50,40 +50,6 @@ typedef enum apple_view_type { APPLE_VIEW_TYPE_METAL, } apple_view_type_t; -#ifdef HAVE_METAL -#import - -@interface MetalView : MTKView -@end - -#ifdef HAVE_COCOA_METAL - -@protocol ApplePlatform - -/*! @brief renderView returns the current render view based on the viewType */ -@property (readonly) id renderView; - -/*! @brief isActive returns true if the application has focus */ -@property (readonly) bool hasFocus; - -@property (readwrite) apple_view_type_t viewType; - -/*! @brief setVideoMode adjusts the video display to the specified mode */ -- (void)setVideoMode:(gfx_ctx_mode_t)mode; - -/*! @brief setCursorVisible specifies whether the cursor is visible */ -- (void)setCursorVisible:(bool)v; - -/*! @brief controls whether the screen saver should be disabled and - * the displays should not sleep. - */ -- (bool)setDisableDisplaySleep:(bool)disable; -@end - -extern id apple_platform; -#endif -#endif - #if defined(HAVE_COCOATOUCH) #include diff --git a/ui/drivers/cocoa/cocoa_common.m b/ui/drivers/cocoa/cocoa_common.m index 3705e2ac77..18b86bbb1d 100644 --- a/ui/drivers/cocoa/cocoa_common.m +++ b/ui/drivers/cocoa/cocoa_common.m @@ -29,27 +29,6 @@ #ifdef HAVE_COCOATOUCH #import "GCDWebUploader.h" #import "WebServer.h" - -#endif - -#ifdef HAVE_METAL -@implementation MetalView - -- (void)keyDown:(NSEvent*)theEvent -{ -} - -/* Stop the annoying sound when pressing a key. */ -- (BOOL)acceptsFirstResponder -{ - return YES; -} - -- (BOOL)isFlipped -{ - return YES; -} -@end #endif static CocoaView* g_instance; @@ -354,6 +333,6 @@ void *glkitview_init(void); }]; #endif } -#endif // end HAVE_COCOATOUCH +#endif @end