private static void UpdateHandJoints(InputDeviceCharacteristics flag, Hand hand)
        {
            List <InputDevice> inputDeviceList = new List <InputDevice>();

            InputDevices.GetDevicesWithCharacteristics(InputDeviceCharacteristics.HandTracking | flag, inputDeviceList);
            UnityEngine.XR.Hand xrHand = default;
            foreach (InputDevice device in inputDeviceList)
            {
                if (device.TryGetFeatureValue(CommonUsages.isTracked, out bool isTracked) &&
                    isTracked &&
                    device.TryGetFeatureValue(CommonUsages.handData, out xrHand))
                {
                    break;
                }
            }

            if (xrHand != default)
            {
                hand?.UpdateHandJoints(xrHand);
            }
            else
            {
                // If we get here, we didn't successfully update hand joints for any tracked input device
                hand?.DisableHandJoints();
            }
        }
Exemplo n.º 2
0
    void Start()
    {
        List <InputDevice> devices = new List <InputDevice>();
        //InputDevices.GetDevices(devices);
        InputDeviceCharacteristics rightControllerCharacteristics = InputDeviceCharacteristics.Right | InputDeviceCharacteristics.Controller;

        InputDevices.GetDevicesWithCharacteristics(rightControllerCharacteristics, devices);


        Debug.Log("Hello: " + gameObject.name);

        foreach (var item in devices)
        {
            Debug.Log(item.name + item.characteristics);
        }
        if (devices.Count > 0)
        {
            targetDevice = devices[0];
            GameObject prefab = controllerPrefabs.Find(controllerPrefabs => controllerPrefabs.name == targetDevice.name);
            if (prefab)
            {
                spawedController = Instantiate(prefab, transform);
            }
            else
            {
                Debug.LogError("Do not find the controller model!");
                spawedController = Instantiate(controllerPrefabs[0], transform);
            }
        }
    }
Exemplo n.º 3
0
    // Start is called before the first frame update
    void Start()
    {
        List <InputDevice>         devices         = new List <InputDevice>();
        InputDeviceCharacteristics rightController = InputDeviceCharacteristics.Right | InputDeviceCharacteristics.Controller;

        InputDevices.GetDevicesWithCharacteristics(rightController, devices);

        foreach (var device in devices)
        {
            Debug.Log(device.name + device.characteristics);
        }

        if (devices.Count > 0)
        {
            targetDevice = devices[0];
            // Device name read from InputDevice must match the Model names added in Unity
            GameObject prefab = controllerPrefabs.Find(controller => controller.name == targetDevice.name);
            if (prefab)
            {
                spawnedController = Instantiate(prefab, transform);
            }
            else
            {
                Debug.Log("Did not find the controller model named: " + targetDevice.name);
                Debug.Log("Loading default controller model");
                spawnedController = Instantiate(controllerPrefabs[0], transform);
            }
        }
    }
Exemplo n.º 4
0
    // Main Function: Change the visual representation of the left/right controllers
    void Start()
    {
        List <InputDevice> devices = new List <InputDevice>();

        if (controller.Equals(Orientation.Left))
        {
            ControllerCharacteristics = InputDeviceCharacteristics.Controller | InputDeviceCharacteristics.Left;
            InputDevices.GetDevicesWithCharacteristics(ControllerCharacteristics, devices);
            leftController = devices[0];
            GameObject prefab = controllerPrefabs.Find(controller => controller.name.Equals("Oculus Quest Controller - Left"));
            if (prefab)
            {
                targetController_spawn = Instantiate(prefab, transform);
            }
        }
        else if (controller.Equals(Orientation.Right))
        {
            ControllerCharacteristics = InputDeviceCharacteristics.Controller | InputDeviceCharacteristics.Right;
            InputDevices.GetDevicesWithCharacteristics(ControllerCharacteristics, devices);
            rightController = devices[0];
            GameObject prefab = controllerPrefabs.Find(controller => controller.name.Equals("Oculus Quest Controller - Right"));
            if (prefab)
            {
                targetController_spawn = Instantiate(prefab, transform);
            }
        }
    }
