コード例 #1
0
 private void SetSystemKey()
 {
     if (controllerlink.switchHomeKey)
     {
         if (Controller.UPvr_GetKeyLongPressed(0, Pvr_KeyCode.HOME) || Controller.UPvr_GetKeyLongPressed(1, Pvr_KeyCode.HOME))
         {
             if (Pvr_UnitySDKManager.SDK.HmdOnlyrot)
             {
                 Pvr_UnitySDKManager.pvr_UnitySDKSensor.OptionalResetUnitySDKSensor(1, 0);
             }
             else
             {
                 if (Pvr_UnitySDKManager.SDK.safeToast != null)
                 {
                     if (controllerlink.trackingmode == 4)
                     {
                         Pvr_UnitySDKManager.pvr_UnitySDKSensor.OptionalResetUnitySDKSensor(1, 1);
                     }
                     else
                     {
                         if (Pvr_UnitySDKManager.SDK.safeToast.activeSelf)
                         {
                             Pvr_UnitySDKManager.SDK.safeToast.SetActive(false);
                             Pvr_UnitySDKManager.pvr_UnitySDKSensor.OptionalResetUnitySDKSensor(1, 1);
                         }
                         else
                         {
                             Pvr_UnitySDKManager.pvr_UnitySDKSensor.OptionalResetUnitySDKSensor(1, 0);
                         }
                         controllerlink.ResetHeadSensorForController();
                     }
                 }
                 else
                 {
                     if (controllerlink.trackingmode == 0 || controllerlink.trackingmode == 1)
                     {
                         Pvr_UnitySDKManager.pvr_UnitySDKSensor.ResetUnitySDKSensor();
                     }
                 }
             }
             if (Pvr_UnitySDKManager.SDK.ControllerOnlyrot || controllerlink.controller0Connected && Controller.UPvr_GetControllerPOS(0).Equals(Vector3.zero) || controllerlink.controller1Connected && Controller.UPvr_GetControllerPOS(1).Equals(Vector3.zero))
             {
                 if (Controller.UPvr_GetKeyLongPressed(0, Pvr_KeyCode.HOME))
                 {
                     ResetController(0);
                 }
                 if (Controller.UPvr_GetKeyLongPressed(1, Pvr_KeyCode.HOME))
                 {
                     ResetController(1);
                 }
             }
         }
     }
     if (controllerlink.picoDevice)
     {
         if (controllerlink.switchHomeKey)
         {
             if (Controller.UPvr_GetKeyClick(0, Pvr_KeyCode.HOME) || Controller.UPvr_GetKeyClick(1, Pvr_KeyCode.HOME) && !stopConnect)
             {
                 controllerlink.RebackToLauncher();
             }
         }
         if (Controller.UPvr_GetKeyClick(0, Pvr_KeyCode.VOLUMEUP) || Controller.UPvr_GetKeyClick(1, Pvr_KeyCode.VOLUMEUP))
         {
             controllerlink.TurnUpVolume();
         }
         if (Controller.UPvr_GetKeyClick(0, Pvr_KeyCode.VOLUMEDOWN) || Controller.UPvr_GetKeyClick(1, Pvr_KeyCode.VOLUMEDOWN))
         {
             controllerlink.TurnDownVolume();
         }
         if (!Controller.UPvr_GetKey(0, Pvr_KeyCode.VOLUMEUP) && !Controller.UPvr_GetKey(0, Pvr_KeyCode.VOLUMEDOWN) && !Controller.UPvr_GetKey(1, Pvr_KeyCode.VOLUMEUP) && !Controller.UPvr_GetKey(1, Pvr_KeyCode.VOLUMEDOWN))
         {
             cTime = 1.0f;
         }
         if (Controller.UPvr_GetKey(0, Pvr_KeyCode.VOLUMEUP) || Controller.UPvr_GetKey(1, Pvr_KeyCode.VOLUMEUP))
         {
             cTime -= Time.deltaTime;
             if (cTime <= 0)
             {
                 cTime = 0.2f;
                 controllerlink.TurnUpVolume();
             }
         }
         if (!Controller.UPvr_GetKey(0, Pvr_KeyCode.HOME) && !Controller.UPvr_GetKey(1, Pvr_KeyCode.HOME) && (Controller.UPvr_GetKey(0, Pvr_KeyCode.VOLUMEDOWN) || Controller.UPvr_GetKey(1, Pvr_KeyCode.VOLUMEDOWN)))
         {
             cTime -= Time.deltaTime;
             if (cTime <= 0)
             {
                 cTime = 0.2f;
                 controllerlink.TurnDownVolume();
             }
         }
     }
     if (controllerlink.goblinserviceStarted)
     {
         if (Controller.UPvr_GetKey(0, Pvr_KeyCode.HOME) && Controller.UPvr_GetKey(0, Pvr_KeyCode.VOLUMEDOWN) && !stopConnect)
         {
             disConnectTime += Time.deltaTime;
             if (disConnectTime > 1.0)
             {
                 DisConnectBLE();
                 controllerlink.hummingBirdMac = "";
                 stopConnect    = true;
                 disConnectTime = 0;
             }
         }
     }
 }
