Game Development Reference
In-Depth Information
TOUCHINPUT* ti = new TOUCHINPUT[NumInputs];
DWORD Res = GetTouchInputInfo_Ptr(
(HANDLE)lParam, NumInputs, ti, sizeof(TOUCHINPUT));
double EventTime = Env_GetSeconds();
if ( !Res ) { break; }
7.
For each touch point, we update its status in the global array g_TouchPoints .
This is the main difference from the Android code, since there we decode the
MotionEvent structure in Java code and pass a list of points to the native code:
for (unsigned int i = 0; i < NumInputs ; ++i)
{
POINT touch_pt = GetTouchPoint(Window, ti[i]);
vec2 Coord(touch_pt.x / ImageWidth,
touch_pt.y / ImageHeight);
sTouchPoint pt(ti[i].dwID, Coord,
MOTION_MOVE, EventTime);
if (ti[i].dwFlags & TOUCHEVENTF_DOWN)
pt.FFlag = MOTION_DOWN;
if (ti[i].dwFlags & TOUCHEVENTF_UP)
pt.FFlag = MOTION_UP;
Viewport_UpdateTouchPoint(pt);
}
8.
Then, we clean up the temporary array:
CloseTouchInputHandle_Ptr((HANDLE)lParam);
delete[] ti;
9.
We remove all the released points:
Viewport_ClearReleasedPoints();
10. Finally, we handle all the active touch points:
Viewport_UpdateCurrentGesture();
break;
}
11. The event handler uses a global list of touch points:
std::list<sTouchPoint> g_TouchPoints;
12. The sTouchPoint structure point encapsulates the coordinates, the touch point ID ,
a motion lag, and the associated event time stamp for a single touch point:
struct sTouchPoint
{
int FID;
vec2 FPoint;
 
Search WWH ::




Custom Search