Merge pull request #2085 from fr500/master

Update QT companion UI
This commit is contained in:
Twinaphex 2015-09-01 08:47:18 +02:00
commit 9c6f1c2c91
12 changed files with 120 additions and 26 deletions

View File

@ -222,7 +222,7 @@ endif
ifeq ($(HAVE_QT), 1)
OBJ += ui/drivers/ui_qt.o
# TODO/FIXME - figure out which libraries we need to link against
LIBS += -lQt5Quick -lQt5Widgets -lQt5Gui -lQt5Qml -lQt5Network -lQt5Core -lglu32 -lopengl32 -L./ui/drivers/qt/release -lwrapper
LIBS += -lQt5Quick -lQt5Widgets -lQt5Gui -lQt5Qml -lQt5Network -lQt5Core -lglu32 -lopengl32 -L./ui/drivers/qt/wrapper/build/release -lwrapper
endif
# LibretroDB

View File

@ -404,6 +404,6 @@ add_define_make OS "$OS"
# Creates config.mk and config.h.
add_define_make GLOBAL_CONFIG_DIR "$GLOBAL_CONFIG_DIR"
VARS="RGUI LAKKA GLUI XMB ALSA OSS OSS_BSD OSS_LIB AL RSOUND ROAR JACK COREAUDIO CORETEXT PULSE SDL SDL2 D3D9 DINPUT LIBUSB XINPUT DSOUND XAUDIO OPENGL EXYNOS DISPMANX SUNXI OMAP GLES GLES3 VG EGL KMS GBM DRM DYLIB GETOPT_LONG THREADS CG LIBXML2 ZLIB DYNAMIC FFMPEG AVCODEC AVFORMAT AVUTIL SWSCALE FREETYPE STB_FONT XKBCOMMON XVIDEO X11 XEXT XF86VM XINERAMA WAYLAND MALI_FBDEV VIVANTE_FBDEV NETWORKING NETPLAY NETWORK_CMD STDIN_CMD COMMAND SOCKET_LEGACY FBO STRL STRCASESTR MMAP PYTHON FFMPEG_ALLOC_CONTEXT3 FFMPEG_AVCODEC_OPEN2 FFMPEG_AVIO_OPEN FFMPEG_AVFORMAT_WRITE_HEADER FFMPEG_AVFORMAT_NEW_STREAM FFMPEG_AVCODEC_ENCODE_AUDIO2 SWRESAMPLE FFMPEG_AVCODEC_ENCODE_VIDEO2 BSV_MOVIE VIDEOCORE NEON FLOATHARD FLOATSOFTFP UDEV V4L2 AV_CHANNEL_LAYOUT 7ZIP PARPORT IMAGEVIEWER COCOA AVFOUNDATION CORELOCATION IOHIDMANAGER LIBRETRODB"
VARS="RGUI LAKKA GLUI XMB ALSA OSS OSS_BSD OSS_LIB AL RSOUND ROAR JACK COREAUDIO CORETEXT PULSE SDL SDL2 D3D9 DINPUT LIBUSB XINPUT DSOUND XAUDIO OPENGL EXYNOS DISPMANX SUNXI OMAP GLES GLES3 VG EGL KMS GBM DRM DYLIB GETOPT_LONG THREADS CG LIBXML2 ZLIB DYNAMIC FFMPEG AVCODEC AVFORMAT AVUTIL SWSCALE FREETYPE STB_FONT XKBCOMMON XVIDEO X11 XEXT XF86VM XINERAMA WAYLAND MALI_FBDEV VIVANTE_FBDEV NETWORKING NETPLAY NETWORK_CMD STDIN_CMD COMMAND SOCKET_LEGACY FBO STRL STRCASESTR MMAP PYTHON FFMPEG_ALLOC_CONTEXT3 FFMPEG_AVCODEC_OPEN2 FFMPEG_AVIO_OPEN FFMPEG_AVFORMAT_WRITE_HEADER FFMPEG_AVFORMAT_NEW_STREAM FFMPEG_AVCODEC_ENCODE_AUDIO2 SWRESAMPLE FFMPEG_AVCODEC_ENCODE_VIDEO2 BSV_MOVIE VIDEOCORE NEON FLOATHARD FLOATSOFTFP UDEV V4L2 AV_CHANNEL_LAYOUT 7ZIP PARPORT IMAGEVIEWER COCOA AVFOUNDATION CORELOCATION IOHIDMANAGER LIBRETRODB QT"
create_config_make config.mk $VARS
create_config_header config.h $VARS

View File

@ -57,3 +57,4 @@ HAVE_PRESERVE_DYLIB=no # Disable dlclose() for Valgrind support
HAVE_PARPORT=auto # Parallel port joypad support
HAVE_IMAGEVIEWER=yes # Built-in image viewer support.
HAVE_MMAP=auto # MMAP support
HAVE_QT=no # QT companion support

View File

@ -0,0 +1,47 @@
#include <QDebug>
#include "../wrapper/wrapper.h"
#include "../wimp/wimp.h"
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
struct Wimp* t;
int i=0;
void *initGui(void *arg)
{
char **arguments = (char**)arg;
t = ctrWimp(i,arguments);
CreateMainWindow(t); //-->uncomment this to open the QT gui
return 0;
}
int main(int argc, char *argv[])
{
i = argc;
pthread_t gui;
int rc;
rc=pthread_create(&gui, NULL, initGui, (void *)argv);
if(rc!=0)
{
printf("failed");
exit(1);
}
for(int j=0;j<100;j++)
{
Sleep(1000);
printf("test = %d\n",i);
i++;
if(j < 2)
t->SetTitle("test");
}
pthread_join(gui,NULL);
return 0;
}

