2015-04-12 16:56:23 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2016-06-04 02:24:54 +00:00
|
|
|
* Copyright (C) 2011-2016 - Daniel De Matteis
|
2015-04-12 16:56:23 +00:00
|
|
|
*
|
|
|
|
* 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 <stdint.h>
|
|
|
|
#include <boolean.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2015-09-01 03:23:40 +00:00
|
|
|
#include "general.h"
|
|
|
|
#include "system.h"
|
2015-04-12 16:56:23 +00:00
|
|
|
|
|
|
|
#include <file/file_path.h>
|
|
|
|
#include <rthreads/rthreads.h>
|
|
|
|
|
2016-05-16 18:21:53 +00:00
|
|
|
#include "../ui_companion_driver.h"
|
|
|
|
#include "../../tasks/tasks_internal.h"
|
2015-04-12 19:20:57 +00:00
|
|
|
#include "qt/wrapper/wrapper.h"
|
2015-04-12 16:56:23 +00:00
|
|
|
|
2016-06-09 17:51:50 +00:00
|
|
|
#ifdef HAVE_QT_WRAPPER
|
2015-04-13 04:29:46 +00:00
|
|
|
struct Wimp* wimp;
|
2016-06-09 17:51:50 +00:00
|
|
|
#endif
|
2015-04-13 04:29:46 +00:00
|
|
|
char* args[] = {""};
|
|
|
|
|
2015-04-12 16:56:23 +00:00
|
|
|
typedef struct ui_companion_qt
|
|
|
|
{
|
2016-06-09 17:51:50 +00:00
|
|
|
void *empty;
|
|
|
|
#ifdef HAVE_QT_WRAPPER
|
2015-04-12 16:56:23 +00:00
|
|
|
volatile bool quit;
|
|
|
|
slock_t *lock;
|
|
|
|
sthread_t *thread;
|
2016-06-09 17:51:50 +00:00
|
|
|
#endif
|
2015-04-12 16:56:23 +00:00
|
|
|
} ui_companion_qt_t;
|
|
|
|
|
2016-06-09 17:51:50 +00:00
|
|
|
#ifdef HAVE_QT_WRAPPER
|
2015-04-12 16:56:23 +00:00
|
|
|
static void qt_thread(void *data)
|
|
|
|
{
|
|
|
|
ui_companion_qt_t *handle = (ui_companion_qt_t*)data;
|
2015-04-13 04:29:46 +00:00
|
|
|
wimp = ctrWimp(0, NULL);
|
|
|
|
if(wimp)
|
2015-09-01 03:23:40 +00:00
|
|
|
{
|
2016-06-09 17:51:50 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
2015-09-01 22:37:23 +00:00
|
|
|
GetSettings(wimp, settings);
|
|
|
|
CreateMainWindow(wimp);
|
2015-09-01 03:23:40 +00:00
|
|
|
}
|
2015-04-12 16:56:23 +00:00
|
|
|
}
|
2016-06-09 17:51:50 +00:00
|
|
|
#endif
|
2015-04-12 16:56:23 +00:00
|
|
|
|
|
|
|
static void ui_companion_qt_deinit(void *data)
|
|
|
|
{
|
|
|
|
ui_companion_qt_t *handle = (ui_companion_qt_t*)data;
|
|
|
|
|
|
|
|
if (!handle)
|
|
|
|
return;
|
|
|
|
|
2016-06-09 17:51:50 +00:00
|
|
|
#ifdef HAVE_QT_WRAPPER
|
2015-04-12 16:56:23 +00:00
|
|
|
slock_free(handle->lock);
|
|
|
|
sthread_join(handle->thread);
|
2016-06-09 17:51:50 +00:00
|
|
|
#endif
|
2015-04-12 16:56:23 +00:00
|
|
|
|
|
|
|
free(handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *ui_companion_qt_init(void)
|
|
|
|
{
|
|
|
|
ui_companion_qt_t *handle = (ui_companion_qt_t*)calloc(1, sizeof(*handle));
|
|
|
|
if (!handle)
|
|
|
|
return NULL;
|
2016-06-09 17:51:50 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_QT_WRAPPER
|
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
handle->lock = slock_new();
|
|
|
|
handle->thread = sthread_create(qt_thread, handle);
|
2015-04-12 16:56:23 +00:00
|
|
|
if (!handle->thread)
|
|
|
|
{
|
|
|
|
slock_free(handle->lock);
|
|
|
|
free(handle);
|
|
|
|
return NULL;
|
|
|
|
}
|
2016-06-09 17:51:50 +00:00
|
|
|
#endif
|
2015-04-12 16:56:23 +00:00
|
|
|
|
|
|
|
return handle;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ui_companion_qt_iterate(void *data, unsigned action)
|
|
|
|
{
|
|
|
|
(void)data;
|
|
|
|
(void)action;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ui_companion_qt_notify_content_loaded(void *data)
|
|
|
|
{
|
|
|
|
(void)data;
|
|
|
|
}
|
|
|
|
|
2015-04-13 04:29:46 +00:00
|
|
|
static void ui_companion_qt_toggle(void *data)
|
|
|
|
{
|
|
|
|
ui_companion_qt_init();
|
|
|
|
}
|
|
|
|
|
2015-04-20 16:38:47 +00:00
|
|
|
static void ui_companion_qt_event_command(void *data, enum event_command cmd)
|
2015-04-13 11:46:48 +00:00
|
|
|
{
|
|
|
|
ui_companion_qt_t *handle = (ui_companion_qt_t*)data;
|
|
|
|
|
|
|
|
if (!handle)
|
|
|
|
return;
|
|
|
|
|
2016-06-09 17:51:50 +00:00
|
|
|
#ifdef HAVE_QT_WRAPPER
|
2015-04-13 11:46:48 +00:00
|
|
|
slock_lock(handle->lock);
|
2016-05-09 18:20:50 +00:00
|
|
|
command_event(cmd, NULL);
|
2015-04-13 11:46:48 +00:00
|
|
|
slock_unlock(handle->lock);
|
2016-06-09 17:51:50 +00:00
|
|
|
#endif
|
2015-04-13 11:46:48 +00:00
|
|
|
}
|
|
|
|
|
2015-05-11 07:56:13 +00:00
|
|
|
static void ui_companion_qt_notify_list_pushed(void *data, file_list_t *list,
|
|
|
|
file_list_t *menu_list)
|
|
|
|
{
|
|
|
|
(void)data;
|
|
|
|
(void)list;
|
|
|
|
(void)menu_list;
|
|
|
|
}
|
|
|
|
|
2015-04-12 16:56:23 +00:00
|
|
|
const ui_companion_driver_t ui_companion_qt = {
|
|
|
|
ui_companion_qt_init,
|
|
|
|
ui_companion_qt_deinit,
|
|
|
|
ui_companion_qt_iterate,
|
2015-04-13 04:29:46 +00:00
|
|
|
ui_companion_qt_toggle,
|
2015-04-13 11:46:48 +00:00
|
|
|
ui_companion_qt_event_command,
|
2015-04-12 16:56:23 +00:00
|
|
|
ui_companion_qt_notify_content_loaded,
|
2015-05-11 07:56:13 +00:00
|
|
|
ui_companion_qt_notify_list_pushed,
|
2015-08-15 00:46:25 +00:00
|
|
|
NULL,
|
2015-08-30 11:03:34 +00:00
|
|
|
NULL,
|
2015-09-22 20:20:03 +00:00
|
|
|
NULL,
|
2016-06-08 13:47:00 +00:00
|
|
|
&ui_browser_window_null,
|
2016-06-08 04:29:52 +00:00
|
|
|
&ui_msg_window_null,
|
2016-06-09 18:11:26 +00:00
|
|
|
&ui_window_qt,
|
2016-06-07 14:31:35 +00:00
|
|
|
&ui_application_null,
|
2015-04-12 16:56:23 +00:00
|
|
|
"qt",
|
|
|
|
};
|