private void detectPress(FinchChirality chirality) { FinchController controller = chirality == FinchChirality.Right ? RightController : LeftController; FinchNodeType nodeType = chirality == FinchChirality.Right ? FinchNodeType.RightHand : FinchNodeType.LeftHand; bool wasInvoked = false; if (FinchDownEvent != null && controller.GetPressDown(button)) { FinchDownEvent.Invoke(); wasInvoked = true; } if (FinchUpEvent != null && RightController.GetPressUp(button)) { FinchUpEvent.Invoke(); wasInvoked = true; } if (Vibration && wasInvoked) { FinchVR.HapticPulse(nodeType, VibrationTimeMs); } }
protected override void Update() { ButtonEventType = FinchButtonEventType.Any; base.Update(); bool startedTouching = !bothTouching && ((LeftController.GetPress(Button) && RightController.GetPressDown(Button)) || (RightController.GetPress(Button) && LeftController.GetPressDown(Button))); bool eventCanBeInvoked = !alreadyInvoked && bothTouching; bool stoppedTouching = bothTouching && (LeftController.GetPressUp(Button) || RightController.GetPressUp(Button)); if (startedTouching) { bothTouching = true; stopWatch = new System.Diagnostics.Stopwatch(); stopWatch.Start(); } else if (eventCanBeInvoked) { if (stopWatch.ElapsedMilliseconds >= longTapTimeMs) { stopWatch.Stop(); alreadyInvoked = true; LongTapBothTouchpads.Invoke(); if (Vibration) { RightController.HapticPulse(VibrationTimeMs); LeftController.HapticPulse(VibrationTimeMs); } } } else if (stoppedTouching) { bothTouching = false; alreadyInvoked = false; stopWatch.Stop(); } }