コード例 #2
0
 private void SetSystemKey()
 {
     if (Pvr_UnitySDKManager.SDK.HeadDofNum == HeadDofNum.ThreeDof || Pvr_UnitySDKManager.SDK.SixDofRecenter)
     {
         if (Controller.UPvr_GetKeyLongPressed(0, Pvr_KeyCode.HOME))
         {
             Pvr_UnitySDKManager.pvr_UnitySDKSensor.OptionalResetUnitySDKSensor(1, 0);
             if (Pvr_UnitySDKManager.SDK.HeadDofNum == HeadDofNum.SixDof && Pvr_UnitySDKManager.SDK.SixDofRecenter)
             {
                 controllerlink.ResetHeadSensorForController();
             }
             ResetController(0);
         }
         if (Controller.UPvr_GetKeyLongPressed(1, Pvr_KeyCode.HOME))
         {
             Pvr_UnitySDKManager.pvr_UnitySDKSensor.OptionalResetUnitySDKSensor(1, 0);
             if (Pvr_UnitySDKManager.SDK.HeadDofNum == HeadDofNum.SixDof && Pvr_UnitySDKManager.SDK.SixDofRecenter)
             {
                 controllerlink.ResetHeadSensorForController();
             }
             ResetController(1);
         }
     }
     else
     {
         if (Controller.UPvr_GetKeyLongPressed(0, Pvr_KeyCode.HOME))
         {
             ResetController(0);
         }
         if (Controller.UPvr_GetKeyLongPressed(1, Pvr_KeyCode.HOME))
         {
             ResetController(1);
         }
     }
     //pico device支持的系统按键
     if (controllerlink.picoDevice)
     {
         if (!longPressclock && (Controller.UPvr_GetKeyUp(0, Pvr_KeyCode.HOME) || Controller.UPvr_GetKeyUp(1, Pvr_KeyCode.HOME)) && !stopConnect)
         {
             controllerlink.RebackToLauncher();
         }
         if (!longPressclock && (Controller.UPvr_GetKeyUp(0, Pvr_KeyCode.VOLUMEUP) || Controller.UPvr_GetKeyUp(1, Pvr_KeyCode.VOLUMEUP)))
         {
             controllerlink.TurnUpVolume();
         }
         if (!longPressclock && (Controller.UPvr_GetKeyUp(0, Pvr_KeyCode.VOLUMEDOWN) || Controller.UPvr_GetKeyUp(1, Pvr_KeyCode.VOLUMEDOWN)))
         {
             controllerlink.TurnDownVolume();
         }
         if (!Controller.UPvr_GetKey(0, Pvr_KeyCode.VOLUMEUP) && !Controller.UPvr_GetKey(0, Pvr_KeyCode.VOLUMEDOWN) && !Controller.UPvr_GetKey(1, Pvr_KeyCode.VOLUMEUP) && !Controller.UPvr_GetKey(1, Pvr_KeyCode.VOLUMEDOWN))
         {
             cTime = 1.0f;
         }
         if (Controller.UPvr_GetKey(0, Pvr_KeyCode.VOLUMEUP) || Controller.UPvr_GetKey(1, Pvr_KeyCode.VOLUMEUP))
         {
             cTime -= Time.deltaTime;
             if (cTime <= 0)
             {
                 cTime = 0.2f;
                 controllerlink.TurnUpVolume();
             }
         }
         if (Controller.UPvr_GetKey(0, Pvr_KeyCode.VOLUMEDOWN) || Controller.UPvr_GetKey(1, Pvr_KeyCode.VOLUMEDOWN))
         {
             cTime -= Time.deltaTime;
             if (cTime <= 0)
             {
                 cTime = 0.2f;
                 controllerlink.TurnDownVolume();
             }
         }
     }
     if (controllerlink.trackingmode == 1 || controllerlink.trackingmode == 0)
     {
         //phone和pico device都支持解绑
         if (Controller.UPvr_GetKey(0, Pvr_KeyCode.HOME) && Controller.UPvr_GetKey(0, Pvr_KeyCode.VOLUMEDOWN) && !stopConnect)
         {
             disConnectTime += Time.deltaTime;
             if (disConnectTime > 1.0)
             {
                 DisConnectBLE();
                 controllerlink.hummingBirdMac = "";
                 stopConnect    = true;
                 disConnectTime = 0;
             }
         }
     }
 }
