all repos — mgba @ c91ad7f85f8e24f9641e8f15c297fb9d2d10e13a

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;
25
26class GameController : public QObject {
27Q_OBJECT
28
29public:
30	GameController(QObject* parent = nullptr);
31	~GameController();
32
33	const uint32_t* drawContext() const { return m_drawContext; }
34	GBAThread* thread() { return &m_threadContext; }
35
36	bool isPaused();
37
38#ifdef USE_GDB_STUB
39	ARMDebugger* debugger();
40	void setDebugger(ARMDebugger*);
41#endif
42
43signals:
44	void frameAvailable(const uint32_t*);
45	void gameStarted(GBAThread*);
46	void gameStopped(GBAThread*);
47	void gamePaused(GBAThread*);
48	void gameUnpaused(GBAThread*);
49	void stateLoaded(GBAThread*);
50
51	void postLog(int level, const QString& log);
52
53public slots:
54	void loadGame(const QString& path);
55	void closeGame();
56	void setPaused(bool paused);
57	void reset();
58	void frameAdvance();
59	void keyPressed(int key);
60	void keyReleased(int key);
61	void setAudioBufferSamples(int samples);
62	void setFPSTarget(float fps);
63	void loadState(int slot);
64	void saveState(int slot);
65
66#ifdef BUILD_SDL
67private slots:
68	void testSDLEvents();
69
70private:
71	GBASDLEvents m_sdlEvents;
72	int m_activeButtons;
73#endif
74
75private:
76	void updateKeys();
77
78	uint32_t* m_drawContext;
79	GBAThread m_threadContext;
80	GBAVideoSoftwareRenderer* m_renderer;
81	int m_activeKeys;
82
83	QFile* m_rom;
84	QFile* m_bios;
85
86	QThread* m_audioThread;
87	AudioProcessor* m_audioProcessor;
88
89	QMutex m_pauseMutex;
90	bool m_pauseAfterFrame;
91};
92
93}
94
95#endif