O'Reilly logo

Leap Motion Development Essentials by Mischa Spiegelmock

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Receiving gestures

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required