View File

@ -0,0 +1,20 @@
TARGET = wimp-test
CONFIG += console
SOURCES += main.cpp
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../wimp/build/release/ -lwimp.dll
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../wimp/build/debug/ -lwimp.dll
else:unix: LIBS += -L$$PWD/../wimp/build/ -lwimp.dll
INCLUDEPATH += $$PWD/../wimp/build/release
DEPENDPATH += $$PWD/../wimp/build/release
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../wrapper/build/release/ -lwrapper.dll
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../wrapper/build/debug/ -lwrapper.dll
else:unix: LIBS += -L$$PWD/../wrapper/build/ -lwrapper.dll
INCLUDEPATH += $$PWD/../wrapper/build/release
DEPENDPATH += $$PWD/../wrapper/build/release

View File

@ -21,20 +21,30 @@
#include <QQuickWindow>
QObject *topLevel;
QQuickWindow *window;
int Wimp::CreateMainWindow()
static settings_t *settings;
int Wimp::CreateMainWindow(char* windowTitle)
{
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
topLevel = engine.rootObjects().value(0);
window = qobject_cast<QQuickWindow *>(topLevel);
SetTitle(windowTitle);
SetTitle("Hello QT");
return this->exec();
}
void Wimp::SetTitle(char* title)
{
window->setTitle(title);
window->setTitle(title);
}
void Wimp::ConfigGetPtr(settings_t *g_config)
{
settings = g_config;
/* test print the value of max users to compare with the value in RA */
printf("Max Users: %d\n",g_config->input.max_users);
fflush(stdout);
}

View File

@ -20,15 +20,19 @@
#include <QtWidgets/qwidget.h>
#include <QtWidgets/qapplication.h>
#include <QtQml/qqmlapplicationengine.h>
#include <QtQuick/qquickwindow.h>
#include "configuration.h"
class WIMPSHARED_EXPORT Wimp : public QGuiApplication
{
QQuickWindow *window;
Q_OBJECT
public:
Wimp(int argc, char *argv[]): QGuiApplication(argc, argv) {}
int CreateMainWindow();
int CreateMainWindow(char* windowTitle);
void SetTitle(char* title);
void ConfigGetPtr(settings_t *g_config);
};

View File

@ -20,3 +20,7 @@ HEADERS +=\
RESOURCES += \
qml.qrc
INCLUDEPATH += $$PWD/../../../../
INCLUDEPATH += $$PWD/../../../../libretro-common/include/

View File

@ -29,14 +29,14 @@ Wimp* ctrWimp(int argc, char *argv[]){
return new Wimp(argc,argv);
}
int CreateMainWindow(Wimp* p)
int CreateMainWindow(Wimp* p, char* windowTitle)
{
return p->CreateMainWindow();
return p->CreateMainWindow(windowTitle);
}
void SetTitle(Wimp*p, char* title)
void ConfigGetPtr(Wimp*p, settings_t *g_config)
{
return p->SetTitle(title);
return p->ConfigGetPtr(g_config);
}
#ifdef __cplusplus

View File

@ -13,6 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "configuration.h"
#ifndef WRAPPER_H
#define WRAPPER_H
@ -25,8 +26,8 @@ typedef struct Wimp Wimp;
Wimp* ctrWimp(int argc, char *argv[]);
int CreateMainWindow(Wimp* p);
void SetTitle(Wimp* p, char* title);
int CreateMainWindow(Wimp* p, char* windowTitle);
void ConfigGetPtr(Wimp*p, settings_t *g_config);
#ifdef __cplusplus
}

View File

@ -14,7 +14,12 @@ HEADERS += \
wrapper.h
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../release -lwimp
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../wimp/build/release/ -lwimp.dll
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../wimp/build/debug/ -lwimp.dll
else:unix: LIBS += -L$$PWD/../wimp/build/ -lwimp.dll
win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../release/libwimp.dll.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../release/wimp.lib
INCLUDEPATH += $$PWD/../wimp/build/release
DEPENDPATH += $$PWD/../wimp/build/release
INCLUDEPATH += $$PWD/../../../../
INCLUDEPATH += $$PWD/../../../../libretro-common/include/

View File

@ -18,6 +18,8 @@
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include "general.h"
#include "system.h"
#include <file/file_path.h>
#include <rthreads/rthreads.h>
@ -38,11 +40,18 @@ typedef struct ui_companion_qt
static void qt_thread(void *data)
{
ui_companion_qt_t *handle = (ui_companion_qt_t*)data;
settings_t *settings = config_get_ptr();
/* test print the value of max users to compare with the value in QT */
RARCH_LOG("Max Users: %d\n", settings->input.max_users);
ui_companion_qt_t *handle = (ui_companion_qt_t*)data;
wimp = ctrWimp(0, NULL);
if(wimp)
CreateMainWindow(wimp);
{
ConfigGetPtr(wimp, settings);
CreateMainWindow(wimp, "RetroArch QT");
}
return;
}
@ -63,16 +72,11 @@ static void ui_companion_qt_deinit(void *data)
static void *ui_companion_qt_init(void)
{
ui_companion_qt_t *handle = (ui_companion_qt_t*)calloc(1, sizeof(*handle));
fflush(stdout);
if (!handle)
return NULL;
handle->lock = slock_new();
handle->thread = sthread_create(qt_thread, handle);
if (!handle->thread)
{
slock_free(handle->lock);
@ -87,8 +91,6 @@ static int ui_companion_qt_iterate(void *data, unsigned action)
{
(void)data;
(void)action;
printf("Test");
fflush(stdout);
return 0;
}