void ShowFeatures() { string displayTextAccumulator = ""; int nodeNumber = 0; InputDevice device = InputDevices.GetDeviceAtXRNode(node); if (device == null) { displayTextAccumulator = "Device not found at node " + node.ToString(); } else { List <InputFeatureUsage> features = new List <InputFeatureUsage>(); if (device.TryGetFeatureUsages(features)) { foreach (InputFeatureUsage feature in features) { displayTextAccumulator += ("<" + nodeNumber + "> " + feature.name + " - \"" + feature.type.ToString() + "\"\n"); nodeNumber++; } } else { displayTextAccumulator = "No Features were found!"; } } listText.text = displayTextAccumulator; }
void CreateControllerVisual(XRNode nodeType) { #if UNITY_5 var position = InputTracking.GetLocalPosition(nodeType); if (position == Vector3.zero) { TraceHelper.LogDiff("Not creating controller for " + nodeType.ToString(), TraceCacheGrouping.IgnoreController); return; } #endif GameObject go = new GameObject(); go.transform.parent = ControllersRoot; go.name = "Controller" + nodeType.ToString(); uDevices[nodeType] = go.transform; var coroutine = StartCoroutine(Attach(go, ControllersRoot, nodeType)); }
void Update() { if (NodeTitle_Text != null) { NodeTitle_Text.text = m_Node.ToString(); } var nodeStates = new List <XRNodeState>(); UnityEngine.XR.InputTracking.GetNodeStates(nodeStates); XRNodeState?state = null; foreach (XRNodeState nodeState in nodeStates) { if (nodeState.nodeType == m_Node) { state = nodeState; break; } } if (state.HasValue) { XRNodeState node = state.Value; Vector3 tempVector; Quaternion tempQuaternion; // Translation Information SetImageColor(Position_Image, node.TryGetPosition(out tempVector)); Position_Text.text = Vector3ToFieldText(tempVector); SetImageColor(Velocity_Image, node.TryGetVelocity(out tempVector)); Velocity_Text.text = Vector3ToFieldText(tempVector); SetImageColor(Acceleration_Image, node.TryGetAcceleration(out tempVector)); Acceleration_Text.text = Vector3ToFieldText(tempVector); // Rotation Information SetImageColor(Rotation_Image, node.TryGetRotation(out tempQuaternion)); Rotation_Text.text = QuaternionToFieldText(tempQuaternion); SetImageColor(AngularVelocity_Image, node.TryGetAngularVelocity(out tempVector)); AngularVelocity_Text.text = Vector3ToFieldText(tempVector); SetImageColor(AngularAcceleration_Image, node.TryGetAngularAcceleration(out tempVector)); AngularAcceleration_Text.text = Vector3ToFieldText(tempVector); } else { // Translation Information SetImageColor(Position_Image, false); SetImageColor(Velocity_Image, false); SetImageColor(Acceleration_Image, false); // Rotation Information SetImageColor(Rotation_Image, false); SetImageColor(AngularVelocity_Image, false); SetImageColor(AngularAcceleration_Image, false); } }
void ShowFeatures() { string displayTextAccumulator = ""; int nodeNumber = 0; InputDevice device = InputDevices.GetDeviceAtXRNode(node); if (device == null) { displayTextAccumulator = "Device not found at node " + node.ToString(); } else { List <InputFeatureUsage> features = new List <InputFeatureUsage>(); if (device.TryGetFeatureUsages(features)) { foreach (InputFeatureUsage feature in features) { displayTextAccumulator += ("<" + nodeNumber + "> " + feature.name + " "); // Can't use switch statement because types are not considered constant if (feature.type == typeof(bool)) { displayTextAccumulator += TextAccumBool(device, feature); } if (feature.type == typeof(float)) { displayTextAccumulator += TextAccumFloat(device, feature); } if (feature.type == typeof(Vector2)) { displayTextAccumulator += TextAccumVector2(device, feature); } if (feature.type == typeof(Vector3)) { displayTextAccumulator += TextAccumVector3(device, feature); } if (feature.type == typeof(uint)) { displayTextAccumulator += TextAccumUint(device, feature); } displayTextAccumulator += ("\n"); nodeNumber++; } } else { displayTextAccumulator = "No Features were found!"; } } listText.text = displayTextAccumulator; }
private bool CheckGripButton(InputButtonStates state) { if (NodeType == XRNode.LeftHand) { return(ModuleInput.Instance.GetSelectionMethodRift().AuxiliarGripButton(state)); } else if (NodeType == XRNode.RightHand) { return(ModuleInput.Instance.GetSelectionMethodRift().MainGripButton(state)); } else { Debug.Log("XRNode type mus be a Hand! Current type is" + NodeType.ToString()); } return(false); }
void Update() { HapticCapabilities caps = new HapticCapabilities(); InputDevice device = InputDevices.GetDeviceAtXRNode(node); if (device == null || !device.TryGetHapticCapabilities(out caps) ) { return; } nodeCheck.text = node.ToString(); numChannels.text = caps.numChannels.ToString(); supportsImpulse.text = caps.supportsImpulse.ToString(); supportsBuffer.text = caps.supportsBuffer.ToString(); bufferFreqHz.text = caps.bufferFrequencyHz.ToString(); bufferMaxSize.text = caps.bufferMaxSize.ToString(); bufferOptimalSize.text = caps.bufferOptimalSize.ToString(); }
public bool CheckTriggerButton(InputButtonStates state) { if (NodeType == XRNode.LeftHand) { return(Input.GetButton(InputStatics.Auxiliar_Trigger)); } else if (NodeType == XRNode.RightHand) { return(Input.GetButton(InputStatics.Main_Trigger)); } else { Debug.Log("XRNode type mus be a Hand! Current type is" + NodeType.ToString()); } return(false); }
private void Print(string buttonId, string value, bool isActive, XRNode xRNode) { string key = buttonId + "-" + xRNode.ToString(); // Find input space int index = printManager.inputIds.IndexOf(key); Text inputSpace; if (index > -1) { inputSpace = printManager.textInputs[index]; } else { inputSpace = CreateTextInput(printManager.inputIds.Count); printManager.inputIds.Add(key); printManager.textInputs.Add(inputSpace); } inputSpace.color = (isActive) ? Color.green : Color.red; inputSpace.text = ($"[{buttonId} | {xRNode}] {value}"); }
private void Update() { bool controllerValid = false; InputDevice controllerDevice = InputDevices.GetDeviceAtXRNode(s_controllerNode); #if USING_STEAMVR controllerValid = true; #else controllerValid = controllerDevice.isValid; #endif // Debug.Log("Input device: " + controllerDevice.ToString()); if (controllerValid) { //Trigger float triggerValue = 0.0f; bool featureGrabbed; #if USING_STEAMVR triggerValue = s_triggerState.GetAxis(_hand); featureGrabbed = true; #else featureGrabbed = controllerDevice.TryGetFeatureValue(CommonUsages.trigger, out triggerValue); #endif if (featureGrabbed) { // Debug.Log("Trigger value: " + triggerValue); if (triggerValue > 0.3f && _previousTriggerValue < 0.3f) { JAVR_ControllerInputEvents.InputDeviceButtonAction(JAVR_ControllerInputAction.Press, (InputFeatureUsage)CommonUsages.trigger, s_controllerNode, triggerValue); Debug.Log("Trigger pressed: " + s_controllerNode.ToString()); } if (triggerValue < 0.001f && _previousTriggerValue > 0.001f) { JAVR_ControllerInputEvents.InputDeviceButtonAction(JAVR_ControllerInputAction.Release, (InputFeatureUsage)CommonUsages.trigger, s_controllerNode, triggerValue); } _previousTriggerValue = triggerValue; } else { Debug.Log("Getting trigger info failed!"); } //Grip float gripValue = 0.0f; #if USING_STEAMVR gripValue = s_gripState.GetAxis(_hand); #else featureGrabbed = controllerDevice.TryGetFeatureValue(CommonUsages.grip, out gripValue); #endif if (featureGrabbed) { if (gripValue > 0.01f && _previousGripValue < 0.01f) { JAVR_ControllerInputEvents.InputDeviceButtonAction(JAVR_ControllerInputAction.Press, (InputFeatureUsage)CommonUsages.grip, s_controllerNode, gripValue); Debug.Log("Grip pressed: " + s_controllerNode.ToString()); } if (gripValue < 0.01f && _previousGripValue > 0.01f) { JAVR_ControllerInputEvents.InputDeviceButtonAction(JAVR_ControllerInputAction.Release, (InputFeatureUsage)CommonUsages.grip, s_controllerNode, gripValue); } _previousGripValue = gripValue; } else { Debug.Log("Getting grip info failed!"); } #if USING_STEAMVR #else //MenuButon, ONLY left bool menuButtonValue = false; featureGrabbed = false; if (controllerDevice.TryGetFeatureValue(CommonUsages.menuButton, out menuButtonValue) && s_controllerNode == XRNode.LeftHand) { if (menuButtonValue && !_previousMenuButtonValue) { JAVR_ControllerInputEvents.InputDeviceButtonAction(JAVR_ControllerInputAction.Press, (InputFeatureUsage)CommonUsages.menuButton, s_controllerNode, 1.0f); } if (menuButtonValue && !_previousMenuButtonValue) { JAVR_ControllerInputEvents.InputDeviceButtonAction(JAVR_ControllerInputAction.Release, (InputFeatureUsage)CommonUsages.menuButton, s_controllerNode, 0.0f); } _previousMenuButtonValue = menuButtonValue; } #endif //Primary Button bool primaryButtonValue = false; if (controllerDevice.TryGetFeatureValue(CommonUsages.primaryButton, out primaryButtonValue)) { if (primaryButtonValue && !_previousPrimaryButton) { JAVR_ControllerInputEvents.InputDeviceButtonAction(JAVR_ControllerInputAction.Press, (InputFeatureUsage)CommonUsages.primaryButton, s_controllerNode, 1.0f); Debug.Log("Primary button Pressed"); } if (primaryButtonValue && !_previousPrimaryButton) { JAVR_ControllerInputEvents.InputDeviceButtonAction(JAVR_ControllerInputAction.Release, (InputFeatureUsage)CommonUsages.primaryButton, s_controllerNode, 0.0f); } _previousPrimaryButton = primaryButtonValue; } //Secondary Button bool secondaryButtonValue = false; if (controllerDevice.TryGetFeatureValue(CommonUsages.secondaryButton, out secondaryButtonValue)) { if (secondaryButtonValue && !_previousSecondaryButton) { JAVR_ControllerInputEvents.InputDeviceButtonAction(JAVR_ControllerInputAction.Press, (InputFeatureUsage)CommonUsages.secondaryButton, s_controllerNode, 1.0f); Debug.Log("Secondary button Pressed"); } if (secondaryButtonValue && !_previousSecondaryButton) { JAVR_ControllerInputEvents.InputDeviceButtonAction(JAVR_ControllerInputAction.Release, (InputFeatureUsage)CommonUsages.secondaryButton, s_controllerNode, 0.0f); } _previousSecondaryButton = secondaryButtonValue; } } }
private void Start() { device = new InputDevice(); title.text = node.ToString(); }