Skip to content

Commit

Permalink
Starting to interface with the devices a bit.
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasnoble committed Jan 4, 2020
1 parent f770ed7 commit 67c24d3
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 5 deletions.
40 changes: 40 additions & 0 deletions src/ftdi/abstract-ftd2xx-win32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,44 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
***************************************************************************/

#ifdef _WIN32

#define WIN32_LEAN_AND_MEAN
#include "ftd2xx.h"
#include "ftdi/abstract.h"

static std::vector<PCSX::FTDI::Device> s_devices;

void PCSX::FTDI::DeviceList::scan() {
FT_STATUS status;
DWORD numDevs = 0;

s_devices.clear();
status = FT_CreateDeviceInfoList(&numDevs);

if (status != FT_OK || numDevs == 0) return;

FT_DEVICE_LIST_INFO_NODE* nodes = new FT_DEVICE_LIST_INFO_NODE[numDevs];

status = FT_GetDeviceInfoList(nodes, &numDevs);

if (status == FT_OK && numDevs != 0) {
s_devices.resize(numDevs);
for (DWORD i = 0; i < numDevs; i++) {
const FT_DEVICE_LIST_INFO_NODE* n = nodes + i;
s_devices[i].m_locked = n->Flags & FT_FLAGS_OPENED;
s_devices[i].m_highSpeed = n->Flags & FT_FLAGS_HISPEED;
s_devices[i].m_vendorID = (n->ID >> 16) & 0xffff;
s_devices[i].m_deviceID = n->ID & 0xffff;
s_devices[i].m_type = n->Type;
s_devices[i].m_serial = n->SerialNumber;
s_devices[i].m_description = n->Description;
}
}

delete[] nodes;
}

const std::vector<PCSX::FTDI::Device>& PCSX::FTDI::DeviceList::get() { return s_devices; }

#endif
43 changes: 43 additions & 0 deletions src/ftdi/abstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,46 @@
***************************************************************************/

#pragma once

#include <stdint.h>

#include <string>
#include <vector>

namespace PCSX {

namespace FTDI {

class DeviceList;
class Device {
public:
bool isLocked() const { return m_locked; }
bool isHighSpeed() const { return m_highSpeed; }
uint16_t getVendorID() const { return m_vendorID; }
uint16_t getDeviceID() const { return m_deviceID; }
uint32_t getType() const { return m_type; }
const std::string& getSerial() const { return m_serial; }
const std::string& getDescription() const { return m_description; }

private:
bool m_locked = false;
bool m_highSpeed = false;
uint16_t m_vendorID = 0;
uint16_t m_deviceID = 0;
uint32_t m_type = 0;
std::string m_serial = "";
std::string m_description = "";
void* m_handle = nullptr;

friend class DeviceList;
};

class DeviceList {
public:
static void scan();
static const std::vector<Device>& get();
};

} // namespace FTDI

} // namespace PCSX
5 changes: 5 additions & 0 deletions src/gui/gui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ void PCSX::GUI::endFrame() {
ImGui::MenuItem(_("Show ImGui Demo"), nullptr, &m_showDemo);
ImGui::Separator();
ImGui::MenuItem(_("About"), nullptr, &m_showAbout);
ImGui::MenuItem(_("FTDI"), nullptr, &m_showFTDI);
ImGui::EndMenu();
}
ImGui::Separator();
Expand Down Expand Up @@ -572,6 +573,10 @@ void PCSX::GUI::endFrame() {
m_breakpoints.draw(_("Breakpoints"));
}

if (m_showFTDI) {
m_ftdi.draw(_("FTDI"));
}

about();
biosCounters();
interruptsScaler();
Expand Down
12 changes: 7 additions & 5 deletions src/gui/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,17 @@

#include <string>

#include "flags.h"

#include "imgui.h"
#include "imgui_memory_editor/imgui_memory_editor.h"

#include "core/system.h"
#include "flags.h"
#include "gui/widgets/assembly.h"
#include "gui/widgets/breakpoints.h"
#include "gui/widgets/filedialog.h"
#include "gui/widgets/ftdi.h"
#include "gui/widgets/log.h"
#include "gui/widgets/registers.h"
#include "gui/widgets/vram-viewer.h"
#include "imgui.h"
#include "imgui_memory_editor/imgui_memory_editor.h"
#include "main/settings.h"

#if defined(__MACOSX__)
Expand Down Expand Up @@ -132,6 +131,7 @@ class GUI final {
bool m_showDemo = false;
bool m_showAbout = false;
bool m_showInterruptsScaler = false;
bool m_showFTDI = false;
Widgets::Log m_log = {settings.get<ShowLog>().value};
struct MemoryEditorWrapper {
MemoryEditorWrapper() {
Expand Down Expand Up @@ -173,6 +173,8 @@ class GUI final {
Widgets::VRAMViewer m_clutVRAMviewer;
Widgets::VRAMViewer m_VRAMviewers[4];

Widgets::FTDI m_ftdi = {m_showFTDI};

uv_loop_t m_loop;
};

Expand Down
2 changes: 2 additions & 0 deletions vsprojects/gui/gui.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
<ClCompile Include="..\..\src\gui\widgets\assembly.cc" />
<ClCompile Include="..\..\src\gui\widgets\breakpoints.cc" />
<ClCompile Include="..\..\src\gui\widgets\filedialog.cc" />
<ClCompile Include="..\..\src\gui\widgets\ftdi.cc" />
<ClCompile Include="..\..\src\gui\widgets\log.cc" />
<ClCompile Include="..\..\src\gui\widgets\registers.cc" />
<ClCompile Include="..\..\src\gui\widgets\vram-viewer.cc" />
Expand All @@ -151,6 +152,7 @@
<ClInclude Include="..\..\src\gui\widgets\assembly.h" />
<ClInclude Include="..\..\src\gui\widgets\breakpoints.h" />
<ClInclude Include="..\..\src\gui\widgets\filedialog.h" />
<ClInclude Include="..\..\src\gui\widgets\ftdi.h" />
<ClInclude Include="..\..\src\gui\widgets\log.h" />
<ClInclude Include="..\..\src\gui\widgets\registers.h" />
<ClInclude Include="..\..\src\gui\widgets\vram-viewer.h" />
Expand Down
6 changes: 6 additions & 0 deletions vsprojects/gui/gui.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
<ClCompile Include="..\..\src\gui\widgets\vram-viewer.cc">
<Filter>Source Files\widgets</Filter>
</ClCompile>
<ClCompile Include="..\..\src\gui\widgets\ftdi.cc">
<Filter>Source Files\widgets</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\gui\gui.h">
Expand All @@ -68,6 +71,9 @@
<ClInclude Include="..\..\src\gui\widgets\vram-viewer.h">
<Filter>Header Files\widgets</Filter>
</ClInclude>
<ClInclude Include="..\..\src\gui\widgets\ftdi.h">
<Filter>Header Files\widgets</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
Expand Down

0 comments on commit 67c24d3

Please sign in to comment.