Game Development Reference
In-Depth Information
15. The Viewport_ClearReleasedPoints() function removes all the points with the
motion lag set to MOTION_UP :
void Viewport_ClearReleasedPoints()
{
auto first = FTouchPoints.begin();
auto result = first;
for ( ; first != FTouchPoints.end() ; ++first )
if ( first->FFlag != MOTION_UP ) *result++ = *first;
FTouchPoints.erase( result, FTouchPoints.end() );
}
16. The last function, Viewport_UpdateCurrentGesture() , sends the point list to
the gesture processor:
void Viewport_UpdateCurrentGesture()
{
Viewport_ProcessMotion( MOTION_START,
vec2(), false, MOTION_MOVE );
auto j = FTouchPoints.begin();
for ( ; j != FTouchPoints.end(); ++j )
Viewport_ProcessMotion( j->FID, j->FPoint,
j->IsPressed(), j->FFlag );
Viewport_ProcessMotion( MOTION_END, vec2(), false,
MOTION_MOVE );
}
How it works...
In the WM_CREATE event handler, we register our window as the touch event responder:
case WM_CREATE:
...
g_TouchEnabled = false;
BYTE DigitizerStatus = (BYTE)GetSystemMetrics( SM_DIGITIZER );
if ( (DigitizerStatus & (0x80 + 0x40)) != 0 )
{
BYTE nInputs = (BYTE)GetSystemMetrics( SM_MAXIMUMTOUCHES );
if ( LoadTouchFuncs() )
{
if ( !RegisterTouchWindow_Ptr(h, 0) )
{
LOGI( "Enabled, num points: %d\n", (int)nInputs );
g_TouchEnabled = true;
break;
}
}
}
Then we get a sequence of touch events in the Viewport_ProcessMotion() function.
 
Search WWH ::




Custom Search