示例#1
0
    void FixedUpdate()
    {
        int headMocapID = CAVE2.GetCAVE2Manager().head1MocapID;
        int wandMocapID = CAVE2.GetCAVE2Manager().wand1MocapID;
        int wandID      = CAVE2.GetCAVE2Manager().wand1ControllerID;

        // Get/Create Primary Head
        OmicronMocapSensor mainHeadSensor;

        if (!mocapSensors.ContainsKey(headMocapID))
        {
            mainHeadSensor            = gameObject.AddComponent <OmicronMocapSensor>();
            mainHeadSensor.sourceID   = headMocapID;
            mocapSensors[headMocapID] = mainHeadSensor;
        }
        else
        {
            mainHeadSensor = (OmicronMocapSensor)mocapSensors[headMocapID];
        }

        // Get/Create Primary Head
        OmicronMocapSensor wandMocapSensor;

        if (!mocapSensors.ContainsKey(wandMocapID))
        {
            wandMocapSensor           = gameObject.AddComponent <OmicronMocapSensor>();
            wandMocapSensor.sourceID  = wandMocapID;
            mocapSensors[wandMocapID] = wandMocapSensor;
        }
        else
        {
            wandMocapSensor = (OmicronMocapSensor)mocapSensors[wandMocapID];
        }

        // Get Primary Wand (ID 1)
        OmicronController wandController;

        if (!wandControllers.ContainsKey(wandID))
        {
            wandController          = gameObject.AddComponent <OmicronController>();
            wandController.sourceID = wandID;
            wandControllers[wandID] = wandController;
        }
        else
        {
            wandController = (OmicronController)wandControllers[wandID];
        }

        Vector2 analog1 = Vector2.zero;
        Vector2 analog2 = Vector2.zero;
        int     flags   = 0;

        // Mocap
        if (CAVE2.GetCAVE2Manager().mocapEmulation)
        {
            mainHeadSensor.position    = CAVE2.GetCAVE2Manager().simulatorHeadPosition;
            mainHeadSensor.orientation = Quaternion.Euler(CAVE2.GetCAVE2Manager().simulatorHeadRotation);

            wandMocapSensor.position    = CAVE2.GetCAVE2Manager().simulatorWandPosition;
            wandMocapSensor.orientation = Quaternion.Euler(CAVE2.GetCAVE2Manager().simulatorWandRotation);
        }
        else if (CAVE2.GetCAVE2Manager().usingKinectTrackingSimulator)
        {
            CAVE2.GetCAVE2Manager().simulatorHeadPosition = GetHeadPosition(1);
            CAVE2.GetCAVE2Manager().simulatorWandPosition = GetWandPosition(1);

            mainHeadSensor.position    = CAVE2.GetCAVE2Manager().simulatorHeadPosition;
            mainHeadSensor.orientation = Quaternion.Euler(CAVE2.GetCAVE2Manager().simulatorHeadRotation);

            wandMocapSensor.position    = CAVE2.GetCAVE2Manager().simulatorWandPosition;
            wandMocapSensor.orientation = Quaternion.Euler(CAVE2.GetCAVE2Manager().simulatorWandRotation);
        }

        // Wand Buttons
        if (CAVE2.GetCAVE2Manager().keyboardEventEmulation)
        {
            float analogUD = Input.GetAxis(CAVE2.GetCAVE2Manager().wandSimulatorAnalogUD);
            float analogLR = Input.GetAxis(CAVE2.GetCAVE2Manager().wandSimulatorAnalogLR);
            //bool turn = CAVE2.GetCAVE2Manager().simulatorWandStrafeAsTurn;

            analog1 = new Vector2(analogLR, analogUD);

            if (Input.GetKey(CAVE2.GetCAVE2Manager().wandSimulatorDPadUp))
            {
                flags += (int)EventBase.Flags.ButtonUp;
            }
            if (Input.GetKey(CAVE2.GetCAVE2Manager().wandSimulatorDPadDown))
            {
                flags += (int)EventBase.Flags.ButtonDown;
            }
            if (Input.GetKey(CAVE2.GetCAVE2Manager().wandSimulatorDPadLeft))
            {
                flags += (int)EventBase.Flags.ButtonLeft;
            }
            if (Input.GetKey(CAVE2.GetCAVE2Manager().wandSimulatorDPadRight))
            {
                flags += (int)EventBase.Flags.ButtonRight;
            }

            // Wand Button 1 (Triangle/Y)
            //if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.Button1)))
            //    flags += (int)EventBase.Flags.Button1;
            // F -> Wand Button 2 (Circle/B)
            if (Input.GetButton(CAVE2.GetCAVE2Manager().wandSimulatorButton2))
            {
                flags += (int)EventBase.Flags.Button2;
            }
            // R -> Wand Button 3 (Cross/A)
            if (Input.GetButton(CAVE2.GetCAVE2Manager().wandSimulatorButton3))
            {
                flags += (int)EventBase.Flags.Button3;
            }
            // Wand Button 4 (Square/X)
            //if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.Button4)))
            //    flags += (int)EventBase.Flags.Button4;
            // Wand Button 8 (R1/RB)
            //if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.SpecialButton3)))
            //    flags += (int)EventBase.Flags.SpecialButton3;
            // Wand Button 5 (L1/LB)
            if (Input.GetKey(CAVE2.GetCAVE2Manager().wandSimulatorButton5))
            {
                flags += (int)EventBase.Flags.Button5;
            }
            // Wand Button 6 (L3)
            if (Input.GetButton(CAVE2.GetCAVE2Manager().wandSimulatorButton6))
            {
                flags += (int)EventBase.Flags.Button6;
            }
            // Wand Button 7 (L2)
            if (Input.GetKey(CAVE2.GetCAVE2Manager().wandSimulatorButton7))
            {
                flags += (int)EventBase.Flags.Button7;
            }
            // Wand Button 8 (R2)
            //if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.Button8)))
            //    flags += (int)EventBase.Flags.Button8;
            // Wand Button 9 (R3)
            //if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.Button9)))
            //    flags += (int)EventBase.Flags.Button9;
            // Wand Button SP1 (Back)
            //if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.SpecialButton1)))
            //    flags += (int)EventBase.Flags.SpecialButton1;
            // Wand Button SP2 (Start)
            //if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.SpecialButton2)))
            //    flags += (int)EventBase.Flags.SpecialButton2;
        }

        // getReal3D
#if USING_GETREAL3D
        if (!CAVE2.IsSimulatorMode())
        {
            mainHeadSensor.position    = getReal3D.Input.head.position;
            mainHeadSensor.orientation = getReal3D.Input.head.rotation;

            wandMocapSensor.position    = getReal3D.Input.wand.position;
            wandMocapSensor.orientation = getReal3D.Input.wand.rotation;

            analog1 = new Vector2(
                getReal3D.Input.GetAxis(CAVE2.CAVE2ToGetReal3DAxis(CAVE2.Axis.LeftAnalogStickLR)),
                getReal3D.Input.GetAxis(CAVE2.CAVE2ToGetReal3DAxis(CAVE2.Axis.LeftAnalogStickUD))
                );
            analog2 = new Vector2(
                getReal3D.Input.GetAxis(CAVE2.CAVE2ToGetReal3DAxis(CAVE2.Axis.RightAnalogStickLR)),
                getReal3D.Input.GetAxis(CAVE2.CAVE2ToGetReal3DAxis(CAVE2.Axis.RightAnalogStickUD))
                );

            flags = 0;
            float DPadUD = getReal3D.Input.GetAxis("DPadUD");
            float DPadLR = getReal3D.Input.GetAxis("DPadLR");
            if (DPadUD > 0)
            {
                flags += (int)EventBase.Flags.ButtonUp;
            }
            else if (DPadUD < 0)
            {
                flags += (int)EventBase.Flags.ButtonDown;
            }
            if (DPadLR < 0)
            {
                flags += (int)EventBase.Flags.ButtonLeft;
            }
            else if (DPadLR > 0)
            {
                flags += (int)EventBase.Flags.ButtonRight;
            }

            // Wand Button 1 (Triangle/Y)
            if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.Button1)))
            {
                flags += (int)EventBase.Flags.Button1;
            }
            // F -> Wand Button 2 (Circle/B)
            if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.Button2)))
            {
                flags += (int)EventBase.Flags.Button2;
            }
            // R -> Wand Button 3 (Cross/A)
            if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.Button3)))
            {
                flags += (int)EventBase.Flags.Button3;
            }
            // Wand Button 4 (Square/X)
            if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.Button4)))
            {
                flags += (int)EventBase.Flags.Button4;
            }
            // Wand Button 8 (R1/RB)
            if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.SpecialButton3)))
            {
                flags += (int)EventBase.Flags.SpecialButton3;
            }
            // Wand Button 5 (L1/LB)
            if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.Button5)))
            {
                flags += (int)EventBase.Flags.Button5;
            }
            // Wand Button 6 (L3)
            if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.Button6)))
            {
                flags += (int)EventBase.Flags.Button6;
            }
            // Wand Button 7 (L2)
            if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.Button7)))
            {
                flags += (int)EventBase.Flags.Button7;
            }
            // Wand Button 8 (R2)
            if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.Button8)))
            {
                flags += (int)EventBase.Flags.Button8;
            }
            // Wand Button 9 (R3)
            if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.Button9)))
            {
                flags += (int)EventBase.Flags.Button9;
            }
            // Wand Button SP1 (Back)
            if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.SpecialButton1)))
            {
                flags += (int)EventBase.Flags.SpecialButton1;
            }
            // Wand Button SP2 (Start)
            if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.SpecialButton2)))
            {
                flags += (int)EventBase.Flags.SpecialButton2;
            }
        }
