RetroArch/ui/drivers/ui_qt.cpp

170 lines
3.5 KiB
C++
Raw Normal View History

/* RetroArch - A frontend for libretro.
2016-06-04 02:24:54 +00:00
* Copyright (C) 2011-2016 - 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 <stdint.h>
#include <boolean.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <file/file_path.h>
#include <rthreads/rthreads.h>
2016-09-11 12:54:34 +00:00
#ifdef HAVE_CONFIG_H
#include "../../config.h"
#endif
2016-11-20 02:19:56 +00:00
#ifdef HAVE_QT_WRAPPER
2016-09-11 12:54:34 +00:00
#include "qt/wrapper/wrapper.h"
2016-11-20 02:19:56 +00:00
#else
#include "ui_qt.h"
#endif
2016-05-16 18:21:53 +00:00
#include "../ui_companion_driver.h"
2016-09-06 04:11:44 +00:00
#include "../../core.h"
2016-09-05 16:33:22 +00:00
#include "../../configuration.h"
2016-09-11 12:54:34 +00:00
#include "../../runloop.h"
2016-05-16 18:21:53 +00:00
#include "../../tasks/tasks_internal.h"
#ifdef HAVE_QT_WRAPPER
struct Wimp* wimp;
char* args[] = {""};
2016-06-10 08:15:38 +00:00
#endif
typedef struct ui_companion_qt
{
void *empty;
#ifdef HAVE_QT_WRAPPER
volatile bool quit;
slock_t *lock;
sthread_t *thread;
#endif
} ui_companion_qt_t;
#ifdef HAVE_QT_WRAPPER
static void qt_thread(void *data)
{
ui_companion_qt_t *handle = (ui_companion_qt_t*)data;
wimp = ctrWimp(0, NULL);
if(wimp)
{
settings_t *settings = config_get_ptr();
GetSettings(wimp, settings);
CreateMainWindow(wimp);
}
}
#endif
static void ui_companion_qt_deinit(void *data)
{
ui_companion_qt_t *handle = (ui_companion_qt_t*)data;
if (!handle)
return;
#ifdef HAVE_QT_WRAPPER
slock_free(handle->lock);
sthread_join(handle->thread);
#endif
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;
#ifdef HAVE_QT_WRAPPER
settings_t *settings = config_get_ptr();
handle->lock = slock_new();
handle->thread = sthread_create(qt_thread, handle);
if (!handle->thread)
{
slock_free(handle->lock);
free(handle);
return NULL;
}
#endif
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;
}
static void ui_companion_qt_toggle(void *data)
{
ui_companion_qt_init();
}
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;
#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);
#endif
2015-04-13 11:46:48 +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;
}
const ui_companion_driver_t ui_companion_qt = {
ui_companion_qt_init,
ui_companion_qt_deinit,
ui_companion_qt_iterate,
ui_companion_qt_toggle,
2015-04-13 11:46:48 +00:00
ui_companion_qt_event_command,
ui_companion_qt_notify_content_loaded,
ui_companion_qt_notify_list_pushed,
NULL,
NULL,
NULL,
NULL,
2016-11-20 02:19:56 +00:00
#ifdef HAVE_QT_WRAPPER
NULL,
NULL,
NULL,
NULL,
#else
&ui_browser_window_qt,
&ui_msg_window_qt,
2016-06-09 18:11:26 +00:00
&ui_window_qt,
2016-06-09 18:18:08 +00:00
&ui_application_qt,
2016-11-20 02:19:56 +00:00
#endif
"qt",
};