private bool TryCalibrate(FinchChirality chirality, bool swap) { FinchController mainController = chirality == FinchChirality.Left ? FinchController.Left : FinchController.Right; FinchController additionalController = chirality == FinchChirality.Left ? FinchController.Right : FinchController.Left; bool leftCalibrate = leftPressDown && FinchController.Left.GetPressTime(FinchControllerElement.HomeButton) > FinchCalibration.Settings.TimePressingToCallCalibration; bool rightCalibrate = rightPressDown && FinchController.Right.GetPressTime(FinchControllerElement.HomeButton) > FinchCalibration.Settings.TimePressingToCallCalibration; bool mainCalibrate = chirality == FinchChirality.Left ? leftCalibrate : rightCalibrate; bool additionalCalibrate = chirality == FinchChirality.Left ? rightCalibrate : leftCalibrate; if (mainCalibrate || additionalCalibrate && swap) { if (mainCalibrate) { mainController.HapticPulse(FinchCalibration.Settings.HapticTime); mainController.Calibrate(); } else { additionalController.HapticPulse(FinchCalibration.Settings.HapticTime); additionalController.Calibrate(); FinchCore.SwapNodes(FinchNodeType.LeftHand, FinchNodeType.RightHand); FinchCore.Interop.FinchSwapCalibrations(1, 0); } } return(mainCalibrate || additionalCalibrate && swap); }
protected void UpdateHandTransform(GameObject controllerObject, FinchController controller) { if (controllerObject != null && controllerObject.activeSelf) { controllerObject.transform.localRotation = controller.GetRotation(); controllerObject.transform.localPosition = controller.GetPosition(); } }
private void LateUpdate() { controller = FinchController.GetController(Chirality); ButtonUpdate(); BatteryUpdate(); TouchElementUpdate(); StateUpdate(); }
private void LateUpdate() { controller = FinchController.GetController(Chirality); ButtonUpdate(); BatteryUpdate(); UpdateJoystick(); UpdateTouchpad(); StateUpdate(); }
private void TriggerAnimation(FinchController controller, FinchControllerElement element, GameObject model) { if (controller.GetPressDown(element)) { model.transform.localPosition = new Vector3(0, 0, 0.021f); } else if (controller.GetPressUp(element)) { model.transform.localPosition = new Vector3(0, 0, 0); } }
private void HandleMaterialChange(FinchController controller, MeshRenderer Renderer, int materialIndex, Material pressed, Material unpressed, FinchControllerElement element) { if (controller.GetPressDown(element)) { Material[] arrayCopy = Renderer.materials; arrayCopy[materialIndex] = pressed; Renderer.materials = arrayCopy; } else if (controller.GetPressUp(element)) { Material[] arrayCopy = Renderer.materials; arrayCopy[materialIndex] = unpressed; Renderer.materials = arrayCopy; } }
private void Update() { FinchController controller = FinchVR.GetFinchController(Chirality); if (controller == null) { return; } HandleMaterialChange(controller, TriggerRenderer, 0, TriggerPressed, TriggerUnpressed, FinchControllerElement.IndexTrigger); TriggerAnimation(controller, FinchControllerElement.IndexTrigger, TriggerObject); HandleMaterialChange(controller, VolumeRenderer, 1, VolumePlusPressed, VolumePlusUnpressed, FinchControllerElement.ButtonThree); HandleMaterialChange(controller, VolumeRenderer, 2, VolumeMinusPressed, VolumeMinusUnpressed, FinchControllerElement.ButtonTwo); HandleMaterialChange(controller, HomeButtonRenderer, 0, HomeCalibrationButtonPressed, HomeCalibrationButtonUnpressed, FinchControllerElement.ButtonZero); HandleMaterialChange(controller, AppButtonRenderer, 1, AppButtonPressed, AppButtonUnpressed, FinchControllerElement.ButtonOne); }
void Update() { FinchController controller = FinchVR.GetFinchController(Chirality); if (touchRenderer == null || controller == null) { return; } touchRenderer.material = TouchOpaque; if (controller.IsTouching()) { if (!wasTouching) { wasTouching = true; elapsedScaleTimeSeconds = 0.0f; } Vector3 scale = Vector3.Lerp(Vector3.zero, TouchpadPointDimensions, elapsedScaleTimeSeconds / TouchpadPointScaleDurationSeconds); transform.localScale = scale; float x = TouchpadRadius * controller.GetTouchAxes().x; float y = TouchpadPointYOffset + TouchpadRadius * controller.GetTouchAxes().y; float z = 3.8f; transform.localPosition = new Vector3(x, y, z); } else { if (wasTouching) { wasTouching = false; elapsedScaleTimeSeconds = 0.0f; } Vector3 scale = Vector3.Lerp(TouchpadPointDimensions, Vector3.zero, elapsedScaleTimeSeconds / TouchpadPointScaleDurationSeconds); transform.localScale = scale; } elapsedScaleTimeSeconds += Time.deltaTime; }
private void TryCalibrate() { if (CalibrationButtonPress()) { if (NodeAngleChecker.IsCorrectAngle) { FinchController.Left.HapticPulse(FinchCalibration.Settings.HapticTime); FinchController.Right.HapticPulse(FinchCalibration.Settings.HapticTime); FinchController.Calibrate(FinchChirality.Both); NextStep(); } else { TutorialNotification.SetActive(false); WarningNotification.SetActive(true); } } }
private bool CalibrationButtonPress() { if (FinchController.Left.IsConnected && FinchController.Right.IsConnected) { return(FinchController.GetPressDown(FinchChirality.Both, FinchControllerElement.HomeButton)); } if (FinchController.Left.IsConnected) { return(FinchController.GetPressDown(FinchChirality.Left, FinchControllerElement.HomeButton)); } if (FinchController.Right.IsConnected) { return(FinchController.GetPressDown(FinchChirality.Right, FinchControllerElement.HomeButton)); } return(false); }
private void FastCalibrate(FinchController controller) { controller.HapticPulse(Settings.HapticTime); controller.Calibrate(); }