Handling multi-touch events on Windows
Once we have installed the MultiTouchVista
driver, or if we happen to have a multi-touch-capable screen, we can initialize an event loop in the application and handle the WM_TOUCH
messages.
Getting ready
The first recipe contains all the relevant information about multi-touch handling. In this recipe, we only extend our code for Microsoft Windows.
Note
This book doesn’t discuss about multi-touch input emulation for Mac.
How to do it...
The
MinGW
toolchain does not include the latest Windows SDK headers, so a number of constants should be defined to use theWM_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
The
TOUCHINPUT
structure encapsulates a single touch using theWinAPI
data types and should also be declared...