Пример #1
0
    private void UpdateController()
    {
        controllerProvider.ReadState(controllerState);

        // If a headset recenter was requested, do it now.
        if (controllerState.headsetRecenterRequested)
        {
#if UNITY_EDITOR
            GvrViewer sdk = GvrViewer.Instance;
            if (sdk)
            {
                sdk.Recenter();
            }
            else
            {
                for (int i = 0; i < Camera.allCameras.Length; i++)
                {
                    Camera cam = Camera.allCameras[i];
                    // Do not reset pitch, which is how it works on the device.
                    cam.transform.rotation = Quaternion.Euler(cam.transform.rotation.eulerAngles.x, 0, 0);
                }
            }
#else
            InputTracking.Recenter();
#endif  // UNITY_EDITOR
        }
    }
Пример #2
0
    internal void Update()
    {
        if (lastUpdatedFrameCount != Time.frameCount)
        {
            if (!valid)
            {
                Debug.LogError("Using an invalid GvrControllerInputDevice. Please acquire a new one from GvrControllerInput.GetDevice().");
                return;
            }
            // The controller state must be updated prior to any function using the
            // controller API to ensure the state is consistent throughout a frame.
            lastUpdatedFrameCount = Time.frameCount;

            GvrConnectionState oldState = State;

            controllerProvider.ReadState(controllerState, controllerId);
            UpdateTouchPosCentered();

#if UNITY_EDITOR
            if (IsDominantHand)
            {
                // Make sure the EditorEmulator is updated immediately.
                if (GvrEditorEmulator.Instance != null)
                {
                    GvrEditorEmulator.Instance.UpdateEditorEmulation();
                }
            }
#endif  // UNITY_EDITOR

            if (OnStateChanged != null && State != oldState)
            {
                OnStateChanged(State, oldState);
            }
        }
    }
    void Update()
    {
        if (lastUpdatedFrameCount != Time.frameCount)
        {
            // The controller state must be updated prior to any function using the
            // controller API to ensure the state is consistent throughout a frame.
            lastUpdatedFrameCount = Time.frameCount;

            GvrConnectionState oldState = State;

            controllerProvider.ReadState(controllerState);
            UpdateTouchPosCentered();

            if (OnStateChanged != null && State != oldState)
            {
                OnStateChanged(State, oldState);
            }

            if (OnControllerInputUpdated != null)
            {
                OnControllerInputUpdated();
            }

            if (OnPostControllerInputUpdated != null)
            {
                OnPostControllerInputUpdated();
            }
        }
    }
Пример #4
0
    private void UpdateController()
    {
        controllerProvider.ReadState(controllerStateLeft, 0);
        controllerProvider.ReadState(controllerStateRight, 1);

#if UNITY_EDITOR
        // If a headset recenter was requested, do it now.
        if (controllerStateLeft.recentered)
        {
            for (int i = 0; i < Camera.allCameras.Length; i++)
            {
                Camera cam = Camera.allCameras[i];
                // Do not reset pitch, which is how it works on the device.
                cam.transform.localRotation = Quaternion.Euler(cam.transform.localRotation.eulerAngles.x, 0, 0);
            }
        }
#endif  // UNITY_EDITOR
    }
Пример #5
0
        private void UpdateController()
        {
            controllerProvider.ReadState(controllerState, isRightController);

            if (controllerState.headsetRecenterRequested)
            {
                if (HeadsetRecenter != null)
                {
                    HeadsetRecenter();
                }
                controllerState.headsetRecenterRequested = false;
            }
        }
Пример #6
0
    private void UpdateController()
    {
        controllerProvider.ReadState(controllerState);

        // If the controller was recentered, also recenter the headset.
        if (controllerState.recentered)
        {
            GvrViewer sdk = GvrViewer.Instance;
            if (sdk)
            {
                sdk.Recenter();
            }
        }
    }
Пример #7
0
        public override int GetInputState(ref XDevicePlugin.ControllerState state)
        {
            if (m_ControllerProvider == null)
            {
                return(-1);
            }
            m_ControllerProvider.ReadState(m_State);
            //
            state.axes[(int)ControllerAxis.PrimaryThumbX] = (m_State.touchPos.x - .5f) * 2f;
            state.axes[(int)ControllerAxis.PrimaryThumbY] = (m_State.touchPos.y - .5f) * -2f;
            //
            state.buttons = 0;
            if (m_State.isTouching)
            {
                state.buttons |= (uint)DaydreamButton.Touch;
            }
            if (m_State.clickButtonState)
            {
                state.buttons |= (uint)DaydreamButton.Click;
            }
            if (m_State.appButtonState)
            {
                state.buttons |= (uint)DaydreamButton.App;
            }
            if (m_State.recentering)
            {
                state.buttons |= (uint)DaydreamButton.Home;
            }
            //
            int i;

            i = 4; while (i-- > 0)
            {
                state.rotation[i] = m_State.orientation[i];
            }
            i = 3; while (i-- > 0)
            {
                state.accelerometer[i] = m_State.accel[i];
            }
            i = 3; while (i-- > 0)
            {
                state.gyroscope[i] = m_State.gyro[i];
            }
            //
            return(0);
        }
