If this is a Mac game, you should have access to the Quartz api event. This is the easiest way to generate mouse events in OS X ...
I would recommend just tracking the position of the palm (hand) and moving the cursor based on this.
Here's how I do palm tracking:
float handX = ([[hand palmPosition] x]); float handY = (-[[hand palmPosition] y] + 150);
"+ 150" is the number of millimeters above the Leap device that is used as "0". From there, you can move the cursor based on a hand shift from 0.
Function that I use to move the cursor (using quartz):
- (void)mouseEventWithType:(CGEventType)type loc:(CGPoint)loc deltaX:(float)dX deltaY:(float)dY { CGEventRef theEvent = CGEventCreateMouseEvent(NULL, type, loc, kCGMouseButtonLeft); CGEventSetIntegerValueField(theEvent, kCGMouseEventDeltaX, dX); CGEventSetIntegerValueField(theEvent, kCGMouseEventDeltaY, dY); CGEventPost(kCGHIDEventTap, theEvent); CFRelease(theEvent); }
and an example of a function call:
[self mouseEventWithType:kCGEventMouseMoved loc:CGPointMake(newLocX, newLocY) deltaX:dX deltaY:dY]
This call will move the mouse. Basically you just pass the new mouse location and the corresponding deltas relative to the last cursor position.
I can provide more examples, such as examples for getting the location of a mouse, a mouse click, or even a complete mouse move program ...
EDIT 1:
To handle a click and drag using quartz, you can call the same function as above, pass only kCGEventLeftMouseDown .
The trap is that you cannot call kCGEventMouseMoved for drag and drop, you must pass kCGEventLeftMouseDragged while dragging.
After completing the drag, you must go through kCGEventLeftMouseUp .
To make one click (without dragging and dropping), you simply call the mouse down, and then right up, without any resistance ...