private void VisualizeTriggers() { if (controller.GetPressUp(FinchControllerElement.ButtonGrip)) { HighlightedGripButton.transform.localPosition = transformGripButton; GripButton.SetActive(true); HighlightedGripButton.SetActive(false); } else if (controller.GetPressDown(FinchControllerElement.ButtonGrip)) { HighlightedGripButton.SetActive(true); GripButton.SetActive(false); HighlightedGripButton.transform.localPosition -= new Vector3(GripChangeCoeff, 0, 0); } if (controller.GetPressUp(FinchControllerElement.IndexTrigger)) { HighlightedIndexTrigger.SetActive(false); IndexTrigger.SetActive(true); } else if (controller.GetPressDown(FinchControllerElement.IndexTrigger)) { HighlightedIndexTrigger.SetActive(true); IndexTrigger.SetActive(false); } if (controller.GetPress(FinchControllerElement.IndexTrigger)) { if (Type == SixDOFType.WithStick) { float tiltAroundXIndex = controller.GetIndexTrigger() * IndexTriggerChangeCoeffWithStick; Quaternion targetIndex = Quaternion.Euler(tiltAroundXIndex, 0, 0); HighlightedIndexTrigger.transform.localRotation = Quaternion.Slerp(transformIndexRotation, targetIndex, 1); } else if (Type == SixDOFType.WithTouchpad) { float tiltAroundXIndex = controller.GetIndexTrigger() * IndexTriggerChangeCoeffWithTouchpad; Quaternion targetIndex = Quaternion.Euler(tiltAroundXIndex, 0, 0); HighlightedIndexTrigger.transform.localRotation = Quaternion.Slerp(transformIndexRotation, targetIndex, 1); } } }
// Update is called once per frame void Update() { FinchController controller = FinchVR.GetFinchController(Chirality); if (flag == 0) { setdrawnow(1); } flag++; if (flag == 65536) { flag = 1; } if (Input.GetKeyDown(KeyCode.B) || controller.GetPress(FinchControllerElement.ButtonThumb)) { setdrawnow(2); } if (drawnow) { setline(); } }
private void DetectLongTap(FinchButtonEventType buttonEventType) { FinchController controller = buttonEventType == FinchButtonEventType.Right ? RightController : LeftController; int ind = buttonEventType == FinchButtonEventType.Right ? 0 : 1; if (controller.GetPress(FinchControllerElement.Touchpad)) { if (!isPressed[ind]) { isPressed[ind] = true; stopWatch = new System.Diagnostics.Stopwatch(); stopWatch.Start(); } else { if (!alreadyInvoked[ind] && stopWatch.ElapsedMilliseconds >= longTapTimeMs) { stopWatch.Stop(); alreadyInvoked[ind] = true; LongTapEvent.Invoke(); if (Vibration) { FinchVR.HapticPulse(ind == 0 ? FinchNodeType.RightHand : FinchNodeType.LeftHand, VibrationTimeMs); } } } } else { if (isPressed[ind]) { isPressed[ind] = alreadyInvoked[ind] = false; stopWatch.Stop(); } } }