In order to receive information and updates about gestures that the controller can recognize for us, we must first politely inform our trusty controller of our desires in the onInit
callback:
void Listener::onInit(const Leap::Controller &controller) { controller.enableGesture(Leap::Gesture::TYPE_SCREEN_TAP); controller.enableGesture(Leap::Gesture::TYPE_SWIPE); }
And thus for the remainder of the controller's existence it shall diligently try its utmost to notify us when it believes someone has swiped their fingers through the air in a deliberate fashion.
How are we to be notified? When our onFrame
callback retrieves a Frame
we can ask it if there are any gestures taking place in that frame. Leap::Frame::gestures()
returns a Leap::GestureList
that contains a list of generic Leap::Gesture
instances. A type of Leap::Gesture
can be determined, and a suitable subclass with type-specific augmentations can then be constructed:
Leap::GestureList gestures = controller.frame...