private void PlayWeaponFireHaptics(Weapon weapon) { if (!VRConfig.configUseWeaponHaptics.Value) { return; } float intensity = GetFireHapticStrength(weapon, VRConfig.configShootingHapticsStrength.Value); float duration = 0.03f; float frequency = 40f; if (Controllers.aimingTwoHanded) { intensity *= .5f; intensity = Mathf.Max(intensity, 0.075f); SteamVR_InputHandler.TriggerHapticPulse(Mathf.Lerp(duration, duration * 1.5f, intensity), Mathf.Lerp(frequency, frequency * 1.5f, intensity), intensity, Controllers.GetDeviceFromHandType(Controllers.offHandControllerType)); } SteamVR_InputHandler.TriggerHapticPulse( Mathf.Lerp(duration, duration * 1.5f, intensity), Mathf.Lerp(frequency, frequency * 1.5f, intensity), intensity, Controllers.GetDeviceFromHandType(Controllers.mainControllerType)); }
private void GlueGunPressureHaptics(float pressure) { if (!VRConfig.configUseWeaponHaptics.Value) { return; } if (pressure > 0.05f && Time.time > lastVibrateTime) { float intensity = pressure; intensity *= intensity; float duration = 0.1f; float frequency = Mathf.Lerp(20, 35, pressure); float vibrateDelay = vibrationDelay; if (pressure >= 0.99f) { intensity = 2f; duration = .08f; frequency = 80; vibrateDelay *= 2f; } SteamVR_InputHandler.TriggerHapticPulse( Mathf.Lerp(duration, duration * 1.5f, intensity), Mathf.Lerp(frequency, frequency * 1.5f, intensity), intensity, Controllers.GetDeviceFromHandType(Controllers.mainControllerType)); lastVibrateTime = Time.time + vibrateDelay; } }
private static void Prefix(PUI_SkipText __instance, Action onSkip) { if (SteamVR_InputHandler.GetActionDown(InputAction.Fire)) { onSkip?.Invoke(); } }
public void UpdateObjectiveDisplay() { if (m_objectiveDisplay != null) { m_objectiveDisplay.text = "WARDEN OBJECTIVE: \n \n " + m_mainObjective + " \n \n " + m_subObjective; m_objectiveDisplay.ForceMeshUpdate(false); SteamVR_InputHandler.TriggerHapticPulse(0.01f, 1 / .025f, 0.2f, Controllers.GetDeviceFromHandType(Controllers.offHandControllerType)); } }
private static bool Prefix(InputAction action, ref string __result) { string res = ""; if (SteamVR_InputHandler.TryGetActionNameFromInputAction(action, ref res)) { Log.Debug($"Got action name from SteamVR_Input - {res}"); __result = res; return(false); } return(true); }
private void PlayWeaponReloadHaptics() { float duration = 0.03f; float frequency = 40f; float intensity = .5f; SteamVR_InputHandler.TriggerHapticPulse( Mathf.Lerp(duration, duration * 1.5f, intensity), Mathf.Lerp(frequency, frequency * 1.5f, intensity), intensity, Controllers.GetDeviceFromHandType(Controllers.mainControllerType)); }
public void SwitchState() { int maxStateIndex = Enum.GetValues(typeof(WatchState)).Length - 1; int nextIndex = (int)m_currentState + 1; if (nextIndex > maxStateIndex) { nextIndex = 0; } SwitchState((WatchState)nextIndex); SteamVR_InputHandler.TriggerHapticPulse(0.025f, 1 / .025f, 0.3f, Controllers.GetDeviceFromHandType(Controllers.offHandControllerType)); }
private void SelectClosestRadialItem() { RadialItem lastClosest = closest; float closestDistance = 9999f; GameObject hand = GetHand(); if (closest != null && Vector3.Distance(closest.transform.position, hand.transform.position) > m_maxDistance * m_scale) { closest = null; } foreach (RadialItem item in radialItems) { if (item != closest) { item.Deselect(); } } foreach (RadialItem item in radialItems) { if (!item.Active) { continue; } float distance = Vector3.Distance(item.transform.position, hand.transform.position); if (distance < closestDistance) { closestDistance = distance; closest = item; } } if (closest != null && closest != lastClosest) { if (closestDistance < m_maxDistance * m_scale) { CellSound.Post(AK.EVENTS.GAME_MENU_SELECT_GEAR, closest.transform.position); SteamVR_InputHandler.TriggerHapticPulse(0.02f, 40f, 0.25f, Controllers.GetDeviceFromInteractionHandType(targetHand)); closest.Select(); m_lastHovered = closest; } else { closest = null; } } }
private void Setup() { DontDestroyOnLoad(gameObject); SteamVR.Initialize(false); var res = SteamVR_Camera.GetSceneResolution(); Log.Info($"SteamVR Setup - HMD Res: {res.width}x{res.height}"); WeaponArchetypeVRData.Setup(); SteamVR_InputHandler.Setup(); gameObject.AddComponent <HMD>(); gameObject.AddComponent <Controllers>(); gameObject.AddComponent <VRKeyboard>(); gameObject.AddComponent <VRAssets>(); // Delay the overlay setup so we don't 'hitch' the player's camera while everything else loads. Invoke(nameof(VRSystems.SetupOverlay), .5f); }
private void HammerSmackHaptics(float dmg) { if (!VRConfig.configUseWeaponHaptics.Value) { return; } float duration = 0.2f; float frequency = 55f; dmg = dmg.RemapClamped(0, 1, 0.10f, VRConfig.configShootingHapticsStrength.Value); SteamVR_InputHandler.TriggerHapticPulse(Mathf.Lerp(duration, duration * 2.5f, dmg), Mathf.Lerp(frequency, frequency * 1.3f, dmg), Mathf.Lerp(0.1f, 1f, dmg), Controllers.GetDeviceFromHandType(Controllers.mainControllerType)); }
private void Update() { if (UI_Core.m_uiPass && m_overlayTarget == null) { CreateRenderTexture(); Popup_Camera = UI_Core.m_uiPass.transform.GetComponent <Camera>(); UI_Camera = Popup_Camera.transform.GetComponentInChildren <UI_RenderUI>().gameObject.GetComponent <Camera>(); return; } if (m_overlayHandle != OpenVR.k_ulOverlayHandleInvalid) { if (SteamVR_InputHandler.GetActionDown(InputAction.Crouch) || SteamVR_InputHandler.GetActionDown(InputAction.Aim)) { OrientateOverlay(); } RenderUI(); } }
private void PlayReceiveDamageHaptics(float dmg, Vector3 direction) { if (dmg > .5) { dmg = dmg.RemapClamped(0, 10f, 0, .75f); float duration = 0.08f; float frequency = 55f; SteamVR_InputHandler.TriggerHapticPulse(Mathf.Lerp(duration, duration * 2.5f, dmg), Mathf.Lerp(frequency, frequency * 1.3f, dmg), Mathf.Lerp(0.5f, 1f, dmg), Controllers.GetDeviceFromHandType(Controllers.offHandControllerType)); SteamVR_InputHandler.TriggerHapticPulse(Mathf.Lerp(duration, duration * 2.5f, dmg), Mathf.Lerp(frequency, frequency * 1.3f, dmg), Mathf.Lerp(0.1f, 1f, dmg), Controllers.GetDeviceFromHandType(Controllers.mainControllerType)); } }
private void ChatMsgReceived(string msg) { if (msgBuffer.Contains(msg)) { return; } SteamVR_InputHandler.TriggerHapticPulse(0.1f, 40f, .75f, Controllers.GetDeviceFromInteractionHandType(InteractionHand.Offhand)); CellSound.Post(AK.EVENTS.GAME_MENU_CHANGE_PAGE, transform.position); msgBuffer.Enqueue(msg); if (msgBuffer.Count > 8) { msgBuffer.Dequeue(); } m_chatDisplay.text = ""; foreach (string chatMsg in msgBuffer) { m_chatDisplay.text += chatMsg + "\n"; } m_chatDisplay.ForceMeshUpdate(false); }
private static void Postfix(InputAction action, ref bool __result) { __result = __result || SteamVR_InputHandler.GetAction(action) || WeaponRadialMenu.GetSpecialActionMappingDown(action); }
private static void Postfix(InputAction action, ref bool __result) { __result = __result || SteamVR_InputHandler.GetActionUp(action); }
private static void Postfix(InputAction action, ref float __result) { __result += SteamVR_InputHandler.GetAxis(action); }