genekogan / ofxLeapMotion2

A wrapper for the Leap Motion SDK compatible with Leap 2.0 Beta with skeletal tracking
MIT License
61 stars 33 forks source link

Gesture Support #2

Open a2hill opened 9 years ago

a2hill commented 9 years ago

I'm using your addon in my project and I noticed there are quite a few stubs for gesture support. Since I need gestures for my project I'm going to be implementing some gesture functionality and I was going to submit a pull request when I'm done. Do you have any input on how I go about doing this?

My current plan of action is to add ofEvents to ofxLeapMotion and have updateGestures call ofNotifyEvent on each respective event (onSwipeUp onSwipeDown, etc).

To make listeners easy to implement I was going to outline a small class, ofxLeapGestureListener, which can be inherited by a user's ofApp class. ofxLeapGestureListener will provide stub methods (onSwipeUp onSwipeDown, etc) that do nothing for each action. Since the methods are not virtual, the user only needs to reimplement the event handler methods (in their ofApp class) for the gestures they care about. This is similar to how onKeyPressed, onMouseEvent, etc. are all currently handled.

To make attaching listeners easy I was going to add a method:

setupGestures(ofxLeapGestureListener * listener)

which calls ofAddListener for each event handler implemented in ofxLeapGestureListener and then calls the actual setupGestures() method.

Implemented this way, there would only be one line added (in addition to overriding any "onGestureEvent" methods) to the user's ofApp.cpp:

leapController.setupGestures(this);

Any thoughts on this?

genekogan commented 9 years ago

hi @a2hill yes i think this would be a great addition. originally all i did was fork theo's ofxLeapMotion and adapt it for the newer leap libraries which supported hand skeleton tracking (and finger identification). i didn't make any updates for the gestures.

rachelmax commented 5 years ago

@a2hill - did you end up adding gestures? Any chance you could share that file? Thanks, Rachel

a2hill commented 5 years ago

@rachelmax Honestly I'm not sure. I have this patch that I created a number of years ago, you might give it a shot but its been so long since I've worked on this that I don't really remember. Hope it helps! add_gesture_events.txt

rachelmax commented 5 years ago

@a2hill - thanks for the file! I'll give it a shot.