コード例 #3
0
    private void SetSystemKey()
    {
        if (controllerlink.switchHomeKey)
        {
            if (Pvr_UnitySDKManager.SDK.HeadDofNum == HeadDofNum.ThreeDof || Pvr_UnitySDKManager.SDK.SixDofRecenter)
            {
                if (Controller.UPvr_GetKeyLongPressed(0, Pvr_KeyCode.HOME))
                {
                    if (Pvr_UnitySDKManager.SDK.IsViewerLogicFlow)
                    {
                        Pvr_UnitySDKManager.pvr_UnitySDKSensor.ResetUnitySDKSensorAll();
                    }
                    else
                    {
                        if (Pvr_UnitySDKManager.SDK.safeToast.activeSelf)
                        {
                            Pvr_UnitySDKManager.SDK.safeToast.SetActive(false);
                            Pvr_UnitySDKManager.pvr_UnitySDKSensor.OptionalResetUnitySDKSensor(1, 1);
                        }
                        else
                        {
                            Pvr_UnitySDKManager.pvr_UnitySDKSensor.OptionalResetUnitySDKSensor(1, 0);
                        }
                        if (Pvr_UnitySDKManager.SDK.HeadDofNum == HeadDofNum.SixDof && Pvr_UnitySDKManager.SDK.SixDofRecenter)
                        {
                            controllerlink.ResetHeadSensorForController();
                        }
                    }
                    ResetController(0);
                }
                if (Controller.UPvr_GetKeyLongPressed(1, Pvr_KeyCode.HOME))
                {
                    if (Pvr_UnitySDKManager.SDK.IsViewerLogicFlow)
                    {
                        Pvr_UnitySDKManager.pvr_UnitySDKSensor.ResetUnitySDKSensorAll();
                    }
                    else
                    {
                        if (Pvr_UnitySDKManager.SDK.safeToast.activeSelf)
                        {
                            Pvr_UnitySDKManager.SDK.safeToast.SetActive(false);
                            Pvr_UnitySDKManager.pvr_UnitySDKSensor.OptionalResetUnitySDKSensor(1, 1);
                        }
                        else
                        {
                            Pvr_UnitySDKManager.pvr_UnitySDKSensor.OptionalResetUnitySDKSensor(1, 0);
                        }
                        if (Pvr_UnitySDKManager.SDK.HeadDofNum == HeadDofNum.SixDof && Pvr_UnitySDKManager.SDK.SixDofRecenter)
                        {
                            controllerlink.ResetHeadSensorForController();
                        }
                    }
                    ResetController(1);
                }
            }
            else
            {
                if (Controller.UPvr_GetKeyLongPressed(0, Pvr_KeyCode.HOME))
                {
                    ResetController(0);
                }
                if (Controller.UPvr_GetKeyLongPressed(1, Pvr_KeyCode.HOME))
                {
                    ResetController(1);
                }
            }
        }


        if (controllerlink.picoDevice)
        {
            if (controllerlink.switchHomeKey)
            {
                if (!controllerlink.Controller0.HomeKey.LongPressedClock && Controller.UPvr_GetKeyUp(0, Pvr_KeyCode.HOME) || !controllerlink.Controller1.HomeKey.LongPressedClock && Controller.UPvr_GetKeyUp(1, Pvr_KeyCode.HOME) && !stopConnect)
                {
                    controllerlink.RebackToLauncher();
                }
            }
            if (!controllerlink.Controller0.VolumeUpKey.LongPressedClock && Controller.UPvr_GetKeyUp(0, Pvr_KeyCode.VOLUMEUP) || !controllerlink.Controller1.VolumeUpKey.LongPressedClock && Controller.UPvr_GetKeyUp(1, Pvr_KeyCode.VOLUMEUP))
            {
                controllerlink.TurnUpVolume();
            }
            if (!controllerlink.Controller0.VolumeDownKey.LongPressedClock && Controller.UPvr_GetKeyUp(0, Pvr_KeyCode.VOLUMEDOWN) || !controllerlink.Controller1.VolumeDownKey.LongPressedClock && Controller.UPvr_GetKeyUp(1, Pvr_KeyCode.VOLUMEDOWN))
            {
                controllerlink.TurnDownVolume();
            }
            if (!Controller.UPvr_GetKey(0, Pvr_KeyCode.VOLUMEUP) && !Controller.UPvr_GetKey(0, Pvr_KeyCode.VOLUMEDOWN) && !Controller.UPvr_GetKey(1, Pvr_KeyCode.VOLUMEUP) && !Controller.UPvr_GetKey(1, Pvr_KeyCode.VOLUMEDOWN))
            {
                cTime = 1.0f;
            }
            if (Controller.UPvr_GetKey(0, Pvr_KeyCode.VOLUMEUP) || Controller.UPvr_GetKey(1, Pvr_KeyCode.VOLUMEUP))
            {
                cTime -= Time.deltaTime;
                if (cTime <= 0)
                {
                    cTime = 0.2f;
                    controllerlink.TurnUpVolume();
                }
            }
            if (!Controller.UPvr_GetKey(0, Pvr_KeyCode.HOME) && !Controller.UPvr_GetKey(1, Pvr_KeyCode.HOME) && (Controller.UPvr_GetKey(0, Pvr_KeyCode.VOLUMEDOWN) || Controller.UPvr_GetKey(1, Pvr_KeyCode.VOLUMEDOWN)))
            {
                cTime -= Time.deltaTime;
                if (cTime <= 0)
                {
                    cTime = 0.2f;
                    controllerlink.TurnDownVolume();
                }
            }
        }
        if (controllerlink.goblinserviceStarted)
        {
            if (Controller.UPvr_GetKey(0, Pvr_KeyCode.HOME) && Controller.UPvr_GetKey(0, Pvr_KeyCode.VOLUMEDOWN) && !stopConnect)
            {
                disConnectTime += Time.deltaTime;
                if (disConnectTime > 1.0)
                {
                    DisConnectBLE();
                    controllerlink.hummingBirdMac = "";
                    stopConnect    = true;
                    disConnectTime = 0;
                }
            }
        }
    }
