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