summaryrefslogtreecommitdiff
path: root/src/citra_qt/bootmanager.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/citra_qt/bootmanager.h')
-rw-r--r--src/citra_qt/bootmanager.h68
1 files changed, 26 insertions, 42 deletions
diff --git a/src/citra_qt/bootmanager.h b/src/citra_qt/bootmanager.h
index 288da45a1..715faf2d7 100644
--- a/src/citra_qt/bootmanager.h
+++ b/src/citra_qt/bootmanager.h
@@ -9,72 +9,58 @@
9 9
10#include "common/common.h" 10#include "common/common.h"
11#include "common/emu_window.h" 11#include "common/emu_window.h"
12#include "common/thread.h"
12 13
13class QScreen; 14class QScreen;
14class QKeyEvent; 15class QKeyEvent;
15 16
16class GRenderWindow; 17class GRenderWindow;
18class GMainWindow;
17 19
18class EmuThread : public QThread 20class EmuThread : public QThread
19{ 21{
20 Q_OBJECT 22 Q_OBJECT
21 23
22public: 24public:
23 /** 25 EmuThread(GRenderWindow* render_window);
24 * Set image filename
25 *
26 * @param filename
27 * @warning Only call when not running!
28 */
29 void SetFilename(std::string filename);
30 26
31 /** 27 /**
32 * Start emulation (on new thread) 28 * Start emulation (on new thread)
33 *
34 * @warning Only call when not running! 29 * @warning Only call when not running!
35 */ 30 */
36 void run() override; 31 void run() override;
37 32
38 /** 33 /**
39 * Allow the CPU to process a single instruction (if cpu is not running) 34 * Steps the emulation thread by a single CPU instruction (if the CPU is not already running)
40 *
41 * @note This function is thread-safe 35 * @note This function is thread-safe
42 */ 36 */
43 void ExecStep() { exec_cpu_step = true; } 37 void ExecStep() { exec_step = true; }
44 38
45 /** 39 /**
46 * Allow the CPU to continue processing instructions without interruption 40 * Sets whether the emulation thread is running or not
47 * 41 * @param running Boolean value, set the emulation thread to running if true
48 * @note This function is thread-safe 42 * @note This function is thread-safe
49 */ 43 */
50 void SetCpuRunning(bool running) { cpu_running = running; } 44 void SetRunning(bool running) { this->running = running; }
51 45
52 /** 46 /**
53 * Allow the CPU to continue processing instructions without interruption 47 * Check if the emulation thread is running or not
54 * 48 * @return True if the emulation thread is running, otherwise false
55 * @note This function is thread-safe 49 * @note This function is thread-safe
56 */ 50 */
57 bool IsCpuRunning() { return cpu_running; } 51 bool IsRunning() { return running; }
58
59 52
60public slots:
61 /** 53 /**
62 * Stop emulation and wait for the thread to finish. 54 * Requests for the emulation thread to stop running
63 *
64 * @details: This function will wait a second for the thread to finish; if it hasn't finished until then, we'll terminate() it and wait another second, hoping that it will be terminated by then.
65 * @note: This function is thread-safe.
66 */ 55 */
67 void Stop(); 56 void RequestStop() {
57 stop_run = true;
58 running = false;
59 };
68 60
69private: 61private:
70 friend class GRenderWindow; 62 bool exec_step;
71 63 bool running;
72 EmuThread(GRenderWindow* render_window);
73
74 std::string filename;
75
76 bool exec_cpu_step;
77 bool cpu_running;
78 std::atomic<bool> stop_run; 64 std::atomic<bool> stop_run;
79 65
80 GRenderWindow* render_window; 66 GRenderWindow* render_window;
@@ -100,10 +86,7 @@ class GRenderWindow : public QWidget, public EmuWindow
100 Q_OBJECT 86 Q_OBJECT
101 87
102public: 88public:
103 GRenderWindow(QWidget* parent = NULL); 89 GRenderWindow(QWidget* parent, EmuThread* emu_thread);
104 ~GRenderWindow();
105
106 void closeEvent(QCloseEvent*) override;
107 90
108 // EmuWindow implementation 91 // EmuWindow implementation
109 void SwapBuffers() override; 92 void SwapBuffers() override;
@@ -116,8 +99,6 @@ public:
116 void restoreGeometry(const QByteArray& geometry); // overridden 99 void restoreGeometry(const QByteArray& geometry); // overridden
117 QByteArray saveGeometry(); // overridden 100 QByteArray saveGeometry(); // overridden
118 101
119 EmuThread& GetEmuThread();
120
121 void keyPressEvent(QKeyEvent* event) override; 102 void keyPressEvent(QKeyEvent* event) override;
122 void keyReleaseEvent(QKeyEvent* event) override; 103 void keyReleaseEvent(QKeyEvent* event) override;
123 104
@@ -134,15 +115,18 @@ public:
134public slots: 115public slots:
135 void moveContext(); // overridden 116 void moveContext(); // overridden
136 117
118 void OnEmulationStarting(EmuThread* emu_thread);
119 void OnEmulationStopping();
120
137private: 121private:
138 void OnMinimalClientAreaChangeRequest(const std::pair<unsigned,unsigned>& minimal_size) override; 122 void OnMinimalClientAreaChangeRequest(const std::pair<unsigned,unsigned>& minimal_size) override;
139 123
140 QGLWidget* child; 124 QGLWidget* child;
141 125
142 EmuThread emu_thread;
143
144 QByteArray geometry; 126 QByteArray geometry;
145 127
146 /// Device id of keyboard for use with KeyMap 128 /// Device id of keyboard for use with KeyMap
147 int keyboard_id; 129 int keyboard_id;
130
131 EmuThread* emu_thread;
148}; 132};