#endif
        if (UnityEngine.VR.VRSettings.enabled)
        {
            // VR Left Controller (Keycode.Joystick2)
            // Button2 - Menu
            // Button8 - Thumbstick Press
            // Button16 - Thumbstick Touch
            // Button14 - Index Trigger
            // Axis1 - Thumbstick Horz
            // Axis2 - Thumbstick Vert
            // Axis9 - Index Trigger
            // Axis11 - Hand Trigger
            flags = 0;
            if (Input.GetKey(KeyCode.Joystick2Button2))
            {
            }
            if (Input.GetKey(KeyCode.Joystick2Button8))
            {
                flags += (int)EventBase.Flags.Button6;
            }
            if (Input.GetKey(KeyCode.Joystick2Button16))
            {
            }
            if (Input.GetKey(KeyCode.Joystick2Button14))
            {
                flags += (int)EventBase.Flags.Button7;
            }
            if (Input.GetAxis("Grip L") > 0)
            {
                flags += (int)EventBase.Flags.Button5;
                flags += (int)EventBase.Flags.Button3;
            }

            // VR Right Controller (Keycode.Joystick1)
            // Button0 - Menu
            // Button9 - Thumbstick Press
            // Button17 - Thumbstick Touch
            // Button15 - Index Trigger
            // Axis4 - Thumbstick Horz
            // Axis5 - Thumbstick Vert
            // Axis10 - Index Trigger
            // Axis12 - Hand Trigger
            if (Input.GetKey(KeyCode.Joystick1Button0))
            {
                flags += (int)EventBase.Flags.Button2;
            }
            if (Input.GetKey(KeyCode.Joystick1Button9))
            {
            }
            if (Input.GetKey(KeyCode.Joystick1Button17))
            {
            }
            if (Input.GetKey(KeyCode.Joystick2Button15))
            {
            }

            if (Input.GetAxis("Grip R") > 0.5f)
            {
                flags += (int)EventBase.Flags.Button3;
            }
            if (Input.GetAxis("Horizontal2") < -0.5f && Input.GetKey(KeyCode.Joystick1Button9))
            {
                flags += (int)EventBase.Flags.ButtonLeft;
            }
            else if (Input.GetAxis("Horizontal2") > 0.5f && Input.GetKey(KeyCode.Joystick1Button9))
            {
                flags += (int)EventBase.Flags.ButtonRight;
            }
            if (Input.GetAxis("Vertical2") < -0.5f && Input.GetKey(KeyCode.Joystick1Button9))
            {
                flags += (int)EventBase.Flags.ButtonUp;
            }
            else if (Input.GetAxis("Vertical2") > 0.5f && Input.GetKey(KeyCode.Joystick1Button9))
            {
                flags += (int)EventBase.Flags.ButtonDown;
            }
        }

        // Update wandManager
        if (CAVE2.UsingGetReal3D() || CAVE2.GetCAVE2Manager().keyboardEventEmulation)
        {
            wandController.UpdateAnalog(analog1, analog2, Vector2.zero, Vector2.zero);
            wandController.rawFlags = flags;
        }
    }
