Exemplo n.º 1
0
    void Update()
    {
        OVRInput.Controller activeController = OVRInput.GetActiveController();

        data.Length = 0;
        byte recenterCount = OVRInput.GetControllerRecenterCount();

        data.AppendFormat("RecenterCount: {0}\n", recenterCount);

        byte battery = OVRInput.GetControllerBatteryPercentRemaining();

        data.AppendFormat("Battery: {0}\n", battery);

        float framerate = OVRPlugin.GetAppFramerate();

        data.AppendFormat("Framerate: {0:F2}\n", framerate);

        string activeControllerName = activeController.ToString();

        data.AppendFormat("Active: {0}\n", activeControllerName);

        string connectedControllerNames = OVRInput.GetConnectedControllers().ToString();

        data.AppendFormat("Connected: {0}\n", connectedControllerNames);

        data.AppendFormat("PrevConnected: {0}\n", prevConnected);

        controllers.Update();
        controllers.AppendToStringBuilder(ref data);

        prevConnected = connectedControllerNames;

        Vector3 rot = OVRInput.GetLocalControllerRotation(activeController).eulerAngles;

        if (rot.x > 180f)
        {
            rot.x -= 360f;
        }
        if (rot.y > 180f)
        {
            rot.y -= 360f;
        }
        if (rot.z > 180f)
        {
            rot.z -= 360f;
        }

        data.AppendFormat("Orientation: ({0:F2}, {1:F2}, {2:F2})\n", rot.x, rot.y, rot.z);
        //Quaternion rot = OVRInput.GetLocalControllerRotation(activeController);
        //data.AppendFormat("Orientation: ({0:F2}, {1:F2}, {2:F2})\n", rot.x, rot.y, rot.z, rot.w);

        Vector3 angVel = OVRInput.GetLocalControllerAngularVelocity(activeController);

        data.AppendFormat("AngVel: ({0:F2}, {1:F2}, {2:F2})\n", angVel.x, angVel.y, angVel.z);

        Vector3 angAcc = OVRInput.GetLocalControllerAngularAcceleration(activeController);

        data.AppendFormat("AngAcc: ({0:F2}, {1:F2}, {2:F2})\n", angAcc.x, angAcc.y, angAcc.z);

        Vector3 pos = OVRInput.GetLocalControllerPosition(activeController);

        data.AppendFormat("Position: ({0:F2}, {1:F2}, {2:F2})\n", pos.x, pos.y, pos.z);

        Vector3 vel = OVRInput.GetLocalControllerVelocity(activeController);

        data.AppendFormat("Vel: ({0:F2}, {1:F2}, {2:F2})\n", vel.x, vel.y, vel.z);

        Vector3 acc = OVRInput.GetLocalControllerAcceleration(activeController);

        data.AppendFormat("Acc: ({0:F2}, {1:F2}, {2:F2})\n", acc.x, acc.y, acc.z);

        Vector2 primaryTouchpad = OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad);

        data.AppendFormat("PrimaryTouchpad: ({0:F2}, {1:F2})\n", primaryTouchpad.x, primaryTouchpad.y);

        Vector2 secondaryTouchpad = OVRInput.Get(OVRInput.Axis2D.SecondaryTouchpad);

        data.AppendFormat("SecondaryTouchpad: ({0:F2}, {1:F2})\n", secondaryTouchpad.x, secondaryTouchpad.y);

        float indexTrigger = OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger);

        data.AppendFormat("PrimaryIndexTriggerAxis1D: ({0:F2})\n", indexTrigger);

        float handTrigger = OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger);

        data.AppendFormat("PrimaryHandTriggerAxis1D: ({0:F2})\n", handTrigger);

        for (int i = 0; i < monitors.Count; i++)
        {
            monitors[i].Update();
            monitors[i].AppendToStringBuilder(ref data);
        }

        if (uiText != null)
        {
            uiText.text = data.ToString();
        }
    }
