Ejemplo n.º 1
0
    private void GetControllerHandle()
    {
        IControllerHandle ControllerHandle = HvrApi.GetControllerHandle();

        if (ControllerHandle == null)
        {
            HVRLogCore.LOGW(TAG, "ControllerHandle is null");
            return;
        }
        int[] indices = ControllerHandle.GetValidIndices();
        if (Application.platform == RuntimePlatform.Android)
        {
            if (gameObject.name.Equals("HVRLeftController"))
            {
                HVRLogCore.LOGI(TAG, "current is left controller");
                if (indices.Length >= 3)
                {
                    m_LeftController = ControllerHandle.GetControllerByIndex(indices[2]);
                }
                m_Controller        = m_LeftController;
                m_IsRightController = false;
                if (m_LeftController == null || !m_LeftController.IsAvailable())
                {
                    HVRLogCore.LOGI(TAG, "left controller is not available");
                    gameObject.SetActive(false);
                }
            }
            else
            {
                HVRLogCore.LOGI(TAG, "current is right controller");
                m_RightController   = ControllerHandle.GetControllerByIndex(indices[1]);
                m_Controller        = m_RightController;
                m_IsRightController = true;
            }
        }
        else
        {
            m_Controller      = ControllerHandle.GetControllerByIndex(indices[1]);
            m_RightController = m_Controller;
            m_LeftController  = m_Controller;
        }
    }
Ejemplo n.º 2
0
 private void ControllerPositionInit()
 {
     if (HVRArmModel.Instance != null)
     {
         HVRArmModel.Instance.OnInit(); //Controller position initialization
     }
     m_HandleInitPosition = HVRArmModel.m_DefaultControllerPosition + new Vector3(0.0f, 0.0f, HVRArmModel.m_Radius);
     if (HVRControllerManager.m_IsLeftHandMode || gameObject.name.Equals("HVRLeftController"))
     {
         HVRLogCore.LOGW(TAG, "m_HandleInitPosition.x *= -1");
         m_HandleInitPosition.x *= -1;
     }
     else
     {
         HVRLogCore.LOGW(TAG, "m_HandleInitPosition.x *= 1");
         m_HandleInitPosition.x *= 1;
     }
     transform.position = m_HandleInitPosition + HVRLayoutCore.m_CamCtrObj.position;
     m_InitDistance     = Vector3.Distance(transform.position, HVRLayoutCore.m_CamCtrObj.position);
 }
Ejemplo n.º 3
0
    void Update()
    {
        if (m_Controller == null)
        {
            HVRLogCore.LOGW(TAG, "m_Controller is null");
            return;
        }
        bool isControllerDataValid = false;

        ControllerStatus controllerStatus = m_Controller.GetControllerStatus();

        switch (controllerStatus)
        {
        case ControllerStatus.ControllerStatusDisconnected:
            HVRLogCore.LOGW(TAG, "Controller Disconnected");
            break;

        case ControllerStatus.ControllerStatusScanning:
            HVRLogCore.LOGI(TAG, "Controller Scanning");
            break;

        case ControllerStatus.ControllerStatusConnecting:
            HVRLogCore.LOGI(TAG, "Controller Connecting");
            break;

        case ControllerStatus.ControllerStatusConnected:
            isControllerDataValid = true;
            break;

        case ControllerStatus.ControllerStatusError:
            break;
        }

        if (!isControllerDataValid)
        {
            return;
        }
        UpdateControllerMode();
        UpdateControllerPos();
    }