示例#2
0
    void FixedUpdate()
    {
        int headMocapID  = CAVE2.GetCAVE2Manager().head1MocapID;
        int wandMocapID  = CAVE2.GetCAVE2Manager().wand1MocapID;
        int wand2MocapID = CAVE2.GetCAVE2Manager().wand2MocapID;
        int wandID       = CAVE2.GetCAVE2Manager().wand1ControllerID;
        int wand2ID      = CAVE2.GetCAVE2Manager().wand2ControllerID;

        // Get/Create Primary Head
        OmicronMocapSensor mainHeadSensor;

        if (!mocapSensors.ContainsKey(headMocapID))
        {
            mainHeadSensor            = gameObject.AddComponent <OmicronMocapSensor>();
            mainHeadSensor.sourceID   = headMocapID;
            mocapSensors[headMocapID] = mainHeadSensor;
        }
        else
        {
            mainHeadSensor = (OmicronMocapSensor)mocapSensors[headMocapID];
        }

        // Get/Create Primary Wand
        OmicronMocapSensor wandMocapSensor;

        if (!mocapSensors.ContainsKey(wandMocapID))
        {
            wandMocapSensor           = gameObject.AddComponent <OmicronMocapSensor>();
            wandMocapSensor.sourceID  = wandMocapID;
            mocapSensors[wandMocapID] = wandMocapSensor;
        }
        else
        {
            wandMocapSensor = (OmicronMocapSensor)mocapSensors[wandMocapID];
        }

        // Get Primary Wand (ID 1)
        OmicronController wandController;

        if (!wandControllers.ContainsKey(wandID))
        {
            wandController          = gameObject.AddComponent <OmicronController>();
            wandController.sourceID = wandID;
            wandControllers[wandID] = wandController;
        }
        else
        {
            wandController = (OmicronController)wandControllers[wandID];
        }

        // Get/Create Secondary Wand
        OmicronMocapSensor wand2MocapSensor;

        if (!mocapSensors.ContainsKey(wand2MocapID))
        {
            wand2MocapSensor           = gameObject.AddComponent <OmicronMocapSensor>();
            wand2MocapSensor.sourceID  = wand2MocapID;
            mocapSensors[wand2MocapID] = wand2MocapSensor;
        }
        else
        {
            wand2MocapSensor = (OmicronMocapSensor)mocapSensors[wand2MocapID];
        }

        // Get Secondary Wand (ID 1)
        OmicronController wandController2;

        if (!wandControllers.ContainsKey(wand2ID))
        {
            wandController2          = gameObject.AddComponent <OmicronController>();
            wandController2.sourceID = wand2ID;
            wandControllers[wand2ID] = wandController2;
        }
        else
        {
            wandController2 = (OmicronController)wandControllers[wand2ID];
        }

        Vector2 wand1_analog1 = Vector2.zero;
        Vector2 wand1_analog2 = Vector2.zero;
        Vector2 wand1_analog3 = Vector2.zero;
        int     wand1_flags   = 0;

        Vector2 wand2_analog1 = Vector2.zero;
        Vector2 wand2_analog2 = Vector2.zero;
        Vector2 wand2_analog3 = Vector2.zero;
        int     wand2_flags   = 0;

        // Mocap
        if (CAVE2.GetCAVE2Manager().mocapEmulation)
        {
            if (UnityEngine.VR.VRSettings.enabled)
            {
                if (VRDevice.model == "Vive MV")
                {
                    CAVE2.GetCAVE2Manager().simulatorHeadPosition = InputTracking.GetLocalPosition(VRNode.Head);
                    CAVE2.GetCAVE2Manager().simulatorHeadRotation = InputTracking.GetLocalRotation(VRNode.Head).eulerAngles;
#if UNITY_5_5_OR_NEWER
                    CAVE2.GetCAVE2Manager().simulatorWandPosition = InputTracking.GetLocalPosition(VRNode.LeftHand);
                    CAVE2.GetCAVE2Manager().simulatorWandRotation = InputTracking.GetLocalRotation(VRNode.LeftHand).eulerAngles;

                    wand2MocapSensor.position    = InputTracking.GetLocalPosition(VRNode.RightHand);
                    wand2MocapSensor.orientation = InputTracking.GetLocalRotation(VRNode.RightHand);
#endif
                }
                else
                {
                    // Hack: InputTracking isn't using some offset that the Main Camera is otherwise getting. Calculate the diff here:
                    Vector3 oculusRealHeadPosition = Camera.main.transform.localPosition;
                    Vector3 positionOffset         = oculusRealHeadPosition - InputTracking.GetLocalPosition(VRNode.Head);

                    CAVE2.GetCAVE2Manager().simulatorHeadPosition = InputTracking.GetLocalPosition(VRNode.Head) + positionOffset;
                    CAVE2.GetCAVE2Manager().simulatorHeadRotation = InputTracking.GetLocalRotation(VRNode.Head).eulerAngles;
#if UNITY_5_5_OR_NEWER
                    CAVE2.GetCAVE2Manager().simulatorWandPosition = InputTracking.GetLocalPosition(VRNode.LeftHand) + positionOffset;
                    CAVE2.GetCAVE2Manager().simulatorWandRotation = InputTracking.GetLocalRotation(VRNode.LeftHand).eulerAngles;

                    wand2MocapSensor.position    = InputTracking.GetLocalPosition(VRNode.RightHand) + positionOffset;
                    wand2MocapSensor.orientation = InputTracking.GetLocalRotation(VRNode.RightHand);
#endif
                }
            }

            mainHeadSensor.position    = CAVE2.GetCAVE2Manager().simulatorHeadPosition;
            mainHeadSensor.orientation = Quaternion.Euler(CAVE2.GetCAVE2Manager().simulatorHeadRotation);

            wandMocapSensor.position    = CAVE2.GetCAVE2Manager().simulatorWandPosition;
            wandMocapSensor.orientation = Quaternion.Euler(CAVE2.GetCAVE2Manager().simulatorWandRotation);
        }
        else if (CAVE2.GetCAVE2Manager().usingKinectTrackingSimulator)
        {
            CAVE2.GetCAVE2Manager().simulatorHeadPosition = GetHeadPosition(1);
            CAVE2.GetCAVE2Manager().simulatorWandPosition = GetWandPosition(1);

            mainHeadSensor.position    = CAVE2.GetCAVE2Manager().simulatorHeadPosition;
            mainHeadSensor.orientation = Quaternion.Euler(CAVE2.GetCAVE2Manager().simulatorHeadRotation);

            wandMocapSensor.position    = CAVE2.GetCAVE2Manager().simulatorWandPosition;
            wandMocapSensor.orientation = Quaternion.Euler(CAVE2.GetCAVE2Manager().simulatorWandRotation);
        }

        // Wand Buttons
        if (CAVE2.GetCAVE2Manager().keyboardEventEmulation)
        {
            float wand1_analogUD = Input.GetAxis(CAVE2.GetCAVE2Manager().wandSimulatorAnalogUD);
            float wand1_analogLR = Input.GetAxis(CAVE2.GetCAVE2Manager().wandSimulatorAnalogLR);
            //bool turn = CAVE2.GetCAVE2Manager().simulatorWandStrafeAsTurn;

            wand1_analog1 = new Vector2(wand1_analogLR, wand1_analogUD);

            if (Input.GetKey(CAVE2.GetCAVE2Manager().wandSimulatorDPadUp))
            {
                wand1_flags += (int)EventBase.Flags.ButtonUp;
            }
            if (Input.GetKey(CAVE2.GetCAVE2Manager().wandSimulatorDPadDown))
            {
                wand1_flags += (int)EventBase.Flags.ButtonDown;
            }
            if (Input.GetKey(CAVE2.GetCAVE2Manager().wandSimulatorDPadLeft))
            {
                wand1_flags += (int)EventBase.Flags.ButtonLeft;
            }
            if (Input.GetKey(CAVE2.GetCAVE2Manager().wandSimulatorDPadRight))
            {
                wand1_flags += (int)EventBase.Flags.ButtonRight;
            }

            // Wand Button 1 (Triangle/Y)
            //if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.Button1)))
            //    flags += (int)EventBase.Flags.Button1;
            // F -> Wand Button 2 (Circle/B)
            if (Input.GetButton(CAVE2.GetCAVE2Manager().wandSimulatorButton2))
            {
                wand1_flags += (int)EventBase.Flags.Button2;
            }
            // R -> Wand Button 3 (Cross/A)
            if (Input.GetButton(CAVE2.GetCAVE2Manager().wandSimulatorButton3))
            {
                wand1_flags += (int)EventBase.Flags.Button3;
            }
            // Wand Button 4 (Square/X)
            //if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.Button4)))
            //    flags += (int)EventBase.Flags.Button4;
            // Wand Button 8 (R1/RB)
            //if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.SpecialButton3)))
            //    flags += (int)EventBase.Flags.SpecialButton3;
            // Wand Button 5 (L1/LB)
            if (Input.GetKey(CAVE2.GetCAVE2Manager().wandSimulatorButton5))
            {
                wand1_flags += (int)EventBase.Flags.Button5;
            }
            // Wand Button 6 (L3)
            if (Input.GetButton(CAVE2.GetCAVE2Manager().wandSimulatorButton6))
            {
                wand1_flags += (int)EventBase.Flags.Button6;
            }
            // Wand Button 7 (L2)
            if (Input.GetKey(CAVE2.GetCAVE2Manager().wandSimulatorButton7))
            {
                wand1_flags += (int)EventBase.Flags.Button7;
            }
            // Wand Button 8 (R2)
            //if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.Button8)))
            //    flags += (int)EventBase.Flags.Button8;
            // Wand Button 9 (R3)
            //if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.Button9)))
            //    flags += (int)EventBase.Flags.Button9;
            // Wand Button SP1 (Back)
            //if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.SpecialButton1)))
            //    flags += (int)EventBase.Flags.SpecialButton1;
            // Wand Button SP2 (Start)
            //if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.SpecialButton2)))
            //    flags += (int)EventBase.Flags.SpecialButton2;
        }

        // getReal3D
#if USING_GETREAL3D
        if (!CAVE2.IsSimulatorMode())
        {
            wand1_analog1 = new Vector2(
                getReal3D.Input.GetAxis(CAVE2.CAVE2ToGetReal3DAxis(CAVE2.Axis.LeftAnalogStickLR)),
                getReal3D.Input.GetAxis(CAVE2.CAVE2ToGetReal3DAxis(CAVE2.Axis.LeftAnalogStickUD))
                );
            wand1_analog2 = new Vector2(
                getReal3D.Input.GetAxis(CAVE2.CAVE2ToGetReal3DAxis(CAVE2.Axis.RightAnalogStickLR)),
                getReal3D.Input.GetAxis(CAVE2.CAVE2ToGetReal3DAxis(CAVE2.Axis.RightAnalogStickUD))
                );

            wand1_flags = 0;
            // wand2_flags = 0;

            float wand1_DPadUD = getReal3D.Input.GetAxis("DPadUD");
            float wand1_DPadLR = getReal3D.Input.GetAxis("DPadLR");

            if (wand1_DPadUD > 0)
            {
                wand1_flags += (int)EventBase.Flags.ButtonUp;
            }
            else if (wand1_DPadUD < 0)
            {
                wand1_flags += (int)EventBase.Flags.ButtonDown;
            }
            if (wand1_DPadLR < 0)
            {
                wand1_flags += (int)EventBase.Flags.ButtonLeft;
            }
            else if (wand1_DPadLR > 0)
            {
                wand1_flags += (int)EventBase.Flags.ButtonRight;
            }

            // Wand Button 1 (Triangle/Y)
            if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.Button1)))
            {
                wand1_flags += (int)EventBase.Flags.Button1;
            }
            // F -> Wand Button 2 (Circle/B)
            if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.Button2)))
            {
                wand1_flags += (int)EventBase.Flags.Button2;
            }
            // R -> Wand Button 3 (Cross/A)
            if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.Button3)))
            {
                wand1_flags += (int)EventBase.Flags.Button3;
            }
            // Wand Button 4 (Square/X)
            if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.Button4)))
            {
                wand1_flags += (int)EventBase.Flags.Button4;
            }
            // Wand Button 8 (R1/RB)
            if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.SpecialButton3)))
            {
                wand1_flags += (int)EventBase.Flags.SpecialButton3;
            }
            // Wand Button 5 (L1/LB)
            if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.Button5)))
            {
                wand1_flags += (int)EventBase.Flags.Button5;
            }
            // Wand Button 6 (L3)
            if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.Button6)))
            {
                wand1_flags += (int)EventBase.Flags.Button6;
            }
            // Wand Button 7 (L2)
            if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.Button7)))
            {
                wand1_flags += (int)EventBase.Flags.Button7;
            }
            // Wand Button 8 (R2)
            if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.Button8)))
            {
                wand1_flags += (int)EventBase.Flags.Button8;
            }
            // Wand Button 9 (R3)
            if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.Button9)))
            {
                wand1_flags += (int)EventBase.Flags.Button9;
            }
            // Wand Button SP1 (Back)
            if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.SpecialButton1)))
            {
                wand1_flags += (int)EventBase.Flags.SpecialButton1;
            }
            // Wand Button SP2 (Start)
            if (getReal3D.Input.GetButton(CAVE2.CAVE2ToGetReal3DButton(CAVE2.Button.SpecialButton2)))
            {
                wand1_flags += (int)EventBase.Flags.SpecialButton2;
            }
        }
