Search code examples
javaleap-motion

How to get the specific finger that made gesture with leap motion controller


I am trying to find out which finger performed KEY_TAP gesture from leap motion controller.

I have this code: missed tap gestures from leap motion in java

Can anyone give an example in JAVA of how to get the finger/fingers (if more than one) that made the gesture ?


Solution

  • The tap gesture have a pointables() method that gives you the tapping pointable -- there will be only one per tap, though you can have multiple fingers tapping at the same time. To identify the finger, you can use the Finger.type() method (after checking that the tapping pointable is a finger -- it could also be a tool). Once you have a list of gestures, you can identify the tapping finger as follows:

    for(Gesture gesture : gestures){
      if(gesture.type() == KeyTapGesture.classType()){
        KeyTapGesture keytap = new KeyTapGesture(gesture);
        Pointable tappingPointable = keytap.pointable();
        if(tappingPointable.isFinger()){
          Finger tappingFinger = new Finger(tappingPointable);
          println("Tapper: " + tappingFinger.type());
        }
      }
    }