Exemplo n.º 5
0
    InputDevice GetHand(InputDeviceCharacteristics side)
    {
        List <InputDevice>         devices         = new List <InputDevice>();
        InputDeviceCharacteristics characteristics = InputDeviceCharacteristics.Controller | side;

        InputDevices.GetDevicesWithCharacteristics(characteristics, devices);
        return(devices.Count > 0 ? devices[0] : default);
Exemplo n.º 6
0
    /// <summary>
    /// This function is called,
    /// when primarybutton is down.
    /// turns the player 90 degrees left or right,
    /// depending on the hmd rotation.
    /// </summary>
    /// <param name="device">device which is used for press</param>
    public void AcceptTurn(InputDeviceCharacteristics device)
    {
        if (!isTurningToggled)
        {
            return;
        }

        if (moving)
        {
            return;
        }

        if (dotProduct < 0) //if looking opposite from body direction
        {
            //cross = Vector3.Cross(rig.transform.forward, hmd.forward);

            if (cross.y > 0) // head is turned 90deg to the right from body
            {
                //Debug.Log("Dot hmd.forward and rig.forward: " + dotProduct); //Use this value to know if user is looking "backwards"
                //Debug.Log("Cross product : " + Vector3.Cross(rig.transform.forward, hmd.forward)); this used to know which way turning -y left y right
                //Snap turn body 90 degrees right
                rig.transform.Rotate(Vector3.up, 90);
            }
            if (cross.y < 0) // head is turned 90deg to the left from body
            {
                rig.transform.Rotate(Vector3.up, -90);
            }
        }
    }
Exemplo n.º 7
0
        void OnEnable()
        {
            if (inputMap == null)
            {
                Debug.LogError("A Input Map must be assigned to WebXRController!");
                return;
            }
            WebXRManager.OnControllerUpdate += OnControllerUpdate;
            WebXRManager.OnHandUpdate       += OnHandUpdate;
            WebXRManager.OnHeadsetUpdate    += onHeadsetUpdate;
            SetVisible(false);
#if UNITY_EDITOR
            switch (hand)
            {
            case WebXRControllerHand.LEFT:
                xrHand = InputDeviceCharacteristics.Controller | InputDeviceCharacteristics.Left;
                break;

            case WebXRControllerHand.RIGHT:
                xrHand = InputDeviceCharacteristics.Controller | InputDeviceCharacteristics.Right;
                break;
            }

            List <InputDevice> allDevices = new List <InputDevice>();
            InputDevices.GetDevicesWithCharacteristics(xrHand, allDevices);
            foreach (InputDevice device in allDevices)
            {
                HandleInputDevicesConnected(device);
            }

            InputDevices.deviceConnected    += HandleInputDevicesConnected;
            InputDevices.deviceDisconnected += HandleInputDevicesDisconnected;
#endif
        }
Exemplo n.º 8
0
        private VRModuleDeviceClass GetDeviceClass(string name, InputDeviceCharacteristics characteristics)
        {
            bool isTracker = Regex.IsMatch(name, @"tracker", RegexOptions.IgnoreCase);

            if ((characteristics & InputDeviceCharacteristics.HeadMounted) != 0)
            {
                return(VRModuleDeviceClass.HMD);
            }

            if ((characteristics & InputDeviceCharacteristics.Controller) != 0 && !isTracker)
            {
                return(VRModuleDeviceClass.Controller);
            }

            if ((characteristics & InputDeviceCharacteristics.TrackingReference) != 0)
            {
                return(VRModuleDeviceClass.TrackingReference);
            }

            if ((characteristics & InputDeviceCharacteristics.TrackedDevice) != 0)
            {
                return(VRModuleDeviceClass.GenericTracker);
            }

            return(VRModuleDeviceClass.Invalid);
        }
Exemplo n.º 9
0
    // So that game still works even when they are no controllers
    void TryInitialize()
    {
        List <InputDevice>         devices = new List <InputDevice>();
        InputDeviceCharacteristics rightControllerCharacteristics = InputDeviceCharacteristics.Right | InputDeviceCharacteristics.Controller;

        InputDevices.GetDevicesWithCharacteristics(rightControllerCharacteristics, devices);


        foreach (var item in devices)
        {
            Debug.Log(item.name + item.characteristics);
        }

        if (devices.Count > 0)
        {
            targetDevice = devices[0];
            GameObject prefab = controllerPrefabs.Find(controller => controller.name == targetDevice.name);
            if (prefab)
            {
                spawnedHandModel = Instantiate(prefab, transform);
                handAnimator     = spawnedHandModel.GetComponent <Animator>();
            }
            else
            {
                Debug.LogError("Did not find corresponding controller model");
                spawnedHandModel = Instantiate(controllerPrefabs[0], transform);
                handAnimator     = spawnedHandModel.GetComponent <Animator>();
            }
        }
        //spawnedHandModel = Instantiate(controllerPrefabs[0], transform);
        //handAnimator = spawnedHandModel.GetComponent<Animator>();
    }
Exemplo n.º 10
0
        void OnEnable()
        {
            WebXRManager.OnControllerUpdate += OnControllerUpdate;
            WebXRManager.OnHandUpdate       += OnHandUpdateInternal;
            WebXRManager.OnHeadsetUpdate    += OnHeadsetUpdate;
            SetControllerActive(false);
            SetHandActive(false);
#if UNITY_EDITOR || !UNITY_WEBGL
            switch (hand)
            {
            case WebXRControllerHand.LEFT:
                xrHand = InputDeviceCharacteristics.Controller | InputDeviceCharacteristics.Left;
                break;

            case WebXRControllerHand.RIGHT:
                xrHand = InputDeviceCharacteristics.Controller | InputDeviceCharacteristics.Right;
                break;
            }

            List <InputDevice> allDevices = new List <InputDevice>();
            InputDevices.GetDevicesWithCharacteristics(xrHand, allDevices);
            foreach (InputDevice device in allDevices)
            {
                HandleInputDevicesConnected(device);
            }

            InputDevices.deviceConnected    += HandleInputDevicesConnected;
            InputDevices.deviceDisconnected += HandleInputDevicesDisconnected;
#endif
        }
Exemplo n.º 11
0
    // Start is called before the first frame update
    void Start()
    {
        //Get the controllers
        List <InputDevice>         devices_right             = new List <InputDevice>();
        List <InputDevice>         devices_left              = new List <InputDevice>();
        InputDeviceCharacteristics ControllerCharacteristics = InputDeviceCharacteristics.Controller | InputDeviceCharacteristics.Right;

        InputDevices.GetDevicesWithCharacteristics(ControllerCharacteristics, devices_right);
        rightController           = devices_right[0];
        ControllerCharacteristics = InputDeviceCharacteristics.Controller | InputDeviceCharacteristics.Left;
        InputDevices.GetDevicesWithCharacteristics(ControllerCharacteristics, devices_left);
        leftController = devices_left[0];

        //Instantiate de selection bubble
        sphere_rendered = Instantiate(sphere, transform.position, Quaternion.identity);

        //Instantiate the snow globe
        snowGlobe = Instantiate(snowglobe_prefab);
        snowGlobe.transform.localScale = new Vector3(0.3f, 0.3f, 0.3f);

        //Instantitate Collider Representation
        collider_visual = Instantiate(colliderVis_prefab, transform);
        collider_visual.transform.position = new Vector3(transform.position.x - 0.008f, transform.position.y - 0.0024f, transform.position.z + 0.0304f);
        collider_visual.SetActive(true);
    }
Exemplo n.º 12
0
    // Start is called before the first frame update
    void Start()
    {
        List <InputDevice>         devices = new List <InputDevice>();
        InputDeviceCharacteristics rightControllerCharacteristics = InputDeviceCharacteristics.Right | InputDeviceCharacteristics.Controller;

        InputDevices.GetDevicesWithCharacteristics(rightControllerCharacteristics, devices);

        foreach (var item in devices)
        {
            //Log the movement
            // Debug.Log(item.name + item.characteristics);
        }

        //Changes Model Based On VR HeadSet Used
        if (devices.Count > 0)
        {
            targetDevice = devices[0];
            GameObject prefab = controllerPrefabs.Find(controller => controller.name == targetDevice.name);
            if (prefab)
            {
                spawnedController = Instantiate(prefab, transform);
            }
            else
            {
                //If we cant find the model, let the console know so we can change the naming.
                UnityEngine.Debug.Log("Could Not Find Right Model");
            }
        }
    }
Exemplo n.º 13
0
    // Start is called before the first frame update
    void Start()
    {
        List <InputDevice>         devices = new List <InputDevice>();
        InputDeviceCharacteristics rightControllerCharacteristics = InputDeviceCharacteristics.Right | InputDeviceCharacteristics.Controller;

        InputDevices.GetDevicesWithCharacteristics(controllerCharacteristics, devices);

        foreach (var item in devices)
        {
            Debug.Log(item.name + item.characteristics);
        }

        if (devices.Count > 0)
        {
            targetDevice = devices[0];
            GameObject prefab = controllerPrefabs.Find(controller => controller.name == targetDevice.name);
            if (prefab)
            {
                spawnedController = Instantiate(prefab, transform);
            }
            else
            {
                Debug.Log("Your controller doesnt exist in the system because it's shit m8");
                spawnedHandModel = Instantiate(controllerPrefabs[0], transform);
            }

            spawnedHandModel = Instantiate(handModelPrefab, transform);
            handAnimaor      = spawnedHandModel.GetComponent <Animator>();
        }
    }
Exemplo n.º 14
0
        public static void GetDevicesWithCharacteristics(InputDeviceCharacteristics desiredCharacteristics, List <InputDevice> inputDevices)
        {
            bool flag = inputDevices == null;

            if (flag)
            {
                throw new ArgumentNullException("inputDevices");
            }
            bool flag2 = InputDevices.s_InputDeviceList == null;

            if (flag2)
            {
                InputDevices.s_InputDeviceList = new List <InputDevice>();
            }
            InputDevices.GetDevices_Internal(InputDevices.s_InputDeviceList);
            inputDevices.Clear();
            foreach (InputDevice current in InputDevices.s_InputDeviceList)
            {
                bool flag3 = (current.characteristics & desiredCharacteristics) == desiredCharacteristics;
                if (flag3)
                {
                    inputDevices.Add(current);
                }
            }
        }
    // Start is called before the first frame update
    void Start()
    {
        // InputDevices.GetDevices(devices);
        List <InputDevice>         devices = new List <InputDevice>();
        InputDeviceCharacteristics rcc     = InputDeviceCharacteristics.Right | InputDeviceCharacteristics.Controller;

        InputDevices.GetDevicesWithCharacteristics(rcc, devices);

        foreach (var item in devices)
        {
            Debug.Log(item.name + item.characteristics);
        }


        if (devices.Count > 0)
        {
            targetDevice = devices[0];
            GameObject prefab = controllerPrefabs.Find(controller => controller.name == targetDevice.name);
            if (prefab)
            {
                spawnedController = Instantiate(prefab, transform);
            }
            else
            {
                Debug.Log("Did not find corresponding contorller model");
                spawnedController = Instantiate(controllerPrefabs[0], transform);
            }
        }
    }
Exemplo n.º 16
0
 public UnityXRDevice(string id, bool isConnected, bool isTracked, InputDeviceCharacteristics characteristics)
 {
     this.id              = id;
     this.isConnected     = isConnected;
     this.isTracked       = isTracked;
     this.characteristics = characteristics;
 }
    public void ChangeUIRaycaster(GameSettings settings)
    {
        if (settings.CurrentHand == PreferredHand.Left)
        {
            //Debug.Log("Setting left camera!");
            graphicRaycastCameras[2].gameObject.SetActive(false);
            graphicRaycastCameras[1].gameObject.SetActive(true);
            graphicRaycastCamera = graphicRaycastCameras[1];
            graphicRaycastCamera.GetComponent <UIRaycaster>().Activate();
            device = InputDeviceCharacteristics.Left;
        }
        else if (settings.CurrentHand == PreferredHand.Right)
        {
            //Debug.Log("Setting right camera!");
            graphicRaycastCameras[1].gameObject.SetActive(false);
            graphicRaycastCameras[2].gameObject.SetActive(true);
            graphicRaycastCamera = graphicRaycastCameras[2];
            graphicRaycastCamera.GetComponent <UIRaycaster>().Activate();
            device = InputDeviceCharacteristics.Right;
        }
        else if (settings.CurrentHand == PreferredHand.Hmd)
        {
            graphicRaycastCameras[1].gameObject.SetActive(false);
            graphicRaycastCameras[2].gameObject.SetActive(false);
            graphicRaycastCamera = graphicRaycastCameras[0];
            device = InputDeviceCharacteristics.HeadMounted;
        }

        Debug.Log(this + " Changed raycast camera : " + device + ", " + graphicRaycastCamera.gameObject.name);
    }
Exemplo n.º 18
0
        /// <summary>
        /// Gets the XR InputDevice and sets the correct model to display.
        /// This is where a controller is detected and initialized.
        /// </summary>
        /// <returns>True if successful</returns>
        private bool InitializeController(bool isRight, InputDeviceCharacteristics characteristics,
                                          out InputDevice inputDevice,
                                          GameObject handPrefab,
                                          XRController modelParent, out Animator handAnimator, out UiInputHints inputHints,
                                          out XrBrush brush)
        {
            var devices = new List <InputDevice>();

            InputDevices.GetDevicesWithCharacteristics(characteristics, devices);

            foreach (var item in devices)
            {
                Debug.Log($"Detected {item.name}: {item.characteristics}");
            }

            handAnimator = null;
            if (devices.Count > 0)
            {
                inputDevice = devices[0];

                var deviceName = inputDevice.name;
                var prefab     = useHands ? handPrefab : controllerPrefabs.Find(p => deviceName.StartsWith(p.name));

                if (!prefab)
                {
                    //TODO: find correct names for Rift CV1 and Quest
                    Debug.LogWarning(
                        $"Could not find controller model with name {deviceName}, using default controllers.");
                    prefab = controllerPrefabs[isRight ? 1 : 0];
                }

                var go = Instantiate(prefab, modelParent.modelTransform);
                if (useHands)
                {
                    handAnimator = go.GetComponent <Animator>();
                }

                inputHints = go.GetComponentInChildren <UiInputHints>();
                inputHints.Initialize();
                if (inputHints)
                {
                    RepaintInputHints(!isRight, isRight);
                }

                brush = go.GetComponentInChildren <XrBrush>();
                if (brush)
                {
                    brush.Initialize(isRight);
                }

                return(true);
            }

            inputDevice = default;
            inputHints  = null;
            brush       = null;
            // Debug.LogWarning("No hand controller found with characteristic: " + c);
            return(false);
        }
 public bool IsCorrectInputDevice(InputDeviceCharacteristics theHand)
 {
     if (device.HasFlag(theHand))
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 20
0
        internal static InputDeviceRole GetDeviceRole(ulong deviceId)
        {
            InputDeviceCharacteristics deviceCharacteristics = InputDevices.GetDeviceCharacteristics(deviceId);
            bool            flag = (deviceCharacteristics & (InputDeviceCharacteristics.HeadMounted | InputDeviceCharacteristics.TrackedDevice)) == (InputDeviceCharacteristics.HeadMounted | InputDeviceCharacteristics.TrackedDevice);
            InputDeviceRole result;

            if (flag)
            {
                result = InputDeviceRole.Generic;
            }
            else
            {
                bool flag2 = (deviceCharacteristics & (InputDeviceCharacteristics.HeldInHand | InputDeviceCharacteristics.TrackedDevice | InputDeviceCharacteristics.Left)) == (InputDeviceCharacteristics.HeldInHand | InputDeviceCharacteristics.TrackedDevice | InputDeviceCharacteristics.Left);
                if (flag2)
                {
                    result = InputDeviceRole.LeftHanded;
                }
                else
                {
                    bool flag3 = (deviceCharacteristics & (InputDeviceCharacteristics.HeldInHand | InputDeviceCharacteristics.TrackedDevice | InputDeviceCharacteristics.Right)) == (InputDeviceCharacteristics.HeldInHand | InputDeviceCharacteristics.TrackedDevice | InputDeviceCharacteristics.Right);
                    if (flag3)
                    {
                        result = InputDeviceRole.RightHanded;
                    }
                    else
                    {
                        bool flag4 = (deviceCharacteristics & InputDeviceCharacteristics.Controller) == InputDeviceCharacteristics.Controller;
                        if (flag4)
                        {
                            result = InputDeviceRole.GameController;
                        }
                        else
                        {
                            bool flag5 = (deviceCharacteristics & (InputDeviceCharacteristics.TrackedDevice | InputDeviceCharacteristics.TrackingReference)) == (InputDeviceCharacteristics.TrackedDevice | InputDeviceCharacteristics.TrackingReference);
                            if (flag5)
                            {
                                result = InputDeviceRole.TrackingReference;
                            }
                            else
                            {
                                bool flag6 = (deviceCharacteristics & InputDeviceCharacteristics.TrackedDevice) == InputDeviceCharacteristics.TrackedDevice;
                                if (flag6)
                                {
                                    result = InputDeviceRole.HardwareTracker;
                                }
                                else
                                {
                                    result = InputDeviceRole.Unknown;
                                }
                            }
                        }
                    }
                }
            }
            return(result);
        }
Exemplo n.º 21
0
    private IEnumerator Init(byte waitFor)
    {
        initAttemptsPool--;
        if (initAttemptsPool > 0)
        {
            yield return(new WaitForSeconds(waitFor));

            if (controller.display && controller.models.Length == 0)
            {
                throw new System.Exception("No controller model to display. Fill controller models into HandController");
            }

            List <InputDevice>         devices = new List <InputDevice>();
            InputDeviceCharacteristics controllerCharacteristics = InputDeviceCharacteristics.Controller | ((controllerNode == ControllerNode.LeftHand) ? InputDeviceCharacteristics.Left : InputDeviceCharacteristics.Right);
            InputDevices.GetDevicesWithCharacteristics(controllerCharacteristics, devices);

            GameObject controllerPrefab = controller.models[0];
            if (devices.Count > 0)
            {
                targetDevice = devices[0];
                GameObject realController = System.Array.Find(controller.models, controller => controller.name == targetDevice.name);
                if (realController)
                {
                    controllerPrefab = realController;
                }
                else
                {
                    Debug.LogWarning("Corresponding controller was not found!");
                }
            }
            else
            {
                Debug.LogError("No input device controller found!");
            }

            if (!targetDevice.isValid)
            {
                StartCoroutine(Init(1)); // try again after a second
            }
            else
            {
                hand.target   = Instantiate(hand.model, transform);
                hand.animator = hand.target.GetComponent <Animator>();

                controller.target  = Instantiate(controllerPrefab, transform);
                controller.display = controllerDisplayRequest;

                SetVisual((controller.display) ? Visual.controller : Visual.hand);
            }
        }
        else
        {
            throw new System.Exception("Controller initialization attempts failed");
        }
        yield break;
    }
Exemplo n.º 22
0
    void Start()
    {
        devices = new List <InputDevice>();
        InputDeviceCharacteristics RConChar = InputDeviceCharacteristics.Right;

        InputDevices.GetDevicesWithCharacteristics(RConChar, devices);
        if (devices.Count > 0)
        {
            targetDev = devices[0];
        }
    }
Exemplo n.º 23
0
    private void OnValidate()
    {
        InputDeviceCharacteristics leftHand  = InputDeviceCharacteristics.Left;
        InputDeviceCharacteristics rightHand = InputDeviceCharacteristics.Right;

        if (!_controllerCharacteristics.HasFlag(leftHand) && !_controllerCharacteristics.HasFlag(rightHand))
        {
            Debug.LogWarning("Accept only one Left or Right" + _controllerCharacteristics);
            _controllerCharacteristics = InputDeviceCharacteristics.None;
        }
    }
Exemplo n.º 24
0
 /// <summary>
 /// If forgot to set InputDeviceCharacteristics inside the editor,
 /// this function autosets the variable by the child index.
 /// 0 == LeftController
 /// 1 == RightController
 /// </summary>
 void CheckHand()
 {
     if (transform.parent.GetChild(0) == transform)
     {
         hand = InputDeviceCharacteristics.Left;
     }
     if (transform.parent.GetChild(1) == transform)
     {
         hand = InputDeviceCharacteristics.Right;
     }
 }
Exemplo n.º 25
0
        public InputDevice?GetDeviceByCharacteristics(InputDeviceCharacteristics characteristics)
        {
            foreach (var device in devices)
            {
                if (device.characteristics == characteristics)
                {
                    return(device);
                }
            }

            return(null);
        }
Exemplo n.º 26
0
 void OnCollisionEnter(Collision col)
 {
     // When target is hit
     if (col.gameObject.tag == "Selectable" & !selection.Contains(col.gameObject))
     {
         selection.Add(col.gameObject);
         List <InputDevice>         devices_right             = new List <InputDevice>();
         InputDeviceCharacteristics ControllerCharacteristics = InputDeviceCharacteristics.Controller | InputDeviceCharacteristics.Right;
         InputDevices.GetDevicesWithCharacteristics(ControllerCharacteristics, devices_right);
         InputDevice rightController = devices_right[0];
         rightController.SendHapticImpulse(0, 1, 0.1f);
     }
 }
Exemplo n.º 27
0
        public void Awake()
        {
            _devices = EVRManager.Instance.GetModule <EVRDevices>();

            if (side == Side.Left)
            {
                _characteristics |= InputDeviceCharacteristics.Left;
            }
            else
            {
                _characteristics |= InputDeviceCharacteristics.Right;
            }
        }
Exemplo n.º 28
0
    void Start()
    {
        devicesR = new List <InputDevice>();
        devicesL = new List <InputDevice>();
        InputDeviceCharacteristics RConChar = InputDeviceCharacteristics.Right;
        InputDeviceCharacteristics LConChar = InputDeviceCharacteristics.Left;

        InputDevices.GetDevicesWithCharacteristics(RConChar, devicesR);
        InputDevices.GetDevicesWithCharacteristics(LConChar, devicesL);
        RDev = devicesR[0];
        LDev = devicesL[0];
        SetHandMat();
    }
Exemplo n.º 29
0
    void Start()
    {
        m_RightLineVisual         = RightTeleportInteractor.GetComponent <XRInteractorLineVisual>();
        m_RightLineVisual.enabled = false;

        m_LeftLineVisual         = LeftTeleportInteractor.GetComponent <XRInteractorLineVisual>();
        m_LeftLineVisual.enabled = false;

        m_RightController = RightTeleportInteractor.GetComponent <XRReleaseController>();
        m_LeftController  = LeftTeleportInteractor.GetComponent <XRReleaseController>();

        m_OriginalRightMask = RightTeleportInteractor.interactionLayerMask;
        m_OriginalLeftMask  = LeftTeleportInteractor.interactionLayerMask;

        if (!DisableSetupForDebug)
        {
            transform.position = StartingPosition.position;
            transform.rotation = StartingPosition.rotation;

            if (TeleporterParent != null)
            {
                TeleporterParent.SetActive(false);
            }
        }

        InputDeviceCharacteristics leftTrackedControllerFilter = InputDeviceCharacteristics.HeldInHand | InputDeviceCharacteristics.Left;
        List <InputDevice>         foundControllers            = new List <InputDevice>();

        InputDevices.GetDevicesWithCharacteristics(leftTrackedControllerFilter, foundControllers);

        if (foundControllers.Count > 0)
        {
            m_LeftInputDevice = foundControllers[0];
        }


        InputDeviceCharacteristics rightTrackedControllerFilter = InputDeviceCharacteristics.HeldInHand | InputDeviceCharacteristics.Right;

        InputDevices.GetDevicesWithCharacteristics(rightTrackedControllerFilter, foundControllers);

        if (foundControllers.Count > 0)
        {
            m_RightInputDevice = foundControllers[0];
        }

        if (m_Rig.TrackingOriginMode != TrackingOriginModeFlags.Floor)
        {
            m_Rig.cameraYOffset = 1.8f;
        }
    }
Exemplo n.º 30
0
    // Start is called before the first frame update
    void Start()
    {
        List <InputDevice>         devices         = new List <InputDevice>();
        InputDeviceCharacteristics rightController = InputDeviceCharacteristics.Right | InputDeviceCharacteristics.Controller;

        InputDevices.GetDevicesWithCharacteristics(rightController, devices);

        if (devices.Count > 0)
        {
            device = devices[0];
        }

        Instantiate(swordPrefab, transform);
    }