all repos — mgba @ d83520c5a246b8096ceb02ce001f4ee7291bba9f

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 = false;
 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	bool isPaused();
 41	bool isLoaded() { return m_gameOpen; }
 42
 43	bool audioSync() const { return m_audioSync; }
 44	bool videoSync() const { return m_videoSync; }
 45
 46	void setInputController(InputController* controller) { m_inputController = controller; }
 47
 48#ifdef USE_GDB_STUB
 49	ARMDebugger* debugger();
 50	void setDebugger(ARMDebugger*);
 51#endif
 52
 53signals:
 54	void frameAvailable(const uint32_t*);
 55	void gameStarted(GBAThread*);
 56	void gameStopped(GBAThread*);
 57	void gamePaused(GBAThread*);
 58	void gameUnpaused(GBAThread*);
 59	void stateLoaded(GBAThread*);
 60
 61	void postLog(int level, const QString& log);
 62
 63public slots:
 64	void loadGame(const QString& path, bool dirmode = false);
 65	void loadBIOS(const QString& path);
 66	void loadPatch(const QString& path);
 67	void openGame();
 68	void closeGame();
 69	void setPaused(bool paused);
 70	void reset();
 71	void frameAdvance();
 72	void keyPressed(int key);
 73	void keyReleased(int key);
 74	void setAudioBufferSamples(int samples);
 75	void setFPSTarget(float fps);
 76	void loadState(int slot);
 77	void saveState(int slot);
 78	void setVideoSync(bool);
 79	void setAudioSync(bool);
 80	void setFrameskip(int);
 81	void setTurbo(bool, bool forced = true);
 82	void setAVStream(GBAAVStream*);
 83	void clearAVStream();
 84
 85#ifdef BUILD_SDL
 86private slots:
 87	void testSDLEvents();
 88
 89private:
 90	GBASDLEvents m_sdlEvents;
 91	int m_activeButtons;
 92#endif
 93
 94private:
 95	void updateKeys();
 96
 97	uint32_t* m_drawContext;
 98	GBAThread m_threadContext;
 99	GBAVideoSoftwareRenderer* m_renderer;
100	int m_activeKeys;
101
102	bool m_gameOpen;
103	bool m_dirmode;
104
105	QString m_fname;
106	QString m_bios;
107	QString m_patch;
108
109	QThread* m_audioThread;
110	AudioProcessor* m_audioProcessor;
111
112	QMutex m_pauseMutex;
113	bool m_pauseAfterFrame;
114
115	bool m_videoSync;
116	bool m_audioSync;
117	bool m_turbo;
118	bool m_turboForced;
119
120	InputController* m_inputController;
121};
122
123}
124
125#endif