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