public void Init(SaberType type, VRControllersInputManager vrControllersInputManager) { OVRInput.Controller oculusController; XRNode node; if (type == SaberType.SaberA) { oculusController = OVRInput.Controller.LTouch; node = XRNode.LeftHand; } else { oculusController = OVRInput.Controller.RTouch; node = XRNode.RightHand; } var controllerInputDevice = InputDevices.GetDeviceAtXRNode(node); var vrSystem = OVRInput.IsControllerConnected(oculusController) ? VRSystem.Oculus : VRSystem.SteamVR; var dir = _config.ThumstickDirection; var triggerHandler = new TriggerHandler(node, _config.TriggerThreshold, _config.ReverseTrigger); var gripHandler = new GripHandler(vrSystem, oculusController, controllerInputDevice, _config.GripThreshold, _config.ReverseGrip); var thumbstickAction = new ThumbstickHandler(node, _config.ThumbstickThreshold, dir, _config.ReverseThumbstick); _trickInputHandler.Add(_config.TriggerAction, triggerHandler); _trickInputHandler.Add(_config.GripAction, gripHandler); _trickInputHandler.Add(_config.ThumbstickAction, thumbstickAction); _logger.Debug("Started Input Manager using " + vrSystem); }
public void Construct(IVRPlatformHelper vrPlatformHelper, BeatmapObjectCallbackController callbackController, AudioTimeSyncController audioTimeSyncController, VRControllersInputManager vrControllersInputManager) { _vrPlatformHelper = vrPlatformHelper; _callbackController = callbackController; _audioTimeSyncController = audioTimeSyncController; _vrControllersInputManager = vrControllersInputManager; }
public void Init(SaberType type, VRControllersInputManager vrControllersInputManager) { OVRInput.Controller oculusController; XRNode node; if (type == SaberType.SaberA) { oculusController = OVRInput.Controller.LTouch; node = XRNode.LeftHand; } else { oculusController = OVRInput.Controller.RTouch; node = XRNode.RightHand; } var controllerInputDevice = InputDevices.GetDeviceAtXRNode(node); var vrSystem = OVRInput.IsControllerConnected(oculusController) ? VRSystem.Oculus : VRSystem.SteamVR; var dir = (ThumstickDir)Enum.Parse(typeof(ThumstickDir), PluginConfig.Instance.ThumstickDirection, true); var triggerHandler = new TriggerHandler(node, PluginConfig.Instance.TriggerThreshold); var gripHandler = new GripHandler(vrSystem, oculusController, controllerInputDevice, PluginConfig.Instance.GripThreshold); var thumbstickAction = new ThumbstickHandler(node, PluginConfig.Instance.ThumbstickThreshold, dir); _trickInputHandler.Add(PluginConfig.Instance.TriggerAction.GetEnumValue <TrickAction>(), triggerHandler); _trickInputHandler.Add(PluginConfig.Instance.GripAction.GetEnumValue <TrickAction>(), gripHandler); _trickInputHandler.Add(PluginConfig.Instance.ThumbstickAction.GetEnumValue <TrickAction>(), thumbstickAction); Plugin.Log.Debug("Started Input Manager using " + vrSystem); }
public void Awake() { _standardLevelGameplayManager = Resources.FindObjectsOfTypeAll <StandardLevelGameplayManager>().FirstOrDefault(); // Use the appropriate level failed event if (_standardLevelGameplayManager) { _standardLevelGameplayManager.levelFailedEvent += this.OnLevelFail; _standardLevel = true; } else { _missionLevelGameplayManager = Resources.FindObjectsOfTypeAll <MissionLevelGameplayManager>().FirstOrDefault(); _missionLevelGameplayManager.levelFailedEvent += this.OnLevelFail; _standardLevel = false; } // Get all the necessary fields _standardLevelFailedController = Resources.FindObjectsOfTypeAll <StandardLevelFailedController>().FirstOrDefault(); if (_standardLevelFailedController) { _standardLevelSceneSetupData = _standardLevelFailedController.GetField <StandardLevelScenesTransitionSetupDataSO, StandardLevelFailedController>("_standardLevelSceneSetupData"); _standardInitData = _standardLevelFailedController.GetField <StandardLevelFailedController.InitData, StandardLevelFailedController>("_initData"); _prepareLevelCompletionResults = _standardLevelFailedController.GetField <PrepareLevelCompletionResults, StandardLevelFailedController>("_prepareLevelCompletionResults"); } else { _missionLevelFailedController = Resources.FindObjectsOfTypeAll <MissionLevelFailedController>().FirstOrDefault(); _missionLevelSceneSetupData = _missionLevelFailedController.GetField <MissionLevelScenesTransitionSetupDataSO, MissionLevelFailedController>("_missionLevelSceneSetupData"); _missionInitData = _missionLevelFailedController.GetField <MissionLevelFailedController.InitData, MissionLevelFailedController>("_initData"); _missionObjectiveCheckersManager = _missionLevelFailedController.GetField <MissionObjectiveCheckersManager, MissionLevelFailedController>("_missionObjectiveCheckersManager"); _prepareLevelCompletionResults = _missionLevelFailedController.GetField <PrepareLevelCompletionResults, MissionLevelFailedController>("_prepareLevelCompletionResults"); } _vrControllersInputManager = Resources.FindObjectsOfTypeAll <PauseMenuManager>().FirstOrDefault() .GetField <VRControllersInputManager, PauseMenuManager>("_vrControllersInputManager"); }
public void Update() { if (_messageDisplayTime > 0f) { _messageDisplayTime -= Time.deltaTime; if (_messageDisplayTime <= 0f) { _messageDisplayTime = 0f; _messageDisplayText.text = ""; } } if (Config.Instance.EnableVoiceChat && Config.Instance.MicEnabled) { if (!Config.Instance.PushToTalk) { isRecording = true; } else { switch (Config.Instance.PushToTalkButton) { case 0: isRecording = ControllersHelper.GetLeftGrip(); break; case 1: isRecording = ControllersHelper.GetRightGrip(); break; case 2: isRecording = VRControllersInputManager.TriggerValue(XRNode.LeftHand) > 0.85f; break; case 3: isRecording = VRControllersInputManager.TriggerValue(XRNode.RightHand) > 0.85f; break; case 4: isRecording = ControllersHelper.GetLeftGrip() && ControllersHelper.GetRightGrip(); break; case 5: isRecording = VRControllersInputManager.TriggerValue(XRNode.RightHand) > 0.85f && VRControllersInputManager.TriggerValue(XRNode.LeftHand) > 0.85f; break; case 6: isRecording = ControllersHelper.GetLeftGrip() || ControllersHelper.GetRightGrip(); break; case 7: isRecording = VRControllersInputManager.TriggerValue(XRNode.RightHand) > 0.85f || VRControllersInputManager.TriggerValue(XRNode.LeftHand) > 0.85f; break; default: isRecording = Input.anyKey; break; } } } else { isRecording = false; } if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) { if (Input.GetKeyDown(KeyCode.Keypad0)) { fixedSendRate = 0; Misc.Logger.Info($"Variable send rate"); } else if (Input.GetKeyDown(KeyCode.Keypad1)) { fixedSendRate = 1; Misc.Logger.Info($"Forced full send rate"); } else if (Input.GetKeyDown(KeyCode.Keypad2)) { fixedSendRate = 2; Misc.Logger.Info($"Forced half send rate"); } else if (Input.GetKeyDown(KeyCode.Keypad3)) { fixedSendRate = 3; Misc.Logger.Info($"Forced one third send rate"); } } if (needToSendUpdates) { if (fixedSendRate == 1 || (fixedSendRate == 0 && Client.Instance.Tickrate > 67.5f * (1f / 90 / Time.deltaTime))) { sendRateCounter = 0; UpdatePlayerInfo(); #if DEBUG && VERBOSE Misc.Logger.Info($"Full send rate! FPS: {(1f / Time.deltaTime).ToString("0.0")}, TPS: {Client.Instance.Tickrate.ToString("0.0")}"); #endif } else if (fixedSendRate == 2 || (fixedSendRate == 0 && Client.Instance.Tickrate > 37.5f * (1f / 90 / Time.deltaTime))) { sendRateCounter++; if (sendRateCounter >= 1) { sendRateCounter = 0; UpdatePlayerInfo(); #if DEBUG && VERBOSE Misc.Logger.Info($"Half send rate! FPS: {(1f / Time.deltaTime).ToString("0.0")}, TPS: {Client.Instance.Tickrate.ToString("0.0")}"); #endif } } else if (fixedSendRate == 3 || (fixedSendRate == 0 && Client.Instance.Tickrate <= 37.5f * (1f / 90 / Time.deltaTime))) { sendRateCounter++; if (sendRateCounter >= 2) { sendRateCounter = 0; UpdatePlayerInfo(); #if DEBUG && VERBOSE Misc.Logger.Info($"One third send rate! FPS: {(1f / Time.deltaTime).ToString("0.0")}, TPS: {Client.Instance.Tickrate.ToString("0.0")}"); #endif } } } }
public void Update() { if (!Client.Instance.connected) { return; } if (_messageDisplayTime > 0f) { _messageDisplayTime -= Time.deltaTime; if (_messageDisplayTime <= 0f) { _messageDisplayTime = 0f; if (_messageDisplayText != null) { _messageDisplayText.text = ""; } } } if (Config.Instance.EnableVoiceChat && Config.Instance.MicEnabled) { if (!Config.Instance.PushToTalk) { isRecording = true; } else { switch (Config.Instance.PushToTalkButton) { case 0: isRecording = ControllersHelper.GetLeftGrip(); break; case 1: isRecording = ControllersHelper.GetRightGrip(); break; case 2: isRecording = VRControllersInputManager.TriggerValue(XRNode.LeftHand) > 0.85f; break; case 3: isRecording = VRControllersInputManager.TriggerValue(XRNode.RightHand) > 0.85f; break; case 4: isRecording = ControllersHelper.GetLeftGrip() && ControllersHelper.GetRightGrip(); break; case 5: isRecording = VRControllersInputManager.TriggerValue(XRNode.RightHand) > 0.85f && VRControllersInputManager.TriggerValue(XRNode.LeftHand) > 0.85f; break; case 6: isRecording = ControllersHelper.GetLeftGrip() || ControllersHelper.GetRightGrip(); break; case 7: isRecording = VRControllersInputManager.TriggerValue(XRNode.RightHand) > 0.85f || VRControllersInputManager.TriggerValue(XRNode.LeftHand) > 0.85f; break; default: isRecording = Input.anyKey; break; } } } else { isRecording = false; } if (isVoiceChatActive && voiceChatListener != null) { voiceChatListener.isListening = isRecording; } if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) { if (Input.GetKeyDown(KeyCode.Keypad0)) { _fixedSendRate = 0; Plugin.log.Info($"Variable send rate"); } else if (Input.GetKeyDown(KeyCode.Keypad1)) { _fixedSendRate = 1; Plugin.log.Info($"Forced full send rate"); } else if (Input.GetKeyDown(KeyCode.Keypad2)) { _fixedSendRate = 2; Plugin.log.Info($"Forced half send rate"); } else if (Input.GetKeyDown(KeyCode.Keypad3)) { _fixedSendRate = 3; Plugin.log.Info($"Forced one third send rate"); } } if (needToSendUpdates) { if (_fixedSendRate == 1 || (_fixedSendRate == 0 && Client.Instance.tickrate > (1f / Time.deltaTime / 3f * 2f + 5f)) || _spectatorInRoom) { _sendRateCounter = 0; UpdatePlayerInfo(); #if DEBUG && VERBOSE Plugin.log.Info($"Full send rate! FPS: {(1f / Time.deltaTime).ToString("0.0")}, TPS: {Client.Instance.Tickrate.ToString("0.0")}, Trigger: TPS>{1f / Time.deltaTime / 3f * 2f + 5f}"); #endif } else if (_fixedSendRate == 2 || (_fixedSendRate == 0 && Client.Instance.tickrate > (1f / Time.deltaTime / 3f + 5f))) { _sendRateCounter++; if (_sendRateCounter >= 1) { _sendRateCounter = 0; UpdatePlayerInfo(); #if DEBUG && VERBOSE Plugin.log.Info($"Half send rate! FPS: {(1f / Time.deltaTime).ToString("0.0")}, TPS: {Client.Instance.Tickrate.ToString("0.0")}, Trigger: TPS>{1f / Time.deltaTime / 3f + 5f}"); #endif } } else if (_fixedSendRate == 3 || (_fixedSendRate == 0 && Client.Instance.tickrate <= (1f / Time.deltaTime / 3f + 5f))) { _sendRateCounter++; if (_sendRateCounter >= 2) { _sendRateCounter = 0; UpdatePlayerInfo(); #if DEBUG && VERBOSE Plugin.log.Info($"One third send rate! FPS: {(1f / Time.deltaTime).ToString("0.0")}, TPS: {Client.Instance.Tickrate.ToString("0.0")}, Trigger: TPS<={1f / Time.deltaTime / 3f + 5f}"); #endif } } } }
public static bool MenuButton() { return(VRControllersInputManager.MenuButton()); }
public static float RightHorizontalAxis() { return(VRControllersInputManager.HorizontalAxisValue(UnityEngine.XR.XRNode.RightHand)); }
public static float LeftVerticalAxis() { return(VRControllersInputManager.VerticalAxisValue(UnityEngine.XR.XRNode.LeftHand)); }
public static bool RightTrigger() { return(VRControllersInputManager.TriggerValue(UnityEngine.XR.XRNode.RightHand) > 0.75f); }