In case anyone else is going down this path:
I got it working with my opengl app as follows.
ofxWinTouch seems to be broken and I cant get it to build , but I was able to use GestureEngine.cpp from that project which essentially most most of the gesture event handling seems to be done. Kudos to the author of that.
You have to hack your app to receive windows messages , and pass gesture messages to GestureEngine.cpp before passing other messages to the current windows event handler (ofappglutwindow?). So the way I accomplished this is to do something very similar to what ofAppGlutWindow already does in fixCloseWindowOnWin32. For my case I simply
changed ofApp.cpp:
#include "GestureEngine.h"
static CGestureEngine* s_GestureEngine;
static WNDPROC currentWndProc;
static HWND handle = NULL;
static LRESULT CALLBACK interceptWinProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
switch(Msg)
{
case 0x0119 /*WM_GESTURE*/:
//printf("Gesture");
s_GestureEngine->WndProc(hwnd, wParam, lParam);
break;
case 0x0240 /*WM_TOUCH */:
printf("touch");
break;
default:
return CallWindowProc(currentWndProc, handle, Msg, wParam, lParam);
break;
}
return 0;
}
//store the current message event handler for the window
inline void Win32TouchHackStartup()
{
s_GestureEngine = new CGestureEngine();
handle = WindowFromDC(wglGetCurrentDC());
currentWndProc = (WNDPROC)GetWindowLongPtr(handle, GWL_WNDPROC);
SetWindowLongPtr(handle, GWL_WNDPROC, (long)interceptWinProc);
}
inline void Win32TouchHackShutDown()
{
delete s_GestureEngine;
s_GestureEngine=NULL;
}
#else//_WIN32_WINNT
inline void Win32TouchHackStartup(){}
inline void Win32TouchHackShutDown(){}
#endif
Now modify setup to use the hack
//now modify setup:
//-----------------------------------------------------------------------------------------
ofApp::setup()
{
...
Win32TouchHackStartup();
}
Finally its a matter of doing the work in GestureEngine::ProcessMove for example. In my code I didnt want to have to derive from CGestureEngine , so i removed all the virtuals , made and interface class and defined the function
//-----------------------------------------------------------------------------------------
void CGestureEngine::ProcessMove( const LONG ldx, const LONG ldy )
{
m_GestureInterface.ProcessMoveGesture(ldx, ldy);
}
GestureInterface feeds to my camera system (modified from ofEasyCam). In the case of PanGesture:
void Cam::PanGesture(long dx, long dy)
{
float gestureSensitivityX = 1.0f;
float gestureSensitivityY = 1.0f;
moveX = -dx * gestureSensitivityX * (getDistance() + FLT_EPSILON)/viewport.width;
moveY = dy * gestureSensitivityY * (getDistance() + FLT_EPSILON)/viewport.height;
//printf("orig y = %d, x = %f , y= %f\n", dy, moveX, moveY);
updateTranslation();
}