2015-04-11 23:31:03 +00:00
|
|
|
/* 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 <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
2015-08-05 11:56:59 +00:00
|
|
|
#include <boolean.h>
|
|
|
|
|
2015-09-05 18:34:22 +00:00
|
|
|
#include "../driver.h"
|
|
|
|
|
2015-04-11 23:31:03 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "../config.h"
|
|
|
|
#endif
|
|
|
|
|
2015-08-05 11:56:59 +00:00
|
|
|
static bool main_ui_companion_is_on_foreground;
|
|
|
|
|
2015-04-11 23:31:03 +00:00
|
|
|
static const ui_companion_driver_t *ui_companion_drivers[] = {
|
2015-11-19 06:41:14 +00:00
|
|
|
#if defined(_WIN32) && !defined(_XBOX)
|
2015-11-19 06:23:41 +00:00
|
|
|
&ui_companion_win32,
|
|
|
|
#endif
|
2015-04-20 10:43:07 +00:00
|
|
|
#ifdef HAVE_COCOA
|
|
|
|
&ui_companion_cocoa,
|
|
|
|
#endif
|
2015-04-19 14:24:51 +00:00
|
|
|
#ifdef HAVE_COCOATOUCH
|
2015-04-12 01:18:37 +00:00
|
|
|
&ui_companion_cocoatouch,
|
2015-04-12 16:56:23 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_QT
|
|
|
|
&ui_companion_qt,
|
2015-04-12 01:18:37 +00:00
|
|
|
#endif
|
2015-04-11 23:31:03 +00:00
|
|
|
&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++)
|
|
|
|
{
|
2015-06-15 04:01:54 +00:00
|
|
|
if (!strcmp(ui_companion_drivers[i]->ident, ident))
|
2015-04-11 23:31:03 +00:00
|
|
|
return ui_companion_drivers[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-08-05 11:56:59 +00:00
|
|
|
void ui_companion_set_foreground(unsigned enable)
|
|
|
|
{
|
|
|
|
main_ui_companion_is_on_foreground = enable;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ui_companion_is_on_foreground(void)
|
|
|
|
{
|
|
|
|
return main_ui_companion_is_on_foreground;
|
|
|
|
}
|
|
|
|
|
2015-04-11 23:31:03 +00:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
|
|
|
|
for (i = 0; ui_companion_drivers[i]; i++)
|
2015-04-12 00:09:14 +00:00
|
|
|
return ui_companion_drivers[i];
|
2015-04-11 23:31:03 +00:00
|
|
|
|
2015-04-12 00:09:14 +00:00
|
|
|
return NULL;
|
2015-04-11 23:31:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const ui_companion_driver_t *ui_companion_get_ptr(void)
|
|
|
|
{
|
|
|
|
driver_t *driver = driver_get_ptr();
|
|
|
|
if (!driver)
|
|
|
|
return NULL;
|
|
|
|
return driver->ui_companion;
|
|
|
|
}
|
2015-04-20 16:34:55 +00:00
|
|
|
|
2015-04-20 16:36:36 +00:00
|
|
|
void ui_companion_event_command(enum event_command action)
|
2015-04-20 16:34:55 +00:00
|
|
|
{
|
|
|
|
driver_t *driver = driver_get_ptr();
|
|
|
|
const ui_companion_driver_t *ui = ui_companion_get_ptr();
|
|
|
|
|
|
|
|
if (driver && ui && ui->event_command)
|
|
|
|
ui->event_command(driver->ui_companion_data, action);
|
|
|
|
}
|