Seems like a specific case can be fairly simple to implement. Divide the input area into four quadrants and track the position through each quadrant. The sequence of quandrants determines if they have completed or traveled in a circle.
Pseudo-code to describe the idea:
static touchKeeper; //touch, quadrant
static touchIndex=0;
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[allTouches allObjects] objectAtIndex:0];
touchKeeper[touchIndex].touch = touch;
touchKepper[touchIndex].quadrant = DetectQuadrant(touch));
if (touchIndex > 3 && (touchKeeper[3].quadrant == touchKeeper[2].quadrant+1 == touchKeeper[1].quadrant+2 == touchKeeper[0].quadrant+3)) {
[self doCircleAction];
touchIndex=0;
}
else touchIndex++;
}
The idea is that you only need to roughly identify a particular touch to a region. So the quadrant routine would something like this:
int DetectQuadrant(UITouch *touch) {
CGPoint point;
point = [touch locationInView:self];
if (endPoint.x > X1 && endPoint.x < X2 && endPoint.Y > Y1 && endPoint.Y < Y2)
return QUAD1;
} else etc
I use quadrants as an example - clearly you could draw a square and think 'circle!'. The accuracy is improved by making more regions in the Detect method. The main idea is to think in terms of sequences of regions in order to achieve the desired behavior without excessive complication (like bezier curve detection or similar nonsense). This pseudo code is certainly brutish and I'm sure there's a nice way to finesse the implementation. I've been thinking about 'circular motion detection' for a project I'm working on and this was the rough idea I came up with.
Enjoy!