#define WM_TOUCH 0x0240
BOOL WINAPI RegisterTouchWindow(HWND,ULONG);
#define PRAGMA_API RegisterTouchWindow;user32!RegisterTouchWindow
typedef struct {
LONG x;
LONG y;
HANDLE hSource;
DWORD dwID;
DWORD dwFlags;
DWORD dwMask;
DWORD dwTime;
LONG dwExtraInfo;
DWORD cxContact;
DWORD cyContact;
} PTOUCHINPUT;
BOOL WINAPI GetTouchInputInfo(LPARAM,UINT,PTOUCHINPUT*,int);
#define PRAGMA_API GetTouchInputInfo;user32!GetTouchInputInfo
LRESULT CALLBACK OriginalHandler(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK MyMessageHandler(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if (message==WM_TOUCH) // touch?!
{
UINT cInputs=1;
PTOUCHINPUT pInputs;
GetTouchInputInfo(lParam,cInputs,&pInputs,sizeof(PTOUCHINPUT));
var touch_x=pInputs.x/100;
var touch_y=pInputs.y/100;
vec_set(mouse_pos.x,vector(touch_x,touch_y,0));
// or may do something different...
return 1;
}
return OriginalHandler(hwnd,message,wParam,lParam);
}
function main()
{
OriginalHandler=on_message; // save handler
on_message=MyMessageHandler; // custom ON_MESSAGE handler
RegisterTouchWindow(hWnd,0); // The engine window uses touch
}