예제 #1
0
 // Token: 0x060005B1 RID: 1457 RVA: 0x0001BD76 File Offset: 0x00019F76
 public VelocityRumble(global::SteamVR_Controller.Device device, ushort microDuration, float milliInterval, float maxVelocity, ushort maxMicroDuration, float maxMilliInterval)
 {
     this.Device            = device;
     this._MaxMilliInterval = maxMilliInterval;
     this._MaxMicroDuration = maxMicroDuration;
     this._MaxVelocity      = maxVelocity;
     this._MilliInterval    = milliInterval;
     this._MicroDuration    = microDuration;
 }
예제 #2
0
        // Token: 0x0600045C RID: 1116 RVA: 0x00015B58 File Offset: 0x00013D58
        protected override void OnUpdate()
        {
            base.OnUpdate();
            global::SteamVR_Controller.Device controller = base.Controller;
            bool pressDown = controller.GetPressDown(12884901888UL);

            if (pressDown)
            {
                global::VRGIN.Core.VR.Input.Mouse.LeftButtonDown();
                this.pressDownTime = global::UnityEngine.Time.unscaledTime;
            }
            bool pressUp = controller.GetPressUp(4UL);

            if (pressUp)
            {
                bool flag = this.Gui;
                if (flag)
                {
                    this.AbandonGUI();
                }
                else
                {
                    this.TakeGUI(global::System.Linq.Enumerable.FirstOrDefault <global::VRGIN.Visuals.GUIQuad>(global::VRGIN.Visuals.GUIQuadRegistry.Quads, (global::VRGIN.Visuals.GUIQuad q) => !q.IsOwned));
                }
            }
            bool touchDown = controller.GetTouchDown(4294967296UL);

            if (touchDown)
            {
                this.touchDownPosition      = controller.GetAxis(global::Valve.VR.EVRButtonId.k_EButton_Axis0);
                this.touchDownMousePosition = global::VRGIN.Native.MouseOperations.GetClientCursorPosition();
            }
            bool flag2 = controller.GetTouch(4294967296UL) && global::UnityEngine.Time.unscaledTime - this.pressDownTime > 0.3f;

            if (flag2)
            {
                global::UnityEngine.Vector2 axis   = controller.GetAxis(global::Valve.VR.EVRButtonId.k_EButton_Axis0);
                global::UnityEngine.Vector2 vector = axis - ((global::VRGIN.Core.VR.HMD == global::VRGIN.Core.HMDType.Oculus) ? global::UnityEngine.Vector2.zero : this.touchDownPosition);
                float num = (global::VRGIN.Core.VR.HMD == global::VRGIN.Core.HMDType.Oculus) ? (global::UnityEngine.Time.unscaledDeltaTime * 5f) : 1f;
                this._DeltaX += (double)(vector.x * (float)global::VRGIN.Core.VRGUI.Width) * 0.1 * (double)num;
                this._DeltaY += (double)(-(double)vector.y * (float)global::VRGIN.Core.VRGUI.Height) * 0.2 * (double)num;
                int num2 = (int)((this._DeltaX > 0.0) ? global::System.Math.Floor(this._DeltaX) : global::System.Math.Ceiling(this._DeltaX));
                int num3 = (int)((this._DeltaY > 0.0) ? global::System.Math.Floor(this._DeltaY) : global::System.Math.Ceiling(this._DeltaY));
                this._DeltaX -= (double)num2;
                this._DeltaY -= (double)num3;
                global::VRGIN.Core.VR.Input.Mouse.MoveMouseBy(num2, num3);
                this.touchDownPosition = axis;
            }
            bool pressUp2 = controller.GetPressUp(12884901888UL);

            if (pressUp2)
            {
                global::VRGIN.Core.VR.Input.Mouse.LeftButtonUp();
                this.pressDownTime = 0f;
            }
        }
