Gesture recognition

Is tere any In-built library for gesture recognition….for swipe left , right , up , down

For now i am using the following code to find out the gesture:-
@ float xDistance = abs(midX - beginX); // beginx,beginy are touch location in touch began method
float yDistance = abs(midY - beginY); //midx,midy are touch location in touch moved method

if (xDistance > yDistance)
{
if (beginX > midX)
{
CCLOG (“swipe left”);
}
else
{
CCLOG (“swipe right”);
}
}
else
{
if (beginY < midY)
{
CCLOG (“swipe up”);
} }
else
{
CCLOG (“swipe down”);
} }

}
@