#endif
        if (UnityEngine.VR.VRSettings.enabled)
        {
            wand1_flags = 0;
            wand2_flags = 0;

            // VR Left Controller  ---------------------------------

            // Oculus Touch Left: Button.Three / X (Press)
            // Vive Left: Menu Button
            if (Input.GetKey(KeyCode.JoystickButton2))
            {
                if (vrModel == VRModel.Vive)
                {
                    // Ignore left menu button, mapped from right controller
                    // since accidental trackpad on left is common
                    //wand1_flags += (int)EventBase.Flags.Button2;
                }
                else
                {
                    wand1_flags += (int)EventBase.Flags.Button2;
                }
                if (debug)
                {
                    Debug.Log("JoystickButton2");
                }
            }

            // Oculus Touch Left: Button.Four / Y (Press)
            // Vive Left: N/A
            if (Input.GetKey(KeyCode.JoystickButton3))
            {
                wand1_flags += (int)EventBase.Flags.Button3;
                if (debug)
                {
                    Debug.Log("JoystickButton3");
                }
            }

            // Oculus Touch Left: Button.Start / Menu
            // Vive Left: N/A
            if (Input.GetKey(KeyCode.JoystickButton7))
            {
                if (debug)
                {
                    Debug.Log("JoystickButton7");
                }
            }

            // Oculus Touch Left: Analog Stick (Press)
            // Vive Left: Analog Stick (Press)
            if (Input.GetKey(KeyCode.JoystickButton8))
            {
                wand1_flags += (int)EventBase.Flags.Button6;
                if (debug)
                {
                    Debug.Log("JoystickButton8");
                }
            }

            // Oculus Touch Left: Button.Three / X (Touch)
            // Vive Left: N/A
            if (Input.GetKey(KeyCode.JoystickButton12))
            {
                if (debug)
                {
                    Debug.Log("JoystickButton12");
                }
            }

            // Oculus Touch Left: Button.Four / Y (Touch)
            // Vive Left: N/A
            if (Input.GetKey(KeyCode.JoystickButton13))
            {
                if (debug)
                {
                    Debug.Log("JoystickButton13");
                }
            }

            // Oculus Touch Left: IndexTrigger (Touch)
            // Vive Left: IndexTrigger (Touch)
            if (Input.GetKey(KeyCode.JoystickButton14))
            {
                if (debug)
                {
                    Debug.Log("JoystickButton14");
                }
            }

            // Oculus Touch Left: ThumbRest (Touch)
            // Vive Left: N/A
            if (Input.GetKey(KeyCode.JoystickButton18))
            {
                if (debug)
                {
                    Debug.Log("JoystickButton18");
                }
            }

            /*
             * Grip L/R are not default Unity InputManager axis, but
             * are required for proper mapping of VR controller buttons.
             * The following can be added to the Axis. All other fields
             * are blank unless otherwise specified
             *
             * Name: Trigger L
             * Gravity: 3
             * Dead: 0.001
             * Sensitivity: 3
             * Type: Joystick Axis
             * Axis: 9th axis (Joysticks)
             * JoyNum: Get Motion from all Joysticks
             *
             * Name: Trigger R
             * Gravity: 3
             * Dead: 0.001
             * Sensitivity: 3
             * Type: Joystick Axis
             * Axis: 10th axis (Joysticks)
             * JoyNum: Get Motion from all Joysticks
             *
             * Name: Grip L
             * Gravity: 3
             * Dead: 0.001
             * Sensitivity: 3
             * Type: Joystick Axis
             * Axis: 11th axis (Joysticks)
             * JoyNum: Get Motion from all Joysticks
             *
             * Name: Grip R
             * Gravity: 3
             * Dead: 0.001
             * Sensitivity: 3
             * Type: Joystick Axis
             * Axis: 12th axis (Joysticks)
             * JoyNum: Get Motion from all Joysticks
             */
            // Oculus Touch Left: IndexTrigger (Press)
            // Vive Left: IndexTrigger (Press)
            wand1_analog3.y = Input.GetAxis("Trigger L");
            if (Input.GetAxis("Trigger L") > 0.1f)
            {
                if (vrModel == VRModel.Vive)
                {
                    wand1_flags += (int)EventBase.Flags.Button7;
                }
                else
                {
                    wand1_flags += (int)EventBase.Flags.Button5;
                }
            }

            // Oculus Touch Left: HandTrigger (Press)
            // Vive Left: HandTrigger (Press)
            wand1_analog3.x = Input.GetAxis("Grip L");
            if (Input.GetAxis("Grip L") > 0.1f)
            {
                if (vrModel == VRModel.Vive)
                {
                    wand1_flags += (int)EventBase.Flags.Button5;
                }
                else
                {
                    wand2_flags += (int)EventBase.Flags.Button7;
                }
            }

            // Oculus Touch Right: HandTrigger (Press)
            // Vive Right: HandTrigger (Press)
            wand2_analog3.x = Input.GetAxis("Grip R");
            if (Input.GetAxis("Grip R") > 0.1f)
            {
                if (vrModel == VRModel.Vive)
                {
                    wand1_flags += (int)EventBase.Flags.Button3;
                }
                else
                {
                    wand2_flags += (int)EventBase.Flags.Button7;
                }
            }

            // Oculus Touch Right: IndexTrigger (Press)
            // Vive Right: IndexTrigger (Press)
            wand2_analog3.y = Input.GetAxis("Trigger R");
            if (Input.GetAxis("Trigger R") > 0.1f)
            {
                if (vrModel == VRModel.Vive)
                {
                    wand2_flags += (int)EventBase.Flags.Button7;
                }
                else
                {
                    wand2_flags += (int)EventBase.Flags.Button5;
                }
            }

            // VR Right Controller ---------------------------------
            // For CAVE2 simulator mode, we map the right controller
            // analog stick to the DPad
            bool rightAnalogDPadActivate = false;

            // Oculus Touch Right: Button.One / A (Press)
            // Vive Right: Menu Button
            if (Input.GetKey(KeyCode.JoystickButton0))
            {
                if (vrModel == VRModel.Vive)
                {
                    // Map the right menu button to main wand for Vive
                    // since accidental trackpad on left is common
                    wand1_flags += (int)EventBase.Flags.Button2;
                }
                else
                {
                    wand2_flags += (int)EventBase.Flags.Button2;
                }
                if (debug)
                {
                    Debug.Log("JoystickButton0");
                }
            }

            // Oculus Touch Right: Button.Two / B (Press)
            // Vive Right: N/A
            if (Input.GetKey(KeyCode.JoystickButton1))
            {
                wand2_flags += (int)EventBase.Flags.Button3;
                if (debug)
                {
                    Debug.Log("JoystickButton1");
                }
            }

            // Oculus Touch Right: Oculus Button Reserved

            // Oculus Touch Right: Analog Stick (Press)
            // Vive Right: Analog Stick (Press)
            if (Input.GetKey(KeyCode.JoystickButton9))
            {
                if (vrModel == VRModel.Vive)
                {
                    rightAnalogDPadActivate = true;
                }
                wand2_flags += (int)EventBase.Flags.Button6;
                if (debug)
                {
                    Debug.Log("JoystickButton9");
                }
            }

            // Oculus Touch Right: Button.One / A (Touch)
            // Vive Right: N/A
            if (Input.GetKey(KeyCode.JoystickButton10))
            {
                if (debug)
                {
                    Debug.Log("JoystickButton10");
                }
            }

            // Oculus Touch Right: Button.Two / B (Touch)
            // Vive Right: N/A
            if (Input.GetKey(KeyCode.JoystickButton11))
            {
                if (debug)
                {
                    Debug.Log("JoystickButton11");
                }
            }

            // Oculus Touch Right: IndexTrigger (Touch)
            // Vive Right: IndexTrigger (Touch)
            if (Input.GetKey(KeyCode.JoystickButton15))
            {
                if (debug)
                {
                    Debug.Log("JoystickButton15");
                }
            }

            // Oculus Touch Right: ThumbRest (Touch)
            // Vive Right: N/A
            if (Input.GetKey(KeyCode.JoystickButton19))
            {
                if (debug)
                {
                    Debug.Log("JoystickButton19");
                }
            }

            wand1_analog1 = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
            wand2_analog1 = new Vector2(Input.GetAxis("Horizontal2"), -Input.GetAxis("Vertical2"));

            // Oculus Touch Right: Analog (Touch)
            // Vive Right: Analog (Touch)
            if (Input.GetKey(KeyCode.JoystickButton17))
            {
                if (vrModel == VRModel.Vive)
                {
                    // Right analog dpad is activated on pad press on Vive
                }
                else
                {
                    rightAnalogDPadActivate = true;
                }
            }

            // For CAVE2 simulator purposes, we're treating the right analog as the DPad
            if (rightAnalogDPadActivate &&
                (Input.GetAxis("Vertical2") != 0 ||
                 Input.GetAxis("Horizontal2") != 0)
                )
            {
                /*
                 * Horizontal2/Vertical2 are not default Unity InputManager axis, but
                 * are required for proper mapping of the second VR controller pad/analog stick.
                 * The following can be added to the Axis. All other fields
                 * are blank unless otherwise specified
                 *
                 * Name: Horizontal2
                 * Gravity: 3
                 * Dead: 0.001
                 * Sensitivity: 3
                 * Type: Joystick Axis
                 * Axis: 4th axis (Joysticks)
                 * JoyNum: Get Motion from all Joysticks
                 *
                 * Name: Vertical2
                 * Gravity: 3
                 * Dead: 0.001
                 * Sensitivity: 3
                 * Type: Joystick Axis
                 * Axis: 5th axis (Joysticks)
                 * JoyNum: Get Motion from all Joysticks
                 */
                float padAngle = Mathf.Rad2Deg * Mathf.Atan2(Input.GetAxis("Vertical2"), Input.GetAxis("Horizontal2"));

                if (padAngle < -45 && padAngle > -135)
                {
                    wand1_flags += (int)EventBase.Flags.ButtonUp;
                }
                else if (padAngle > -45 && padAngle < 45)
                {
                    wand1_flags += (int)EventBase.Flags.ButtonRight;
                }
                else if (padAngle > 45 && padAngle < 135)
                {
                    wand1_flags += (int)EventBase.Flags.ButtonDown;
                }
                else if (padAngle < -135 || padAngle > 135)
                {
                    wand1_flags += (int)EventBase.Flags.ButtonLeft;
                }
            }
        }

        // Only apply tracking when not in simulator mode
        if (!CAVE2.IsSimulatorMode())
        {
#if USING_GETREAL3D
            mainHeadSensor.position    = getReal3D.Input.head.position;
            mainHeadSensor.orientation = getReal3D.Input.head.rotation;

            wandMocapSensor.position    = getReal3D.Input.wand.position;
            wandMocapSensor.orientation = getReal3D.Input.wand.rotation;

            wand2MocapSensor.position    = getReal3D.Input.GetSensor("Wand2").position;
            wand2MocapSensor.orientation = getReal3D.Input.GetSensor("Wand2").rotation;
#endif
        }

        wandController.UpdateAnalog(wand1_analog1, wand1_analog2, wand1_analog3, Vector2.zero);
        wandController.rawFlags = wand1_flags;

        wandController2.UpdateAnalog(wand2_analog1, wand2_analog2, wand2_analog3, Vector2.zero);
        wandController2.rawFlags = wand2_flags;

        /*
         * // If Omicron server is enabled, let Omicron handle tracker/controller data instead of getReal3D
         * // Unless keyboard emulation is enabled
         * if (CAVE2.UsingOmicronServer() || CAVE2.GetCAVE2Manager().keyboardEventEmulation)
         * {
         *  wandController.UpdateAnalog(wand1_analog1, wand1_analog2, wand1_analog3, Vector2.zero);
         *  wandController.rawFlags = wand1_flags;
         *
         *  wandController2.UpdateAnalog(wand2_analog1, wand2_analog2, wand2_analog3, Vector2.zero);
         *  wandController2.rawFlags = wand2_flags;
         * }
         */
    }