Skip to content

Commit 98c872b

Browse files
committed
LibUV glue.
1 parent 720de96 commit 98c872b

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

src/ftdi/abstract-ftd2xx-win32.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ static HANDLE s_kickEvent = nullptr;
5959
static std::shared_mutex s_listLock;
6060
static unsigned s_numOpened = 0;
6161

62+
static PCSX::GUI* s_gui = nullptr;
63+
6264
PCSX::FTDI::Device::~Device() {
6365
assert(m_private->m_state == Private::DeviceData::STATE_CLOSED);
6466
assert(!m_private->m_event);
@@ -189,4 +191,6 @@ void PCSX::FTDI::Devices::stopThread() {
189191

190192
bool PCSX::FTDI::Devices::isThreadRunning() { return s_threadRunning; }
191193

194+
void PCSX::FTDI::Devices::setGUI(GUI* gui) { s_gui = gui; }
195+
192196
#endif

src/ftdi/abstract.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,14 @@
2121

2222
#include <stdint.h>
2323

24+
#include <atomic>
2425
#include <functional>
2526
#include <string>
2627
#include <vector>
2728

29+
#include "gui/gui.h"
30+
#include "support/slice.h"
31+
2832
namespace PCSX {
2933

3034
namespace FTDI {
@@ -60,6 +64,27 @@ class Device {
6064

6165
Private::DeviceData* m_private;
6266

67+
static const unsigned SLICES_COUNT = 256;
68+
Slice m_slices[SLICES_COUNT];
69+
std::atomic_uint16_t m_slicesIndexes = 0;
70+
71+
unsigned usedSlices() {
72+
uint16_t indexes = m_slicesIndexes.load();
73+
unsigned first = indexes & 0xff;
74+
unsigned last = (indexes >> 8) & 0xff;
75+
if (last < first) last += 256;
76+
return last - first;
77+
}
78+
79+
unsigned availableSlices() { return 256 - usedSlices(); }
80+
81+
Slice& allocateSlice() {
82+
while (availableSlices() == 0)
83+
;
84+
uint16_t indexes = m_slicesIndexes.fetch_add(0x100);
85+
return m_slices[(indexes >> 8) & 0xff];
86+
}
87+
6388
friend class Devices;
6489
};
6590

@@ -70,6 +95,7 @@ class Devices {
7095
static bool isThreadRunning();
7196
static void startThread();
7297
static void stopThread();
98+
static void setGUI(GUI*);
7399

74100
// technically private, but difficult to enforce properly
75101
static void threadProc();

src/gui/gui.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ class GUI final {
105105
}
106106
}
107107

108+
uv_loop_t &loop();
109+
108110
private:
109111
GLFWwindow *m_window = nullptr;
110112
int &m_glfwPosX = settings.get<WindowPosX>().value;

src/main/main.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "core/r3000a.h"
3131
#include "core/sstate.h"
3232
#include "flags.h"
33+
#include "ftdi/abstract.h"
3334
#include "gui/gui.h"
3435
#include "spu/interface.h"
3536
#include "support/slice.h"
@@ -197,6 +198,7 @@ int main(int argc, char **argv) {
197198
LoadPlugins();
198199
PCSX::g_emulator.m_gpu->open(s_gui);
199200
PCSX::g_emulator.m_spu->open();
201+
PCSX::FTDI::setGUI(s_gui);
200202

201203
PCSX::g_emulator.EmuInit();
202204
PCSX::g_emulator.EmuReset();

0 commit comments

Comments
 (0)