From 4c2b301efbfc6f72d24e676ee24812868a6f1008 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 12 Apr 2015 01:31:03 +0200 Subject: [PATCH] (UI Companion) Start creating UI companion interface --- Makefile.common | 2 ++ driver.h | 2 ++ griffin/griffin.c | 7 ++++ ui/drivers/ui_null.c | 40 +++++++++++++++++++++ ui/ui_companion_driver.c | 77 ++++++++++++++++++++++++++++++++++++++++ ui/ui_companion_driver.h | 68 +++++++++++++++++++++++++++++++++++ 6 files changed, 196 insertions(+) create mode 100644 ui/drivers/ui_null.c create mode 100644 ui/ui_companion_driver.c create mode 100644 ui/ui_companion_driver.h diff --git a/Makefile.common b/Makefile.common index 8defec2bfa..b03cc09226 100644 --- a/Makefile.common +++ b/Makefile.common @@ -94,6 +94,8 @@ endif OBJ += frontend/frontend.o \ frontend/frontend_driver.o \ frontend/drivers/platform_null.o \ + ui/ui_companion_driver.o \ + ui/drivers/ui_null.o \ libretro_version_1.o \ retroarch.o \ runloop.o \ diff --git a/driver.h b/driver.h index c59ea8d83a..e944fe0b3e 100644 --- a/driver.h +++ b/driver.h @@ -27,6 +27,7 @@ #include #include "frontend/frontend_driver.h" +#include "ui/ui_companion_driver.h" #include "gfx/video_driver.h" #include "audio/audio_driver.h" @@ -190,6 +191,7 @@ enum typedef struct driver { const frontend_ctx_driver_t *frontend_ctx; + const ui_companion_driver_t *ui_companion; const audio_driver_t *audio; const video_driver_t *video; const void *video_context; diff --git a/griffin/griffin.c b/griffin/griffin.c index 66e40b7be1..2e73ab1c7f 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -634,6 +634,13 @@ FRONTEND #include "../core_info.c" +/*============================================================ +UI +============================================================ */ +#include "../ui/ui_companion_driver.c" + +#include "../ui/drivers/ui_null.c" + /*============================================================ MAIN ============================================================ */ diff --git a/ui/drivers/ui_null.c b/ui/drivers/ui_null.c new file mode 100644 index 0000000000..d4e67ba085 --- /dev/null +++ b/ui/drivers/ui_null.c @@ -0,0 +1,40 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2014-2015 - Ali Bouhlel + * + * 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 "../ui_companion_driver.h" + +static void ui_companion_null_deinit(void *data) +{ + (void)data; +} + +static void ui_companion_null_init(void *data) +{ + (void)data; +} + +const ui_companion_driver_t ui_companion_null = { + ui_companion_null_init, + ui_companion_null_deinit, + NULL, + NULL, + "null", +}; diff --git a/ui/ui_companion_driver.c b/ui/ui_companion_driver.c new file mode 100644 index 0000000000..c748be54db --- /dev/null +++ b/ui/ui_companion_driver.c @@ -0,0 +1,77 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2011-2015 - 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 . + */ + +#include "ui_companion_driver.h" +#include "../driver.h" +#include + +#ifdef HAVE_CONFIG_H +#include "../config.h" +#endif + +static const ui_companion_driver_t *ui_companion_drivers[] = { + &ui_companion_null, + NULL +}; + +/** + * ui_companion_find_driver: + * @ident : Identifier name of driver to find. + * + * Finds driver with @ident. Does not initialize. + * + * Returns: pointer to driver if successful, otherwise NULL. + **/ +const ui_companion_driver_t *ui_companion_find_driver(const char *ident) +{ + unsigned i; + + for (i = 0; ui_companion_drivers[i]; i++) + { + if (strcmp(ui_companion_drivers[i]->ident, ident) == 0) + return ui_companion_drivers[i]; + } + + return NULL; +} + +/** + * ui_companion_init_first: + * + * Finds first suitable driver and initialize. + * + * Returns: pointer to first suitable driver, otherwise NULL. + **/ +const ui_companion_driver_t *ui_companion_init_first(void) +{ + unsigned i; + const ui_companion_driver_t *ui_companion = NULL; + + for (i = 0; ui_companion_drivers[i]; i++) + { + ui_companion = ui_companion_drivers[i]; + break; + } + + return ui_companion; +} + +const ui_companion_driver_t *ui_companion_get_ptr(void) +{ + driver_t *driver = driver_get_ptr(); + if (!driver) + return NULL; + return driver->ui_companion; +} diff --git a/ui/ui_companion_driver.h b/ui/ui_companion_driver.h new file mode 100644 index 0000000000..f2dee7cb29 --- /dev/null +++ b/ui/ui_companion_driver.h @@ -0,0 +1,68 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2015 - 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 __UI_COMPANION_DRIVER_H +#define __UI_COMPANION_DRIVER_H + +#include +#include + +#ifdef HAVE_CONFIG_H +#include "../config.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct ui_companion_driver +{ + void (*init)(void *data); + void (*deinit)(void *data); + void (*toggle_companion_ui)(void); + void (*notify_content_loaded)(void); + + const char *ident; +} ui_companion_driver_t; + +extern const ui_companion_driver_t ui_companion_null; + +/** + * ui_companion_find_driver: + * @ident : Identifier name of driver to find. + * + * Finds driver with @ident. Does not initialize. + * + * Returns: pointer to driver if successful, otherwise NULL. + **/ +const ui_companion_driver_t *ui_companion_find_driver(const char *ident); + +const ui_companion_driver_t *ui_companion_get_ptr(void); + +/** + * ui_companion_init_first: + * + * Finds first suitable driver and initialize. + * + * Returns: pointer to first suitable driver, otherwise NULL. + **/ +const ui_companion_driver_t *ui_companion_init_first(void); + +#ifdef __cplusplus +} +#endif + +#endif