1
0
mirror of synced 2024-11-24 06:50:14 +01:00

this wont compile someone pls halp

This commit is contained in:
doomertheboomer 2023-07-26 20:13:03 +07:00
parent 7a5beba9b7
commit f575830f56
5 changed files with 267 additions and 191 deletions

View File

@ -107,6 +107,7 @@
<InlineFunctionExpansion>Disabled</InlineFunctionExpansion> <InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>false</OmitFramePointers> <OmitFramePointers>false</OmitFramePointers>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>

View File

@ -1,10 +1,10 @@
#include "drs.h" #pragma pack(push)
#include "includes.h"
#include <windows.h> #include <windows.h>
#include <thread> #include <thread>
#include "includes.h"
#pragma pack(push) bool kinectRunning = false;
bool kinectStarted = false;
typedef struct { typedef struct {
union { union {
@ -48,13 +48,15 @@ void (*touch_callback)(
int unk1, int unk1,
const void *user_data); const void *user_data);
namespace drs {
void* TouchSDK_Constructor(void* in) {
void* TouchSDK_Constructor(void* in) {
return in; return in;
} }
bool TouchSDK_SendData(dev_info_t*, bool TouchSDK_SendData(dev_info_t*,
unsigned char* const, int, unsigned char* const, unsigned char* const, int, unsigned char* const,
unsigned char* output, int output_size) { unsigned char* output, int output_size) {
@ -64,64 +66,64 @@ namespace drs {
output[1] = 0xa5; output[1] = 0xa5;
} }
return true; return true;
} }
bool TouchSDK_SetSignalInit(dev_info_t*, int) { bool TouchSDK_SetSignalInit(dev_info_t*, int) {
return true; return true;
} }
void TouchSDK_Destructor(void* This) { void TouchSDK_Destructor(void* This) {
} }
int TouchSDK_GetYLedTotal(dev_info_t*, int) { int TouchSDK_GetYLedTotal(dev_info_t*, int) {
return 53; return 53;
} }
int TouchSDK_GetXLedTotal(dev_info_t*, int) { int TouchSDK_GetXLedTotal(dev_info_t*, int) {
return 41; return 41;
} }
bool TouchSDK_DisableTouch(dev_info_t*, int) { bool TouchSDK_DisableTouch(dev_info_t*, int) {
return true; return true;
} }
bool TouchSDK_DisableDrag(dev_info_t*, int) { bool TouchSDK_DisableDrag(dev_info_t*, int) {
return true; return true;
} }
bool TouchSDK_DisableWheel(dev_info_t*, int) { bool TouchSDK_DisableWheel(dev_info_t*, int) {
return true; return true;
} }
bool TouchSDK_DisableRightClick(dev_info_t*, int) { bool TouchSDK_DisableRightClick(dev_info_t*, int) {
return true; return true;
} }
bool TouchSDK_SetMultiTouchMode(dev_info_t*, int) { bool TouchSDK_SetMultiTouchMode(dev_info_t*, int) {
return true; return true;
} }
bool TouchSDK_EnableTouchWidthData(dev_info_t*, int) { bool TouchSDK_EnableTouchWidthData(dev_info_t*, int) {
return true; return true;
} }
bool TouchSDK_EnableRawData(dev_info_t*, int) { bool TouchSDK_EnableRawData(dev_info_t*, int) {
return true; return true;
} }
bool TouchSDK_SetAllEnable(dev_info_t*, bool, int) { bool TouchSDK_SetAllEnable(dev_info_t*, bool, int) {
return true; return true;
} }
int TouchSDK_GetTouchDeviceCount(void* This) { int TouchSDK_GetTouchDeviceCount(void* This) {
return 1; return 1;
} }
unsigned int TouchSDK_GetTouchSDKVersion(void) { unsigned int TouchSDK_GetTouchSDKVersion(void) {
return 0x01030307; return 0x01030307;
} }
int TouchSDK_InitTouch(void* This, dev_info_t* devices, int max_devices, void* touch_event_cb, int TouchSDK_InitTouch(void* This, dev_info_t* devices, int max_devices, void* touch_event_cb,
void* hotplug_callback, void* userdata) { void* hotplug_callback, void* userdata) {
// fake touch device // fake touch device
@ -140,21 +142,21 @@ namespace drs {
// success // success
return 1; return 1;
} }
inline DWORD scale_double_to_xy(double val) { inline DWORD scale_double_to_xy(double val) {
return static_cast<DWORD>(val * 32768); return static_cast<DWORD>(val * 32768);
} }
inline DWORD scale_double_to_height(double val) { inline DWORD scale_double_to_height(double val) {
return static_cast<DWORD>(val * 1312); return static_cast<DWORD>(val * 1312);
} }
inline DWORD scale_double_to_width(double val) { inline DWORD scale_double_to_width(double val) {
return static_cast<DWORD>(val * 1696); return static_cast<DWORD>(val * 1696);
} }
void fire_touches(drs_touch_t* events, size_t event_count) { void fire_touches(drs_touch_t* events, size_t event_count) {
// check callback first // check callback first
if (!touch_callback) { if (!touch_callback) {
@ -203,9 +205,86 @@ namespace drs {
// fire callback // fire callback
touch_callback(&dev, game_touches.get(), (int)event_count, 0, user_data); touch_callback(&dev, game_touches.get(), (int)event_count, 0, user_data);
}
void start_kinect() {
if (kinectRunning) return;
if (!kinectStarted) {
kinectStarted = true;
std::thread t([] {
puts("starting kinect thread");
// dance floor plane
const float touch_width = 1.f;
const float touch_height = 1.f;
// main loop
while (kinectRunning) {
// iterate foots
for (auto& foot : VR_FOOTS) {
// update event details
foot.event.id = foot.id;
foot.event.x = 0;
foot.event.y = 0;
foot.event.width = 100;
foot.event.height = foot.event.width;
foot.event.type = DRS_DOWN;
// check previous event
switch (foot.event.type) {
case DRS_UP:
// generate down event
foot.event.type = DRS_DOWN;
break;
case DRS_DOWN:
case DRS_MOVE:
// generate move event
foot.event.type = DRS_MOVE;
break;
default:
break;
} }
void hookDancepad() { // send event
fire_touches(&foot.event, 1);
continue;
// foot not intersecting with plane
switch (foot.event.type) {
case DRS_DOWN:
case DRS_MOVE:
// generate up event
foot.event.type = DRS_UP;
fire_touches(&foot.event, 1);
break;
case DRS_UP:
default:
break;
}
}
// slow down
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
kinectStarted = false;
return nullptr;
});
t.detach();
}
}
void hookDancepad() {
MH_Initialize(); MH_Initialize();
MH_CreateHookApi(L"TouchSDKDll.dll", "??0TouchSDK@@QEAA@XZ", TouchSDK_Constructor, NULL); MH_CreateHookApi(L"TouchSDKDll.dll", "??0TouchSDK@@QEAA@XZ", TouchSDK_Constructor, NULL);
MH_CreateHookApi(L"TouchSDKDll.dll", "?SendData@TouchSDK@@QEAA_NU_DeviceInfo@@QEAEH1HH@Z", TouchSDK_SendData, NULL); MH_CreateHookApi(L"TouchSDKDll.dll", "?SendData@TouchSDK@@QEAA_NU_DeviceInfo@@QEAEH1HH@Z", TouchSDK_SendData, NULL);
@ -225,5 +304,4 @@ namespace drs {
MH_CreateHookApi(L"TouchSDKDll.dll", "?InitTouch@TouchSDK@@QEAAHPEAU_DeviceInfo@@HP6AXU2@PEBU_TouchPointData@@HHPEBX@ZP6AX1_N3@ZPEAX@Z", TouchSDK_InitTouch, NULL); MH_CreateHookApi(L"TouchSDKDll.dll", "?InitTouch@TouchSDK@@QEAAHPEAU_DeviceInfo@@HP6AXU2@PEBU_TouchPointData@@HHPEBX@ZP6AX1_N3@ZPEAX@Z", TouchSDK_InitTouch, NULL);
MH_EnableHook(MH_ALL_HOOKS); MH_EnableHook(MH_ALL_HOOKS);
}
} }

View File

@ -1,23 +1,21 @@
#pragma once #pragma once
namespace drs { enum DRS_TOUCH_TYPE {
enum DRS_TOUCH_TYPE {
DRS_DOWN = 0, DRS_DOWN = 0,
DRS_UP = 1, DRS_UP = 1,
DRS_MOVE = 2, DRS_MOVE = 2,
}; };
typedef struct drs_touch_t { typedef struct drs_touch_t {
int type = DRS_UP; int type = DRS_UP;
int id = 0; int id = 0;
double x = 0.0; double x = 0.0;
double y = 0.0; double y = 0.0;
double width = 1; double width = 1;
double height = 1; double height = 1;
}; };
struct VRFoot { struct VRFoot {
unsigned int id; unsigned int id;
unsigned int index = 2; unsigned int index = 2;
float length = 3.1; float length = 3.1;
@ -26,18 +24,18 @@ namespace drs {
float height = 3; float height = 3;
//linalg::aliases::float4 rotation {0, 0, 0, 1}; //linalg::aliases::float4 rotation {0, 0, 0, 1};
drs_touch_t event{}; drs_touch_t event{};
//unsigned int get_index();
//linalg::aliases::float3 to_world(linalg::aliases::float3 pos); //linalg::aliases::float3 to_world(linalg::aliases::float3 pos);
}; };
extern char DRS_TAPELED[38 * 49][3]; extern char DRS_TAPELED[38 * 49][3];
//extern linalg::aliases::float3 VR_SCALE; //extern linalg::aliases::float3 VR_SCALE;
//extern linalg::aliases::float3 VR_OFFSET; //extern linalg::aliases::float3 VR_OFFSET;
extern float VR_ROTATION; extern float VR_ROTATION;
extern VRFoot VR_FOOTS[2]; extern VRFoot VR_FOOTS[2];
void fire_touches(drs_touch_t* events, size_t event_count);
//void start_vr();
void hookDancepad();
} void fire_touches(drs_touch_t* events, size_t event_count);
void start_kinect();
void hookDancepad();

View File

@ -7,7 +7,7 @@
#include "kiero/minhook/include/MinHook.h" #include "kiero/minhook/include/MinHook.h"
#include "kiero/injector/injector.hpp" #include "kiero/injector/injector.hpp"
#include "d3d9.h" #include "d3d9.h"
#include "drs.h"
typedef LRESULT(CALLBACK* WNDPROC)(HWND, UINT, WPARAM, LPARAM); typedef LRESULT(CALLBACK* WNDPROC)(HWND, UINT, WPARAM, LPARAM);
typedef uintptr_t PTR; typedef uintptr_t PTR;

View File

@ -1,5 +1,4 @@
#include "includes.h" #include "includes.h"
#include "drs.h"
static uintptr_t imageBase; static uintptr_t imageBase;
@ -45,7 +44,7 @@ BOOL WINAPI DllMain(HMODULE hMod, DWORD dwReason, LPVOID lpReserved)
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hMod); DisableThreadLibraryCalls(hMod);
imageBase = (uintptr_t)GetModuleHandleA(0); imageBase = (uintptr_t)GetModuleHandleA(0);
drs::hookDancepad(); hookDancepad();
break; break;
} }