Game Development Reference
In-Depth Information
15. The main routine is the HandleTouch() method:
void HandleTouch( int ContactID, const vec2& Pos, bool Pressed,
eMotionFlag Flag )
{
16. If the touch has just started, we reset the values for each button and axis:
if ( ContactID == MOTION_START )
{
for ( size_t i = 0; i != MAX_TOUCH_CONTACTS; i++ )
{
if ( FPushedButtons[i] )
{
this->SetKeyState(
FPushedButtons[i]->FIndex, false );
FPushedButtons[i] = NULL;
}
if ( FPushedAxis[i] )
{
this->SetAxisValue(
FPushedAxis[i]->FAxis1, 0.0f );
this->SetAxisValue(
FPushedAxis[i]->FAxis2, 0.0f );
FPushedAxis[i] = NULL;
}
}
return;
}
if ( ContactID == MOTION_END ) { return; }
if ( ContactID < 0 || ContactID >= MAX_TOUCH_CONTACTS )
{ return; }
17. If the pointer is moving, we look up the respective button or axis:
if ( Flag == MOTION_DOWN || Flag == MOTION_MOVE )
{
vec4 Colour = GetColourAtPoint( Pos );
sBitmapButton* Button = GetButtonForColour( Colour );
sBitmapAxis* Axis = GetAxisForColour( Colour );
18. For each button we ind, set the pressed state to true:
if ( Button && Pressed )
{
int Idx = Button->FIndex;
this->SetKeyState( Idx, true );
FPushedButtons[ContactID] = Button;
}
 
Search WWH ::




Custom Search