예제 #3
0
 // Token: 0x06000425 RID: 1061 RVA: 0x00014C90 File Offset: 0x00012E90
 private void TryReleaseLock()
 {
     global::SteamVR_Controller.Device input = this.Input;
     foreach (global::Valve.VR.EVRButtonId buttonId in global::System.Linq.Enumerable.OfType <global::Valve.VR.EVRButtonId>(global::System.Enum.GetValues(typeof(global::Valve.VR.EVRButtonId))))
     {
         bool press = input.GetPress(buttonId);
         if (press)
         {
             return;
         }
     }
     this._Lock.Release();
 }
    // Token: 0x060000E8 RID: 232 RVA: 0x00009F88 File Offset: 0x00008188
    private void PrintControllerStatus(int index)
    {
        global::SteamVR_Controller.Device device = global::SteamVR_Controller.Input(index);
        global::UnityEngine.Debug.Log("index: " + device.index.ToString());
        global::UnityEngine.Debug.Log("connected: " + device.connected.ToString());
        global::UnityEngine.Debug.Log("hasTracking: " + device.hasTracking.ToString());
        global::UnityEngine.Debug.Log("outOfRange: " + device.outOfRange.ToString());
        global::UnityEngine.Debug.Log("calibrating: " + device.calibrating.ToString());
        global::UnityEngine.Debug.Log("uninitialized: " + device.uninitialized.ToString());
        string text = "pos: ";

        global::UnityEngine.Vector3 pos = device.transform.pos;
        global::UnityEngine.Debug.Log(text + pos.ToString());
        global::UnityEngine.Debug.Log("rot: " + device.transform.rot.eulerAngles.ToString());
        global::UnityEngine.Debug.Log("velocity: " + device.velocity.ToString());
        global::UnityEngine.Debug.Log("angularVelocity: " + device.angularVelocity.ToString());
        int deviceIndex  = global::SteamVR_Controller.GetDeviceIndex(global::SteamVR_Controller.DeviceRelation.Leftmost, global::Valve.VR.ETrackedDeviceClass.Controller, 0);
        int deviceIndex2 = global::SteamVR_Controller.GetDeviceIndex(global::SteamVR_Controller.DeviceRelation.Rightmost, global::Valve.VR.ETrackedDeviceClass.Controller, 0);

        global::UnityEngine.Debug.Log((deviceIndex == deviceIndex2) ? "first" : ((deviceIndex == index) ? "left" : "right"));
    }
예제 #5
0
        // Token: 0x06000424 RID: 1060 RVA: 0x00014B00 File Offset: 0x00012D00
        protected override void OnUpdate()
        {
            base.OnUpdate();
            global::SteamVR_Controller.Device device = global::SteamVR_Controller.Input((int)this.Tracking.index);
            bool flag = this._Lock != null && this._Lock.IsInvalidating;

            if (flag)
            {
                this.TryReleaseLock();
            }
            bool flag2 = this._Lock == null || !this._Lock.IsValid;

            if (flag2)
            {
                bool pressDown = device.GetPressDown(global::Valve.VR.EVRButtonId.k_EButton_ApplicationMenu);
                if (pressDown)
                {
                    this.appButtonPressTime = new float?(global::UnityEngine.Time.unscaledTime);
                }
                bool flag3;
                if (device.GetPress(global::Valve.VR.EVRButtonId.k_EButton_ApplicationMenu))
                {
                    float?num  = global::UnityEngine.Time.unscaledTime - this.appButtonPressTime;
                    float num2 = 0.5f;
                    flag3 = (num.GetValueOrDefault() > num2 & num != null);
                }
                else
                {
                    flag3 = false;
                }
                bool flag4 = flag3;
                if (flag4)
                {
                    this.ShowHelp();
                    this.appButtonPressTime = default(float?);
                }
                bool pressUp = device.GetPressUp(global::Valve.VR.EVRButtonId.k_EButton_ApplicationMenu);
                if (pressUp)
                {
                    bool flag5 = this.helpShown;
                    if (flag5)
                    {
                        this.HideHelp();
                    }
                    else
                    {
                        bool flag6 = this.ActiveTool;
                        if (flag6)
                        {
                            this.ActiveTool.enabled = false;
                        }
                        this.ToolIndex = (this.ToolIndex + 1) % this.Tools.Count;
                        bool flag7 = this.ActiveTool;
                        if (flag7)
                        {
                            this.ActiveTool.enabled = true;
                        }
                    }
                    this.appButtonPressTime = default(float?);
                }
            }
        }
