all repos — mgba @ 467fbcf54d0942b2732aec8c6643f2616bb0174b

mGBA Game Boy Advance Emulator

src/platform/qt/GameController.h (view raw)

  1#ifndef QGBA_GAME_CONTROLLER
  2#define QGBA_GAME_CONTROLLER
  3
  4#include <QFile>
  5#include <QImage>
  6#include <QObject>
  7#include <QMutex>
  8#include <QString>
  9
 10extern "C" {
 11#include "gba-thread.h"
 12#ifdef BUILD_SDL
 13#include "sdl-events.h"
 14#endif
 15}
 16
 17struct GBAAudio;
 18struct GBAVideoSoftwareRenderer;
 19
 20class QThread;
 21
 22namespace QGBA {
 23
 24class AudioProcessor;
 25class InputController;
 26
 27class GameController : public QObject {
 28Q_OBJECT
 29
 30public:
 31	static const bool VIDEO_SYNC = true;
 32	static const bool AUDIO_SYNC = true;
 33
 34	GameController(QObject* parent = nullptr);
 35	~GameController();
 36
 37	const uint32_t* drawContext() const { return m_drawContext; }
 38	GBAThread* thread() { return &m_threadContext; }
 39
 40	void threadInterrupt();
 41	void threadContinue();
 42
 43	bool isPaused();
 44	bool isLoaded() { return m_gameOpen; }
 45
 46	bool audioSync() const { return m_audioSync; }
 47	bool videoSync() const { return m_videoSync; }
 48
 49	void setInputController(InputController* controller) { m_inputController = controller; }
 50
 51#ifdef USE_GDB_STUB
 52	ARMDebugger* debugger();
 53	void setDebugger(ARMDebugger*);
 54#endif
 55
 56signals:
 57	void frameAvailable(const uint32_t*);
 58	void gameStarted(GBAThread*);
 59	void gameStopped(GBAThread*);
 60	void gamePaused(GBAThread*);
 61	void gameUnpaused(GBAThread*);
 62	void stateLoaded(GBAThread*);
 63
 64	void postLog(int level, const QString& log);
 65
 66public slots:
 67	void loadGame(const QString& path, bool dirmode = false);
 68	void loadBIOS(const QString& path);
 69	void loadPatch(const QString& path);
 70	void openGame();
 71	void closeGame();
 72	void setPaused(bool paused);
 73	void reset();
 74	void frameAdvance();
 75	void keyPressed(int key);
 76	void keyReleased(int key);
 77	void setAudioBufferSamples(int samples);
 78	void setFPSTarget(float fps);
 79	void loadState(int slot);
 80	void saveState(int slot);
 81	void setVideoSync(bool);
 82	void setAudioSync(bool);
 83	void setFrameskip(int);
 84	void setTurbo(bool, bool forced = true);
 85	void setAVStream(GBAAVStream*);
 86	void clearAVStream();
 87
 88#ifdef BUILD_SDL
 89private slots:
 90	void testSDLEvents();
 91
 92private:
 93	GBASDLEvents m_sdlEvents;
 94	int m_activeButtons;
 95#endif
 96
 97private:
 98	void updateKeys();
 99
100	uint32_t* m_drawContext;
101	GBAThread m_threadContext;
102	GBAVideoSoftwareRenderer* m_renderer;
103	int m_activeKeys;
104
105	bool m_gameOpen;
106	bool m_dirmode;
107
108	QString m_fname;
109	QString m_bios;
110	QString m_patch;
111
112	QThread* m_audioThread;
113	AudioProcessor* m_audioProcessor;
114
115	QMutex m_pauseMutex;
116	bool m_pauseAfterFrame;
117
118	bool m_videoSync;
119	bool m_audioSync;
120	bool m_turbo;
121	bool m_turboForced;
122
123	InputController* m_inputController;
124};
125
126}
127
128#endif