1
0
mirror of synced 2024-11-14 23:07:36 +01:00

add support for WinTouch touchscreens

This commit is contained in:
Bemani Witch 2022-11-27 21:12:50 +01:00
parent 8ba29ce495
commit 6fa64211ec
4 changed files with 35 additions and 7 deletions

View File

@ -184,7 +184,14 @@ static LRESULT Hook_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
if (msg == WM_LBUTTONDOWN ||
msg == WM_LBUTTONUP)
{
mt6SetTouchData(lParam, msg == WM_LBUTTONDOWN);
mt6SetTouchData(lParam, msg == WM_LBUTTONDOWN, false);
return 0;
}
if (msg == WM_POINTERDOWN ||
msg == WM_POINTERUP)
{
mt6SetTouchData(lParam, msg == WM_POINTERDOWN, true);
return 0;
}

View File

@ -462,7 +462,14 @@ static LRESULT Hook_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
if (msg == WM_LBUTTONDOWN ||
msg == WM_LBUTTONUP)
{
mt6SetTouchData(lParam, msg == WM_LBUTTONDOWN);
mt6SetTouchData(lParam, msg == WM_LBUTTONDOWN, false);
return 0;
}
if (msg == WM_POINTERDOWN ||
msg == WM_POINTERUP)
{
mt6SetTouchData(lParam, msg == WM_POINTERDOWN, true);
return 0;
}

View File

@ -31,6 +31,8 @@ static unsigned displaySizeY = 0;
static float scaleFactorX = 0.0f;
static float scaleFactorY = 0.0f;
static HWND gameWindow;
typedef INT(WINAPI* GetSystemMetrics_t)(int);
static GetSystemMetrics_t pGetSystemMetrics;
@ -48,12 +50,22 @@ int WINAPI hook_GetSystemMetrics(int nIndex)
return pGetSystemMetrics(nIndex);
}
void mt6SetTouchData(LPARAM lParam, BOOL down)
void mt6SetTouchData(LPARAM lParam, BOOL down, BOOL isTouchScreen)
{
if (bHasBooted)
{
unsigned short mx = GET_X_LPARAM(lParam);
unsigned short my = GET_Y_LPARAM(lParam);
unsigned short mx;
unsigned short my;
if (isTouchScreen) {
POINT point = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
ScreenToClient(gameWindow, &point);
mx = point.x;
my = point.y;
}
else {
mx = GET_X_LPARAM(lParam);
my = GET_Y_LPARAM(lParam);
}
// Touchscreen y coordinates are inverted
my = displaySizeY - my;
@ -237,7 +249,7 @@ DWORD mt6SerialNamedPipeServer(LPVOID _)
if (connected)
{
puts("client connection established, spawning thread");
DWORD tid = 0;
CreateThread(NULL, 0, mt6SerialTouchThread, pipe, 0, &tid);
printf("thread spawned, tid=%d\n", tid);
@ -253,6 +265,8 @@ void mt6SetDisplayParams(HWND hwnd) {
displaySizeY = rect.bottom;
scaleFactorX = (float)16383 / displaySizeX;
scaleFactorY = (float)16383 / displaySizeY;
RegisterTouchWindow(hwnd, 0);
gameWindow = hwnd;
printf("display is %dx%d (scale factor of %f, %f)\n", displaySizeX, displaySizeY, scaleFactorX, scaleFactorY);
}

View File

@ -3,6 +3,6 @@
static HANDLE touchDevice;
void mt6SetTouchData(LPARAM lParam, BOOL down);
void mt6SetTouchData(LPARAM lParam, BOOL down, BOOL isTouchScreen);
void mt6SetDisplayParams(HWND hwnd);
void mt6SerialTouchInit();