all repos — mgba @ 6560db2ef58e1a192a2356fd8ae1de65379b838c

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
35	bool isPaused();
36
37#ifdef USE_GDB_STUB
38	ARMDebugger* debugger();
39	void setDebugger(ARMDebugger*);
40#endif
41
42signals:
43	void frameAvailable(const uint32_t*);
44	void gameStarted(GBAThread*);
45	void gameStopped(GBAThread*);
46	void gamePaused(GBAThread*);
47	void gameUnpaused(GBAThread*);
48
49public slots:
50	void loadGame(const QString& path);
51	void closeGame();
52	void setPaused(bool paused);
53	void reset();
54	void frameAdvance();
55	void keyPressed(int key);
56	void keyReleased(int key);
57	void setAudioBufferSamples(int samples);
58	void setFPSTarget(float fps);
59
60#ifdef BUILD_SDL
61private slots:
62	void testSDLEvents();
63
64private:
65	GBASDLEvents m_sdlEvents;
66	int m_activeButtons;
67#endif
68
69private:
70	void updateKeys();
71
72	uint32_t* m_drawContext;
73	GBAThread m_threadContext;
74	GBAVideoSoftwareRenderer* m_renderer;
75	int m_activeKeys;
76
77	QFile* m_rom;
78	QFile* m_bios;
79
80	QThread* m_audioThread;
81	AudioProcessor* m_audioProcessor;
82
83	QMutex m_pauseMutex;
84	bool m_pauseAfterFrame;
85};
86
87}
88
89#endif