コード例 #4
0
    // Update is called once per frame
    void Update()
    {
        #region AndroidData
#if UNITY_ANDROID
        if (controllerlink.isConnect)
        {
            //手柄转动四元数
            lark2state = controllerlink.GetHBSensorState();
            JsonData Jstate = JsonMapper.ToObject(lark2state);
            lark2w = Convert.ToSingle(Jstate[0].ToString());
            lark2x = Convert.ToSingle(Jstate[1].ToString());
            lark2y = Convert.ToSingle(Jstate[2].ToString());
            lark2z = Convert.ToSingle(Jstate[3].ToString());
            Controller.ControllerQua = new Quaternion(lark2x, lark2y, lark2z, lark2w);

            //lark2手柄键值TouchpadX,TouchpadY,HomeKeyPress,AppKeyPress,ClickKeyPress,VolumeUpKeyPress,VolumeDownKeyPress,BatteryLevel
            lark2key = controllerlink.javaHummingbirdClass.CallStatic <string>("getHBKeyEvent");
            if (enableKeyEvent)
            {
                JsonData JKey = JsonMapper.ToObject(lark2key);
                if (Convert.ToInt16(JKey[0].ToString()) > 0 || Convert.ToInt16(JKey[1].ToString()) > 0)
                {
                    if (Convert.ToInt16(JKey[0].ToString()) == 0)
                    {
                        TouchPadPosition.x = 1;
                    }
                    if (Convert.ToInt16(JKey[1].ToString()) == 0)
                    {
                        TouchPadPosition.y = 1;
                    }
                    TouchPadPosition.x = Convert.ToInt16(JKey[0].ToString());
                    TouchPadPosition.y = Convert.ToInt16(JKey[1].ToString());
                }
                else
                {
                    touchNum++;
                    if (touchNum >= 1)
                    {
                        TouchPadPosition.x = 0;
                        TouchPadPosition.y = 0;
                        touchNum           = 0;
                    }
                }
                Controller.BatteryLevel = Convert.ToInt16(JKey[7].ToString());

                #region base api
                //键值状态
                //Home Key
                if (Convert.ToInt16(JKey[2].ToString()) == 1)
                {
                    if (!HomeKey.state)
                    {
                        HomeKey.pressedDown = true;
                        longPressclock      = false;
                    }
                    else
                    {
                        HomeKey.pressedDown = false;
                    }
                    HomeKey.state = true;
                }
                else
                {
                    if (HomeKey.state)
                    {
                        HomeKey.pressedUp = true;
                    }
                    else
                    {
                        HomeKey.pressedUp = false;
                    }
                    HomeKey.state       = false;
                    HomeKey.pressedDown = false;
                }
                //APP Key
                if (Convert.ToInt16(JKey[3].ToString()) == 1)
                {
                    if (!APPKey.state)
                    {
                        APPKey.pressedDown = true;
                        longPressclock     = false;
                    }
                    else
                    {
                        APPKey.pressedDown = false;
                    }
                    APPKey.state = true;
                }
                else
                {
                    if (APPKey.state)
                    {
                        APPKey.pressedUp = true;
                    }
                    else
                    {
                        APPKey.pressedUp = false;
                    }
                    APPKey.state       = false;
                    APPKey.pressedDown = false;
                }
                //Touchpad Key
                if (Convert.ToInt16(JKey[4].ToString()) == 1)
                {
                    if (!TouchPadKey.state)
                    {
                        TouchPadKey.pressedDown = true;
                        longPressclock          = false;
                    }
                    else
                    {
                        TouchPadKey.pressedDown = false;
                    }
                    TouchPadKey.state = true;
                }
                else
                {
                    if (TouchPadKey.state)
                    {
                        TouchPadKey.pressedUp = true;
                    }
                    else
                    {
                        TouchPadKey.pressedUp = false;
                    }
                    TouchPadKey.state       = false;
                    TouchPadKey.pressedDown = false;
                }
                //VolumeUP Key
                if (Convert.ToInt16(JKey[5].ToString()) == 1)
                {
                    if (!VolumeUpKey.state)
                    {
                        VolumeUpKey.pressedDown = true;
                        longPressclock          = false;
                    }
                    else
                    {
                        VolumeUpKey.pressedDown = false;
                    }
                    VolumeUpKey.state = true;
                }
                else
                {
                    if (VolumeUpKey.state)
                    {
                        VolumeUpKey.pressedUp = true;
                    }
                    else
                    {
                        VolumeUpKey.pressedUp = false;
                    }
                    VolumeUpKey.state       = false;
                    VolumeUpKey.pressedDown = false;
                }
                //VolumeDown Key
                if (Convert.ToInt16(JKey[6].ToString()) == 1)
                {
                    if (!VolumeDownKey.state)
                    {
                        VolumeDownKey.pressedDown = true;
                        longPressclock            = false;
                    }
                    else
                    {
                        VolumeDownKey.pressedDown = false;
                    }
                    VolumeDownKey.state = true;
                }
                else
                {
                    if (VolumeDownKey.state)
                    {
                        VolumeDownKey.pressedUp = true;
                    }
                    else
                    {
                        VolumeDownKey.pressedUp = false;
                    }
                    VolumeDownKey.state       = false;
                    VolumeDownKey.pressedDown = false;
                }
            }

            #endregion

            #region extended api
            //打开扩展API后,提供长按和滑动功能
            if (ExtendedAPI)
            {
                //slip
                if (TouchPadPosition.x > 0 || TouchPadPosition.y > 0)
                {
                    if (!touchClock)
                    {
                        touchXBegin = TouchPadPosition.x;
                        touchYBegin = TouchPadPosition.y;
                        touchClock  = true;
                    }
                    touchXEnd = TouchPadPosition.x;
                    touchYEnd = TouchPadPosition.y;
                }
                else
                {
                    if (touchXEnd > touchXBegin)
                    {
                        if (touchYEnd > touchYBegin)
                        {
                            if (touchXEnd - touchXBegin > slipNum && ((touchXEnd - touchXBegin) > (touchYEnd - touchYBegin)))
                            {
                                //slide up
                                TouchPadKey.slideup = true;
                            }
                            if (touchYEnd - touchYBegin > slipNum && ((touchYEnd - touchYBegin) > (touchXEnd - touchXBegin)))
                            {
                                //slide right
                                TouchPadKey.slideright = true;
                            }
                        }
                        else if (touchYEnd < touchYBegin)
                        {
                            if (touchXEnd - touchXBegin > slipNum && ((touchXEnd - touchXBegin) > (touchYBegin - touchYEnd)))
                            {
                                //slide up
                                TouchPadKey.slideup = true;
                            }
                            if (touchYBegin - touchYEnd > slipNum && ((touchYBegin - touchYEnd) > (touchXEnd - touchXBegin)))
                            {
                                //slide left
                                TouchPadKey.slideleft = true;
                            }
                        }
                    }
                    else if (touchXEnd < touchXBegin)
                    {
                        if (touchYEnd > touchYBegin)
                        {
                            if (touchXBegin - touchXEnd > slipNum && ((touchXBegin - touchXEnd) > (touchYEnd - touchYBegin)))
                            {
                                //slide down
                                TouchPadKey.slidedown = true;
                            }
                            if (touchYEnd - touchYBegin > slipNum && ((touchYEnd - touchYBegin) > (touchXBegin - touchXEnd)))
                            {
                                //slide right
                                TouchPadKey.slideright = true;
                            }
                        }
                        else if (touchYEnd < touchYBegin)
                        {
                            if (touchXBegin - touchXEnd > slipNum && ((touchXBegin - touchXEnd) > (touchYBegin - touchYEnd)))
                            {
                                //slide down
                                TouchPadKey.slidedown = true;
                            }
                            if (touchYBegin - touchYEnd > slipNum && ((touchYBegin - touchYEnd) > (touchXBegin - touchXEnd)))
                            {
                                //slide left
                                TouchPadKey.slideleft = true;
                            }
                        }
                    }
                    else
                    {
                        TouchPadKey.slideright = false;
                        TouchPadKey.slideleft  = false;
                        TouchPadKey.slidedown  = false;
                        TouchPadKey.slideup    = false;
                    }
                    touchXBegin = 0;
                    touchXEnd   = 0;
                    touchYBegin = 0;
                    touchYEnd   = 0;
                    touchClock  = false;
                }

                //longpress
                if (HomeKey.state)
                {
                    HomeKey.timecount += Time.deltaTime;
                    if (HomeKey.timecount >= longPressTime && !HomeKey.longPressedClock)
                    {
                        HomeKey.longPressed      = true;
                        HomeKey.longPressedClock = true;
                        longPressclock           = true;
                    }
                    else
                    {
                        HomeKey.longPressed = false;
                    }
                }
                else
                {
                    HomeKey.longPressedClock = false;
                    HomeKey.timecount        = 0;
                    HomeKey.longPressed      = false;
                }
                if (APPKey.state)
                {
                    APPKey.timecount += Time.deltaTime;
                    if (APPKey.timecount >= longPressTime && !APPKey.longPressedClock)
                    {
                        APPKey.longPressed      = true;
                        APPKey.longPressedClock = true;
                        longPressclock          = true;
                    }
                    else
                    {
                        APPKey.longPressed = false;
                    }
                }
                else
                {
                    APPKey.longPressedClock = false;
                    APPKey.timecount        = 0;
                    APPKey.longPressed      = false;
                }
                if (TouchPadKey.state)
                {
                    TouchPadKey.timecount += Time.deltaTime;
                    if (TouchPadKey.timecount >= longPressTime && !TouchPadKey.longPressedClock)
                    {
                        TouchPadKey.longPressed      = true;
                        TouchPadKey.longPressedClock = true;
                        longPressclock = true;
                    }
                    else
                    {
                        TouchPadKey.longPressed = false;
                    }
                }
                else
                {
                    TouchPadKey.longPressedClock = false;
                    TouchPadKey.timecount        = 0;
                    TouchPadKey.longPressed      = false;
                }
                if (VolumeUpKey.state)
                {
                    VolumeUpKey.timecount += Time.deltaTime;
                    if (VolumeUpKey.timecount >= longPressTime && !VolumeUpKey.longPressedClock)
                    {
                        VolumeUpKey.longPressed      = true;
                        VolumeUpKey.longPressedClock = true;
                        longPressclock = true;
                    }
                    else
                    {
                        VolumeUpKey.longPressed = false;
                    }
                }
                else
                {
                    VolumeUpKey.longPressedClock = false;
                    VolumeUpKey.timecount        = 0;
                    VolumeUpKey.longPressed      = false;
                }
                if (VolumeDownKey.state)
                {
                    VolumeDownKey.timecount += Time.deltaTime;
                    if (VolumeDownKey.timecount >= longPressTime && !VolumeDownKey.longPressedClock)
                    {
                        VolumeDownKey.longPressed      = true;
                        VolumeDownKey.longPressedClock = true;
                        longPressclock = true;
                    }
                    else
                    {
                        VolumeDownKey.longPressed = false;
                    }
                }
                else
                {
                    VolumeDownKey.longPressedClock = false;
                    VolumeDownKey.timecount        = 0;
                    VolumeDownKey.longPressed      = false;
                }
            }
            #endregion


            if (controllerlink.notPhone)
            {
                if (!longPressclock && Controller.UPvr_GetKeyUp(Pvr_KeyCode.HOME) && !stopConnect)
                {
                    controllerlink.RebackToLauncher();
                }
                if (!longPressclock && Controller.UPvr_GetKeyUp(Pvr_KeyCode.VOLUMEUP))
                {
                    controllerlink.TurnUpVolume();
                }
                if (!longPressclock && Controller.UPvr_GetKeyUp(Pvr_KeyCode.VOLUMEDOWN))
                {
                    controllerlink.TurnDownVolume();
                }
                if (!Controller.UPvr_GetKey(Pvr_KeyCode.VOLUMEUP) && !Controller.UPvr_GetKey(Pvr_KeyCode.VOLUMEDOWN))
                {
                    cTime = 1.0f;
                }
                if (Controller.UPvr_GetKey(Pvr_KeyCode.VOLUMEUP))
                {
                    cTime -= Time.deltaTime;
                    if (cTime <= 0)
                    {
                        cTime = 0.2f;
                        controllerlink.TurnUpVolume();
                    }
                }
                if (Controller.UPvr_GetKey(Pvr_KeyCode.VOLUMEDOWN))
                {
                    cTime -= Time.deltaTime;
                    if (cTime <= 0)
                    {
                        cTime = 0.2f;
                        controllerlink.TurnDownVolume();
                    }
                }
            }

            if (Controller.UPvr_GetKey(Pvr_KeyCode.HOME) && Controller.UPvr_GetKey(Pvr_KeyCode.VOLUMEDOWN) && !stopConnect)
            {
                disConnectTime += Time.deltaTime;
                if (disConnectTime > 1.0)
                {
                    DisConnectBLE();
                    controllerlink.hummingBirdMac = "";
                    stopConnect = true;
                }
            }
        }
#endif
        #endregion
        #region IOSData
#if IOS_DEVICE
        Controller.PVR_GetLark2SensorMessage(ref lark2x, ref lark2y, ref lark2z, ref lark2w);
        Controller.ControllerQua = new Quaternion(lark2x, lark2y, lark2z, lark2w);

        Controller.PVR_GetLark2KeyValueMessage(ref lark2touchx, ref lark2touchy, ref lark2home, ref lark2app, ref lark2click, ref lark2volup, ref lark2voldown, ref lark2power);
        if (lark2touchx > 0 || lark2touchy > 0)
        {
            if (lark2touchx == 0)
            {
                TouchPadPosition.x = 1;
            }
            if (lark2touchy == 0)
            {
                TouchPadPosition.y = 1;
            }
            TouchPadPosition.x = lark2touchx;
            TouchPadPosition.y = lark2touchy;
        }
        else
        {
            touchNum++;
            if (touchNum >= 1)
            {
                TouchPadPosition.x = 0;
                TouchPadPosition.y = 0;
                touchNum           = 0;
            }
        }
        Controller.BatteryLevel = lark2power;
        #region base api
        //键值状态
        //Home Key
        if (lark2home == 1)
        {
            if (!HomeKey.state)
            {
                HomeKey.pressedDown = true;
                longPressclock      = false;
            }
            else
            {
                HomeKey.pressedDown = false;
            }
            HomeKey.state = true;
        }
        else
        {
            if (HomeKey.state)
            {
                HomeKey.pressedUp = true;
            }
            else
            {
                HomeKey.pressedUp = false;
            }
            HomeKey.state       = false;
            HomeKey.pressedDown = false;
        }
        //APP Key
        if (lark2app == 1)
        {
            if (!APPKey.state)
            {
                APPKey.pressedDown = true;
                longPressclock     = false;
            }
            else
            {
                APPKey.pressedDown = false;
            }
            APPKey.state = true;
        }
        else
        {
            if (APPKey.state)
            {
                APPKey.pressedUp = true;
            }
            else
            {
                APPKey.pressedUp = false;
            }
            APPKey.state       = false;
            APPKey.pressedDown = false;
        }
        //Touchpad Key
        if (lark2click == 1)
        {
            if (!TouchPadKey.state)
            {
                TouchPadKey.pressedDown = true;
                longPressclock          = false;
            }
            else
            {
                TouchPadKey.pressedDown = false;
            }
            TouchPadKey.state = true;
        }
        else
        {
            if (TouchPadKey.state)
            {
                TouchPadKey.pressedUp = true;
            }
            else
            {
                TouchPadKey.pressedUp = false;
            }
            TouchPadKey.state       = false;
            TouchPadKey.pressedDown = false;
        }
        //VolumeUP Key
        if (lark2volup == 1)
        {
            if (!VolumeUpKey.state)
            {
                VolumeUpKey.pressedDown = true;
                longPressclock          = false;
            }
            else
            {
                VolumeUpKey.pressedDown = false;
            }
            VolumeUpKey.state = true;
        }
        else
        {
            if (VolumeUpKey.state)
            {
                VolumeUpKey.pressedUp = true;
            }
            else
            {
                VolumeUpKey.pressedUp = false;
            }
            VolumeUpKey.state       = false;
            VolumeUpKey.pressedDown = false;
        }
        //VolumeDown Key
        if (lark2voldown == 1)
        {
            if (!VolumeDownKey.state)
            {
                VolumeDownKey.pressedDown = true;
                longPressclock            = false;
            }
            else
            {
                VolumeDownKey.pressedDown = false;
            }
            VolumeDownKey.state = true;
        }
        else
        {
            if (VolumeDownKey.state)
            {
                VolumeDownKey.pressedUp = true;
            }
            else
            {
                VolumeDownKey.pressedUp = false;
            }
            VolumeDownKey.state       = false;
            VolumeDownKey.pressedDown = false;
        }


        #endregion

        #region extended api
        //打开扩展API后,提供长按和滑动功能
        if (ExtendedAPI)
        {
            //slip
            if (TouchPadPosition.x > 0 || TouchPadPosition.y > 0)
            {
                if (!touchClock)
                {
                    touchXBegin = TouchPadPosition.x;
                    touchYBegin = TouchPadPosition.y;
                    touchClock  = true;
                }
                touchXEnd = TouchPadPosition.x;
                touchYEnd = TouchPadPosition.y;
            }
            else
            {
                if (touchXEnd > touchXBegin)
                {
                    if (touchYEnd > touchYBegin)
                    {
                        if (touchXEnd - touchXBegin > slipNum && ((touchXEnd - touchXBegin) > (touchYEnd - touchYBegin)))
                        {
                            //slide up
                            TouchPadKey.slideup = true;
                        }
                        if (touchYEnd - touchYBegin > slipNum && ((touchYEnd - touchYBegin) > (touchXEnd - touchXBegin)))
                        {
                            //slide right
                            TouchPadKey.slideright = true;
                        }
                    }
                    else if (touchYEnd < touchYBegin)
                    {
                        if (touchXEnd - touchXBegin > slipNum && ((touchXEnd - touchXBegin) > (touchYBegin - touchYEnd)))
                        {
                            //slide up
                            TouchPadKey.slideup = true;
                        }
                        if (touchYBegin - touchYEnd > slipNum && ((touchYBegin - touchYEnd) > (touchXEnd - touchXBegin)))
                        {
                            //slide left
                            TouchPadKey.slideleft = true;
                        }
                    }
                }
                else if (touchXEnd < touchXBegin)
                {
                    if (touchYEnd > touchYBegin)
                    {
                        if (touchXBegin - touchXEnd > slipNum && ((touchXBegin - touchXEnd) > (touchYEnd - touchYBegin)))
                        {
                            //slide down
                            TouchPadKey.slidedown = true;
                        }
                        if (touchYEnd - touchYBegin > slipNum && ((touchYEnd - touchYBegin) > (touchXBegin - touchXEnd)))
                        {
                            //slide right
                            TouchPadKey.slideright = true;
                        }
                    }
                    else if (touchYEnd < touchYBegin)
                    {
                        if (touchXBegin - touchXEnd > slipNum && ((touchXBegin - touchXEnd) > (touchYBegin - touchYEnd)))
                        {
                            //slide down
                            TouchPadKey.slidedown = true;
                        }
                        if (touchYBegin - touchYEnd > slipNum && ((touchYBegin - touchYEnd) > (touchXBegin - touchXEnd)))
                        {
                            //slide left
                            TouchPadKey.slideleft = true;
                        }
                    }
                }
                else
                {
                    TouchPadKey.slideright = false;
                    TouchPadKey.slideleft  = false;
                    TouchPadKey.slidedown  = false;
                    TouchPadKey.slideup    = false;
                }
                touchXBegin = 0;
                touchXEnd   = 0;
                touchYBegin = 0;
                touchYEnd   = 0;
                touchClock  = false;
            }

            //longpress
            if (HomeKey.state)
            {
                HomeKey.timecount += Time.deltaTime;
                if (HomeKey.timecount >= longPressTime && !HomeKey.longPressedClock)
                {
                    HomeKey.longPressed      = true;
                    HomeKey.longPressedClock = true;
                    longPressclock           = true;
                }
                else
                {
                    HomeKey.longPressed = false;
                }
            }
            else
            {
                HomeKey.longPressedClock = false;
                HomeKey.timecount        = 0;
                HomeKey.longPressed      = false;
            }
            if (APPKey.state)
            {
                APPKey.timecount += Time.deltaTime;
                if (APPKey.timecount >= longPressTime && !APPKey.longPressedClock)
                {
                    APPKey.longPressed      = true;
                    APPKey.longPressedClock = true;
                    longPressclock          = true;
                }
                else
                {
                    APPKey.longPressed = false;
                }
            }
            else
            {
                APPKey.longPressedClock = false;
                APPKey.timecount        = 0;
                APPKey.longPressed      = false;
            }
            if (TouchPadKey.state)
            {
                TouchPadKey.timecount += Time.deltaTime;
                if (TouchPadKey.timecount >= longPressTime && !TouchPadKey.longPressedClock)
                {
                    TouchPadKey.longPressed      = true;
                    TouchPadKey.longPressedClock = true;
                    longPressclock = true;
                }
                else
                {
                    TouchPadKey.longPressed = false;
                }
            }
            else
            {
                TouchPadKey.longPressedClock = false;
                TouchPadKey.timecount        = 0;
                TouchPadKey.longPressed      = false;
            }
            if (VolumeUpKey.state)
            {
                VolumeUpKey.timecount += Time.deltaTime;
                if (VolumeUpKey.timecount >= longPressTime && !VolumeUpKey.longPressedClock)
                {
                    VolumeUpKey.longPressed      = true;
                    VolumeUpKey.longPressedClock = true;
                    longPressclock = true;
                }
                else
                {
                    VolumeUpKey.longPressed = false;
                }
            }
            else
            {
                VolumeUpKey.longPressedClock = false;
                VolumeUpKey.timecount        = 0;
                VolumeUpKey.longPressed      = false;
            }
            if (VolumeDownKey.state)
            {
                VolumeDownKey.timecount += Time.deltaTime;
                if (VolumeDownKey.timecount >= longPressTime && !VolumeDownKey.longPressedClock)
                {
                    VolumeDownKey.longPressed      = true;
                    VolumeDownKey.longPressedClock = true;
                    longPressclock = true;
                }
                else
                {
                    VolumeDownKey.longPressed = false;
                }
            }
            else
            {
                VolumeDownKey.longPressedClock = false;
                VolumeDownKey.timecount        = 0;
                VolumeDownKey.longPressed      = false;
            }
        }
        #endregion
#endif
        #endregion

        if (Controller.UPvr_GetKeyLongPressed(Pvr_KeyCode.HOME))
        {
            Pvr_UnitySDKManager.pvr_UnitySDKSensor.ResetUnitySDKSensor();
            ResetController();
        }
    }