public static GetDeviceIndex ( DeviceRole role ) : uint | ||
role | DeviceRole | |
Результат | uint |
/// <summary> /// Trigger vibration of the controller identified by role /// </summary> public static void TriggerHapticPulse(HandRole role, ushort intensity = 500) { var system = Valve.VR.OpenVR.System; if (system != null) { system.TriggerHapticPulse(ViveRole.GetDeviceIndex(role), (uint)Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad - (uint)Valve.VR.EVRButtonId.k_EButton_Axis0, (char)intensity); } }
/// <summary> /// Trigger vibration of the controller identified by role /// </summary> public static void TriggerHapticPulse(HandRole role, ushort durationMicroSec = 500) { var system = OpenVR.System; if (system != null) { system.TriggerHapticPulse(ViveRole.GetDeviceIndex(role), (uint)EVRButtonId.k_EButton_SteamVR_Touchpad - (uint)EVRButtonId.k_EButton_Axis0, (char)durationMicroSec); } }
public static Vector3 GetAngularVelocity(DeviceRole role, Transform origin = null) { var index = ViveRole.GetDeviceIndex(role); var rawValue = Vector3.zero; if (index < rawPoses.Length) { rawValue = new Vector3(-rawPoses[index].vAngularVelocity.v0, -rawPoses[index].vAngularVelocity.v1, rawPoses[index].vAngularVelocity.v2); } return(origin == null ? rawValue : origin.TransformVector(rawValue)); }
/// <summary> /// Returns tracking pose of the device identified by role /// </summary> public static Pose GetPose(DeviceRole role, Transform origin = null) { var index = ViveRole.GetDeviceIndex(role); var rawPose = new Pose(); if (index < poses.Length) { rawPose = poses[index]; } if (origin != null) { rawPose = new Pose(origin) * rawPose; rawPose.pos.Scale(origin.localScale); } return(rawPose); }
public void Update() { if (Time.frameCount != prevFrameCount) { prevFrameCount = Time.frameCount; previousState = currentState; CVRSystem system; index = ViveRole.GetDeviceIndex(role); if (!ViveRole.IsValidIndex(index) || (system = OpenVR.System) == null || !system.GetControllerState(index, ref currentState)) { currentState = default(VRControllerState_t); } UpdateHairTrigger(); if (GetPressDown(ControllerButton.Pad)) { padDownAxis = GetAxis(); } if (GetPressDown(ControllerButton.PadTouch)) { padTouchDownAxis = GetAxis(); } for (int i = 0; i < ViveInput.CONTROLLER_BUTTON_COUNT; ++i) { UpdateClickCount((ControllerButton)i); } for (int i = 0; i < ViveInput.CONTROLLER_BUTTON_COUNT; ++i) { InvokeEvent((ControllerButton)i); } } }
public static bool IsCalibrating(DeviceRole role) { var index = ViveRole.GetDeviceIndex(role); return(index < rawPoses.Length && (rawPoses[index].eTrackingResult == ETrackingResult.Calibrating_InProgress || rawPoses[index].eTrackingResult == ETrackingResult.Calibrating_OutOfRange)); }
/// <summary> /// Returns true if tracking data of the device identified by role has valid value. /// </summary> public static bool HasTracking(DeviceRole role) { var index = ViveRole.GetDeviceIndex(role); return(index < rawPoses.Length && rawPoses[index].bPoseIsValid); }
/// <summary> /// Returns true if the device identified by role is connected. /// </summary> public static bool IsConnected(DeviceRole role) { var index = ViveRole.GetDeviceIndex(role); return(index < rawPoses.Length && rawPoses[index].bDeviceIsConnected); }
public static bool IsUninitialized(DeviceRole role) { var index = ViveRole.GetDeviceIndex(role); return(index < rawPoses.Length && rawPoses[index].eTrackingResult == ETrackingResult.Uninitialized); }
public static bool IsOutOfRange(DeviceRole role) { var index = ViveRole.GetDeviceIndex(role); return(index < poses.Length && (poses[index].eTrackingResult == ETrackingResult.Running_OutOfRange || poses[index].eTrackingResult == ETrackingResult.Calibrating_OutOfRange)); }
/// <summary> /// Returns true if the process has focus and the device identified by role is connected / has tracking /// </summary> public static bool IsValid(DeviceRole role) { var index = ViveRole.GetDeviceIndex(role); return(index < poses.Length && poses[index].bDeviceIsConnected && poses[index].bPoseIsValid && hasFocus); }