Exemplo n.º 2
0
    private void Update()
    {
        OVRInput.Controller activeController = OVRInput.GetActiveController();
        this.data.Length = 0;
        byte controllerRecenterCount = OVRInput.GetControllerRecenterCount(OVRInput.Controller.Active);

        this.data.AppendFormat("RecenterCount: {0}\n", controllerRecenterCount);
        byte controllerBatteryPercentRemaining = OVRInput.GetControllerBatteryPercentRemaining(OVRInput.Controller.Active);

        this.data.AppendFormat("Battery: {0}\n", controllerBatteryPercentRemaining);
        float appFramerate = OVRPlugin.GetAppFramerate();

        this.data.AppendFormat("Framerate: {0:F2}\n", appFramerate);
        string arg = activeController.ToString();

        this.data.AppendFormat("Active: {0}\n", arg);
        string arg2 = OVRInput.GetConnectedControllers().ToString();

        this.data.AppendFormat("Connected: {0}\n", arg2);
        this.data.AppendFormat("PrevConnected: {0}\n", OVRGearVrControllerTest.prevConnected);
        OVRGearVrControllerTest.controllers.Update();
        OVRGearVrControllerTest.controllers.AppendToStringBuilder(ref this.data);
        OVRGearVrControllerTest.prevConnected = arg2;
        Quaternion localControllerRotation = OVRInput.GetLocalControllerRotation(activeController);

        this.data.AppendFormat("Orientation: ({0:F2}, {1:F2}, {2:F2}, {3:F2})\n", new object[]
        {
            localControllerRotation.x,
            localControllerRotation.y,
            localControllerRotation.z,
            localControllerRotation.w
        });
        Vector3 localControllerAngularVelocity = OVRInput.GetLocalControllerAngularVelocity(activeController);

        this.data.AppendFormat("AngVel: ({0:F2}, {1:F2}, {2:F2})\n", localControllerAngularVelocity.x, localControllerAngularVelocity.y, localControllerAngularVelocity.z);
        Vector3 localControllerAngularAcceleration = OVRInput.GetLocalControllerAngularAcceleration(activeController);

        this.data.AppendFormat("AngAcc: ({0:F2}, {1:F2}, {2:F2})\n", localControllerAngularAcceleration.x, localControllerAngularAcceleration.y, localControllerAngularAcceleration.z);
        Vector3 localControllerPosition = OVRInput.GetLocalControllerPosition(activeController);

        this.data.AppendFormat("Position: ({0:F2}, {1:F2}, {2:F2})\n", localControllerPosition.x, localControllerPosition.y, localControllerPosition.z);
        Vector3 localControllerVelocity = OVRInput.GetLocalControllerVelocity(activeController);

        this.data.AppendFormat("Vel: ({0:F2}, {1:F2}, {2:F2})\n", localControllerVelocity.x, localControllerVelocity.y, localControllerVelocity.z);
        Vector3 localControllerAcceleration = OVRInput.GetLocalControllerAcceleration(activeController);

        this.data.AppendFormat("Acc: ({0:F2}, {1:F2}, {2:F2})\n", localControllerAcceleration.x, localControllerAcceleration.y, localControllerAcceleration.z);
        Vector2 vector = OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad, OVRInput.Controller.Active);

        this.data.AppendFormat("PrimaryTouchpad: ({0:F2}, {1:F2})\n", vector.x, vector.y);
        Vector2 vector2 = OVRInput.Get(OVRInput.Axis2D.SecondaryTouchpad, OVRInput.Controller.Active);

        this.data.AppendFormat("SecondaryTouchpad: ({0:F2}, {1:F2})\n", vector2.x, vector2.y);
        float num = OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger, OVRInput.Controller.Active);

        this.data.AppendFormat("PrimaryIndexTriggerAxis1D: ({0:F2})\n", num);
        float num2 = OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger, OVRInput.Controller.Active);

        this.data.AppendFormat("PrimaryHandTriggerAxis1D: ({0:F2})\n", num2);
        for (int i = 0; i < this.monitors.Count; i++)
        {
            this.monitors[i].Update();
            this.monitors[i].AppendToStringBuilder(ref this.data);
        }
        if (this.uiText != null)
        {
            this.uiText.text = this.data.ToString();
        }
    }