
// Scheme procedures
extern void touch_began(int, float x, float y);
extern void touch_moved(int, float x, float y);
extern void touch_ended(int, float x, float y);
extern void touch_cancelled(int, float x, float y);

@implementation EAGLView

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
  CGPoint pos;
  for (UITouch *myTouch in touches) {
      pos = [myTouch locationInView:self];
      touch_began((int)myTouch, pos.x, pos.y);
  }
}

// Handles the continuation of a touch.
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
  CGPoint pos;
  for (UITouch *myTouch in touches) {
      pos = [myTouch locationInView:self];
      touch_moved((int)myTouch, pos.x, pos.y);
  }
}

// Handles the end of a touch event.
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
  CGPoint pos;
  for (UITouch *myTouch in touches) {
      pos = [myTouch locationInView:self];
      touch_ended((int)myTouch, pos.x, pos.y);
  }
}

- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
  CGPoint pos;
  for (UITouch *myTouch in touches) {
      pos = [myTouch locationInView:self];
      touch_cancelled((int)myTouch, pos.x, pos.y);
  }
}

@end
