diff options
Diffstat (limited to 'src/frontend/qt_sdl/Window.cpp')
-rw-r--r-- | src/frontend/qt_sdl/Window.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/frontend/qt_sdl/Window.cpp b/src/frontend/qt_sdl/Window.cpp index 23ba784..d1f16a1 100644 --- a/src/frontend/qt_sdl/Window.cpp +++ b/src/frontend/qt_sdl/Window.cpp @@ -81,6 +81,37 @@ #include "ArchiveUtil.h" #include "CameraManager.h" +#include "../../vsr.h" + +#ifdef VSR_INJECTION +#include <fstream> + +void MainWindow::injectPacket(int type) { + QString input_path = QFileDialog::getOpenFileName(this, + "Select packet data file", QDir::currentPath(), "Raw data (*.bin)"); + + if (input_path.length() == 0) { + printf("[VSR] inject packet aborted!\n"); + return; + } + + printf("[VSR] injecting %s...\n", input_path.toStdString().c_str()); + + std::ifstream is(input_path.toStdString()); + std::istream_iterator<uint8_t> start(is), end; + std::vector<uint8_t> buf(start, end); + + // TODO: is this melonDS::NDS::SysTimestamp??? + melonDS::u64 timestamp = 0; + + switch(type) { + case 0: return (void) LocalMP::SendPacket(buf.data(), buf.size(), timestamp); + case 1: return (void) LocalMP::SendCmd(buf.data(), buf.size(), timestamp); + case 3: return (void) LocalMP::SendAck(buf.data(), buf.size(), timestamp); + } +} +#endif + using namespace melonDS; // TEMP @@ -574,6 +605,20 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) actAudioSync->setCheckable(true); connect(actAudioSync, &QAction::triggered, this, &MainWindow::onChangeAudioSync); } +#ifdef VSR_INJECTION + { + QMenu* menu = menubar->addMenu("Inject"); + + QAction* actInjectNormal = menu->addAction("Normal..."); + connect(actInjectNormal, &QAction::triggered, this, [this](){ injectPacket(0); }); + + QAction* actInjectCmd = menu->addAction("CMD..."); + connect(actInjectCmd, &QAction::triggered, this, [this](){ injectPacket(1); }); + + QAction* actInjectAck = menu->addAction("ACK..."); + connect(actInjectAck, &QAction::triggered, this, [this](){ injectPacket(3); }); + } +#endif setMenuBar(menubar); resize(Config::WindowWidth, Config::WindowHeight); |