steal pipe server from project asakura
This commit is contained in:
parent
cdcbd2585a
commit
0648ec7ab2
@ -6,7 +6,8 @@
|
|||||||
bool kinectRunning = false;
|
bool kinectRunning = false;
|
||||||
bool kinectStarted = false;
|
bool kinectStarted = false;
|
||||||
|
|
||||||
extern VRFoot VR_FOOTS[2];
|
VRFoot feet[16];
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
union {
|
union {
|
||||||
@ -158,6 +159,43 @@ inline DWORD scale_double_to_width(double val) {
|
|||||||
return static_cast<DWORD>(val * 1696);
|
return static_cast<DWORD>(val * 1696);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DWORD depthrushWritePort(HANDLE port, char data[], unsigned length)
|
||||||
|
{
|
||||||
|
DWORD numWritten = 0;
|
||||||
|
|
||||||
|
OVERLAPPED ol = { 0, 0, 0, 0, NULL };
|
||||||
|
ol.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||||
|
|
||||||
|
BOOL status = WriteFile(port, data, length, &numWritten, &ol);
|
||||||
|
DWORD xferBytes = 0;
|
||||||
|
|
||||||
|
if (!status)
|
||||||
|
{
|
||||||
|
switch (GetLastError())
|
||||||
|
{
|
||||||
|
case ERROR_SUCCESS:
|
||||||
|
break;
|
||||||
|
case ERROR_IO_PENDING:
|
||||||
|
// Wait for 16ms
|
||||||
|
if (WaitForSingleObject(ol.hEvent, 16) == WAIT_OBJECT_0)
|
||||||
|
{
|
||||||
|
status = GetOverlappedResult(port, &ol, &xferBytes, FALSE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CancelIo(port);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseHandle(ol.hEvent);
|
||||||
|
|
||||||
|
FlushFileBuffers(port);
|
||||||
|
return numWritten;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
@ -209,9 +247,107 @@ void fire_touches(drs_touch_t* events, size_t event_count) {
|
|||||||
touch_callback(&dev, game_touches.get(), (int)event_count, 0, user_data);
|
touch_callback(&dev, game_touches.get(), (int)event_count, 0, user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
VRFoot feet[11];
|
DWORD depthrushTouchThread(HANDLE port)
|
||||||
unsigned long holdcounters[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
{
|
||||||
unsigned long releasecounters[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
char fileBuf[32];
|
||||||
|
puts("starting serial touch thread");
|
||||||
|
|
||||||
|
DWORD times = 0;
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
DWORD bytesRead = 0;
|
||||||
|
memset(fileBuf, 0, 32);
|
||||||
|
|
||||||
|
OVERLAPPED ol = { 0, 0, 0, 0, NULL };
|
||||||
|
BOOL ret = 0;
|
||||||
|
ol.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||||
|
|
||||||
|
BOOL rfResult = ReadFile(port, fileBuf, 32, &bytesRead, &ol);
|
||||||
|
DWORD xferBytes = 0;
|
||||||
|
|
||||||
|
if (!rfResult)
|
||||||
|
{
|
||||||
|
switch (GetLastError())
|
||||||
|
{
|
||||||
|
case ERROR_SUCCESS:
|
||||||
|
break;
|
||||||
|
case ERROR_IO_PENDING:
|
||||||
|
// Wait for 16ms
|
||||||
|
if (WaitForSingleObject(ol.hEvent, 16) == WAIT_OBJECT_0)
|
||||||
|
{
|
||||||
|
rfResult = GetOverlappedResult(port, &ol, &xferBytes, FALSE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CancelIo(port);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseHandle(ol.hEvent);
|
||||||
|
|
||||||
|
if (xferBytes > 0)
|
||||||
|
{
|
||||||
|
printf("IN: xferred %d bytes\n", xferBytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bytesRead > 0)
|
||||||
|
{
|
||||||
|
printf("Read %d bytes: ", bytesRead);
|
||||||
|
for (unsigned x = 0; x < bytesRead; x++)
|
||||||
|
{
|
||||||
|
printf("%02X ", fileBuf[x]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
BOOL packetRecognised = FALSE;
|
||||||
|
|
||||||
|
if (!packetRecognised)
|
||||||
|
{
|
||||||
|
puts("unknown packet, responding with OK");
|
||||||
|
depthrushWritePort(port, (char*)"1", 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Sleep(16);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD depthrushNamedPipeServer(LPVOID _)
|
||||||
|
{
|
||||||
|
puts("init depthrush pipe server");
|
||||||
|
|
||||||
|
HANDLE pipe = CreateNamedPipeW(
|
||||||
|
L"\\\\.\\pipe\\depthrush-api",
|
||||||
|
PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
|
||||||
|
PIPE_TYPE_BYTE | PIPE_WAIT,
|
||||||
|
PIPE_UNLIMITED_INSTANCES,
|
||||||
|
255,
|
||||||
|
255,
|
||||||
|
25,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!pipe)
|
||||||
|
{
|
||||||
|
puts("named pipe creation failed!");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL connected = ConnectNamedPipe(pipe, NULL) ? TRUE : (GetLastError() == ERROR_PIPE_CONNECTED);
|
||||||
|
|
||||||
|
if (connected)
|
||||||
|
{
|
||||||
|
puts("client connection established, spawning thread");
|
||||||
|
|
||||||
|
DWORD tid = 0;
|
||||||
|
CreateThread(NULL, 0, depthrushTouchThread, pipe, 0, &tid);
|
||||||
|
printf("thread spawned, tid=%d\n", tid);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void start_kinect() {
|
void start_kinect() {
|
||||||
|
|
||||||
@ -308,6 +444,7 @@ void hookDancepad() {
|
|||||||
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);
|
||||||
|
CreateThread(NULL, 0, depthrushNamedPipeServer, NULL, 0, NULL);
|
||||||
|
|
||||||
start_kinect();
|
start_kinect();
|
||||||
}
|
}
|
@ -21,20 +21,12 @@ struct VRFoot {
|
|||||||
float size_base = 0.05;
|
float size_base = 0.05;
|
||||||
float size_scale = 0.1;
|
float size_scale = 0.1;
|
||||||
float height = 3;
|
float height = 3;
|
||||||
//linalg::aliases::float4 rotation {0, 0, 0, 1};
|
|
||||||
drs_touch_t event{};
|
drs_touch_t event{};
|
||||||
//linalg::aliases::float3 to_world(linalg::aliases::float3 pos);
|
bool touching = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
//extern char DRS_TAPELED[38 * 49][3];
|
|
||||||
//extern linalg::aliases::float3 VR_SCALE;
|
|
||||||
//extern linalg::aliases::float3 VR_OFFSET;
|
|
||||||
//extern float VR_ROTATION;
|
|
||||||
//extern VRFoot VR_FOOTS[2];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void fire_touches(drs_touch_t* events, size_t event_count);
|
void fire_touches(drs_touch_t* events, size_t event_count);
|
||||||
|
|
||||||
void start_kinect();
|
void start_kinect();
|
||||||
|
|
||||||
void hookDancepad();
|
void hookDancepad();
|
@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
#include <Windowsx.h>
|
||||||
#include <libloaderapi.h>
|
#include <libloaderapi.h>
|
||||||
#include <winnt.h>
|
#include <winnt.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -23,30 +23,13 @@ static int returnFalse() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool init = false;
|
|
||||||
|
|
||||||
/*
|
|
||||||
DWORD WINAPI MainThread(LPVOID lpReserved)
|
|
||||||
{
|
|
||||||
bool init_hook = false;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
|
|
||||||
} while (!init_hook);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
BOOL WINAPI DllMain(HMODULE hMod, DWORD dwReason, LPVOID lpReserved)
|
BOOL WINAPI DllMain(HMODULE hMod, DWORD dwReason, LPVOID lpReserved)
|
||||||
{
|
{
|
||||||
switch (dwReason)
|
|
||||||
{
|
|
||||||
case DLL_PROCESS_ATTACH:
|
|
||||||
DisableThreadLibraryCalls(hMod);
|
DisableThreadLibraryCalls(hMod);
|
||||||
imageBase = (uintptr_t)GetModuleHandleA(0);
|
imageBase = (uintptr_t)GetModuleHandleA(0);
|
||||||
hookDancepad();
|
|
||||||
|
|
||||||
break;
|
hookDancepad(); // drs.cpp
|
||||||
}
|
return true;
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user