Windows 7 Touch Position

Posted By: TSG_Torsten

Windows 7 Touch Position - 02/01/11 20:17

Hi,

i was wondering how it is possible to set the engine mouse_pos to the last touch-position on a touchscrren device using Windows 7. Since the normal windows mouse pointer is also reset to the new position, there should be an easy way?!
vec_set(mouse_pos.x,mouse_cursor.x) didn't work for me.

Regards
TSGames
Posted By: Widi

Re: Windows 7 Touch Position - 02/01/11 20:30

include windows.h and then you can use:
SetCursorPos (var_x,var_y);
Posted By: TSG_Torsten

Re: Windows 7 Touch Position - 02/03/11 18:16

Hi, thanks for you answer!
I don't want to change the windows cursor position, but read the position of the last "touch" event on the screen (where the user has touched with finger/pen).

Regards
TSGames
Posted By: Lukas

Re: Windows 7 Touch Position - 02/03/11 18:22

This may help:
http://msdn.microsoft.com/de-de/magazine/ee336016.aspx
Posted By: TSG_Torsten

Re: Windows 7 Touch Position - 02/03/11 19:43

Thanks Lukas, I've got it finally working laugh

For anyone who also wants to work with it, the code i used:

(lite-c)
Code:
#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
}



Have fun laugh

Regards
TSGames
© 2024 lite-C Forums