chore: CRLF to LF
This commit is contained in:
+117
-117
@@ -1,117 +1,117 @@
|
||||
#include "ddr.h"
|
||||
|
||||
#include "acioemu/handle.h"
|
||||
#include "avs/game.h"
|
||||
#include "hooks/devicehook.h"
|
||||
#include "hooks/setupapihook.h"
|
||||
#include "hooks/sleephook.h"
|
||||
#include "hooks/input/dinput8/hook.h"
|
||||
#include "util/utils.h"
|
||||
#include "util/libutils.h"
|
||||
#include "util/fileutils.h"
|
||||
#include "util/detour.h"
|
||||
|
||||
#include "io.h"
|
||||
|
||||
#include "p3io/foot.h"
|
||||
#include "p3io/p3io.h"
|
||||
#include "p3io/sate.h"
|
||||
#include "p3io/usbmem.h"
|
||||
|
||||
using namespace acioemu;
|
||||
|
||||
namespace games::ddr {
|
||||
|
||||
// settings
|
||||
bool SDMODE = false;
|
||||
|
||||
static decltype(SendMessage) *SendMessage_real = nullptr;
|
||||
|
||||
static SHORT WINAPI GetAsyncKeyState_hook(int vKey) {
|
||||
|
||||
// disable debug keys
|
||||
return 0;
|
||||
}
|
||||
|
||||
static LRESULT WINAPI SendMessage_hook(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) {
|
||||
|
||||
// ignore broadcasts
|
||||
if (hWnd == HWND_BROADCAST) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// fallback
|
||||
return SendMessage_real(hWnd, Msg, wParam, lParam);
|
||||
}
|
||||
|
||||
DDRGame::DDRGame() : Game("Dance Dance Revolution") {
|
||||
}
|
||||
|
||||
void DDRGame::attach() {
|
||||
Game::attach();
|
||||
|
||||
// dinput hook on this dll since the game dll doesn't load it
|
||||
auto game_mdx = libutils::try_library(MODULE_PATH / "gamemdx.dll");
|
||||
hooks::input::dinput8::init(game_mdx);
|
||||
|
||||
// init device hook
|
||||
devicehook_init();
|
||||
|
||||
// add fake devices
|
||||
if (avs::game::DLL_NAME == "arkmdxbio2.dll") {
|
||||
devicehook_add(new acioemu::ACIOHandle(L"COM1"));
|
||||
} else {
|
||||
devicehook_add(new DDRFOOTHandle());
|
||||
devicehook_add(new DDRSATEHandle());
|
||||
devicehook_add(new DDRUSBMEMHandle());
|
||||
devicehook_add(new DDRP3IOHandle());
|
||||
}
|
||||
|
||||
// has nothing to do with P3IO, but is enough to trick the game into SD/HD mode
|
||||
const char *settings_property = ddr::SDMODE ? "Generic Television" : "Generic Monitor";
|
||||
const char settings_detail[] = R"(\\.\P3IO)";
|
||||
|
||||
// settings 1
|
||||
SETUPAPI_SETTINGS settings1 {};
|
||||
settings1.class_guid[0] = 0x1FA4A480;
|
||||
settings1.class_guid[1] = 0x40C7AC60;
|
||||
settings1.class_guid[2] = 0x7952ACA7;
|
||||
settings1.class_guid[3] = 0x5A57340F;
|
||||
memcpy(settings1.property_devicedesc, settings_property, strlen(settings_property) + 1);
|
||||
memcpy(settings1.interface_detail, settings_detail, sizeof(settings_detail));
|
||||
|
||||
// settings 2
|
||||
SETUPAPI_SETTINGS settings2 {};
|
||||
settings2.class_guid[0] = 0x4D36E96E;
|
||||
settings2.class_guid[1] = 0x11CEE325;
|
||||
settings2.class_guid[2] = 0x8C1BF;
|
||||
settings2.class_guid[3] = 0x1803E12B;
|
||||
memcpy(settings2.property_devicedesc, settings_property, strlen(settings_property) + 1);
|
||||
memcpy(settings2.interface_detail, settings_detail, sizeof(settings_detail));
|
||||
|
||||
// init SETUP API
|
||||
setupapihook_init(avs::game::DLL_INSTANCE);
|
||||
|
||||
// DDR ACE actually uses another DLL for things
|
||||
if (game_mdx != nullptr) {
|
||||
setupapihook_init(game_mdx);
|
||||
}
|
||||
|
||||
// add settings
|
||||
setupapihook_add(settings1);
|
||||
setupapihook_add(settings2);
|
||||
|
||||
// misc hooks
|
||||
detour::iat_try("GetAsyncKeyState", GetAsyncKeyState_hook, avs::game::DLL_INSTANCE);
|
||||
detour::iat_try("GetKeyState", GetAsyncKeyState_hook, avs::game::DLL_INSTANCE);
|
||||
SendMessage_real = detour::iat_try("SendMessageW", SendMessage_hook, avs::game::DLL_INSTANCE);
|
||||
detour::iat_try("SendMessageA", SendMessage_hook, avs::game::DLL_INSTANCE);
|
||||
}
|
||||
|
||||
void DDRGame::detach() {
|
||||
Game::detach();
|
||||
|
||||
// dispose device hook
|
||||
devicehook_dispose();
|
||||
}
|
||||
}
|
||||
#include "ddr.h"
|
||||
|
||||
#include "acioemu/handle.h"
|
||||
#include "avs/game.h"
|
||||
#include "hooks/devicehook.h"
|
||||
#include "hooks/setupapihook.h"
|
||||
#include "hooks/sleephook.h"
|
||||
#include "hooks/input/dinput8/hook.h"
|
||||
#include "util/utils.h"
|
||||
#include "util/libutils.h"
|
||||
#include "util/fileutils.h"
|
||||
#include "util/detour.h"
|
||||
|
||||
#include "io.h"
|
||||
|
||||
#include "p3io/foot.h"
|
||||
#include "p3io/p3io.h"
|
||||
#include "p3io/sate.h"
|
||||
#include "p3io/usbmem.h"
|
||||
|
||||
using namespace acioemu;
|
||||
|
||||
namespace games::ddr {
|
||||
|
||||
// settings
|
||||
bool SDMODE = false;
|
||||
|
||||
static decltype(SendMessage) *SendMessage_real = nullptr;
|
||||
|
||||
static SHORT WINAPI GetAsyncKeyState_hook(int vKey) {
|
||||
|
||||
// disable debug keys
|
||||
return 0;
|
||||
}
|
||||
|
||||
static LRESULT WINAPI SendMessage_hook(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) {
|
||||
|
||||
// ignore broadcasts
|
||||
if (hWnd == HWND_BROADCAST) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// fallback
|
||||
return SendMessage_real(hWnd, Msg, wParam, lParam);
|
||||
}
|
||||
|
||||
DDRGame::DDRGame() : Game("Dance Dance Revolution") {
|
||||
}
|
||||
|
||||
void DDRGame::attach() {
|
||||
Game::attach();
|
||||
|
||||
// dinput hook on this dll since the game dll doesn't load it
|
||||
auto game_mdx = libutils::try_library(MODULE_PATH / "gamemdx.dll");
|
||||
hooks::input::dinput8::init(game_mdx);
|
||||
|
||||
// init device hook
|
||||
devicehook_init();
|
||||
|
||||
// add fake devices
|
||||
if (avs::game::DLL_NAME == "arkmdxbio2.dll") {
|
||||
devicehook_add(new acioemu::ACIOHandle(L"COM1"));
|
||||
} else {
|
||||
devicehook_add(new DDRFOOTHandle());
|
||||
devicehook_add(new DDRSATEHandle());
|
||||
devicehook_add(new DDRUSBMEMHandle());
|
||||
devicehook_add(new DDRP3IOHandle());
|
||||
}
|
||||
|
||||
// has nothing to do with P3IO, but is enough to trick the game into SD/HD mode
|
||||
const char *settings_property = ddr::SDMODE ? "Generic Television" : "Generic Monitor";
|
||||
const char settings_detail[] = R"(\\.\P3IO)";
|
||||
|
||||
// settings 1
|
||||
SETUPAPI_SETTINGS settings1 {};
|
||||
settings1.class_guid[0] = 0x1FA4A480;
|
||||
settings1.class_guid[1] = 0x40C7AC60;
|
||||
settings1.class_guid[2] = 0x7952ACA7;
|
||||
settings1.class_guid[3] = 0x5A57340F;
|
||||
memcpy(settings1.property_devicedesc, settings_property, strlen(settings_property) + 1);
|
||||
memcpy(settings1.interface_detail, settings_detail, sizeof(settings_detail));
|
||||
|
||||
// settings 2
|
||||
SETUPAPI_SETTINGS settings2 {};
|
||||
settings2.class_guid[0] = 0x4D36E96E;
|
||||
settings2.class_guid[1] = 0x11CEE325;
|
||||
settings2.class_guid[2] = 0x8C1BF;
|
||||
settings2.class_guid[3] = 0x1803E12B;
|
||||
memcpy(settings2.property_devicedesc, settings_property, strlen(settings_property) + 1);
|
||||
memcpy(settings2.interface_detail, settings_detail, sizeof(settings_detail));
|
||||
|
||||
// init SETUP API
|
||||
setupapihook_init(avs::game::DLL_INSTANCE);
|
||||
|
||||
// DDR ACE actually uses another DLL for things
|
||||
if (game_mdx != nullptr) {
|
||||
setupapihook_init(game_mdx);
|
||||
}
|
||||
|
||||
// add settings
|
||||
setupapihook_add(settings1);
|
||||
setupapihook_add(settings2);
|
||||
|
||||
// misc hooks
|
||||
detour::iat_try("GetAsyncKeyState", GetAsyncKeyState_hook, avs::game::DLL_INSTANCE);
|
||||
detour::iat_try("GetKeyState", GetAsyncKeyState_hook, avs::game::DLL_INSTANCE);
|
||||
SendMessage_real = detour::iat_try("SendMessageW", SendMessage_hook, avs::game::DLL_INSTANCE);
|
||||
detour::iat_try("SendMessageA", SendMessage_hook, avs::game::DLL_INSTANCE);
|
||||
}
|
||||
|
||||
void DDRGame::detach() {
|
||||
Game::detach();
|
||||
|
||||
// dispose device hook
|
||||
devicehook_dispose();
|
||||
}
|
||||
}
|
||||
|
||||
+16
-16
@@ -1,16 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "games/game.h"
|
||||
|
||||
namespace games::ddr {
|
||||
|
||||
// settings
|
||||
extern bool SDMODE;
|
||||
|
||||
class DDRGame : public games::Game {
|
||||
public:
|
||||
DDRGame();
|
||||
virtual void attach() override;
|
||||
virtual void detach() override;
|
||||
};
|
||||
}
|
||||
#pragma once
|
||||
|
||||
#include "games/game.h"
|
||||
|
||||
namespace games::ddr {
|
||||
|
||||
// settings
|
||||
extern bool SDMODE;
|
||||
|
||||
class DDRGame : public games::Game {
|
||||
public:
|
||||
DDRGame();
|
||||
virtual void attach() override;
|
||||
virtual void detach() override;
|
||||
};
|
||||
}
|
||||
|
||||
+87
-87
@@ -1,87 +1,87 @@
|
||||
#include "io.h"
|
||||
|
||||
std::vector<Button> &games::ddr::get_buttons() {
|
||||
static std::vector<Button> analogs;
|
||||
|
||||
if (analogs.empty()) {
|
||||
analogs = GameAPI::Buttons::getButtons("Dance Dance Revolution");
|
||||
|
||||
GameAPI::Buttons::sortButtons(
|
||||
&analogs,
|
||||
"Service",
|
||||
"Test",
|
||||
"Coin Mech",
|
||||
"P1 Start",
|
||||
"P1 Panel Up",
|
||||
"P1 Panel Down",
|
||||
"P1 Panel Left",
|
||||
"P1 Panel Right",
|
||||
"P1 Menu Up",
|
||||
"P1 Menu Down",
|
||||
"P1 Menu Left",
|
||||
"P1 Menu Right",
|
||||
"P2 Start",
|
||||
"P2 Panel Up",
|
||||
"P2 Panel Down",
|
||||
"P2 Panel Left",
|
||||
"P2 Panel Right",
|
||||
"P2 Menu Up",
|
||||
"P2 Menu Down",
|
||||
"P2 Menu Left",
|
||||
"P2 Menu Right"
|
||||
);
|
||||
}
|
||||
|
||||
return analogs;
|
||||
}
|
||||
|
||||
std::vector<Light> &games::ddr::get_lights() {
|
||||
static std::vector<Light> lights;
|
||||
|
||||
if (lights.empty()) {
|
||||
lights = GameAPI::Lights::getLights("Dance Dance Revolution");
|
||||
|
||||
GameAPI::Lights::sortLights(
|
||||
&lights,
|
||||
"P1 Foot Left",
|
||||
"P1 Foot Up",
|
||||
"P1 Foot Right",
|
||||
"P1 Foot Down",
|
||||
"P2 Foot Left",
|
||||
"P2 Foot Up",
|
||||
"P2 Foot Right",
|
||||
"P2 Foot Down",
|
||||
"Spot Red",
|
||||
"Spot Blue",
|
||||
"Top Spot Red",
|
||||
"Top Spot Blue",
|
||||
"P1 Halogen Upper",
|
||||
"P1 Halogen Lower",
|
||||
"P2 Halogen Upper",
|
||||
"P2 Halogen Lower",
|
||||
"P1 Button",
|
||||
"P2 Button",
|
||||
"Neon",
|
||||
"HD P1 Start",
|
||||
"HD P1 Menu Left-Right",
|
||||
"HD P1 Menu Up-Down",
|
||||
"HD P2 Start",
|
||||
"HD P2 Menu Left-Right",
|
||||
"HD P2 Menu Up-Down",
|
||||
"HD P1 Speaker F R",
|
||||
"HD P1 Speaker F G",
|
||||
"HD P1 Speaker F B",
|
||||
"HD P1 Speaker W R",
|
||||
"HD P1 Speaker W G",
|
||||
"HD P1 Speaker W B",
|
||||
"HD P2 Speaker F R",
|
||||
"HD P2 Speaker F G",
|
||||
"HD P2 Speaker F B",
|
||||
"HD P2 Speaker W R",
|
||||
"HD P2 Speaker W G",
|
||||
"HD P2 Speaker W B"
|
||||
);
|
||||
}
|
||||
|
||||
return lights;
|
||||
}
|
||||
#include "io.h"
|
||||
|
||||
std::vector<Button> &games::ddr::get_buttons() {
|
||||
static std::vector<Button> analogs;
|
||||
|
||||
if (analogs.empty()) {
|
||||
analogs = GameAPI::Buttons::getButtons("Dance Dance Revolution");
|
||||
|
||||
GameAPI::Buttons::sortButtons(
|
||||
&analogs,
|
||||
"Service",
|
||||
"Test",
|
||||
"Coin Mech",
|
||||
"P1 Start",
|
||||
"P1 Panel Up",
|
||||
"P1 Panel Down",
|
||||
"P1 Panel Left",
|
||||
"P1 Panel Right",
|
||||
"P1 Menu Up",
|
||||
"P1 Menu Down",
|
||||
"P1 Menu Left",
|
||||
"P1 Menu Right",
|
||||
"P2 Start",
|
||||
"P2 Panel Up",
|
||||
"P2 Panel Down",
|
||||
"P2 Panel Left",
|
||||
"P2 Panel Right",
|
||||
"P2 Menu Up",
|
||||
"P2 Menu Down",
|
||||
"P2 Menu Left",
|
||||
"P2 Menu Right"
|
||||
);
|
||||
}
|
||||
|
||||
return analogs;
|
||||
}
|
||||
|
||||
std::vector<Light> &games::ddr::get_lights() {
|
||||
static std::vector<Light> lights;
|
||||
|
||||
if (lights.empty()) {
|
||||
lights = GameAPI::Lights::getLights("Dance Dance Revolution");
|
||||
|
||||
GameAPI::Lights::sortLights(
|
||||
&lights,
|
||||
"P1 Foot Left",
|
||||
"P1 Foot Up",
|
||||
"P1 Foot Right",
|
||||
"P1 Foot Down",
|
||||
"P2 Foot Left",
|
||||
"P2 Foot Up",
|
||||
"P2 Foot Right",
|
||||
"P2 Foot Down",
|
||||
"Spot Red",
|
||||
"Spot Blue",
|
||||
"Top Spot Red",
|
||||
"Top Spot Blue",
|
||||
"P1 Halogen Upper",
|
||||
"P1 Halogen Lower",
|
||||
"P2 Halogen Upper",
|
||||
"P2 Halogen Lower",
|
||||
"P1 Button",
|
||||
"P2 Button",
|
||||
"Neon",
|
||||
"HD P1 Start",
|
||||
"HD P1 Menu Left-Right",
|
||||
"HD P1 Menu Up-Down",
|
||||
"HD P2 Start",
|
||||
"HD P2 Menu Left-Right",
|
||||
"HD P2 Menu Up-Down",
|
||||
"HD P1 Speaker F R",
|
||||
"HD P1 Speaker F G",
|
||||
"HD P1 Speaker F B",
|
||||
"HD P1 Speaker W R",
|
||||
"HD P1 Speaker W G",
|
||||
"HD P1 Speaker W B",
|
||||
"HD P2 Speaker F R",
|
||||
"HD P2 Speaker F G",
|
||||
"HD P2 Speaker F B",
|
||||
"HD P2 Speaker W R",
|
||||
"HD P2 Speaker W G",
|
||||
"HD P2 Speaker W B"
|
||||
);
|
||||
}
|
||||
|
||||
return lights;
|
||||
}
|
||||
|
||||
+82
-82
@@ -1,82 +1,82 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "cfg/api.h"
|
||||
|
||||
namespace games::ddr {
|
||||
|
||||
// all buttons in correct order
|
||||
namespace Buttons {
|
||||
enum {
|
||||
SERVICE,
|
||||
TEST,
|
||||
COIN_MECH,
|
||||
P1_START,
|
||||
P1_PANEL_UP,
|
||||
P1_PANEL_DOWN,
|
||||
P1_PANEL_LEFT,
|
||||
P1_PANEL_RIGHT,
|
||||
P1_MENU_UP,
|
||||
P1_MENU_DOWN,
|
||||
P1_MENU_LEFT,
|
||||
P1_MENU_RIGHT,
|
||||
P2_START,
|
||||
P2_PANEL_UP,
|
||||
P2_PANEL_DOWN,
|
||||
P2_PANEL_LEFT,
|
||||
P2_PANEL_RIGHT,
|
||||
P2_MENU_UP,
|
||||
P2_MENU_DOWN,
|
||||
P2_MENU_LEFT,
|
||||
P2_MENU_RIGHT,
|
||||
};
|
||||
}
|
||||
|
||||
// all lights in correct order
|
||||
namespace Lights {
|
||||
enum {
|
||||
P1_FOOT_LEFT,
|
||||
P1_FOOT_UP,
|
||||
P1_FOOT_RIGHT,
|
||||
P1_FOOT_DOWN,
|
||||
P2_FOOT_LEFT,
|
||||
P2_FOOT_UP,
|
||||
P2_FOOT_RIGHT,
|
||||
P2_FOOT_DOWN,
|
||||
SPOT_RED,
|
||||
SPOT_BLUE,
|
||||
TOP_SPOT_RED,
|
||||
TOP_SPOT_BLUE,
|
||||
P1_HALOGEN_UPPER,
|
||||
P1_HALOGEN_LOWER,
|
||||
P2_HALOGEN_UPPER,
|
||||
P2_HALOGEN_LOWER,
|
||||
P1_BUTTON,
|
||||
P2_BUTTON,
|
||||
NEON,
|
||||
HD_P1_START,
|
||||
HD_P1_LEFT_RIGHT,
|
||||
HD_P1_UP_DOWN,
|
||||
HD_P2_START,
|
||||
HD_P2_LEFT_RIGHT,
|
||||
HD_P2_UP_DOWN,
|
||||
HD_P1_SPEAKER_F_R,
|
||||
HD_P1_SPEAKER_F_G,
|
||||
HD_P1_SPEAKER_F_B,
|
||||
HD_P1_SPEAKER_W_R,
|
||||
HD_P1_SPEAKER_W_G,
|
||||
HD_P1_SPEAKER_W_B,
|
||||
HD_P2_SPEAKER_F_R,
|
||||
HD_P2_SPEAKER_F_G,
|
||||
HD_P2_SPEAKER_F_B,
|
||||
HD_P2_SPEAKER_W_R,
|
||||
HD_P2_SPEAKER_W_G,
|
||||
HD_P2_SPEAKER_W_B,
|
||||
};
|
||||
}
|
||||
|
||||
// getters
|
||||
std::vector<Button> &get_buttons();
|
||||
std::vector<Light> &get_lights();
|
||||
}
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "cfg/api.h"
|
||||
|
||||
namespace games::ddr {
|
||||
|
||||
// all buttons in correct order
|
||||
namespace Buttons {
|
||||
enum {
|
||||
SERVICE,
|
||||
TEST,
|
||||
COIN_MECH,
|
||||
P1_START,
|
||||
P1_PANEL_UP,
|
||||
P1_PANEL_DOWN,
|
||||
P1_PANEL_LEFT,
|
||||
P1_PANEL_RIGHT,
|
||||
P1_MENU_UP,
|
||||
P1_MENU_DOWN,
|
||||
P1_MENU_LEFT,
|
||||
P1_MENU_RIGHT,
|
||||
P2_START,
|
||||
P2_PANEL_UP,
|
||||
P2_PANEL_DOWN,
|
||||
P2_PANEL_LEFT,
|
||||
P2_PANEL_RIGHT,
|
||||
P2_MENU_UP,
|
||||
P2_MENU_DOWN,
|
||||
P2_MENU_LEFT,
|
||||
P2_MENU_RIGHT,
|
||||
};
|
||||
}
|
||||
|
||||
// all lights in correct order
|
||||
namespace Lights {
|
||||
enum {
|
||||
P1_FOOT_LEFT,
|
||||
P1_FOOT_UP,
|
||||
P1_FOOT_RIGHT,
|
||||
P1_FOOT_DOWN,
|
||||
P2_FOOT_LEFT,
|
||||
P2_FOOT_UP,
|
||||
P2_FOOT_RIGHT,
|
||||
P2_FOOT_DOWN,
|
||||
SPOT_RED,
|
||||
SPOT_BLUE,
|
||||
TOP_SPOT_RED,
|
||||
TOP_SPOT_BLUE,
|
||||
P1_HALOGEN_UPPER,
|
||||
P1_HALOGEN_LOWER,
|
||||
P2_HALOGEN_UPPER,
|
||||
P2_HALOGEN_LOWER,
|
||||
P1_BUTTON,
|
||||
P2_BUTTON,
|
||||
NEON,
|
||||
HD_P1_START,
|
||||
HD_P1_LEFT_RIGHT,
|
||||
HD_P1_UP_DOWN,
|
||||
HD_P2_START,
|
||||
HD_P2_LEFT_RIGHT,
|
||||
HD_P2_UP_DOWN,
|
||||
HD_P1_SPEAKER_F_R,
|
||||
HD_P1_SPEAKER_F_G,
|
||||
HD_P1_SPEAKER_F_B,
|
||||
HD_P1_SPEAKER_W_R,
|
||||
HD_P1_SPEAKER_W_G,
|
||||
HD_P1_SPEAKER_W_B,
|
||||
HD_P2_SPEAKER_F_R,
|
||||
HD_P2_SPEAKER_F_G,
|
||||
HD_P2_SPEAKER_F_B,
|
||||
HD_P2_SPEAKER_W_R,
|
||||
HD_P2_SPEAKER_W_G,
|
||||
HD_P2_SPEAKER_W_B,
|
||||
};
|
||||
}
|
||||
|
||||
// getters
|
||||
std::vector<Button> &get_buttons();
|
||||
std::vector<Light> &get_lights();
|
||||
}
|
||||
|
||||
+92
-92
@@ -1,92 +1,92 @@
|
||||
#include "foot.h"
|
||||
|
||||
#include "rawinput/rawinput.h"
|
||||
#include "util/logging.h"
|
||||
|
||||
#include "../ddr.h"
|
||||
#include "../io.h"
|
||||
|
||||
bool games::ddr::DDRFOOTHandle::open(LPCWSTR lpFileName) {
|
||||
if (wcscmp(lpFileName, L"COM1") != 0) {
|
||||
return false;
|
||||
}
|
||||
log_info("ddr", "Opened COM1 (FOOT)");
|
||||
return true;
|
||||
}
|
||||
|
||||
int games::ddr::DDRFOOTHandle::read(LPVOID lpBuffer, DWORD nNumberOfBytesToRead) {
|
||||
|
||||
// check data trigger and buffer size
|
||||
if (data_trigger && nNumberOfBytesToRead >= 1) {
|
||||
data_trigger = false;
|
||||
memset(lpBuffer, 0x11, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// no data
|
||||
return 0;
|
||||
}
|
||||
|
||||
int games::ddr::DDRFOOTHandle::write(LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite) {
|
||||
|
||||
// check buffer size for lights
|
||||
if (nNumberOfBytesToWrite == 4) {
|
||||
|
||||
// mappings
|
||||
static const size_t mapping_bits[] = {
|
||||
4, 6, 3, 5, // P1 L, U, R, D,
|
||||
12, 14, 11, 13, // P2 L, U, R, D
|
||||
22 // NEON
|
||||
};
|
||||
|
||||
static const size_t mapping[] = {
|
||||
Lights::P1_FOOT_LEFT,
|
||||
Lights::P1_FOOT_UP,
|
||||
Lights::P1_FOOT_RIGHT,
|
||||
Lights::P1_FOOT_DOWN,
|
||||
Lights::P2_FOOT_LEFT,
|
||||
Lights::P2_FOOT_UP,
|
||||
Lights::P2_FOOT_RIGHT,
|
||||
Lights::P2_FOOT_DOWN,
|
||||
Lights::NEON
|
||||
};
|
||||
|
||||
// get light bits
|
||||
uint32_t light_bits = *((uint32_t*) lpBuffer);
|
||||
|
||||
// get lights
|
||||
auto &lights = get_lights();
|
||||
|
||||
// bit scan
|
||||
for (size_t i = 0; i < 8; i++) {
|
||||
float value = (light_bits & (1 << mapping_bits[i])) ? 1.f : 0.f;
|
||||
GameAPI::Lights::writeLight(RI_MGR, lights.at(mapping[i]), value);
|
||||
}
|
||||
|
||||
// only set the neon if in SD mode
|
||||
// p3io sets it for HD mode.
|
||||
if (games::ddr::SDMODE) {
|
||||
float value = (light_bits & (1 << mapping_bits[8])) ? 1.f : 0.f;
|
||||
GameAPI::Lights::writeLight(RI_MGR, lights.at(mapping[8]), value);
|
||||
}
|
||||
|
||||
// flush
|
||||
RI_MGR->devices_flush_output();
|
||||
}
|
||||
|
||||
// trigger out data
|
||||
data_trigger = true;
|
||||
|
||||
// return all data written
|
||||
return (int) nNumberOfBytesToWrite;
|
||||
}
|
||||
|
||||
int games::ddr::DDRFOOTHandle::device_io(DWORD dwIoControlCode, LPVOID lpInBuffer, DWORD nInBufferSize, LPVOID lpOutBuffer,
|
||||
DWORD nOutBufferSize) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool games::ddr::DDRFOOTHandle::close() {
|
||||
log_info("ddr", "Closed COM1 (FOOT).");
|
||||
return true;
|
||||
}
|
||||
#include "foot.h"
|
||||
|
||||
#include "rawinput/rawinput.h"
|
||||
#include "util/logging.h"
|
||||
|
||||
#include "../ddr.h"
|
||||
#include "../io.h"
|
||||
|
||||
bool games::ddr::DDRFOOTHandle::open(LPCWSTR lpFileName) {
|
||||
if (wcscmp(lpFileName, L"COM1") != 0) {
|
||||
return false;
|
||||
}
|
||||
log_info("ddr", "Opened COM1 (FOOT)");
|
||||
return true;
|
||||
}
|
||||
|
||||
int games::ddr::DDRFOOTHandle::read(LPVOID lpBuffer, DWORD nNumberOfBytesToRead) {
|
||||
|
||||
// check data trigger and buffer size
|
||||
if (data_trigger && nNumberOfBytesToRead >= 1) {
|
||||
data_trigger = false;
|
||||
memset(lpBuffer, 0x11, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// no data
|
||||
return 0;
|
||||
}
|
||||
|
||||
int games::ddr::DDRFOOTHandle::write(LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite) {
|
||||
|
||||
// check buffer size for lights
|
||||
if (nNumberOfBytesToWrite == 4) {
|
||||
|
||||
// mappings
|
||||
static const size_t mapping_bits[] = {
|
||||
4, 6, 3, 5, // P1 L, U, R, D,
|
||||
12, 14, 11, 13, // P2 L, U, R, D
|
||||
22 // NEON
|
||||
};
|
||||
|
||||
static const size_t mapping[] = {
|
||||
Lights::P1_FOOT_LEFT,
|
||||
Lights::P1_FOOT_UP,
|
||||
Lights::P1_FOOT_RIGHT,
|
||||
Lights::P1_FOOT_DOWN,
|
||||
Lights::P2_FOOT_LEFT,
|
||||
Lights::P2_FOOT_UP,
|
||||
Lights::P2_FOOT_RIGHT,
|
||||
Lights::P2_FOOT_DOWN,
|
||||
Lights::NEON
|
||||
};
|
||||
|
||||
// get light bits
|
||||
uint32_t light_bits = *((uint32_t*) lpBuffer);
|
||||
|
||||
// get lights
|
||||
auto &lights = get_lights();
|
||||
|
||||
// bit scan
|
||||
for (size_t i = 0; i < 8; i++) {
|
||||
float value = (light_bits & (1 << mapping_bits[i])) ? 1.f : 0.f;
|
||||
GameAPI::Lights::writeLight(RI_MGR, lights.at(mapping[i]), value);
|
||||
}
|
||||
|
||||
// only set the neon if in SD mode
|
||||
// p3io sets it for HD mode.
|
||||
if (games::ddr::SDMODE) {
|
||||
float value = (light_bits & (1 << mapping_bits[8])) ? 1.f : 0.f;
|
||||
GameAPI::Lights::writeLight(RI_MGR, lights.at(mapping[8]), value);
|
||||
}
|
||||
|
||||
// flush
|
||||
RI_MGR->devices_flush_output();
|
||||
}
|
||||
|
||||
// trigger out data
|
||||
data_trigger = true;
|
||||
|
||||
// return all data written
|
||||
return (int) nNumberOfBytesToWrite;
|
||||
}
|
||||
|
||||
int games::ddr::DDRFOOTHandle::device_io(DWORD dwIoControlCode, LPVOID lpInBuffer, DWORD nInBufferSize, LPVOID lpOutBuffer,
|
||||
DWORD nOutBufferSize) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool games::ddr::DDRFOOTHandle::close() {
|
||||
log_info("ddr", "Closed COM1 (FOOT).");
|
||||
return true;
|
||||
}
|
||||
|
||||
+23
-23
@@ -1,23 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include "hooks/devicehook.h"
|
||||
|
||||
namespace games::ddr {
|
||||
|
||||
class DDRFOOTHandle : public CustomHandle {
|
||||
private:
|
||||
bool data_trigger = false;
|
||||
|
||||
public:
|
||||
bool open(LPCWSTR lpFileName) override;
|
||||
|
||||
int read(LPVOID lpBuffer, DWORD nNumberOfBytesToRead) override;
|
||||
|
||||
int write(LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite) override;
|
||||
|
||||
int device_io(DWORD dwIoControlCode, LPVOID lpInBuffer, DWORD nInBufferSize, LPVOID lpOutBuffer,
|
||||
DWORD nOutBufferSize) override;
|
||||
|
||||
bool close() override;
|
||||
};
|
||||
}
|
||||
#pragma once
|
||||
|
||||
#include "hooks/devicehook.h"
|
||||
|
||||
namespace games::ddr {
|
||||
|
||||
class DDRFOOTHandle : public CustomHandle {
|
||||
private:
|
||||
bool data_trigger = false;
|
||||
|
||||
public:
|
||||
bool open(LPCWSTR lpFileName) override;
|
||||
|
||||
int read(LPVOID lpBuffer, DWORD nNumberOfBytesToRead) override;
|
||||
|
||||
int write(LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite) override;
|
||||
|
||||
int device_io(DWORD dwIoControlCode, LPVOID lpInBuffer, DWORD nInBufferSize, LPVOID lpOutBuffer,
|
||||
DWORD nOutBufferSize) override;
|
||||
|
||||
bool close() override;
|
||||
};
|
||||
}
|
||||
|
||||
+550
-550
File diff suppressed because it is too large
Load Diff
+37
-37
@@ -1,37 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include "acioemu/acioemu.h"
|
||||
#include "hooks/devicehook.h"
|
||||
|
||||
namespace games::ddr {
|
||||
|
||||
class DDRP3IOHandle : public CustomHandle {
|
||||
private:
|
||||
acioemu::ACIOEmu *acio_emu;
|
||||
circular_buffer<uint8_t> read_buf = circular_buffer<uint8_t>(1024);
|
||||
|
||||
class HDXSDevice : public acioemu::ACIODeviceEmu {
|
||||
public:
|
||||
HDXSDevice();
|
||||
|
||||
bool parse_msg(
|
||||
acioemu::MessageData* msg_in,
|
||||
circular_buffer<uint8_t> *response_buffer
|
||||
) override;
|
||||
};
|
||||
|
||||
void write_msg(const uint8_t *data, size_t len);
|
||||
|
||||
public:
|
||||
bool open(LPCWSTR lpFileName) override;
|
||||
|
||||
int read(LPVOID lpBuffer, DWORD nNumberOfBytesToRead) override;
|
||||
|
||||
int write(LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite) override;
|
||||
|
||||
int device_io(DWORD dwIoControlCode, LPVOID lpInBuffer, DWORD nInBufferSize, LPVOID lpOutBuffer,
|
||||
DWORD nOutBufferSize) override;
|
||||
|
||||
bool close() override;
|
||||
};
|
||||
}
|
||||
#pragma once
|
||||
|
||||
#include "acioemu/acioemu.h"
|
||||
#include "hooks/devicehook.h"
|
||||
|
||||
namespace games::ddr {
|
||||
|
||||
class DDRP3IOHandle : public CustomHandle {
|
||||
private:
|
||||
acioemu::ACIOEmu *acio_emu;
|
||||
circular_buffer<uint8_t> read_buf = circular_buffer<uint8_t>(1024);
|
||||
|
||||
class HDXSDevice : public acioemu::ACIODeviceEmu {
|
||||
public:
|
||||
HDXSDevice();
|
||||
|
||||
bool parse_msg(
|
||||
acioemu::MessageData* msg_in,
|
||||
circular_buffer<uint8_t> *response_buffer
|
||||
) override;
|
||||
};
|
||||
|
||||
void write_msg(const uint8_t *data, size_t len);
|
||||
|
||||
public:
|
||||
bool open(LPCWSTR lpFileName) override;
|
||||
|
||||
int read(LPVOID lpBuffer, DWORD nNumberOfBytesToRead) override;
|
||||
|
||||
int write(LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite) override;
|
||||
|
||||
int device_io(DWORD dwIoControlCode, LPVOID lpInBuffer, DWORD nInBufferSize, LPVOID lpOutBuffer,
|
||||
DWORD nOutBufferSize) override;
|
||||
|
||||
bool close() override;
|
||||
};
|
||||
}
|
||||
|
||||
+102
-102
@@ -1,102 +1,102 @@
|
||||
#include "sate.h"
|
||||
#include "util/logging.h"
|
||||
|
||||
using namespace acioemu;
|
||||
|
||||
games::ddr::DDRSATEHandle::SATEDevice::SATEDevice() {
|
||||
this->node_count = 7;
|
||||
}
|
||||
|
||||
bool games::ddr::DDRSATEHandle::SATEDevice::parse_msg(
|
||||
acioemu::MessageData *msg_in,
|
||||
circular_buffer<uint8_t> *response_buffer
|
||||
) {
|
||||
|
||||
// check command
|
||||
switch (msg_in->cmd.code) {
|
||||
case ACIO_CMD_GET_VERSION: {
|
||||
|
||||
// send version data
|
||||
auto msg = this->create_msg(msg_in, MSG_VERSION_SIZE);
|
||||
this->set_version(msg, 0x105, 0, 1, 1, 0, "DDRS");
|
||||
write_msg(msg, response_buffer);
|
||||
delete msg;
|
||||
break;
|
||||
}
|
||||
case ACIO_CMD_CLEAR:
|
||||
case ACIO_CMD_STARTUP:
|
||||
case 0xFF: // BROADCAST
|
||||
{
|
||||
// send status 0
|
||||
auto msg = this->create_msg_status(msg_in, 0x00);
|
||||
write_msg(msg, response_buffer);
|
||||
delete msg;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
// mark as handled
|
||||
return true;
|
||||
}
|
||||
|
||||
bool games::ddr::DDRSATEHandle::open(LPCWSTR lpFileName) {
|
||||
if (wcscmp(lpFileName, L"COM2") != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
log_info("ddr", "Opened COM2 (SATE)");
|
||||
|
||||
// ACIO device
|
||||
acio_emu.add_device(new SATEDevice());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int games::ddr::DDRSATEHandle::read(LPVOID lpBuffer, DWORD nNumberOfBytesToRead) {
|
||||
auto buffer = reinterpret_cast<uint8_t *>(lpBuffer);
|
||||
|
||||
// read from emu
|
||||
DWORD bytes_read = 0;
|
||||
while (bytes_read < nNumberOfBytesToRead) {
|
||||
auto cur_byte = acio_emu.read();
|
||||
|
||||
if (cur_byte.has_value()) {
|
||||
buffer[bytes_read++] = cur_byte.value();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// return amount of bytes read
|
||||
return (int) bytes_read;
|
||||
}
|
||||
|
||||
int games::ddr::DDRSATEHandle::write(LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite) {
|
||||
auto buffer = reinterpret_cast<const uint8_t *>(lpBuffer);
|
||||
|
||||
// write to emu
|
||||
for (DWORD i = 0; i < nNumberOfBytesToWrite; i++) {
|
||||
acio_emu.write(buffer[i]);
|
||||
}
|
||||
|
||||
// return all data written
|
||||
return (int) nNumberOfBytesToWrite;
|
||||
}
|
||||
|
||||
int games::ddr::DDRSATEHandle::device_io(
|
||||
DWORD dwIoControlCode,
|
||||
LPVOID lpInBuffer,
|
||||
DWORD nInBufferSize,
|
||||
LPVOID lpOutBuffer,
|
||||
DWORD nOutBufferSize
|
||||
) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool games::ddr::DDRSATEHandle::close() {
|
||||
log_info("ddr", "Closed COM2 (SATE).");
|
||||
|
||||
return true;
|
||||
}
|
||||
#include "sate.h"
|
||||
#include "util/logging.h"
|
||||
|
||||
using namespace acioemu;
|
||||
|
||||
games::ddr::DDRSATEHandle::SATEDevice::SATEDevice() {
|
||||
this->node_count = 7;
|
||||
}
|
||||
|
||||
bool games::ddr::DDRSATEHandle::SATEDevice::parse_msg(
|
||||
acioemu::MessageData *msg_in,
|
||||
circular_buffer<uint8_t> *response_buffer
|
||||
) {
|
||||
|
||||
// check command
|
||||
switch (msg_in->cmd.code) {
|
||||
case ACIO_CMD_GET_VERSION: {
|
||||
|
||||
// send version data
|
||||
auto msg = this->create_msg(msg_in, MSG_VERSION_SIZE);
|
||||
this->set_version(msg, 0x105, 0, 1, 1, 0, "DDRS");
|
||||
write_msg(msg, response_buffer);
|
||||
delete msg;
|
||||
break;
|
||||
}
|
||||
case ACIO_CMD_CLEAR:
|
||||
case ACIO_CMD_STARTUP:
|
||||
case 0xFF: // BROADCAST
|
||||
{
|
||||
// send status 0
|
||||
auto msg = this->create_msg_status(msg_in, 0x00);
|
||||
write_msg(msg, response_buffer);
|
||||
delete msg;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
// mark as handled
|
||||
return true;
|
||||
}
|
||||
|
||||
bool games::ddr::DDRSATEHandle::open(LPCWSTR lpFileName) {
|
||||
if (wcscmp(lpFileName, L"COM2") != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
log_info("ddr", "Opened COM2 (SATE)");
|
||||
|
||||
// ACIO device
|
||||
acio_emu.add_device(new SATEDevice());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int games::ddr::DDRSATEHandle::read(LPVOID lpBuffer, DWORD nNumberOfBytesToRead) {
|
||||
auto buffer = reinterpret_cast<uint8_t *>(lpBuffer);
|
||||
|
||||
// read from emu
|
||||
DWORD bytes_read = 0;
|
||||
while (bytes_read < nNumberOfBytesToRead) {
|
||||
auto cur_byte = acio_emu.read();
|
||||
|
||||
if (cur_byte.has_value()) {
|
||||
buffer[bytes_read++] = cur_byte.value();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// return amount of bytes read
|
||||
return (int) bytes_read;
|
||||
}
|
||||
|
||||
int games::ddr::DDRSATEHandle::write(LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite) {
|
||||
auto buffer = reinterpret_cast<const uint8_t *>(lpBuffer);
|
||||
|
||||
// write to emu
|
||||
for (DWORD i = 0; i < nNumberOfBytesToWrite; i++) {
|
||||
acio_emu.write(buffer[i]);
|
||||
}
|
||||
|
||||
// return all data written
|
||||
return (int) nNumberOfBytesToWrite;
|
||||
}
|
||||
|
||||
int games::ddr::DDRSATEHandle::device_io(
|
||||
DWORD dwIoControlCode,
|
||||
LPVOID lpInBuffer,
|
||||
DWORD nInBufferSize,
|
||||
LPVOID lpOutBuffer,
|
||||
DWORD nOutBufferSize
|
||||
) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool games::ddr::DDRSATEHandle::close() {
|
||||
log_info("ddr", "Closed COM2 (SATE).");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
+31
-31
@@ -1,31 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include "hooks/devicehook.h"
|
||||
#include "acioemu/acioemu.h"
|
||||
|
||||
namespace games::ddr {
|
||||
|
||||
class DDRSATEHandle : public CustomHandle {
|
||||
private:
|
||||
acioemu::ACIOEmu acio_emu;
|
||||
|
||||
class SATEDevice : public acioemu::ACIODeviceEmu {
|
||||
public:
|
||||
SATEDevice();
|
||||
|
||||
bool parse_msg(acioemu::MessageData *msg_in, circular_buffer<uint8_t> *response_buffer) override;
|
||||
};
|
||||
|
||||
public:
|
||||
bool open(LPCWSTR lpFileName) override;
|
||||
|
||||
int read(LPVOID lpBuffer, DWORD nNumberOfBytesToRead) override;
|
||||
|
||||
int write(LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite) override;
|
||||
|
||||
int device_io(DWORD dwIoControlCode, LPVOID lpInBuffer, DWORD nInBufferSize, LPVOID lpOutBuffer,
|
||||
DWORD nOutBufferSize) override;
|
||||
|
||||
bool close() override;
|
||||
};
|
||||
}
|
||||
#pragma once
|
||||
|
||||
#include "hooks/devicehook.h"
|
||||
#include "acioemu/acioemu.h"
|
||||
|
||||
namespace games::ddr {
|
||||
|
||||
class DDRSATEHandle : public CustomHandle {
|
||||
private:
|
||||
acioemu::ACIOEmu acio_emu;
|
||||
|
||||
class SATEDevice : public acioemu::ACIODeviceEmu {
|
||||
public:
|
||||
SATEDevice();
|
||||
|
||||
bool parse_msg(acioemu::MessageData *msg_in, circular_buffer<uint8_t> *response_buffer) override;
|
||||
};
|
||||
|
||||
public:
|
||||
bool open(LPCWSTR lpFileName) override;
|
||||
|
||||
int read(LPVOID lpBuffer, DWORD nNumberOfBytesToRead) override;
|
||||
|
||||
int write(LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite) override;
|
||||
|
||||
int device_io(DWORD dwIoControlCode, LPVOID lpInBuffer, DWORD nInBufferSize, LPVOID lpOutBuffer,
|
||||
DWORD nOutBufferSize) override;
|
||||
|
||||
bool close() override;
|
||||
};
|
||||
}
|
||||
|
||||
+60
-60
@@ -1,60 +1,60 @@
|
||||
#include "usbmem.h"
|
||||
#include "util/logging.h"
|
||||
|
||||
void games::ddr::DDRUSBMEMHandle::respond(const char *data) {
|
||||
size_t len = strlen(data) + 1;
|
||||
memcpy(response_data, data, len);
|
||||
memcpy(response_data + len, "\r>", 2);
|
||||
response_data_size = len + 2;
|
||||
}
|
||||
|
||||
bool games::ddr::DDRUSBMEMHandle::open(LPCWSTR lpFileName) {
|
||||
if (wcscmp(lpFileName, L"COM3") != 0) {
|
||||
return false;
|
||||
}
|
||||
log_info("ddr", "Opened COM3 (USBMEM)");
|
||||
return true;
|
||||
}
|
||||
|
||||
int games::ddr::DDRUSBMEMHandle::read(LPVOID lpBuffer, DWORD nNumberOfBytesToRead) {
|
||||
|
||||
// check for response
|
||||
if (response_data_size && nNumberOfBytesToRead >= response_data_size) {
|
||||
size_t bytes_read = response_data_size;
|
||||
memcpy(lpBuffer, response_data, response_data_size);
|
||||
response_data_size = 0;
|
||||
return (int) bytes_read;
|
||||
}
|
||||
|
||||
// no data
|
||||
return 0;
|
||||
}
|
||||
|
||||
int games::ddr::DDRUSBMEMHandle::write(LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite) {
|
||||
|
||||
// check CMD
|
||||
if (!memcmp(lpBuffer, "sver", 4))
|
||||
respond("done GQHDXJAA SPICE");
|
||||
else if (!memcmp(lpBuffer, "on_a", 4) ||
|
||||
!memcmp(lpBuffer, "on_b", 4) ||
|
||||
!memcmp(lpBuffer, "offa", 4) ||
|
||||
!memcmp(lpBuffer, "offb", 4) ||
|
||||
!memcmp(lpBuffer, "lma ", 4) ||
|
||||
!memcmp(lpBuffer, "lmb ", 4))
|
||||
respond("done");
|
||||
else
|
||||
respond("not connected");
|
||||
|
||||
// return all data written
|
||||
return (int) nNumberOfBytesToWrite;
|
||||
}
|
||||
|
||||
int games::ddr::DDRUSBMEMHandle::device_io(DWORD dwIoControlCode, LPVOID lpInBuffer, DWORD nInBufferSize,
|
||||
LPVOID lpOutBuffer, DWORD nOutBufferSize) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool games::ddr::DDRUSBMEMHandle::close() {
|
||||
log_info("ddr", "Closed COM3 (USBMEM).");
|
||||
return true;
|
||||
}
|
||||
#include "usbmem.h"
|
||||
#include "util/logging.h"
|
||||
|
||||
void games::ddr::DDRUSBMEMHandle::respond(const char *data) {
|
||||
size_t len = strlen(data) + 1;
|
||||
memcpy(response_data, data, len);
|
||||
memcpy(response_data + len, "\r>", 2);
|
||||
response_data_size = len + 2;
|
||||
}
|
||||
|
||||
bool games::ddr::DDRUSBMEMHandle::open(LPCWSTR lpFileName) {
|
||||
if (wcscmp(lpFileName, L"COM3") != 0) {
|
||||
return false;
|
||||
}
|
||||
log_info("ddr", "Opened COM3 (USBMEM)");
|
||||
return true;
|
||||
}
|
||||
|
||||
int games::ddr::DDRUSBMEMHandle::read(LPVOID lpBuffer, DWORD nNumberOfBytesToRead) {
|
||||
|
||||
// check for response
|
||||
if (response_data_size && nNumberOfBytesToRead >= response_data_size) {
|
||||
size_t bytes_read = response_data_size;
|
||||
memcpy(lpBuffer, response_data, response_data_size);
|
||||
response_data_size = 0;
|
||||
return (int) bytes_read;
|
||||
}
|
||||
|
||||
// no data
|
||||
return 0;
|
||||
}
|
||||
|
||||
int games::ddr::DDRUSBMEMHandle::write(LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite) {
|
||||
|
||||
// check CMD
|
||||
if (!memcmp(lpBuffer, "sver", 4))
|
||||
respond("done GQHDXJAA SPICE");
|
||||
else if (!memcmp(lpBuffer, "on_a", 4) ||
|
||||
!memcmp(lpBuffer, "on_b", 4) ||
|
||||
!memcmp(lpBuffer, "offa", 4) ||
|
||||
!memcmp(lpBuffer, "offb", 4) ||
|
||||
!memcmp(lpBuffer, "lma ", 4) ||
|
||||
!memcmp(lpBuffer, "lmb ", 4))
|
||||
respond("done");
|
||||
else
|
||||
respond("not connected");
|
||||
|
||||
// return all data written
|
||||
return (int) nNumberOfBytesToWrite;
|
||||
}
|
||||
|
||||
int games::ddr::DDRUSBMEMHandle::device_io(DWORD dwIoControlCode, LPVOID lpInBuffer, DWORD nInBufferSize,
|
||||
LPVOID lpOutBuffer, DWORD nOutBufferSize) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool games::ddr::DDRUSBMEMHandle::close() {
|
||||
log_info("ddr", "Closed COM3 (USBMEM).");
|
||||
return true;
|
||||
}
|
||||
|
||||
+26
-26
@@ -1,26 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include "hooks/devicehook.h"
|
||||
|
||||
namespace games::ddr {
|
||||
|
||||
class DDRUSBMEMHandle : public CustomHandle {
|
||||
private:
|
||||
char response_data[256]{};
|
||||
size_t response_data_size = 0;
|
||||
|
||||
void respond(const char *data);
|
||||
|
||||
public:
|
||||
bool open(LPCWSTR lpFileName) override;
|
||||
|
||||
int read(LPVOID lpBuffer, DWORD nNumberOfBytesToRead) override;
|
||||
|
||||
int write(LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite) override;
|
||||
|
||||
int device_io(DWORD dwIoControlCode, LPVOID lpInBuffer, DWORD nInBufferSize, LPVOID lpOutBuffer,
|
||||
DWORD nOutBufferSize) override;
|
||||
|
||||
bool close() override;
|
||||
};
|
||||
}
|
||||
#pragma once
|
||||
|
||||
#include "hooks/devicehook.h"
|
||||
|
||||
namespace games::ddr {
|
||||
|
||||
class DDRUSBMEMHandle : public CustomHandle {
|
||||
private:
|
||||
char response_data[256]{};
|
||||
size_t response_data_size = 0;
|
||||
|
||||
void respond(const char *data);
|
||||
|
||||
public:
|
||||
bool open(LPCWSTR lpFileName) override;
|
||||
|
||||
int read(LPVOID lpBuffer, DWORD nNumberOfBytesToRead) override;
|
||||
|
||||
int write(LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite) override;
|
||||
|
||||
int device_io(DWORD dwIoControlCode, LPVOID lpInBuffer, DWORD nInBufferSize, LPVOID lpOutBuffer,
|
||||
DWORD nOutBufferSize) override;
|
||||
|
||||
bool close() override;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user