2012-12-16 19:47:51 +10:00
|
|
|
#ifndef QTMAIN_H
|
|
|
|
#define QTMAIN_H
|
2012-12-13 16:38:33 +10:00
|
|
|
|
|
|
|
#include <QTouchEvent>
|
2012-12-23 17:47:52 +10:00
|
|
|
#include <QMouseEvent>
|
2013-12-08 20:14:49 +10:00
|
|
|
#include <QInputDialog>
|
2012-12-23 17:47:52 +10:00
|
|
|
#include "gfx_es2/glsl_program.h"
|
2012-12-13 16:38:33 +10:00
|
|
|
#include <QGLWidget>
|
|
|
|
|
2014-12-18 23:57:59 +01:00
|
|
|
#ifndef SDL
|
2012-12-16 19:47:51 +10:00
|
|
|
#include <QAudioOutput>
|
|
|
|
#include <QAudioFormat>
|
2014-07-01 17:14:46 +10:00
|
|
|
#endif
|
2016-10-12 12:32:20 +02:00
|
|
|
#if defined(MOBILE_DEVICE)
|
2013-03-11 11:51:10 +10:00
|
|
|
#include <QAccelerometer>
|
2014-06-30 00:15:37 +10:00
|
|
|
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
2013-03-11 11:51:10 +10:00
|
|
|
QTM_USE_NAMESPACE
|
|
|
|
#endif
|
2014-06-03 09:03:09 +10:00
|
|
|
#endif
|
2012-12-13 16:38:33 +10:00
|
|
|
|
|
|
|
#include "base/display.h"
|
|
|
|
#include "base/logging.h"
|
|
|
|
#include "base/timeutil.h"
|
|
|
|
#include "file/zip_read.h"
|
2015-09-06 13:44:06 +02:00
|
|
|
#include "gfx/gl_common.h"
|
2012-12-13 16:38:33 +10:00
|
|
|
#include "input/input_state.h"
|
2013-07-08 10:04:20 +10:00
|
|
|
#include "input/keycodes.h"
|
2016-01-03 15:03:08 +01:00
|
|
|
#include "thin3d/thin3d.h"
|
2012-12-13 16:38:33 +10:00
|
|
|
#include "base/NativeApp.h"
|
|
|
|
#include "net/resolve.h"
|
2013-08-05 20:08:38 +10:00
|
|
|
#include "base/NKCodeFromQt.h"
|
2012-12-13 16:38:33 +10:00
|
|
|
|
2016-01-03 15:03:08 +01:00
|
|
|
#include "Common/GraphicsContext.h"
|
2014-06-22 11:17:03 +02:00
|
|
|
#include "Core/System.h"
|
2013-11-27 01:30:10 +10:00
|
|
|
#include "Core/Core.h"
|
|
|
|
#include "Core/Config.h"
|
|
|
|
|
2013-01-10 18:06:11 +10:00
|
|
|
// Input
|
|
|
|
void SimulateGamepad(InputState *input);
|
|
|
|
|
2016-01-03 15:03:08 +01:00
|
|
|
class QtDummyGraphicsContext : public DummyGraphicsContext {
|
|
|
|
public:
|
2017-01-30 16:03:03 +01:00
|
|
|
Draw::DrawContext *CreateDrawContext() override {
|
2016-12-26 23:59:42 +01:00
|
|
|
return Draw::T3DCreateGLContext();
|
2016-01-03 15:03:08 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-01-10 18:06:11 +10:00
|
|
|
//GUI
|
2012-12-13 16:38:33 +10:00
|
|
|
class MainUI : public QGLWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2016-02-10 19:37:47 +08:00
|
|
|
explicit MainUI(QWidget *parent = 0);
|
|
|
|
~MainUI();
|
2012-12-13 16:38:33 +10:00
|
|
|
|
2013-12-08 20:14:49 +10:00
|
|
|
public slots:
|
2016-02-10 19:37:47 +08:00
|
|
|
QString InputBoxGetQString(QString title, QString defaultValue);
|
2013-12-08 20:14:49 +10:00
|
|
|
|
2013-11-27 01:30:10 +10:00
|
|
|
signals:
|
|
|
|
void doubleClick();
|
|
|
|
void newFrame();
|
|
|
|
|
2012-12-13 16:38:33 +10:00
|
|
|
protected:
|
2016-02-10 19:37:47 +08:00
|
|
|
void timerEvent(QTimerEvent *);
|
|
|
|
void changeEvent(QEvent *e);
|
|
|
|
bool event(QEvent *e);
|
2013-07-25 14:28:18 +10:00
|
|
|
|
2016-02-10 19:37:47 +08:00
|
|
|
void initializeGL();
|
2016-02-11 00:25:02 +08:00
|
|
|
void resizeGL(int w, int h);
|
2016-02-10 19:37:47 +08:00
|
|
|
void paintGL();
|
2013-07-25 14:28:18 +10:00
|
|
|
|
2016-02-10 19:37:47 +08:00
|
|
|
void updateAccelerometer();
|
2013-03-11 11:51:10 +10:00
|
|
|
|
2012-12-13 16:38:33 +10:00
|
|
|
private:
|
|
|
|
InputState input_state;
|
2016-01-03 15:03:08 +01:00
|
|
|
QtDummyGraphicsContext *graphicsContext;
|
2016-02-11 00:25:02 +08:00
|
|
|
|
|
|
|
float xscale, yscale;
|
2016-10-12 12:32:20 +02:00
|
|
|
#if defined(MOBILE_DEVICE)
|
2013-03-11 11:51:10 +10:00
|
|
|
QAccelerometer* acc;
|
|
|
|
#endif
|
2012-12-13 16:38:33 +10:00
|
|
|
};
|
|
|
|
|
2016-02-10 19:37:47 +08:00
|
|
|
extern MainUI* emugl;
|
2013-12-08 20:14:49 +10:00
|
|
|
|
2014-12-18 23:57:59 +01:00
|
|
|
#ifndef SDL
|
2014-07-01 17:14:46 +10:00
|
|
|
|
2013-01-10 18:06:11 +10:00
|
|
|
// Audio
|
2012-12-16 19:47:51 +10:00
|
|
|
class MainAudio: public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2016-02-10 19:37:47 +08:00
|
|
|
MainAudio() {}
|
|
|
|
~MainAudio();
|
2013-10-26 19:51:29 +10:00
|
|
|
public slots:
|
2016-02-10 19:37:47 +08:00
|
|
|
void run();
|
2013-01-15 20:45:26 +10:00
|
|
|
protected:
|
2016-02-10 19:37:47 +08:00
|
|
|
void timerEvent(QTimerEvent *);
|
2012-12-16 19:47:51 +10:00
|
|
|
private:
|
|
|
|
QIODevice* feed;
|
|
|
|
QAudioOutput* output;
|
|
|
|
int mixlen;
|
|
|
|
char* mixbuf;
|
2013-01-31 23:49:37 +01:00
|
|
|
int timer;
|
2012-12-16 19:47:51 +10:00
|
|
|
};
|
|
|
|
|
2014-12-18 23:57:59 +01:00
|
|
|
#endif //SDL
|
2014-07-01 17:14:46 +10:00
|
|
|
|
2012-12-13 16:38:33 +10:00
|
|
|
#endif
|
|
|
|
|