Settings are now being passed correctly to the QT side

This commit is contained in:
radius 2015-09-01 17:37:23 -05:00
parent f3389bbd42
commit b32a3e55f4
5 changed files with 41 additions and 33 deletions

View File

@ -22,29 +22,18 @@
QObject *topLevel; QObject *topLevel;
static settings_t *settings; int Wimp::CreateMainWindow()
int Wimp::CreateMainWindow(char* windowTitle)
{ {
QQmlApplicationEngine engine; QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
topLevel = engine.rootObjects().value(0); topLevel = engine.rootObjects().value(0);
window = qobject_cast<QQuickWindow *>(topLevel); window = qobject_cast<QQuickWindow *>(topLevel);
SetTitle(windowTitle);
return this->exec(); return this->exec();
} }
void Wimp::GetSettings(settings_t *s)
void Wimp::SetTitle(char* title)
{ {
window->setTitle(title); settings = s;
}
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

@ -16,12 +16,22 @@
#ifndef WIMP_H #ifndef WIMP_H
#define WIMP_H #define WIMP_H
/* this is the only define missing from config.h remove these once
* we can build everything with a single makefile
*/
#ifndef HAVE_MENU
#define HAVE_MENU
#endif
#include "config.h"
#include "configuration.h"
#include "wimp_global.h" #include "wimp_global.h"
#include <QtWidgets/qwidget.h> #include <QtWidgets/qwidget.h>
#include <QtWidgets/qapplication.h> #include <QtWidgets/qapplication.h>
#include <QtQml/qqmlapplicationengine.h> #include <QtQml/qqmlapplicationengine.h>
#include <QtQuick/qquickwindow.h> #include <QtQuick/qquickwindow.h>
#include "configuration.h"
class WIMPSHARED_EXPORT Wimp : public QGuiApplication class WIMPSHARED_EXPORT Wimp : public QGuiApplication
{ {
@ -30,9 +40,16 @@ class WIMPSHARED_EXPORT Wimp : public QGuiApplication
Q_OBJECT Q_OBJECT
public: public:
Wimp(int argc, char *argv[]): QGuiApplication(argc, argv) {} Wimp(int argc, char *argv[]): QGuiApplication(argc, argv) {}
int CreateMainWindow(char* windowTitle);
void SetTitle(char* title); /* create the main QT window */
void ConfigGetPtr(settings_t *g_config); int CreateMainWindow();
/* get a pointer to RetroArch settings */
void GetSettings(settings_t *s);
private:
/* pointer to RetroArch settings */
settings_t *settings;
}; };

View File

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

View File

@ -13,6 +13,11 @@
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef HAVE_MENU
#define HAVE_MENU
#endif
#include "config.h"
#include "configuration.h" #include "configuration.h"
#ifndef WRAPPER_H #ifndef WRAPPER_H
@ -23,11 +28,12 @@ extern "C" {
#endif #endif
typedef struct Wimp Wimp; typedef struct Wimp Wimp;
typedef settings_t (*config_get_ptr_cb);
Wimp* ctrWimp(int argc, char *argv[]); Wimp* ctrWimp(int argc, char *argv[]);
int CreateMainWindow(Wimp* p, char* windowTitle); int CreateMainWindow(Wimp* p);
void ConfigGetPtr(Wimp*p, settings_t *g_config); void GetSettings(Wimp* p, settings_t *s);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -29,7 +29,7 @@
struct Wimp* wimp; struct Wimp* wimp;
char* args[] = {""}; char* args[] = {""};
settings_t *settings;
typedef struct ui_companion_qt typedef struct ui_companion_qt
{ {
@ -41,16 +41,12 @@ typedef struct ui_companion_qt
static void qt_thread(void *data) static void qt_thread(void *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; ui_companion_qt_t *handle = (ui_companion_qt_t*)data;
wimp = ctrWimp(0, NULL); wimp = ctrWimp(0, NULL);
if(wimp) if(wimp)
{ {
ConfigGetPtr(wimp, settings); GetSettings(wimp, settings);
CreateMainWindow(wimp, "RetroArch QT"); CreateMainWindow(wimp);
} }
return; return;
@ -74,7 +70,7 @@ static void *ui_companion_qt_init(void)
ui_companion_qt_t *handle = (ui_companion_qt_t*)calloc(1, sizeof(*handle)); ui_companion_qt_t *handle = (ui_companion_qt_t*)calloc(1, sizeof(*handle));
if (!handle) if (!handle)
return NULL; return NULL;
settings = config_get_ptr();
handle->lock = slock_new(); handle->lock = slock_new();
handle->thread = sthread_create(qt_thread, handle); handle->thread = sthread_create(qt_thread, handle);
if (!handle->thread) if (!handle->thread)