Пример #8
0
    private void UpdateController()
    {
        controllerProvider.ReadState(controllerState);

        // If a headset recenter was requested, do it now.
        if (controllerState.headsetRecenterRequested)
        {
#if UNITY_EDITOR
            GvrViewer sdk = GvrViewer.Instance;
            if (sdk)
            {
                sdk.Recenter();
            }
#else
            InputTracking.Recenter();
#endif  // UNITY_EDITOR
        }
    }
Пример #9
0
    private void UpdateController()
    {
        controllerProvider.ReadState(controllerState);

        // If the controller was recentered, also recenter the headset.
        if (controllerState.recentered)
        {
 #if UNITY_EDITOR
            GvrViewer sdk = GvrViewer.Instance;
            if (sdk)
            {
                sdk.Recenter();
            }
#else
            InputTracking.Recenter();
#endif  // UNITY_EDITOR
        }
    }
Пример #10
0
    void Update()
    {
        //datld: add double click check


        if (lastUpdatedFrameCount != Time.frameCount)
        {
            // The controller state must be updated prior to any function using the
            // controller API to ensure the state is consistent throughout a frame.
            lastUpdatedFrameCount = Time.frameCount;

            GvrConnectionState oldState = State;

            controllerProvider.ReadState(controllerState);
            UpdateTouchPosCentered();

#if UNITY_EDITOR
            // Make sure the EditorEmulator is updated immediately.
            if (GvrEditorEmulator.Instance != null)
            {
                GvrEditorEmulator.Instance.UpdateEditorEmulation();
            }
#endif  // UNITY_EDITOR

            if (OnStateChanged != null && State != oldState)
            {
                OnStateChanged(State, oldState);
            }

            if (OnControllerInputUpdated != null)
            {
                OnControllerInputUpdated();
            }

            if (OnPostControllerInputUpdated != null)
            {
                OnPostControllerInputUpdated();
            }
        }
    }
    //private ControllerState m_PreviousState = new ControllerState();
    void Update()
    {
        if (lastUpdatedFrameCount != Time.frameCount)
        {
            SVR.AtwAPI.BeginTrace("input-update");
            // The controller state must be updated prior to any function using the
            // controller API to ensure the state is consistent throughout a frame.
            lastUpdatedFrameCount = Time.frameCount;

            Svr.Controller.SvrController.CallBegin();
            //GvrConnectionState oldState = State;
            SvrControllerState oldSvrState = SvrState;

            //UnityEngine.Profiling.Profiler.BeginSample("1");
            if (controllerProvider != null)
            {
                controllerProvider.ReadState(controllerStateRight);
                controllerProvider.ReadState(controllerStateLeft);
                controllerProvider.ReadState(controllerStateHead);
                //Svr.SvrLog.Log("controllerState:" + controllerStateRight.connectionState + "," + controllerStateLeft.connectionState + "," + controllerStateHead.connectionState);
            }

            //UnityEngine.Profiling.Profiler.EndSample();
            //UnityEngine.Profiling.Profiler.BeginSample("2");
            UpdateTouchPosCentered();



            mSvrState = ReadSvrContollerState();

#if UNITY_EDITOR
            // Make sure the EditorEmulator is updated immediately.
            if (GvrEditorEmulator.Instance != null)
            {
                GvrEditorEmulator.Instance.UpdateEditorEmulation();
            }
#endif  // UNITY_EDITOR

            //if (OnStateChanged != null && State != oldState)
            //{
            //    OnStateChanged(State, oldState);
            //}
            //UnityEngine.Profiling.Profiler.EndSample();
            //UnityEngine.Profiling.Profiler.BeginSample("3");
            if (OnConterollerChanged != null && SvrState != oldSvrState)
            {
                OnConterollerChanged(SvrState, oldSvrState);
                //if ((SvrState & (SvrControllerState.NoloLeftContoller | SvrControllerState.NoloRightContoller)) != 0)
                //{
                //    //Have Nolo
                //    Svr.SvrSetting.SetNoloConnected(true);
                //}
                //else
                //{
                //    //Nolo DisConnected
                //    Svr.SvrSetting.SetNoloConnected(false);
                //}
            }

            if (OnControllerInputUpdated != null)
            {
                OnControllerInputUpdated();
            }

            if (OnPostControllerInputUpdated != null)
            {
                OnPostControllerInputUpdated();
            }
            //UnityEngine.Profiling.Profiler.EndSample();

            SVR.AtwAPI.EndTrace();
        }
    }