// Token: 0x0600005C RID: 92 RVA: 0x000040C0 File Offset: 0x000022C0
    private void OnDeviceConnected(params object[] args)
    {
        uint num  = (uint)((int)args[0]);
        bool flag = this.connected[(int)num];

        this.connected[(int)num] = false;
        bool flag2 = (bool)args[1];
        bool flag3 = flag2;

        if (flag3)
        {
            global::Valve.VR.CVRSystem system = global::Valve.VR.OpenVR.System;
            bool flag4 = system != null && system.GetTrackedDeviceClass(num) == global::Valve.VR.ETrackedDeviceClass.Controller;
            if (flag4)
            {
                this.connected[(int)num] = true;
                flag = !flag;
            }
        }
        bool flag5 = flag;

        if (flag5)
        {
            this.Refresh();
        }
    }
    // Token: 0x060000E5 RID: 229 RVA: 0x00009EB0 File Offset: 0x000080B0
    private void OnDeviceConnected(params object[] args)
    {
        int num = (int)args[0];

        global::Valve.VR.CVRSystem system = global::Valve.VR.OpenVR.System;
        bool flag = system == null || system.GetTrackedDeviceClass((uint)num) != global::Valve.VR.ETrackedDeviceClass.Controller;

        if (!flag)
        {
            bool flag2 = (bool)args[1];
            bool flag3 = flag2;
            if (flag3)
            {
                global::UnityEngine.Debug.Log(string.Format("Controller {0} connected.", num));
                this.PrintControllerStatus(num);
                this.controllerIndices.Add(num);
            }
            else
            {
                global::UnityEngine.Debug.Log(string.Format("Controller {0} disconnected.", num));
                this.PrintControllerStatus(num);
                this.controllerIndices.Remove(num);
            }
        }
    }
