add support for WinTouch touchscreens
This commit is contained in:
parent
8ba29ce495
commit
6fa64211ec
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user