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(); } }
//EMPTY #region PUBLIC_METHODS #endregion PUBLIC_METHODS #region PRIVATE_METHODS /// <summary> /// Handle the Left Controller input and put them in the Events /// </summary> void CheckLeftControllerInput() { BoolVariable temp; #region TRIGGER temp = LeftVariablesDictionnary.Get("TriggerIsDown"); if (!temp.Value && LeftController.GetHairTriggerDown()) { temp.SetValue(true); _leftEvent = (GameEvent)LeftEventsDictionnary.Get("LeftTriggerDown"); _leftEvent.Raise(); } else if (temp.Value && LeftController.GetHairTriggerUp()) { temp.SetValue(false); _leftEvent = (GameEvent)LeftEventsDictionnary.Get("LeftTriggerUp"); _leftEvent.Raise(); } #endregion TRIGGER #region TOUCHPAD temp = LeftVariablesDictionnary.Get("ThumbIsDown"); LeftThumbOrientation.SetValue(LeftController.GetAxis()); if (LeftController.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad)) { temp.SetValue(true); _leftEvent = (GameEvent)LeftEventsDictionnary.Get("LeftThumbDown"); _leftEvent.Raise(); } else if (temp.Value && LeftController.GetPressUp(SteamVR_Controller.ButtonMask.Touchpad)) { temp.SetValue(false); _leftEvent = (GameEvent)LeftEventsDictionnary.Get("LeftThumbUp"); _leftEvent.Raise(); } if (LeftController.GetTouchDown(SteamVR_Controller.ButtonMask.Touchpad)) { _leftEventBool = (GameEventBool)LeftEventsDictionnary.Get("LeftThumbTouching"); _leftEventBool.Raise(true); } else if (LeftController.GetTouchUp(SteamVR_Controller.ButtonMask.Touchpad)) { _leftEventBool = (GameEventBool)LeftEventsDictionnary.Get("LeftThumbTouching"); _leftEventBool.Raise(false); } #endregion TOUCHPAD #region GRIP temp = LeftVariablesDictionnary.Get("GripIsDown"); if (!temp.Value && LeftController.GetPressDown(SteamVR_Controller.ButtonMask.Grip)) { temp.SetValue(true); _leftEvent = (GameEvent)LeftEventsDictionnary.Get("LeftGripDown"); _leftEvent.Raise(); } else if (temp.Value && LeftController.GetPressUp(SteamVR_Controller.ButtonMask.Grip)) { temp.SetValue(false); _leftEvent = (GameEvent)LeftEventsDictionnary.Get("LeftGripUp"); _leftEvent.Raise(); } #endregion GRIP #region MENU temp = LeftVariablesDictionnary.Get("MenuIsDown"); if (!temp.Value && LeftController.GetPressDown(SteamVR_Controller.ButtonMask.ApplicationMenu)) { temp.SetValue(true); _leftEvent = (GameEvent)LeftEventsDictionnary.Get("LeftMenuDown"); _leftEvent.Raise(); } else if (temp.Value && LeftController.GetPressUp(SteamVR_Controller.ButtonMask.ApplicationMenu)) { temp.SetValue(false); _leftEvent = (GameEvent)LeftEventsDictionnary.Get("LeftMenuUp"); _leftEvent.Raise(); } #endregion MENU }