/// <summary>
    /// If the given controller is in the opposite hand set the Touch controller's active object
    /// to the opposite-hand-controller's active object when it changes
    /// </summary>
    /// <param name="controller">controller to potentially link</param>
    private void AttemptToCreateActiveObjectLink(Controller controller)
    {
        Debug.Log("Controller added: " + controller.name);

        // Ignore touch controllers
        if (controller is OculusTouchController)
        {
            return;
        }

        // Get the oculus touch controller
        // We want the controller in the opposite hand
        OculusTouchController touchController = null;

        if (controller.Location == ControllerLocation.LeftHand)
        {
            touchController = RightController;
        }
        if (controller.Location == ControllerLocation.RightHand)
        {
            touchController = LeftController;
        }

        // If this controller is in one of the hands link it's active object
        if (touchController != null)
        {
            Debug.Log(string.Format("Listening for active object changes on {0} for {1}", controller.name, touchController.name));
            controller.PostActiveObjectsChangedEvent += (oldActiveObjects, newActiveObjects) => { touchController.ActiveObjects = newActiveObjects; };
        }
    }
        public void OculusTouchControllerUpdateTest()
        {
            OculusTouchController leftController  = new OculusTouchController(TrackingState.NotTracked, Utilities.Handedness.Left);
            OculusTouchController rightController = new OculusTouchController(TrackingState.NotTracked, Utilities.Handedness.Right);

            TestGenericJoystickControllerUpdate(leftController);
            TestGenericJoystickControllerUpdate(rightController);
        }
Exemplo n.º 3
0
 void OnDeviceChanged(UnityEngine.InputSystem.InputDevice device, InputDeviceChange change)
 {
     if (change == InputDeviceChange.Added)
     {
         leftTouchController  = (OculusTouchController)OculusTouchController.leftHand;
         rightTouchController = (OculusTouchController)OculusTouchController.rightHand;
         hmd = InputSystem.GetDevice <OculusHMD>();
     }
 }
    /// <summary>
    /// Make sure the controller's location is correct
    /// </summary>
    /// <param name="controller">controller to check</param>
    private void EnsureTouchControllerLocationIsCorrect(OculusTouchController controller)
    {
        if (controller == null)
        {
            return;
        }

        if (controller.Location != ControllerLocation.LeftHand && controller.Location != ControllerLocation.RightHand)
        {
            throw new MissingReferenceException("Oculus touch controllers should be in either the left or right hand");
        }
    }
Exemplo n.º 5
0
        public virtual IEnumerator Start()
        {
            hmd = InputSystem.GetDevice <OculusHMD>();
            leftTouchController  = (OculusTouchController)InputSystem.GetDevice("OculusTouchControllerLeft");
            rightTouchController = (OculusTouchController)InputSystem.GetDevice("OculusTouchControllerRight");
            // inputter = ReInput.players.GetPlayer("Player");
            yield return(new WaitForEndOfFrame());

            yield return(new WaitForEndOfFrame());

            hmd = InputSystem.GetDevice <OculusHMD>();
            leftTouchController  = (OculusTouchController)InputSystem.GetDevice("OculusTouchControllerLeft");
            rightTouchController = (OculusTouchController)InputSystem.GetDevice("OculusTouchControllerRight");
        }
Exemplo n.º 6
0
        void HandleHandOrientation(Transform handTrs, OculusTouchController oculusTouchController, Vector3 initLocalPosition)
        {
            if (oculusTouchController != null)
            {
                handTrs.localPosition = Vector3.ClampMagnitude(oculusTouchController.devicePosition.ReadValue(), maxHandDistance);
                handTrs.localRotation = oculusTouchController.deviceRotation.ReadValue();
            }
            else
            {
                handTrs.localPosition = initLocalPosition;
                handTrs.localRotation = Quaternion.identity;
            }
            Ray        ray = new Ray(trs.position, handTrs.position - trs.position);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, (handTrs.position - trs.position).magnitude, whatICollideWith))
            {
                handTrs.position = hit.point;
            }
        }