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
50 void postLog(int level, const QString& log);
51
52public slots:
53 void loadGame(const QString& path);
54 void closeGame();
55 void setPaused(bool paused);
56 void reset();
57 void frameAdvance();
58 void keyPressed(int key);
59 void keyReleased(int key);
60 void setAudioBufferSamples(int samples);
61 void setFPSTarget(float fps);
62
63#ifdef BUILD_SDL
64private slots:
65 void testSDLEvents();
66
67private:
68 GBASDLEvents m_sdlEvents;
69 int m_activeButtons;
70#endif
71
72private:
73 void updateKeys();
74
75 uint32_t* m_drawContext;
76 GBAThread m_threadContext;
77 GBAVideoSoftwareRenderer* m_renderer;
78 int m_activeKeys;
79
80 QFile* m_rom;
81 QFile* m_bios;
82
83 QThread* m_audioThread;
84 AudioProcessor* m_audioProcessor;
85
86 QMutex m_pauseMutex;
87 bool m_pauseAfterFrame;
88};
89
90}
91
92#endif