Game Development Reference
In-Depth Information
How to do it...
1.
The MinGW toolchain does not include the latest Windows SDK headers, so
a number of constants should be deined to use the WM_TOUCH messages:
#if !defined(_MSC_VER)
#define SM_DIGITIZER 94
#define SM_MAXIMUMTOUCHES 95
#define TOUCHEVENTF_DOWN 0x0001
#define TOUCHEVENTF_MOVE 0x0002
#define TOUCHEVENTF_UP 0x0004
#define TOUCHEVENTF_PRIMARY 0x0010
#define WM_TOUCH 0x0240
2.
The TOUCHINPUT structure encapsulates a single touch using the WinAPI data
types and should also be declared manually for MinGW :
typedef struct _TOUCHINPUT {
LONG x, y;
HANDLE hSource;
DWORD dwID, dwFlags, wMask, dwTime;
ULONG_PTR dwExtraInfo;
DWORD cxContact, cyContact;
} TOUCHINPUT,*PTOUCHINPUT;
#endif
3.
The next four functions provide the touch interface handling for our application.
We declare the function prototypes and static function pointers to load them from
user32.dll :
typedef BOOL (WINAPI *CloseTouchInputHandle_func)(HANDLE);
typedef BOOL (WINAPI *Get_func)(HANDLE, UINT, PTOUCHINPUT, int);
typedef BOOL (WINAPI *RegisterTouch_func)(HWND, ULONG);
typedef BOOL (WINAPI *UnregisterTouch_func)(HWND);
static CloseTouch_func CloseTouchInputHandle_Ptr = NULL;
static Get_func GetTouchInputInfo_Ptr = NULL;
static RegisterTouch_func RegisterTouchWindow_Ptr = NULL;
static UnregisterTouch_func UnregisterTouchWindow_Ptr =
NULL;
 
Search WWH ::




Custom Search