Example #1
0
    void Update()
    {
#if UNITY_ANDROID
        if (controllerlink.neoserviceStarted)
        {
            var sensorData = controllerlink.GetControllerSensorData();
            var keyData    = controllerlink.GetControllerKeyData();

            if (controllerlink.controller0Connected)
            {
                if (Pvr_UnitySDKManager.SDK.ShowVideoSeethrough)
                {
                    //var fixedpose0 = controllerlink.GetControllerFixedSensorState(0);
                    // fixed pose
                    sensorData[2] = -sensorData[2];
                    sensorData[3] = -sensorData[3];
                    controllerlink.Controller0.Rotation.Set(sensorData[0], sensorData[1], sensorData[2], sensorData[3]);
                    controllerlink.Controller0.Position.Set(sensorData[4] / 1000.0f, sensorData[5] / 1000.0f, -sensorData[6] / 1000.0f);
                }
                else
                {
                    controllerlink.Controller0.Rotation.Set(sensorData[7], sensorData[8], sensorData[9],
                                                            sensorData[10]);
                    controllerlink.Controller0.Position.Set(sensorData[11] / 1000.0f, sensorData[12] / 1000.0f,
                                                            -sensorData[13] / 1000.0f);
                }

                if (!controllerlink.Controller0.isShowBoundary)
                {
                    if (controllerlink.getControllerSensorStatus(0) == 0)
                    {
                        Sensor.UPvr_SetReinPosition(sensorData[0], sensorData[1], sensorData[2], sensorData[3], sensorData[4], sensorData[5], sensorData[6], 0, false, 0);
                    }
                    else
                    {
                        controllerlink.Controller0.isShowBoundary = true;
                        Sensor.UPvr_SetReinPosition(sensorData[0], sensorData[1], sensorData[2], sensorData[3], sensorData[4], sensorData[5], sensorData[6], 0, true, Convert.ToInt32((Convert.ToString(keyData[35]) + Convert.ToString(keyData[15]) + "00"), 2));
                    }
                }
                else
                {
                    Sensor.UPvr_SetReinPosition(sensorData[0], sensorData[1], sensorData[2], sensorData[3], sensorData[4], sensorData[5], sensorData[6], 0, true, Convert.ToInt32((Convert.ToString(keyData[35]) + Convert.ToString(keyData[15]) + "00"), 2));
                }
                TransformData(controllerlink.Controller0, 0, keyData);
            }
            else
            {
                Sensor.UPvr_SetReinPosition(sensorData[0], sensorData[1], sensorData[2], sensorData[3], sensorData[4], sensorData[5], sensorData[6], 0, false, 0);
            }

            if (controllerlink.controller1Connected)
            {
                if (Pvr_UnitySDKManager.SDK.ShowVideoSeethrough)
                {
                    //var fixedpose1 = controllerlink.GetControllerFixedSensorState(1);
                    // fixed pose
                    sensorData[16] = -sensorData[16];
                    sensorData[17] = -sensorData[17];
                    controllerlink.Controller1.Rotation.Set(sensorData[14], sensorData[15], sensorData[16], sensorData[17]);
                    controllerlink.Controller1.Position.Set(sensorData[18] / 1000.0f, sensorData[19] / 1000.0f, -sensorData[20] / 1000.0f);
                }
                else
                {
                    controllerlink.Controller1.Rotation.Set(sensorData[21], sensorData[22], sensorData[23],
                                                            sensorData[24]);
                    controllerlink.Controller1.Position.Set(sensorData[25] / 1000.0f, sensorData[26] / 1000.0f,
                                                            -sensorData[27] / 1000.0f);
                }

                if (!controllerlink.Controller1.isShowBoundary)
                {
                    if (controllerlink.getControllerSensorStatus(1) == 0)
                    {
                        Sensor.UPvr_SetReinPosition(sensorData[14], sensorData[15], sensorData[16], sensorData[17], sensorData[18], sensorData[19], sensorData[20], 1, false, 0);
                    }
                    else
                    {
                        controllerlink.Controller1.isShowBoundary = true;
                        Sensor.UPvr_SetReinPosition(sensorData[14], sensorData[15], sensorData[16], sensorData[17], sensorData[18], sensorData[19], sensorData[20], 1, true, Convert.ToInt32((Convert.ToString(keyData[102]) + Convert.ToString(keyData[82]) + "00"), 2));
                    }
                }
                else
                {
                    Sensor.UPvr_SetReinPosition(sensorData[14], sensorData[15], sensorData[16], sensorData[17], sensorData[18], sensorData[19], sensorData[20], 1, true, Convert.ToInt32((Convert.ToString(keyData[102]) + Convert.ToString(keyData[82]) + "00"), 2));
                }
                TransformData(controllerlink.Controller1, 1, keyData);
            }
            else
            {
                Sensor.UPvr_SetReinPosition(sensorData[14], sensorData[15], sensorData[16], sensorData[17], sensorData[18], sensorData[19], sensorData[20], 1, false, 0);
            }
        }

        //Goblin controller
        if (controllerlink.goblinserviceStarted && controllerlink.controller0Connected)
        {
            var pose0 = controllerlink.GetHBControllerPoseData();
            controllerlink.Controller0.Rotation.Set(pose0[0], pose0[1], pose0[2], pose0[3]);

            var key0 = controllerlink.GetHBControllerKeyData();
            TransformData(controllerlink.Controller0, 0, key0);
        }

        SetSystemKey();
#endif
    }