protected override void Update() { base.Update(); if (ButtonEventType == FinchButtonEventType.Right || ButtonEventType == FinchButtonEventType.Any) { detectPress(FinchChirality.Right); } if (ButtonEventType == FinchButtonEventType.Left || ButtonEventType == FinchButtonEventType.Any) { detectPress(FinchChirality.Left); } bool wasInvoked = false; if (ButtonEventType == FinchButtonEventType.BothAtOneTime) { if ((RightController.GetPress(button) && LeftController.GetPressDown(button)) || (LeftController.GetPress(button) && RightController.GetPressDown(button))) { if (FinchDownEvent != null) { FinchDownEvent.Invoke(); wasInvoked = true; } else if (FinchUpEvent != null) { FinchUpEvent.Invoke(); wasInvoked = true; } if (wasInvoked && Vibration) { RightController.HapticPulse(VibrationTimeMs); LeftController.HapticPulse(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(); } }