public double GetMouseToKeyboardTransitionCost(KeyDownEvent keyDownEvent) { PhysicalKey key = FindKey(keyDownEvent.Data); if (key != null) { KeyboardSection parentSection = key.ParentSection; if (parentSection.Handedness == Handedness.Right) { lastMouseHandedAction = ActionType.Keyboard; if (MousePad == null) { throw new Exception("MousePad not specified."); } if (mousePadCenter.X == double.MinValue) { CalculateMousePadCenterPoint(); } double travelDistance = MillerComplexity.GetDistance(parentSection.Center, mousePadCenter); double targetApproachWidth = MillerComplexity.GetTargetApproachWidth(key.Size.Width, key.Size.Height); return(MillerComplexity.GetTargetPressScore(travelDistance, targetApproachWidth)); } } return(0); }
public double GetReachingForMouseTransitionCost() { if (MousePad == null) { throw new Exception("MousePad not specified."); } if (mousePadCenter.X == double.MinValue) { CalculateMousePadCenterPoint(); } if (MousePad.Mouse == null) { throw new Exception("Mouse not specified."); } KeyboardSection nearestSection = GetLastTouchedSectionClosestToMouse(); if (nearestSection == null) { throw new Exception("A keyboard section near the mouse was not found."); } double travelDistance = MillerComplexity.GetDistance(nearestSection.Center, mousePadCenter); double targetApproachWidth = MousePad.Mouse.Width; // Mouse is nearly always approached from the left or right; lastMouseHandedAction = ActionType.Mouse; return(MillerComplexity.GetTargetPressScore(travelDistance, targetApproachWidth)); }
double CalculateCost(PhysicalKey key) { if (KeyIsARepeat(key)) { return(MillerComplexity.GetCostOfRepeatHit(key.EffectiveTargetApproachWidth)); } const double DBL_AverageDistanceToSpaceBarWhileHandsNearHomeKeys = 1.4; /* cm */ if (SpaceBarHitWhileHandsAtHomeRow(key)) { return(MillerComplexity.GetTargetPressScore(DBL_AverageDistanceToSpaceBarWhileHandsNearHomeKeys, key.EffectiveTargetApproachWidth)); // Space bar hit and at least one hand is near the home key row position. } return(MillerComplexity.GetTargetPressScore(GetShortestDistanceToKey(key), key.EffectiveTargetApproachWidth)); }
public override double GetMillerComplexityScore(Event previousEvent) { return(GetBaseComplexityScore(previousEvent) + MillerComplexity.GetMouseDownScore(Duration.TotalMilliseconds) + MillerComplexity.GetTargetPressScore(GetPreviousMouseTravelDistance(previousEvent), MillerComplexity.DefaultMouseTargetWidth)); }