From 3e35593f59867c4537f6fcc190f530e913612785 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Sun, 12 Apr 2015 03:18:37 +0200 Subject: [PATCH] (iOS) Implement UI companion driver for iOS CocoaTouch --- apple/iOS/platform.m | 34 ---------- config.def.h | 5 +- configuration.c | 2 - frontend/drivers/platform_apple.c | 23 ++----- griffin/griffin.c | 4 -- griffin/griffin_objc.m | 2 +- menu/drivers/ios.c | 101 ------------------------------ menu/drivers/ios.h | 25 -------- menu/menu_driver.c | 3 - menu/menu_driver.h | 1 - ui/drivers/ui_cocoatouch.m | 2 +- ui/ui_companion_driver.c | 3 + 12 files changed, 11 insertions(+), 194 deletions(-) delete mode 100644 menu/drivers/ios.c delete mode 100644 menu/drivers/ios.h diff --git a/apple/iOS/platform.m b/apple/iOS/platform.m index 01e2fb5da8..e981d4b10b 100644 --- a/apple/iOS/platform.m +++ b/apple/iOS/platform.m @@ -28,8 +28,6 @@ #import "views.h" #include "../../input/drivers_hid/btstack_hid.h" -#include "../../menu/drivers/ios.h" - id apple_platform; static CFRunLoopObserverRef iterate_observer; @@ -261,31 +259,8 @@ enum return (RetroArch_iOS*)[[UIApplication sharedApplication] delegate]; } -void switch_to_ios(void) -{ - RetroArch_iOS *ap; - runloop_t *runloop = rarch_main_get_ptr(); - - if (!apple_platform) - return; - - ap = (RetroArch_iOS *)apple_platform; - runloop->is_idle = true; - [ap showPauseMenu:ap]; -} - -void notify_content_loaded(void) -{ - if (!apple_platform) - return; - - RetroArch_iOS *ap = (RetroArch_iOS *)apple_platform; - [ap showGameView]; -} - - (void)applicationDidFinishLaunching:(UIApplication *)application { - driver_t *driver = NULL; apple_platform = self; [self setDelegate:self]; @@ -304,15 +279,6 @@ void notify_content_loaded(void) if (rarch_main(0, NULL)) apple_rarch_exited(); - driver = driver_get_ptr(); - - if ( driver->menu_ctx && driver->menu_ctx == &menu_ctx_ios && driver->menu && driver->menu->userdata ) - { - ios_handle_t *ih = (ios_handle_t*)driver->menu->userdata; - ih->switch_to_ios = switch_to_ios; - ih->notify_content_loaded = notify_content_loaded; - } - #ifdef HAVE_MFI apple_gamecontroller_init(); #endif diff --git a/config.def.h b/config.def.h index ea38f25e55..9a7cbc6d58 100644 --- a/config.def.h +++ b/config.def.h @@ -126,7 +126,6 @@ enum MENU_RMENU_XUI, MENU_GLUI, MENU_XMB, - MENU_IOS, }; #if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) || defined(__CELLOS_LV2__) @@ -305,9 +304,7 @@ enum #define OSK_DEFAULT_DRIVER OSK_NULL #endif -#if defined(IOS) -#define MENU_DEFAULT_DRIVER MENU_IOS -#elif defined(HAVE_RMENU) +#if defined(HAVE_RMENU) #define MENU_DEFAULT_DRIVER MENU_RMENU #elif defined(HAVE_RMENU_XUI) #define MENU_DEFAULT_DRIVER MENU_RMENU_XUI diff --git a/configuration.c b/configuration.c index f96aac2ff5..d6066ccc13 100644 --- a/configuration.c +++ b/configuration.c @@ -319,8 +319,6 @@ const char *config_get_default_menu(void) return "rmenu_xui"; case MENU_GLUI: return "glui"; - case MENU_IOS: - return "ios"; case MENU_XMB: return "xmb"; default: diff --git a/frontend/drivers/platform_apple.c b/frontend/drivers/platform_apple.c index 726910776d..b9ce300391 100644 --- a/frontend/drivers/platform_apple.c +++ b/frontend/drivers/platform_apple.c @@ -18,9 +18,7 @@ #include "../../apple/common/CFExtensions.h" #include "../frontend_driver.h" -#ifdef IOS -#include "../../menu/drivers/ios.h" -#endif +#include "../ui/ui_companion_driver.h" #include #include @@ -205,22 +203,11 @@ extern void apple_rarch_exited(void); static void frontend_apple_load_content(void) { - driver_t *driver = driver_get_ptr(); - if (!driver->menu_ctx) - return; - if (!driver->menu) - return; - if (!driver->menu->userdata) - return; + driver_t *driver = driver_get_ptr(); + const ui_companion_driver_t *ui = ui_companion_get_ptr(); -#ifdef IOS - if (driver->menu_ctx == &menu_ctx_ios) - { - ios_handle_t *ih = (ios_handle_t*)driver->menu->userdata; - if (ih) - ih->notify_content_loaded(); - } -#endif + if (ui) + ui->notify_content_loaded(driver->ui_companion_data); } static void frontend_apple_shutdown(bool unused) diff --git a/griffin/griffin.c b/griffin/griffin.c index 2e73ab1c7f..f1fb84dafb 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -751,10 +751,6 @@ MENU #endif -#ifdef IOS -#include "../menu/drivers/ios.c" -#endif - #ifdef HAVE_COMMAND #include "../command.c" #endif diff --git a/griffin/griffin_objc.m b/griffin/griffin_objc.m index 1dca7d2a87..ecda0dbc06 100644 --- a/griffin/griffin_objc.m +++ b/griffin/griffin_objc.m @@ -14,7 +14,7 @@ #include "../apple/iOS/platform.m" #include "../apple/iOS/menu.m" #include "../apple/iOS/browser.m" -//#include "../ui/drivers/ui_cocoatouch.m" +#include "../ui/drivers/ui_cocoatouch.m" #else #include "../apple/OSX/platform.m" #include "../apple/OSX/settings.m" diff --git a/menu/drivers/ios.c b/menu/drivers/ios.c deleted file mode 100644 index f7a7ffa055..0000000000 --- a/menu/drivers/ios.c +++ /dev/null @@ -1,101 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2014-2015 - Jay McCarthy - * - * 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 . - */ - -#include -#include -#include -#include -#include -#include -#include "../menu_driver.h" -#include "../menu.h" -#include "../../general.h" -#include "ios.h" -#include "../menu_input.h" - -static int ios_entry_iterate(unsigned action) -{ - ios_handle_t *ios = NULL; - menu_handle_t *menu = menu_driver_get_ptr(); - - if (!menu) - return -1; - - ios = (ios_handle_t*)menu->userdata; - - if (ios && ios->switch_to_ios) - ios->switch_to_ios(); - - return 0; -} - -static void *ios_init(void) -{ - menu_handle_t *menu = (menu_handle_t*)calloc(1, sizeof(*menu)); - if (!menu) - goto error; - - menu->userdata = (ios_handle_t*)calloc(1, sizeof(ios_handle_t)); - if (!menu->userdata) - goto error; - - return menu; -error: - if (menu->userdata) - free(menu->userdata); - if (menu) - free(menu); - return NULL; -} - -static void ios_free(void *data) -{ - menu_handle_t *menu = (menu_handle_t*)data; - if (!menu) - return; - - if (menu->userdata) - free(menu->userdata); - - free(menu); -} - -menu_ctx_driver_t menu_ctx_ios = { - NULL, // set_texture - NULL, // render_messagebox - NULL, // render - NULL, // frame - ios_init, // init - ios_free, // free - NULL, // context_reset - NULL, // context_destroy - NULL, // populate_entries - NULL, // toggle - NULL, // navigation_clear - NULL, // navigation_decrement - NULL, // navigation_increment - NULL, // navigation_set - NULL, // navigation_set_last - NULL, // navigation_descend_alphabet - NULL, // navigation_ascend_alphabet - NULL, // list_insert - NULL, // list_delete - NULL, // list_clear - NULL, // list_cache - NULL, // list_set_selection - ios_entry_iterate, - NULL, - "ios", -}; diff --git a/menu/drivers/ios.h b/menu/drivers/ios.h deleted file mode 100644 index 2867dbd813..0000000000 --- a/menu/drivers/ios.h +++ /dev/null @@ -1,25 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2014-2015 - Jay McCarthy - * - * 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 _MENU_DISP_IOS_H -#define _MENU_DISP_IOS_H - -typedef struct ios_handle -{ - void (*switch_to_ios)(void); - void (*notify_content_loaded)(void); -} ios_handle_t; - -#endif diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 5d963aa346..8493456d0e 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -23,9 +23,6 @@ #include "../general.h" static const menu_ctx_driver_t *menu_ctx_drivers[] = { -#ifdef IOS - &menu_ctx_ios, -#endif #if defined(HAVE_RMENU) &menu_ctx_rmenu, #endif diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 0c67803671..f902bdb3a4 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -263,7 +263,6 @@ extern menu_ctx_driver_t menu_ctx_rmenu_xui; extern menu_ctx_driver_t menu_ctx_rgui; extern menu_ctx_driver_t menu_ctx_glui; extern menu_ctx_driver_t menu_ctx_xmb; -extern menu_ctx_driver_t menu_ctx_ios; extern menu_ctx_driver_t menu_ctx_null; /** diff --git a/ui/drivers/ui_cocoatouch.m b/ui/drivers/ui_cocoatouch.m index 1b20a3cd84..57d2ab42c4 100644 --- a/ui/drivers/ui_cocoatouch.m +++ b/ui/drivers/ui_cocoatouch.m @@ -50,7 +50,7 @@ void notify_content_loaded(void) [ap showGameView]; } -static int ui_companion_cocoatouch_entry_iterate(void *data, unsigned action) +static int ui_companion_cocoatouch_iterate(void *data, unsigned action) { (void)data; diff --git a/ui/ui_companion_driver.c b/ui/ui_companion_driver.c index 3e99e79798..f33760d3bf 100644 --- a/ui/ui_companion_driver.c +++ b/ui/ui_companion_driver.c @@ -22,6 +22,9 @@ #endif static const ui_companion_driver_t *ui_companion_drivers[] = { +#ifdef IOS + &ui_companion_cocoatouch, +#endif &ui_companion_null, NULL };