From 1a8ad73c3f8a1e70a6d9b4d59752a829b78893e9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 9 Feb 2019 04:40:38 +0100 Subject: [PATCH] (Cocoa) Unify both headers --- gfx/common/metal_common.m | 11 +- gfx/drivers_context/cocoa_gl_ctx_metal.m | 2 +- .../RetroArch_Metal.xcodeproj/project.pbxproj | 2 - ui/drivers/cocoa/cocoa_common.h | 217 +++++++++++++----- ui/drivers/cocoa/cocoa_common_metal.h | 91 -------- ui/drivers/cocoa/cocoa_common_metal.m | 2 +- ui/drivers/cocoa/cocoa_common_shared.h | 90 -------- ui/drivers/cocoa/ui_cocoa_application.m | 4 - ui/drivers/cocoa/ui_cocoa_browser_window.m | 6 +- ui/drivers/cocoa/ui_cocoa_msg_window.m | 5 +- ui/drivers/cocoa/ui_cocoa_window.m | 4 - ui/drivers/ui_cocoa.h | 4 - ui/drivers/ui_cocoa.m | 5 - ui/drivers/ui_cocoatouch_metal.m | 2 +- 14 files changed, 175 insertions(+), 270 deletions(-) delete mode 100644 ui/drivers/cocoa/cocoa_common_metal.h delete mode 100644 ui/drivers/cocoa/cocoa_common_shared.h diff --git a/gfx/common/metal_common.m b/gfx/common/metal_common.m index c73f715692..705445709e 100644 --- a/gfx/common/metal_common.m +++ b/gfx/common/metal_common.m @@ -6,14 +6,17 @@ // #import -#import "metal_common.h" -#import "../../ui/drivers/cocoa/cocoa_common_metal.h" -#import -#import #import #import + +#import #import #include + +#import + +#import "metal_common.h" +#import "../../ui/drivers/cocoa/cocoa_common.h" #import "Context.h" #ifdef HAVE_MENU diff --git a/gfx/drivers_context/cocoa_gl_ctx_metal.m b/gfx/drivers_context/cocoa_gl_ctx_metal.m index 2cc8a231ab..3cd1fede81 100644 --- a/gfx/drivers_context/cocoa_gl_ctx_metal.m +++ b/gfx/drivers_context/cocoa_gl_ctx_metal.m @@ -34,7 +34,7 @@ #include #include -#import "../../ui/drivers/cocoa/cocoa_common_metal.h" +#import "../../ui/drivers/cocoa/cocoa_common.h" #include "../video_driver.h" #include "../../configuration.h" #include "../../verbosity.h" diff --git a/pkg/apple/RetroArch_Metal.xcodeproj/project.pbxproj b/pkg/apple/RetroArch_Metal.xcodeproj/project.pbxproj index 56c1fd0299..8c53a97d26 100644 --- a/pkg/apple/RetroArch_Metal.xcodeproj/project.pbxproj +++ b/pkg/apple/RetroArch_Metal.xcodeproj/project.pbxproj @@ -555,7 +555,6 @@ A9020AF14B9A73364C6CDDA5 /* cocoa_common_metal.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = cocoa_common_metal.m; sourceTree = ""; }; A9020BD6594399DDAB0E2563 /* ui_cocoatouch_metal.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ui_cocoatouch_metal.m; sourceTree = ""; }; A9020C55D864F0E0C6E7DFF9 /* ui_cocoa_window_metal.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ui_cocoa_window_metal.m; sourceTree = ""; }; - A9020E880B5DBFD909921A8F /* cocoa_common_metal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cocoa_common_metal.h; sourceTree = ""; }; A9020EE4BE2C6A15024A32E0 /* ui_cocoa_metal.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ui_cocoa_metal.m; sourceTree = ""; }; A9020F2EEF870903107B0EA7 /* ui_cocoa_application_metal.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ui_cocoa_application_metal.m; sourceTree = ""; }; A9020F48BA562B13D4789292 /* ui_cocoa_browser_window_metal.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ui_cocoa_browser_window_metal.m; sourceTree = ""; }; @@ -959,7 +958,6 @@ 05A8C5BB20DB72F000FF7857 /* cocoa */ = { isa = PBXGroup; children = ( - A9020E880B5DBFD909921A8F /* cocoa_common_metal.h */, A9020AF14B9A73364C6CDDA5 /* cocoa_common_metal.m */, 05A8C5C220DB72F000FF7857 /* cocoa_common.h */, 05A8C5BD20DB72F000FF7857 /* cocoa_common.m */, diff --git a/ui/drivers/cocoa/cocoa_common.h b/ui/drivers/cocoa/cocoa_common.h index 8a32cbe54c..91565fa4b1 100644 --- a/ui/drivers/cocoa/cocoa_common.h +++ b/ui/drivers/cocoa/cocoa_common.h @@ -1,55 +1,162 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2013-2014 - Jason Fetters - * 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 __COCOA_COMMON_H -#define __COCOA_COMMON_H - -#include "cocoa_common_shared.h" - -#if defined(HAVE_COCOATOUCH) -#if TARGET_OS_IOS -@interface CocoaView : UIViewController -#elif TARGET_OS_TV -@interface CocoaView : GCEventViewController -#endif -+ (CocoaView*)get; -@end - -@interface RetroArch_iOS : UINavigationController - -@property (nonatomic) UIWindow* window; -@property (nonatomic) NSString* documentsDirectory; -@property (nonatomic) RAMenuBase* mainmenu; -@property (nonatomic) int menu_count; - -+ (RetroArch_iOS*)get; - -- (void)showGameView; -- (void)toggleUI; -- (void)supportOtherAudioSessions; - -- (void)refreshSystemConfig; -- (void)mainMenuPushPop: (bool)pushp; -- (void)mainMenuRefresh; -@end - -void get_ios_version(int *major, int *minor); - -#endif - -#endif +/* RetroArch - A frontend for libretro. + * Copyright (C) 2013-2014 - Jason Fetters + * 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 __COCOA_COMMON_SHARED_H +#define __COCOA_COMMON_SHARED_H + +#include + +#ifdef HAVE_MENU +#include "../../menu/menu_setting.h" +#include "../../menu/menu_driver.h" +#endif + +typedef enum apple_view_type { + APPLE_VIEW_TYPE_NONE, + APPLE_VIEW_TYPE_OPENGL_ES, + APPLE_VIEW_TYPE_OPENGL, + APPLE_VIEW_TYPE_VULKAN, + 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 + +#if TARGET_OS_TV +#import +#endif + +/*********************************************/ +/* RAMenuBase */ +/* A menu class that displays RAMenuItemBase */ +/* objects. */ +/*********************************************/ +@interface RAMenuBase : UITableViewController +@property (nonatomic) NSMutableArray* sections; +@property (nonatomic) BOOL hidesHeaders; +@property (nonatomic) RAMenuBase* last_menu; +@property (nonatomic) UILabel *osdmessage; + +- (id)initWithStyle:(UITableViewStyle)style; +- (id)itemForIndexPath:(NSIndexPath*)indexPath; + +@end + +#if TARGET_OS_IOS +@interface CocoaView : UIViewController< +AVCaptureAudioDataOutputSampleBufferDelegate> +#elif TARGET_OS_TV +@interface CocoaView : GCEventViewController +#endif ++ (CocoaView*)get; +@end + +@interface RetroArch_iOS : UINavigationController + +@property (nonatomic) UIWindow* window; +@property (nonatomic) NSString* documentsDirectory; +@property (nonatomic) RAMenuBase* mainmenu; +@property (nonatomic) int menu_count; + ++ (RetroArch_iOS*)get; + +- (void)showGameView; +- (void)toggleUI; +- (void)supportOtherAudioSessions; + +- (void)refreshSystemConfig; +- (void)mainMenuPushPop: (bool)pushp; +- (void)mainMenuRefresh; +@end + +void get_ios_version(int *major, int *minor); + +#endif + +typedef struct +{ + char orientations[32]; + unsigned orientation_flags; + char bluetooth_mode[64]; +} apple_frontend_settings_t; +extern apple_frontend_settings_t apple_frontend_settings; + +#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL) +#include + +@interface CocoaView : NSView + ++ (CocoaView*)get; +#if !defined(HAVE_COCOA) && !defined(HAVE_COCOA_METAL) +- (void)display; +#endif + +@end + +#endif + +#define BOXSTRING(x) [NSString stringWithUTF8String:x] +#define BOXINT(x) [NSNumber numberWithInt:x] +#define BOXUINT(x) [NSNumber numberWithUnsignedInt:x] +#define BOXFLOAT(x) [NSNumber numberWithDouble:x] + +#if __has_feature(objc_arc) +#define RELEASE(x) x = nil +#define BRIDGE __bridge +#define UNSAFE_UNRETAINED __unsafe_unretained +#else +#define RELEASE(x) [x release]; \ + x = nil +#define BRIDGE +#define UNSAFE_UNRETAINED +#endif + +#endif diff --git a/ui/drivers/cocoa/cocoa_common_metal.h b/ui/drivers/cocoa/cocoa_common_metal.h deleted file mode 100644 index c3f5c28ff4..0000000000 --- a/ui/drivers/cocoa/cocoa_common_metal.h +++ /dev/null @@ -1,91 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2013-2014 - Jason Fetters - * 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 __COCOA_COMMON_METAL_H -#define __COCOA_COMMON_METAL_H - -#include "cocoa_common_shared.h" - -typedef enum apple_view_type { - APPLE_VIEW_TYPE_NONE, - APPLE_VIEW_TYPE_OPENGL_ES, - APPLE_VIEW_TYPE_OPENGL, - APPLE_VIEW_TYPE_VULKAN, - APPLE_VIEW_TYPE_METAL, -} apple_view_type_t; - -#ifdef HAVE_METAL -#import - -@interface MetalView : MTKView -@end - -#endif - -@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; - -#if defined(HAVE_COCOATOUCH) -@interface CocoaView : UIViewController -+ (CocoaView*)get; -@end - -@interface RetroArch_iOS : UINavigationController - -@property (nonatomic) UIWindow* window; -@property (nonatomic) NSString* documentsDirectory; -@property (nonatomic) RAMenuBase* mainmenu; -@property (nonatomic) int menu_count; - -+ (RetroArch_iOS*)get; - -- (void)showGameView; -- (void)toggleUI; -- (void)supportOtherAudioSessions; - -- (void)refreshSystemConfig; -- (void)mainMenuPushPop: (bool)pushp; -- (void)mainMenuRefresh; -@end - -void get_ios_version(int *major, int *minor); - -#endif - -#endif diff --git a/ui/drivers/cocoa/cocoa_common_metal.m b/ui/drivers/cocoa/cocoa_common_metal.m index 6ae4d47015..d20186285b 100644 --- a/ui/drivers/cocoa/cocoa_common_metal.m +++ b/ui/drivers/cocoa/cocoa_common_metal.m @@ -16,7 +16,7 @@ #import #include -#include "cocoa_common_metal.h" +#include "cocoa_common.h" #include "../ui_cocoa.h" #include diff --git a/ui/drivers/cocoa/cocoa_common_shared.h b/ui/drivers/cocoa/cocoa_common_shared.h deleted file mode 100644 index 209e48621b..0000000000 --- a/ui/drivers/cocoa/cocoa_common_shared.h +++ /dev/null @@ -1,90 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2013-2014 - Jason Fetters - * 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 __COCOA_COMMON_SHARED_H -#define __COCOA_COMMON_SHARED_H - -#include - -#ifdef HAVE_MENU -#include "../../menu/menu_setting.h" -#include "../../menu/menu_driver.h" -#endif - -#if defined(HAVE_COCOATOUCH) -#include - -#if TARGET_OS_TV -#import -#endif - -/*********************************************/ -/* RAMenuBase */ -/* A menu class that displays RAMenuItemBase */ -/* objects. */ -/*********************************************/ -@interface RAMenuBase : UITableViewController -@property (nonatomic) NSMutableArray* sections; -@property (nonatomic) BOOL hidesHeaders; -@property (nonatomic) RAMenuBase* last_menu; -@property (nonatomic) UILabel *osdmessage; - -- (id)initWithStyle:(UITableViewStyle)style; -- (id)itemForIndexPath:(NSIndexPath*)indexPath; - -@end - -#endif - -typedef struct -{ - char orientations[32]; - unsigned orientation_flags; - char bluetooth_mode[64]; -} apple_frontend_settings_t; -extern apple_frontend_settings_t apple_frontend_settings; - -#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL) -#include - -@interface CocoaView : NSView - -+ (CocoaView*)get; -#if !defined(HAVE_COCOA) && !defined(HAVE_COCOA_METAL) -- (void)display; -#endif - -@end - -#endif - -#define BOXSTRING(x) [NSString stringWithUTF8String:x] -#define BOXINT(x) [NSNumber numberWithInt:x] -#define BOXUINT(x) [NSNumber numberWithUnsignedInt:x] -#define BOXFLOAT(x) [NSNumber numberWithDouble:x] - -#if __has_feature(objc_arc) -#define RELEASE(x) x = nil -#define BRIDGE __bridge -#define UNSAFE_UNRETAINED __unsafe_unretained -#else -#define RELEASE(x) [x release]; \ - x = nil -#define BRIDGE -#define UNSAFE_UNRETAINED -#endif - -#endif diff --git a/ui/drivers/cocoa/ui_cocoa_application.m b/ui/drivers/cocoa/ui_cocoa_application.m index d81e79b3f8..14c67ad927 100644 --- a/ui/drivers/cocoa/ui_cocoa_application.m +++ b/ui/drivers/cocoa/ui_cocoa_application.m @@ -20,11 +20,7 @@ #include #include -#if defined(HAVE_COCOA_METAL) -#include "cocoa_common_metal.h" -#elif defined(HAVE_COCOA) #include "cocoa_common.h" -#endif #include "../../ui_companion_driver.h" static void* ui_application_cocoa_initialize(void) diff --git a/ui/drivers/cocoa/ui_cocoa_browser_window.m b/ui/drivers/cocoa/ui_cocoa_browser_window.m index 24acd9057b..d179f335f2 100644 --- a/ui/drivers/cocoa/ui_cocoa_browser_window.m +++ b/ui/drivers/cocoa/ui_cocoa_browser_window.m @@ -21,11 +21,7 @@ #include -#if defined(HAVE_COCOA_METAL) -#include "cocoa_common_metal.h" -#elif defined(HAVE_COCOA) -#endif - +#include "cocoa_common.h" #include "../../ui_companion_driver.h" static bool ui_browser_window_cocoa_open(ui_browser_window_state_t *state) diff --git a/ui/drivers/cocoa/ui_cocoa_msg_window.m b/ui/drivers/cocoa/ui_cocoa_msg_window.m index cf8e92cc43..4cfa5c1a4b 100644 --- a/ui/drivers/cocoa/ui_cocoa_msg_window.m +++ b/ui/drivers/cocoa/ui_cocoa_msg_window.m @@ -21,10 +21,9 @@ #include -#if defined(HAVE_COCOA_METAL) -#include "cocoa_common_metal.h" -#elif defined(HAVE_COCOA) #include "cocoa_common.h" + +#if defined(HAVE_COCOA) extern id apple_platform; #endif diff --git a/ui/drivers/cocoa/ui_cocoa_window.m b/ui/drivers/cocoa/ui_cocoa_window.m index 586f4fbd89..83db6dcaae 100644 --- a/ui/drivers/cocoa/ui_cocoa_window.m +++ b/ui/drivers/cocoa/ui_cocoa_window.m @@ -21,11 +21,7 @@ #include -#if defined(HAVE_COCOA_METAL) -#include "cocoa_common_metal.h" -#elif defined(HAVE_COCOA) #include "cocoa_common.h" -#endif #include "../ui_cocoa.h" #include "../../ui_companion_driver.h" diff --git a/ui/drivers/ui_cocoa.h b/ui/drivers/ui_cocoa.h index cbd7054e44..6b50692cef 100644 --- a/ui/drivers/ui_cocoa.h +++ b/ui/drivers/ui_cocoa.h @@ -23,11 +23,7 @@ #include #include -#if defined(HAVE_COCOA_METAL) -#include "cocoa/cocoa_common_metal.h" -#elif defined(HAVE_COCOA) #include "cocoa/cocoa_common.h" -#endif #include "../ui_companion_driver.h" diff --git a/ui/drivers/ui_cocoa.m b/ui/drivers/ui_cocoa.m index 106f9ec747..7ef1bc35b2 100644 --- a/ui/drivers/ui_cocoa.m +++ b/ui/drivers/ui_cocoa.m @@ -26,12 +26,7 @@ #include #include -#if defined(HAVE_COCOA_METAL) -#include "cocoa/cocoa_common_metal.h" -#elif defined(HAVE_COCOA) #include "cocoa/cocoa_common.h" -#endif - #include "../ui_companion_driver.h" #include "../../input/drivers/cocoa_input.h" #include "../../input/drivers_keyboard/keyboard_event_apple.h" diff --git a/ui/drivers/ui_cocoatouch_metal.m b/ui/drivers/ui_cocoatouch_metal.m index 79eb9865c0..a7dcfadbda 100644 --- a/ui/drivers/ui_cocoatouch_metal.m +++ b/ui/drivers/ui_cocoatouch_metal.m @@ -25,7 +25,7 @@ #include #include -#include "cocoa/cocoa_common_metal.h" +#include "cocoa/cocoa_common.h" #include "../ui_companion_driver.h" #include "../../configuration.h" #include "../../frontend/frontend.h"