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
59#ifdef BUILD_SDL
60private slots:
61 void testSDLEvents();
62
63private:
64 GBASDLEvents m_sdlEvents;
65 int m_activeButtons;
66#endif
67
68private:
69 void updateKeys();
70
71 uint32_t* m_drawContext;
72 GBAThread m_threadContext;
73 GBAVideoSoftwareRenderer* m_renderer;
74 int m_activeKeys;
75
76 QFile* m_rom;
77 QFile* m_bios;
78
79 QThread* m_audioThread;
80 AudioProcessor* m_audioProcessor;
81
82 QMutex m_pauseMutex;
83 bool m_pauseAfterFrame;
84};
85
86}
87
88#endif