예제 #6
0
    // 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);
    }
예제 #7
0
    // Token: 0x06000088 RID: 136 RVA: 0x0000657D File Offset: 0x0000477D
    private global::System.Collections.IEnumerator LoadLevel()
    {
        bool flag = this.loadingScreen != null && this.loadingScreenDistance > 0f;

        if (flag)
        {
            global::SteamVR_Controller.Device hmd = global::SteamVR_Controller.Input(0);
            while (!hmd.hasTracking)
            {
                yield return(null);
            }
            global::SteamVR_Utils.RigidTransform tloading = hmd.transform;
            tloading.rot  = global::UnityEngine.Quaternion.Euler(0f, tloading.rot.eulerAngles.y, 0f);
            tloading.pos += tloading.rot * new global::UnityEngine.Vector3(0f, 0f, this.loadingScreenDistance);
            global::UnityEngine.Transform t = (this.loadingScreenTransform != null) ? this.loadingScreenTransform : base.transform;
            t.position = tloading.pos;
            t.rotation = tloading.rot;
            hmd        = null;
            tloading   = default(global::SteamVR_Utils.RigidTransform);
            t          = null;
        }
        global::SteamVR_LoadLevel._active = this;
        global::SteamVR_Utils.Event.Send("loading", new object[]
        {
            true
        });
        bool flag2 = this.loadingScreenFadeInTime > 0f;

        if (flag2)
        {
            this.fadeRate = 1f / this.loadingScreenFadeInTime;
        }
        else
        {
            this.alpha = 1f;
        }
        global::Valve.VR.CVROverlay overlay = global::Valve.VR.OpenVR.Overlay;
        bool flag3 = this.loadingScreen != null && overlay != null;

        if (flag3)
        {
            this.loadingScreenOverlayHandle = this.GetOverlayHandle("loadingScreen", (this.loadingScreenTransform != null) ? this.loadingScreenTransform : base.transform, this.loadingScreenWidthInMeters);
            bool flag4 = this.loadingScreenOverlayHandle > 0UL;
            if (flag4)
            {
                global::Valve.VR.Texture_t texture = default(global::Valve.VR.Texture_t);
                texture.handle      = this.loadingScreen.GetNativeTexturePtr();
                texture.eType       = global::SteamVR.instance.graphicsAPI;
                texture.eColorSpace = global::Valve.VR.EColorSpace.Auto;
                overlay.SetOverlayTexture(this.loadingScreenOverlayHandle, ref texture);
            }
        }
        bool fadedForeground = false;

        global::SteamVR_Utils.Event.Send("loading_fade_out", new object[]
        {
            this.fadeOutTime
        });
        global::Valve.VR.CVRCompositor compositor = global::Valve.VR.OpenVR.Compositor;
        bool flag5 = compositor != null;

        if (flag5)
        {
            bool flag6 = this.front != null;
            if (flag6)
            {
                global::SteamVR_Skybox.SetOverride(this.front, this.back, this.left, this.right, this.top, this.bottom);
                compositor.FadeGrid(this.fadeOutTime, true);
                yield return(new global::UnityEngine.WaitForSeconds(this.fadeOutTime));
            }
            else
            {
                bool flag7 = this.backgroundColor != global::UnityEngine.Color.clear;
                if (flag7)
                {
                    bool flag8 = this.showGrid;
                    if (flag8)
                    {
                        compositor.FadeToColor(0f, this.backgroundColor.r, this.backgroundColor.g, this.backgroundColor.b, this.backgroundColor.a, true);
                        compositor.FadeGrid(this.fadeOutTime, true);
                        yield return(new global::UnityEngine.WaitForSeconds(this.fadeOutTime));
                    }
                    else
                    {
                        compositor.FadeToColor(this.fadeOutTime, this.backgroundColor.r, this.backgroundColor.g, this.backgroundColor.b, this.backgroundColor.a, false);
                        yield return(new global::UnityEngine.WaitForSeconds(this.fadeOutTime + 0.1f));

                        compositor.FadeGrid(0f, true);
                        fadedForeground = true;
                    }
                }
            }
        }
        global::SteamVR_Render.pauseRendering = true;
        while (this.alpha < 1f)
        {
            yield return(null);
        }
        base.transform.parent = null;
        global::UnityEngine.Object.DontDestroyOnLoad(base.gameObject);
        bool flag9 = this.loadExternalApp;

        if (flag9)
        {
            global::UnityEngine.Debug.Log("Launching external application...");
            global::Valve.VR.CVRApplications applications = global::Valve.VR.OpenVR.Applications;
            bool flag10 = applications == null;
            if (flag10)
            {
                global::UnityEngine.Debug.Log("Failed to get OpenVR.Applications interface!");
            }
            else
            {
                string workingDirectory = global::System.IO.Directory.GetCurrentDirectory();
                string fullPath         = global::System.IO.Path.Combine(workingDirectory, this.externalAppPath);
                global::UnityEngine.Debug.Log("LaunchingInternalProcess");
                global::UnityEngine.Debug.Log("ExternalAppPath = " + this.externalAppPath);
                global::UnityEngine.Debug.Log("FullPath = " + fullPath);
                global::UnityEngine.Debug.Log("ExternalAppArgs = " + this.externalAppArgs);
                global::UnityEngine.Debug.Log("WorkingDirectory = " + workingDirectory);
                global::UnityEngine.Debug.Log("LaunchInternalProcessError: " + applications.LaunchInternalProcess(fullPath, this.externalAppArgs, workingDirectory).ToString());
                global::System.Diagnostics.Process.GetCurrentProcess().Kill();
                workingDirectory = null;
                fullPath         = null;
            }
            applications = null;
        }
        else
        {
            global::UnityEngine.SceneManagement.LoadSceneMode mode = this.loadAdditive ? 1 : 0;
            bool flag11 = this.loadAsync;
            if (flag11)
            {
                global::UnityEngine.Application.backgroundLoadingPriority = 0;
                this.async = global::UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(this.levelName, mode);
                while (!this.async.isDone)
                {
                    yield return(null);
                }
            }
            else
            {
                global::UnityEngine.SceneManagement.SceneManager.LoadScene(this.levelName, mode);
            }
        }
        yield return(null);

        global::System.GC.Collect();
        yield return(null);

        global::UnityEngine.Shader.WarmupAllShaders();
        yield return(new global::UnityEngine.WaitForSeconds(this.postLoadSettleTime));

        global::SteamVR_Render.pauseRendering = false;
        bool flag12 = this.loadingScreenFadeOutTime > 0f;

        if (flag12)
        {
            this.fadeRate = -1f / this.loadingScreenFadeOutTime;
        }
        else
        {
            this.alpha = 0f;
        }
        global::SteamVR_Utils.Event.Send("loading_fade_in", new object[]
        {
            this.fadeInTime
        });
        bool flag13 = compositor != null;

        if (flag13)
        {
            bool flag14 = fadedForeground;
            if (flag14)
            {
                compositor.FadeGrid(0f, false);
                compositor.FadeToColor(this.fadeInTime, 0f, 0f, 0f, 0f, false);
                yield return(new global::UnityEngine.WaitForSeconds(this.fadeInTime));
            }
            else
            {
                compositor.FadeGrid(this.fadeInTime, false);
                yield return(new global::UnityEngine.WaitForSeconds(this.fadeInTime));

                bool flag15 = this.front != null;
                if (flag15)
                {
                    global::SteamVR_Skybox.ClearOverride();
                }
            }
        }
        while (this.alpha > 0f)
        {
            yield return(null);
        }
        bool flag16 = overlay != null;

        if (flag16)
        {
            bool flag17 = this.progressBarOverlayHandle > 0UL;
            if (flag17)
            {
                overlay.HideOverlay(this.progressBarOverlayHandle);
            }
            bool flag18 = this.loadingScreenOverlayHandle > 0UL;
            if (flag18)
            {
                overlay.HideOverlay(this.loadingScreenOverlayHandle);
            }
        }
        global::UnityEngine.Object.Destroy(base.gameObject);
        global::SteamVR_LoadLevel._active = null;
        global::SteamVR_Utils.Event.Send("loading", new object[]
        {
            false
        });
        yield break;
    }