From 67963389eff644d76585c1b15a058ca2271c0e45 Mon Sep 17 00:00:00 2001 From: bicarus <202771338+bicarus-dev@users.noreply.github.com> Date: Sat, 29 Aug 2026 17:21:21 -0700 Subject: [PATCH] drs: hook down movement, adjust touch hooks (#898) When Down Motion button is bound, install hooks into the game that detects down movement via patches. When Disable Touch option is enabled, don't install touch hooks. --- src/spice2x/CMakeLists.txt | 1 + src/spice2x/games/drs/drs.cpp | 78 +++++++++--------- src/spice2x/games/drs/io.cpp | 7 +- src/spice2x/games/drs/io.h | 3 +- src/spice2x/games/drs/motion_cam.cpp | 109 ++++++++++++++++++++++++++ src/spice2x/games/drs/motion_cam.h | 5 ++ src/spice2x/sdk/include/spicesdk_io.h | 1 + 7 files changed, 163 insertions(+), 41 deletions(-) create mode 100644 src/spice2x/games/drs/motion_cam.cpp create mode 100644 src/spice2x/games/drs/motion_cam.h diff --git a/src/spice2x/CMakeLists.txt b/src/spice2x/CMakeLists.txt index 3ee6c02..9a9f09d 100644 --- a/src/spice2x/CMakeLists.txt +++ b/src/spice2x/CMakeLists.txt @@ -520,6 +520,7 @@ set(SOURCE_FILES ${SOURCE_FILES} games/scotto/io.cpp games/drs/drs.cpp games/drs/io.cpp + games/drs/motion_cam.cpp games/drs/rgb_cam.cpp games/we/we.cpp games/we/io.cpp diff --git a/src/spice2x/games/drs/drs.cpp b/src/spice2x/games/drs/drs.cpp index 7d2bf6a..ceac441 100644 --- a/src/spice2x/games/drs/drs.cpp +++ b/src/spice2x/games/drs/drs.cpp @@ -9,6 +9,8 @@ #include "util/logging.h" #include "util/precise_timer.h" #include "util/memutils.h" +#include "io.h" +#include "motion_cam.h" #include "rgb_cam.h" #pragma pack(push) @@ -276,48 +278,50 @@ namespace games::drs { void DRSGame::attach() { Game::attach(); - // TouchSDK hooks - detour::iat("??0TouchSDK@@QEAA@XZ", - (void *) &TouchSDK_Constructor, avs::game::DLL_INSTANCE); - detour::iat("?SendData@TouchSDK@@QEAA_NU_DeviceInfo@@QEAEH1HH@Z", - (void *) &TouchSDK_SendData, avs::game::DLL_INSTANCE); - detour::iat("?SetSignalInit@TouchSDK@@QEAA_NU_DeviceInfo@@H@Z", - (void *) &TouchSDK_SetSignalInit, avs::game::DLL_INSTANCE); - detour::iat("??1TouchSDK@@QEAA@XZ", - (void *) &TouchSDK_Destructor, avs::game::DLL_INSTANCE); - detour::iat("?GetYLedTotal@TouchSDK@@QEAAHU_DeviceInfo@@H@Z", - (void *) &TouchSDK_GetYLedTotal, avs::game::DLL_INSTANCE); - detour::iat("?GetXLedTotal@TouchSDK@@QEAAHU_DeviceInfo@@H@Z", - (void *) &TouchSDK_GetXLedTotal, avs::game::DLL_INSTANCE); - detour::iat("?DisableTouch@TouchSDK@@QEAA_NU_DeviceInfo@@H@Z", - (void *) &TouchSDK_DisableTouch, avs::game::DLL_INSTANCE); - detour::iat("?DisableDrag@TouchSDK@@QEAA_NU_DeviceInfo@@H@Z", - (void *) &TouchSDK_DisableDrag, avs::game::DLL_INSTANCE); - detour::iat("?DisableWheel@TouchSDK@@QEAA_NU_DeviceInfo@@H@Z", - (void *) &TouchSDK_DisableWheel, avs::game::DLL_INSTANCE); - detour::iat("?DisableRightClick@TouchSDK@@QEAA_NU_DeviceInfo@@H@Z", - (void *) &TouchSDK_DisableRightClick, avs::game::DLL_INSTANCE); - detour::iat("?SetMultiTouchMode@TouchSDK@@QEAA_NU_DeviceInfo@@H@Z", - (void *) &TouchSDK_SetMultiTouchMode, avs::game::DLL_INSTANCE); - detour::iat("?EnableTouchWidthData@TouchSDK@@QEAA_NU_DeviceInfo@@H@Z", - (void *) &TouchSDK_EnableTouchWidthData, avs::game::DLL_INSTANCE); - detour::iat("?EnableRawData@TouchSDK@@QEAA_NU_DeviceInfo@@H@Z", - (void *) &TouchSDK_EnableRawData, avs::game::DLL_INSTANCE); - detour::iat("?SetAllEnable@TouchSDK@@QEAA_NU_DeviceInfo@@_NH@Z", - (void *) &TouchSDK_SetAllEnable, avs::game::DLL_INSTANCE); - detour::iat("?GetTouchDeviceCount@TouchSDK@@QEAAHXZ", - (void *) &TouchSDK_GetTouchDeviceCount, avs::game::DLL_INSTANCE); - detour::iat("?GetTouchSDKVersion@TouchSDK@@QEAAIXZ", - (void *) &TouchSDK_GetTouchSDKVersion, avs::game::DLL_INSTANCE); - detour::iat("?InitTouch@TouchSDK@@QEAAHPEAU_DeviceInfo@@HP6AXU2@PEBU_TouchPointData@@HHPEBX@ZP6AX1_N3@ZPEAX@Z", - (void *) &TouchSDK_InitTouch, avs::game::DLL_INSTANCE); - if (!DISABLE_TOUCH) { + // TouchSDK hooks + detour::iat("??0TouchSDK@@QEAA@XZ", + (void *) &TouchSDK_Constructor, avs::game::DLL_INSTANCE); + detour::iat("?SendData@TouchSDK@@QEAA_NU_DeviceInfo@@QEAEH1HH@Z", + (void *) &TouchSDK_SendData, avs::game::DLL_INSTANCE); + detour::iat("?SetSignalInit@TouchSDK@@QEAA_NU_DeviceInfo@@H@Z", + (void *) &TouchSDK_SetSignalInit, avs::game::DLL_INSTANCE); + detour::iat("??1TouchSDK@@QEAA@XZ", + (void *) &TouchSDK_Destructor, avs::game::DLL_INSTANCE); + detour::iat("?GetYLedTotal@TouchSDK@@QEAAHU_DeviceInfo@@H@Z", + (void *) &TouchSDK_GetYLedTotal, avs::game::DLL_INSTANCE); + detour::iat("?GetXLedTotal@TouchSDK@@QEAAHU_DeviceInfo@@H@Z", + (void *) &TouchSDK_GetXLedTotal, avs::game::DLL_INSTANCE); + detour::iat("?DisableTouch@TouchSDK@@QEAA_NU_DeviceInfo@@H@Z", + (void *) &TouchSDK_DisableTouch, avs::game::DLL_INSTANCE); + detour::iat("?DisableDrag@TouchSDK@@QEAA_NU_DeviceInfo@@H@Z", + (void *) &TouchSDK_DisableDrag, avs::game::DLL_INSTANCE); + detour::iat("?DisableWheel@TouchSDK@@QEAA_NU_DeviceInfo@@H@Z", + (void *) &TouchSDK_DisableWheel, avs::game::DLL_INSTANCE); + detour::iat("?DisableRightClick@TouchSDK@@QEAA_NU_DeviceInfo@@H@Z", + (void *) &TouchSDK_DisableRightClick, avs::game::DLL_INSTANCE); + detour::iat("?SetMultiTouchMode@TouchSDK@@QEAA_NU_DeviceInfo@@H@Z", + (void *) &TouchSDK_SetMultiTouchMode, avs::game::DLL_INSTANCE); + detour::iat("?EnableTouchWidthData@TouchSDK@@QEAA_NU_DeviceInfo@@H@Z", + (void *) &TouchSDK_EnableTouchWidthData, avs::game::DLL_INSTANCE); + detour::iat("?EnableRawData@TouchSDK@@QEAA_NU_DeviceInfo@@H@Z", + (void *) &TouchSDK_EnableRawData, avs::game::DLL_INSTANCE); + detour::iat("?SetAllEnable@TouchSDK@@QEAA_NU_DeviceInfo@@_NH@Z", + (void *) &TouchSDK_SetAllEnable, avs::game::DLL_INSTANCE); + detour::iat("?GetTouchDeviceCount@TouchSDK@@QEAAHXZ", + (void *) &TouchSDK_GetTouchDeviceCount, avs::game::DLL_INSTANCE); + detour::iat("?GetTouchSDKVersion@TouchSDK@@QEAAIXZ", + (void *) &TouchSDK_GetTouchSDKVersion, avs::game::DLL_INSTANCE); + detour::iat("?InitTouch@TouchSDK@@QEAAHPEAU_DeviceInfo@@HP6AXU2@PEBU_TouchPointData@@HHPEBX@ZP6AX1_N3@ZPEAX@Z", + (void *) &TouchSDK_InitTouch, avs::game::DLL_INSTANCE); + start_touch(); } else { - log_info("drs", "no native input method detected"); + log_info("drs", "touch input for dance floor disabled"); } + init_down_motion_hook(); + if (RGB_CAMERA_HOOK) { init_rgb_camera_hook(); } diff --git a/src/spice2x/games/drs/io.cpp b/src/spice2x/games/drs/io.cpp index 4cf48ee..4979a61 100644 --- a/src/spice2x/games/drs/io.cpp +++ b/src/spice2x/games/drs/io.cpp @@ -20,7 +20,8 @@ std::vector