-
Notifications
You must be signed in to change notification settings - Fork 19
Gestures
Gestures are predefined user actions. The most common example of a gesture is when a user swipes their hand from left to right (or vice versa).
Gestures can be hard to pull off and get right. On the one hand, you want it to be natural enough for the user to instinctively know how to do the action, but on the other hand, you don't want the user to accidentally perform the gesture.
So there is a balance here that will probably get better as this addon is tested more and more by a variety of users.
One thing to make gestures more intuitive is allowing feedback to occur, not only when a gesture is complete, but also when it has started and been cancelled. Additional steps (more than these 3) may allow more and better feedback. However, as NuiMotion currently stands, we support these three:
-
Gesture Started: User has made an action that causes our listener to begin tracking the gesture. For swipes this could be raising the hand in preparation for the swipe
-
Gesture Cancelled: User has started the gesture, but then did something to invalidate the gesture. A user could have raised their hand for a swipe but put it back down again
-
Gesture Complete: User has successfully completed the gesture.
Many systems just offer the completion events, but again, I believe some sort of visual feedback is important to the user. On occasion, during testing, I've forgotten exactly how to perform a gesture - a visual feedback system can help guide a user.
The gesture step is available via the callback object as well as which hand it was performed with as well as the gesture type performed.
Current types of gestures that are supported include:
- Swipe from left to right with left hand
- Swipe from right to left with right hand
- Swipe from top to bottom with either hand
- Swipe from bottom to top with either hand
- Wave with either hand
Gestures are enumerated in:
nuimotion.Events.Gestures
nuimotion.Events.Gestures.Swipe.types = {left: "SWIPE_LEFT", right: "SWIPE_RIGHT", up: "SWIPE_UP", down: "SWIPE_DOWN"};
nuimotion.Events.Gestures.Wave.types = {hand: "WAVE_HAND"};
Progress events are enumerated as well:
Events.Gestures.Progress = { start: "GESTURE_START", complete: "GESTURE_COMPLETE", cancelled: "GESTURE_CANCELLED" };
nuimotion.addGesture(
[ nuimotion.Events.Gestures.Swipe.types.up,
nuimotion.Events.Gestures.Swipe.types.down,
nuimotion.Events.Gestures.Swipe.types.left,
nuimotion.Events.Gestures.Swipe.types.right,
nuimotion.Events.Gestures.Wave.types.hand],
onEvent);
function onEvent(event) {
if (event.eventType == nuimotion.Events.GESTURE) {
console.log("Gesture: " + event.gestureType + " Hand: " + event.hand + " State: " + event.step);
} else {
console.log("Event: " + event.eventType);
}
}