/// <summary> /// Create a gesture detector that changes the volume when the hand is rotated along the Z axis /// </summary> public static ContinuousGestureDetector RotateHandChangeVolumeGesture() { return(new ContinuousGestureDetector( // Only allow rotation if hand is closed and visible for a bit hand => !hand.IsOpen && hand.TimeVisible >= 500 * 1000, // Track hand roll (angle along Z axis) in radians, from 0 to 2PI delegate(HandStats hand) { if (hand.Roll >= 0) { return hand.Roll; } // Transform the -PI to 0 space to be from PI to 2 * PI return (float)(Math.PI * 2 + hand.Roll); }, // Trigger every 0.35 radians / 20 degrees 0.35f, // Increase volume if rotating clockwise delegate(bool isPositive) { if (isPositive) { VolumeUtil.VolumeUp(); } else { VolumeUtil.VolumeDown(); } }) { DirectionDebounceTime = 500 * 1000 }); }
/// <summary> /// Create a gesture detector that changes the volume when the hand is moved left and right (along the X axis) /// </summary> public static ContinuousGestureDetector MoveHandXChangeVolumeGesture() { return(new ContinuousGestureDetector( // Only acknowledge hand if it's visible for a bit first hand => hand.TimeVisible >= 500 * 1000, // Track lateral hand movement along long axis of Leap hand => hand.PalmPosition.x, // Trigger every 30 millimeters 30, // Increase volume if moving right delegate(bool isPositive) { if (isPositive) { VolumeUtil.VolumeUp(); } else { VolumeUtil.VolumeDown(); } })); }