From b11bde4be4376864b6c07e96bd2f17b068b0d4cf Mon Sep 17 00:00:00 2001 From: Keelin Wheeler Date: Mon, 8 Jan 2018 16:37:20 -0500 Subject: [PATCH] Windows Port: Adding Pen and Touch support for touch screen devices --- desmume/src/frontend/windows/main.cpp | 40 +++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/desmume/src/frontend/windows/main.cpp b/desmume/src/frontend/windows/main.cpp index 9df002719..5f3939f19 100755 --- a/desmume/src/frontend/windows/main.cpp +++ b/desmume/src/frontend/windows/main.cpp @@ -5171,16 +5171,41 @@ DOKEYDOWN: } return 0; + #ifndef WM_POINTERDOWN + #define WM_POINTERDOWN 0x0246 + #endif + #ifndef WM_POINTERUPDATE + #define WM_POINTERUPDATE 0x0245 + #endif + #ifndef POINTER_MESSAGE_FLAG_INCONTACT + #define POINTER_MESSAGE_FLAG_INCONTACT 0x40000 + #endif + #ifndef POINTER_MESSAGE_FLAG_FIRSTBUTTON + #define POINTER_MESSAGE_FLAG_FIRSTBUTTON 0x100000 + #endif + case WM_POINTERDOWN: + case WM_POINTERUPDATE: + case WM_MOUSEMOVE: case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK: - if (wParam & MK_LBUTTON) + if (((message==WM_POINTERDOWN || message== WM_POINTERUPDATE) + && ((wParam & (POINTER_MESSAGE_FLAG_INCONTACT | POINTER_MESSAGE_FLAG_FIRSTBUTTON)))) + || (message != WM_POINTERDOWN && message != WM_POINTERUPDATE && (wParam & MK_LBUTTON))) { SetCapture(hwnd); s32 x = (s32)((s16)LOWORD(lParam)); s32 y = (s32)((s16)HIWORD(lParam)); - + if (message == WM_POINTERDOWN || message == WM_POINTERUPDATE) + { + POINT point; + point.x = x; + point.y = y; + ScreenToClient(hwnd, &point); + x = point.x; + y = point.y; + } UnscaleScreenCoords(x,y); if(HudEditorMode) @@ -5232,11 +5257,22 @@ DOKEYDOWN: return 0; } } + else if (message == WM_POINTERUPDATE + && !(wParam & POINTER_MESSAGE_FLAG_INCONTACT | POINTER_MESSAGE_FLAG_FIRSTBUTTON)) + { + ReleaseCapture(); + HudClickRelease(&Hud); + } if (!StylusAutoHoldPressed) NDS_releaseTouch(); userTouchesScreen = false; return 0; + #ifndef WM_POINTERUP + #define WM_POINTERUP 0x0247 + #endif + case WM_POINTERUP: + case WM_LBUTTONUP: ReleaseCapture();