Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Leap Motion Development Essentials

You're reading from  Leap Motion Development Essentials

Product type Book
Published in Oct 2013
Publisher Packt
ISBN-13 9781849697729
Pages 106 pages
Edition 1st Edition
Languages
Author (1):
Mischa Spiegelmock Mischa Spiegelmock
Profile icon Mischa Spiegelmock

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 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...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}