protected override bool ShouldGestureDeactivate(Hand hand, out DeactivationReason?deactivationReason) { deactivationReason = DeactivationReason.FinishedGesture; // never cancels. return(!(isPalmFacingTarget(hand, selfTarget.position, maxFacingAngle * stopHysteresisMult) && isShakaHand(hand))); }
/// <summary> /// Returns if you want a gesture to deactivate and for what reason. /// </summary> /// <param name="hand">Hand to test gesture</param> /// <param name="deactivationReason">reason for deactivation</param> /// <returns>desired gesture completion state</returns> protected override bool ShouldGestureDeactivate(Hand hand, out DeactivationReason?deactivationReason) { if (!isHandTracked || !( /*(fingerExtentionState.thumbExtended && hand.Fingers[0].IsExtended) &&*/ (hand.Fingers[1].IsExtended) && !(hand.Fingers[2].IsExtended) && !(hand.Fingers[3].IsExtended) && !(hand.Fingers[4].IsExtended) && !hand.IsPinching() )) { deactivationReason = DeactivationReason.CancelledGesture; prevSet = false; currSet = false; return(true); } else if (foundMGO(hand)) { deactivationReason = DeactivationReason.FinishedGesture; return(true); } else { deactivationReason = null; return(false); } }
/// <summary> /// Returns if you want a gesture to deactivate and for what reason. /// </summary> /// <param name="hand">Hand to test gesture</param> /// <param name="deactivationReason">reason for deactivation</param> /// <returns>desired gesture completion state</returns> protected override bool ShouldGestureDeactivate(Hand hand, out DeactivationReason?deactivationReason) { if (!isHandTracked || !debugkeyboardinput.PointToSelectEnabled || !( /*(fingerExtentionState.thumbExtended && hand.Fingers[0].IsExtended) &&*/ (fingerExtentionState.pointerFingerExtended && hand.Fingers[1].IsExtended) && !(fingerExtentionState.middleFingerExtended && hand.Fingers[2].IsExtended) && !(fingerExtentionState.ringFingerExtended && hand.Fingers[3].IsExtended) && !(fingerExtentionState.pinkyFingerExtended && hand.Fingers[4].IsExtended) && !completeBool && !hand.IsPinching() )) { deactivationReason = DeactivationReason.CancelledGesture; return(true); } else if (completeBool) { deactivationReason = DeactivationReason.FinishedGesture; return(true); } else { deactivationReason = null; return(false); } }
protected override bool ShouldGestureDeactivate(Hand hand, out DeactivationReason?deactivationReason) { //We may need to add something to indicate when the user has actually finished. deactivationReason = DeactivationReason.FinishedGesture; return(!(hand.Fingers[1].IsExtended && !hand.Fingers[2].IsExtended && !hand.Fingers[3].IsExtended && !hand.Fingers[4].IsExtended)); }
protected override bool ShouldGestureDeactivate(Hand hand, out DeactivationReason?deactivationReason) { if (!((hand.Fingers.Where(finger => finger.IsExtended).Count() == 5) //&& (Vector3.Angle(hand.PalmNormal.ToVector3(), hand.PalmPosition.ToVector3() - myStraightEdge.center) < angleTolerance) && hand.PalmVelocity.ToVector3().magnitude > velocityTolerance && (hand.PalmPosition.ToVector3() - myStraightEdge.center).magnitude < roughDistance ) ) { deactivationReason = DeactivationReason.CancelledGesture; return(true); } else if (inBounds((hand.StabilizedPalmPosition.ToVector3() - myStraightEdge.center).magnitude, exactBounds) && myStraightEdge.spindle) { deactivationReason = DeactivationReason.FinishedGesture; return(true); } else { deactivationReason = DeactivationReason.CancelledGesture; return(false); } }
protected override bool ShouldGestureDeactivate(Hand hand, out DeactivationReason?deactivationReason) { deactivationReason = DeactivationReason.CancelledGesture; if (!((hand.Fingers.Where(finger => finger.IsExtended).Count() == 5) && Vector3.Angle(hand.PalmNormal.ToVector3(), Vector3.down) < angleTolerance)) { return(true); } else { return(false); } }
protected override bool ShouldGestureDeactivate(Hand leftHand, Hand rightHand, out DeactivationReason?deactivationReason) { var handThatIsTapped = tappedHand == TappedHand.Left ? leftHand : rightHand; var handThatTaps = tappedHand == TappedHand.Left ? rightHand : leftHand; deactivationReason = DeactivationReason.FinishedGesture; if (targetSide == TargetSide.Palm) { return(!doesSatisfy(handThatTaps, handThatIsTapped, facingSameDirection: false, facingRadialAxis: true)); } else { return(!doesSatisfy(handThatTaps, handThatIsTapped, facingSameDirection: true, facingRadialAxis: false)); } }
protected override bool ShouldGestureDeactivate(Hand leftHand, Hand rightHand, out DeactivationReason?reason) { if (GetIsOutOfBounds(leftHand) || GetIsOutOfBounds(rightHand)) { reason = DeactivationReason.CancelledGesture; return(true); } if (leftHand.PinchStrength < DEACTIVATION_PINCH_STRENGTH || rightHand.PinchStrength < DEACTIVATION_PINCH_STRENGTH) { reason = DeactivationReason.FinishedGesture; return(true); } reason = null; return(false); }
protected override bool ShouldGestureDeactivate(Hand hand, out DeactivationReason?deactivationReason) { deactivationReason = DeactivationReason.CancelledGesture; if (!((hand.Fingers.Where(finger => finger.IsExtended).Count() == 5))) { deactivationReason = DeactivationReason.CancelledGesture; return(true); } else if (foundMGO(hand) || cancelLatticeLandPoint(hand)) { deactivationReason = DeactivationReason.FinishedGesture; return(true); } else { return(false); } }
public ActionResult Deactivate([Bind(Include = "Reasons")] DeactivationReason?reasons, [Bind(Include = "Comments")] string comments) { // Set defaults and truncate the comments if needed. Don't report any errors etc to the user while they are trying to deactivate. if (reasons == null) { ModelState.AddModelError(new[] { new RequiredValidationError("reason") }, new StandardErrorHandler()); return(View()); } comments = TextUtil.Truncate(comments, Constants.MaxDeactivationCommentsLength); _userAccountsCommand.DeactivateUserAccount(CurrentRegisteredUser, reasons.Value, comments); // Log out. _authenticationManager.LogOut(HttpContext); // Redirect straight to the default page using HTTP, otherwise HTTPS will be used if the current page is secure. return(RedirectToUrl(new ReadOnlyApplicationUrl(false, NavigationManager.GetHomeUrl().PathAndQuery))); }
public static string GetReason(DeactivationReason?reason) { if (reason == null) { return(null); } // Translates reasons into equivalent old descriptions in database. switch (reason.Value) { case DeactivationReason.Employer: return("HideFromEmployer"); case DeactivationReason.NotLooking: return("NoLongerLooking"); case DeactivationReason.Emails: return("EmailSpam"); case DeactivationReason.JobAlerts: return("JobAlertSpam"); case DeactivationReason.NotUseful: return("NotUseful"); case DeactivationReason.NoJobFound: return("NotFoundJob"); case DeactivationReason.NoContactsFound: return("NotBuiltNetwork"); case DeactivationReason.DifferentLogin: return("Rejoining"); default: return("Other"); } }
protected override bool ShouldGestureDeactivate(Hand leftHand, Hand rightHand, out DeactivationReason?deactivationReason) { Vector3 positionOfInterest; bool isGesturePoseHeld = IsGesturePoseHeld(leftHand, rightHand, out positionOfInterest); _lastKnownPositionOfInterest = positionOfInterest; if (updateIsRelativeHandVelocityLow(leftHand, rightHand) && isGesturePoseHeld) { if (_gestureActiveTime > holdActivationDuration) { // Gesture finished successfully. if (drawHeldPoseDebug) { DebugPing.Ping(positionOfInterest, LeapColor.cerulean, 0.20f); } deactivationReason = DeactivationReason.FinishedGesture; _gestureReady = false; return(true); } else { // Continue gesture activation. deactivationReason = null; return(false); } } else { // Gesture was cancelled. deactivationReason = DeactivationReason.CancelledGesture; return(true); } }
protected override bool ShouldGestureDeactivate(Hand hand, out DeactivationReason? deactivationReason) { deactivationReason = DeactivationReason.FinishedGesture; bool shouldDeactivate = false; _latestPinchStrength = 1f; OnPinchStrengthEvent.Invoke(_latestPinchStrength); if (minDeactivateTimer > MIN_DEACTIVATE_TIME) { var pinchDistance = PinchSegment2SegmentDisplacement(hand).magnitude; if (pinchDistance > pinchDeactivateDistance) { shouldDeactivate = true; if (_drawDebug) { DebugPing.Ping(hand.GetPredictedPinchPosition(), Color.black, 0.20f); } } } else { minDeactivateTimer++; } if (shouldDeactivate) { minReactivateTimer = 0; } return(shouldDeactivate); }
protected override bool ShouldGestureDeactivate(Hand hand, out DeactivationReason?deactivationReason) { throw new System.NotImplementedException(); }
/// <summary> /// A two-handed gesture will deactivate if this method returns true OR if one of /// the hands loses tracking mid-gesture. The method is called once per Update frame /// if the gesture is currently active. /// /// The deactivationReason will be provided to WhenGestureDeactivated if this method /// returns true on a given frame. If a hand lost tracking mid-gesture, the reason /// for deactivation will be CancelledGesture. /// /// The hands provided to this method are guaranteed to be non-null. /// </summary> protected abstract bool ShouldGestureDeactivate(Hand leftHand, Hand rightHand, out DeactivationReason?deactivationReason);
protected override bool ShouldGestureDeactivate(Hand leftHand, Hand rightHand, out DeactivationReason?deactivationReason) { bool outOfBounds = scaleOutOfBounds; if (outOfBounds) { if (absoluteScale > scaleBounds.y) { absoluteScale = scaleBounds.y; } else if (absoluteScale < scaleBounds.x) { absoluteScale = scaleBounds.x; } } if (outOfBounds || leapHandDataLogger.ins.currHands.lIhand.isGraspingObject || leapHandDataLogger.ins.currHands.rIhand.isGraspingObject) { deactivationReason = DeactivationReason.CancelledGesture; } else { deactivationReason = DeactivationReason.FinishedGesture; } return(outOfBounds || (!(leftHand.IsPinching() && rightHand.IsPinching()) && !(leapHandDataLogger.ins.currHands.lIhand.isGraspingObject || leapHandDataLogger.ins.currHands.rIhand.isGraspingObject))); }
protected virtual void onUpdateFrame(Frame frame) { // Initialize frame state. _wasActivated = false; _wasDeactivated = false; _wasCancelled = false; _wasFinished = false; // Get hand data. _lHand = frame.Hands.Query().FirstOrDefault(h => h.IsLeft); _rHand = frame.Hands.Query().FirstOrDefault(h => !h.IsLeft); // Determine the tracked state of hands and fire appropriate methods. _isLeftHandTracked = _lHand != null; _isRightHandTracked = _rHand != null; if (isLeftHandTracked != _wasLeftTracked) { if (isLeftHandTracked) { WhenHandBecomesTracked(_lHand); } else { WhenHandLosesTracking(true); } } if (isRightHandTracked != _wasRightTracked) { if (isRightHandTracked) { WhenHandBecomesTracked(_rHand); } else { WhenHandLosesTracking(false); } } if (isLeftHandTracked) { WhileHandTracked(_lHand); } else { WhileHandUntracked(true); } if (isRightHandTracked) { WhileHandTracked(_rHand); } else { WhileHandUntracked(false); } if (isLeftHandTracked && isRightHandTracked) { WhileBothHandsTracked(_lHand, _rHand); } _wasLeftTracked = isLeftHandTracked; _wasRightTracked = isRightHandTracked; // Determine whether or not the gesture should be active or inactive. bool shouldGestureBeActive; DeactivationReason?deactivationReason = null; if (_lHand == null || _rHand == null) { shouldGestureBeActive = false; } else { if (!_isActive) { if (ShouldGestureActivate(_lHand, _rHand)) { shouldGestureBeActive = true; } else { shouldGestureBeActive = false; } } else { if (ShouldGestureDeactivate(_lHand, _rHand, out deactivationReason)) { shouldGestureBeActive = false; } else { shouldGestureBeActive = true; } } } bool wasGestureSuccessful = deactivationReason.GetValueOrDefault() == DeactivationReason.FinishedGesture; // Fire gesture state change events. if (shouldGestureBeActive != _isActive) { if (shouldGestureBeActive) { _isActive = true; _wasActivated = true; WhenGestureActivated(_lHand, _rHand); OnGestureActivated(); OnTwoHandedGestureActivated(_lHand, _rHand); } else { _isActive = false; _wasDeactivated = true; if (wasGestureSuccessful) { _wasFinished = true; } else { _wasCancelled = true; } WhenGestureDeactivated(_lHand, _rHand, deactivationReason.GetValueOrDefault()); OnGestureDeactivated(); OnTwoHandedGestureDeactivated(_lHand, _rHand); } } // Fire per-update events. if (_isActive) { WhileGestureActive(_lHand, _rHand); } else { WhileGestureInactive(_lHand, _rHand); } }
private static void DeactivateUserAccount(AccountsDataContext dc, Guid userId, Guid deactivatedById, DateTime time, DeactivationReason?reason, string comments) { var entity = GetRegisteredUserEntity(dc, userId); if (entity != null) { entity.flags = (short)((UserFlags)entity.flags).ResetFlag(UserFlags.Activated); dc.UserDeactivationEntities.InsertOnSubmit(new UserDeactivationEntity { id = Guid.NewGuid(), userId = userId, deactivatedById = deactivatedById, time = time, reason = Mappings.GetReason(reason), comments = comments }); dc.SubmitChanges(); } }
protected override bool ShouldGestureDeactivate(Hand hand, out DeactivationReason?deactivationReason) { // Tap gestures are one-shot gestures, so finish the gesture immediately. deactivationReason = DeactivationReason.FinishedGesture; return(true); }
protected override bool ShouldGestureDeactivate(Hand hand, out DeactivationReason?deactivationReason) { deactivationReason = DeactivationReason.FinishedGesture; // only used if we return true return(hand.PinchStrength < PINCH_DEACTIVATION_STRENGTH); }
protected virtual void Update() { if (provider == null) { Debug.LogError("No provider set for " + this.GetType().Name + " in " + this.name + "; you should sure that there is a LeapProvider in " + "your scene and that this component has a LeapProvider reference.", this); this.enabled = false; } _wasActivated = false; _wasDeactivated = false; _wasCancelled = false; _wasFinished = false; var hand = provider.Get(whichHand); // Determine the tracked state of hands and fire appropriate methods. _isHandTracked = hand != null; if (isHandTracked != _wasHandTracked) { if (isHandTracked) { WhenHandBecomesTracked(hand); } else { WhenHandLosesTracking(whichHand == Chirality.Left); } } if (isHandTracked) { WhileHandTracked(hand); } else { WhileHandUntracked(whichHand == Chirality.Left); } _wasHandTracked = isHandTracked; // Determine whether or not the gesture should be active or inactive. bool shouldGestureBeActive; DeactivationReason?deactivationReason = null; if (!isHandTracked) { shouldGestureBeActive = false; } else { if (!_isActive) { if (ShouldGestureActivate(hand)) { shouldGestureBeActive = true; } else { shouldGestureBeActive = false; } } else { if (ShouldGestureDeactivate(hand, out deactivationReason)) { shouldGestureBeActive = false; } else { shouldGestureBeActive = true; } } } // If the deactivation reason is not set, we assume the gesture completed // successfully. bool wasGestureSuccessful = deactivationReason.GetValueOrDefault() == DeactivationReason.FinishedGesture; // Fire gesture state change events. if (shouldGestureBeActive != _isActive) { if (shouldGestureBeActive) { _wasActivated = true; _isActive = true; WhenGestureActivated(hand); OnGestureActivated(); OnOneHandedGestureActivated(hand); } else { _wasDeactivated = true; if (wasGestureSuccessful) { _wasFinished = true; } else { _wasCancelled = true; } _isActive = false; WhenGestureDeactivated(hand, deactivationReason.GetValueOrDefault()); OnGestureDeactivated(); OnOneHandedGestureDeactivated(hand); } } // Fire per-update events. if (_isActive) { WhileGestureActive(hand); } else { WhileGestureInactive(hand); } }
/// <summary> /// The gesture will deactivate if this method returns true OR if the hand loses tracking /// mid-gesture. The method is called once per Update frame if the gesture is currently /// active and the hand is tracked. /// /// The deactivationReason will be provided to WhenGestureDeactivated if this method /// returns true on a given frame. If a hand lost tracking mid-gesture, the reason for /// deactivation will be CancelledGesture. /// /// The hand provided to this method is guaranteed to be non-null. /// </summary> protected abstract bool ShouldGestureDeactivate(Hand hand, out DeactivationReason?deactivationReason);