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
20namespace QGBA {
21
22class AudioDevice;
23
24class GameController : public QObject {
25Q_OBJECT
26
27public:
28 GameController(QObject* parent = nullptr);
29 ~GameController();
30
31 const uint32_t* drawContext() const { return m_drawContext; }
32
33 bool isPaused();
34
35#ifdef USE_GDB_STUB
36 ARMDebugger* debugger();
37 void setDebugger(ARMDebugger*);
38#endif
39
40signals:
41 void frameAvailable(const uint32_t*);
42 void gameStarted(GBAThread*);
43 void gameStopped(GBAThread*);
44
45public slots:
46 void loadGame(const QString& path);
47 void closeGame();
48 void setPaused(bool paused);
49 void frameAdvance();
50 void keyPressed(int key);
51 void keyReleased(int key);
52
53#ifdef BUILD_SDL
54private slots:
55 void testSDLEvents();
56
57private:
58 GBASDLEvents m_sdlEvents;
59 int m_activeButtons;
60#endif
61
62private:
63 void updateKeys();
64
65 uint32_t* m_drawContext;
66 GBAThread m_threadContext;
67 GBAVideoSoftwareRenderer* m_renderer;
68 int m_activeKeys;
69
70 QFile* m_rom;
71 QFile* m_bios;
72
73 QMutex m_pauseMutex;
74 bool m_pauseAfterFrame;
75};
76
77}
78
79#endif