示例#3
0
    // Token: 0x06000076 RID: 118 RVA: 0x00005728 File Offset: 0x00003928
    private void OnDeviceConnected(params object[] args)
    {
        int  num  = (int)args[0];
        bool flag = num != (int)this.index;

        if (!flag)
        {
            base.GetComponent <global::UnityEngine.MeshFilter>().mesh = null;
            bool flag2 = (bool)args[1];
            bool flag3 = flag2;
            if (flag3)
            {
                global::Valve.VR.CVRSystem system = global::Valve.VR.OpenVR.System;
                bool flag4 = system != null && system.GetTrackedDeviceClass((uint)num) == global::Valve.VR.ETrackedDeviceClass.TrackingReference;
                if (flag4)
                {
                    global::Valve.VR.ETrackedPropertyError etrackedPropertyError = global::Valve.VR.ETrackedPropertyError.TrackedProp_Success;
                    float floatTrackedDeviceProperty = system.GetFloatTrackedDeviceProperty((uint)num, global::Valve.VR.ETrackedDeviceProperty.Prop_FieldOfViewLeftDegrees_Float, ref etrackedPropertyError);
                    bool  flag5 = etrackedPropertyError == global::Valve.VR.ETrackedPropertyError.TrackedProp_Success;
                    if (flag5)
                    {
                        this.fovLeft = floatTrackedDeviceProperty;
                    }
                    floatTrackedDeviceProperty = system.GetFloatTrackedDeviceProperty((uint)num, global::Valve.VR.ETrackedDeviceProperty.Prop_FieldOfViewRightDegrees_Float, ref etrackedPropertyError);
                    bool flag6 = etrackedPropertyError == global::Valve.VR.ETrackedPropertyError.TrackedProp_Success;
                    if (flag6)
                    {
                        this.fovRight = floatTrackedDeviceProperty;
                    }
                    floatTrackedDeviceProperty = system.GetFloatTrackedDeviceProperty((uint)num, global::Valve.VR.ETrackedDeviceProperty.Prop_FieldOfViewTopDegrees_Float, ref etrackedPropertyError);
                    bool flag7 = etrackedPropertyError == global::Valve.VR.ETrackedPropertyError.TrackedProp_Success;
                    if (flag7)
                    {
                        this.fovTop = floatTrackedDeviceProperty;
                    }
                    floatTrackedDeviceProperty = system.GetFloatTrackedDeviceProperty((uint)num, global::Valve.VR.ETrackedDeviceProperty.Prop_FieldOfViewBottomDegrees_Float, ref etrackedPropertyError);
                    bool flag8 = etrackedPropertyError == global::Valve.VR.ETrackedPropertyError.TrackedProp_Success;
                    if (flag8)
                    {
                        this.fovBottom = floatTrackedDeviceProperty;
                    }
                    floatTrackedDeviceProperty = system.GetFloatTrackedDeviceProperty((uint)num, global::Valve.VR.ETrackedDeviceProperty.Prop_TrackingRangeMinimumMeters_Float, ref etrackedPropertyError);
                    bool flag9 = etrackedPropertyError == global::Valve.VR.ETrackedPropertyError.TrackedProp_Success;
                    if (flag9)
                    {
                        this.nearZ = floatTrackedDeviceProperty;
                    }
                    floatTrackedDeviceProperty = system.GetFloatTrackedDeviceProperty((uint)num, global::Valve.VR.ETrackedDeviceProperty.Prop_TrackingRangeMaximumMeters_Float, ref etrackedPropertyError);
                    bool flag10 = etrackedPropertyError == global::Valve.VR.ETrackedPropertyError.TrackedProp_Success;
                    if (flag10)
                    {
                        this.farZ = floatTrackedDeviceProperty;
                    }
                    this.UpdateModel();
                }
            }
        }
    }
    // Token: 0x06000052 RID: 82 RVA: 0x00003ACC File Offset: 0x00001CCC
    public static int GetDeviceIndex(global::SteamVR_Controller.DeviceRelation relation, global::Valve.VR.ETrackedDeviceClass deviceClass = global::Valve.VR.ETrackedDeviceClass.Controller, int relativeTo = 0)
    {
        int num = -1;

        global::SteamVR_Utils.RigidTransform t      = (relativeTo < 16) ? global::SteamVR_Controller.Input(relativeTo).transform.GetInverse() : global::SteamVR_Utils.RigidTransform.identity;
        global::Valve.VR.CVRSystem           system = global::Valve.VR.OpenVR.System;
        bool flag = system == null;
        int  result;

        if (flag)
        {
            result = num;
        }
        else
        {
            float num2 = float.MinValue;
            int   num3 = 0;
            while ((long)num3 < 16L)
            {
                bool flag2 = num3 == relativeTo || system.GetTrackedDeviceClass((uint)num3) != deviceClass;
                if (!flag2)
                {
                    global::SteamVR_Controller.Device device = global::SteamVR_Controller.Input(num3);
                    bool flag3 = !device.connected;
                    if (!flag3)
                    {
                        bool flag4 = relation == global::SteamVR_Controller.DeviceRelation.First;
                        if (flag4)
                        {
                            return(num3);
                        }
                        global::UnityEngine.Vector3 vector = t * device.transform.pos;
                        bool  flag5 = relation == global::SteamVR_Controller.DeviceRelation.FarthestRight;
                        float num4;
                        if (flag5)
                        {
                            num4 = vector.x;
                        }
                        else
                        {
                            bool flag6 = relation == global::SteamVR_Controller.DeviceRelation.FarthestLeft;
                            if (flag6)
                            {
                                num4 = -vector.x;
                            }
                            else
                            {
                                global::UnityEngine.Vector3 normalized = new global::UnityEngine.Vector3(vector.x, 0f, vector.z).normalized;
                                float num5 = global::UnityEngine.Vector3.Dot(normalized, global::UnityEngine.Vector3.forward);
                                global::UnityEngine.Vector3 vector2 = global::UnityEngine.Vector3.Cross(normalized, global::UnityEngine.Vector3.forward);
                                bool flag7 = relation == global::SteamVR_Controller.DeviceRelation.Leftmost;
                                if (flag7)
                                {
                                    num4 = ((vector2.y > 0f) ? (2f - num5) : num5);
                                }
                                else
                                {
                                    num4 = ((vector2.y < 0f) ? (2f - num5) : num5);
                                }
                            }
                        }
                        bool flag8 = num4 > num2;
                        if (flag8)
                        {
                            num  = num3;
                            num2 = num4;
                        }
                    }
                }
                num3++;
            }
            result = num;
        }
        return(result);
    }